/* Light theme tokens (default). Dark overrides below; theme is set on <html data-bs-theme>. */
:root, [data-bs-theme="light"] {
    --brand: #16325c;
    --brand-2: #0f2442;
    --brand-text: #16325c;
    --nav-bg: #16325c;
    --accent: #e07a2e;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --page: #f4f6f9;
    --line: #e3e7ee;
    --muted: #6b7686;
    --text: #1f2733;
    --bs-link-color: #1d5bbf;
    --bs-link-color-rgb: 29, 91, 191;
    --bs-link-hover-color: #164a9c;
    --bs-link-hover-color-rgb: 22, 74, 156;

    --st-notstarted-bg: #e9ecf1; --st-notstarted-fg: #3d4756;
    --st-inprogress-bg: #dbe8fc; --st-inprogress-fg: #1a4a99;
    --st-onhold-bg: #fdf0d5;     --st-onhold-fg: #8a5a00;
    --st-completed-bg: #d8f1e0;  --st-completed-fg: #1d6b39;
    --st-cancelled-bg: #f7dcdc;  --st-cancelled-fg: #962a2a;
    --type-bg: #efe8fb;          --type-fg: #5a3a99;
}

[data-bs-theme="dark"] {
    --brand: #2f5fa8;
    --brand-2: #264f8d;
    --brand-text: #9dbcf0;
    --nav-bg: #0f1b2e;
    --accent: #f0904a;
    --surface: #1b2129;
    --surface-2: #222a34;
    --page: #12161c;
    --line: #2e3742;
    --muted: #96a1b0;
    --text: #e3e8ef;
    --bs-body-bg: #1b2129;
    --bs-body-bg-rgb: 27, 33, 41;
    --bs-body-color: #e3e8ef;
    --bs-border-color: #2e3742;
    --bs-link-color: #8fb3f5;
    --bs-link-color-rgb: 143, 179, 245;
    --bs-link-hover-color: #b5cdf8;
    --bs-link-hover-color-rgb: 181, 205, 248;

    --st-notstarted-bg: #2c333d; --st-notstarted-fg: #c3cad4;
    --st-inprogress-bg: #1d3557; --st-inprogress-fg: #a9c8f5;
    --st-onhold-bg: #4a3a14;     --st-onhold-fg: #f2cf85;
    --st-completed-bg: #173d27;  --st-completed-fg: #97dbb0;
    --st-cancelled-bg: #4a1f1f;  --st-cancelled-fg: #f0a9a9;
    --type-bg: #33284d;          --type-fg: #c9b6f2;
}

html { font-size: 15px; }
body { background: var(--page); color: var(--text); }

.app-nav { background: var(--nav-bg); }
.app-nav .navbar-brand { font-weight: 700; letter-spacing: .08em; }
.app-nav .brand-sub { font-weight: 400; letter-spacing: 0; opacity: .7; font-size: .85rem; margin-left: .6rem; }
.app-nav .nav-link.active { color: #fff; box-shadow: inset 0 -3px 0 var(--accent); }

/* Theme toggle */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; padding: 0; border-radius: 50%; border: 1px solid transparent; background: transparent; color: inherit; }
.theme-toggle:hover { background: rgba(255, 255, 255, .12); }
.theme-toggle svg { width: 1.15rem; height: 1.15rem; }
.theme-toggle .icon-sun { display: none; }
[data-bs-theme="dark"] .theme-toggle .icon-sun { display: inline; }
[data-bs-theme="dark"] .theme-toggle .icon-moon { display: none; }
.app-nav .theme-toggle { color: rgba(255, 255, 255, .85); }
.theme-toggle-floating { position: fixed; top: 1rem; right: 1rem; z-index: 10; color: var(--muted); border-color: var(--line); background: var(--surface); }
.theme-toggle-floating:hover { background: var(--surface-2); }

h1.page-title { font-size: 1.6rem; font-weight: 600; margin: 0; }
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head .subtitle { color: var(--muted); }

.card { background: var(--surface); border-color: var(--line); border-radius: .6rem; }
.card-header { background: var(--surface); font-weight: 600; border-color: var(--line); }
.section-label { text-transform: uppercase; font-size: .72rem; letter-spacing: .06em; color: var(--muted); font-weight: 600; }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: .6rem; padding: 1rem 1.1rem; height: 100%; }
.stat .value { font-size: 1.9rem; font-weight: 600; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .85rem; }

.badge-status { font-weight: 500; padding: .35em .65em; border-radius: 1rem; font-size: .78rem; }
.status-notstarted { background: var(--st-notstarted-bg); color: var(--st-notstarted-fg); }
.status-inprogress { background: var(--st-inprogress-bg); color: var(--st-inprogress-fg); }
.status-onhold { background: var(--st-onhold-bg); color: var(--st-onhold-fg); }
.status-completed { background: var(--st-completed-bg); color: var(--st-completed-fg); }
.status-cancelled { background: var(--st-cancelled-bg); color: var(--st-cancelled-fg); }
.badge-type { background: var(--type-bg); color: var(--type-fg); font-weight: 500; border-radius: 1rem; font-size: .78rem; padding: .35em .65em; }

.table { --bs-table-bg: var(--surface); --bs-table-border-color: var(--line); }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: .6rem; overflow: hidden; }
.table-card .table { margin: 0; }
/* Reports: every body cell in the same font and size (headers keep the shared thead style). */
.report-table tbody td, .report-table tbody th, .report-table tbody td * { font-family: var(--bs-body-font-family); font-size: 1rem; }
/* Report tables whose columns have set widths (<th style="width:…%">): long text wraps instead of widening its column;
   below the minimum width the table scrolls sideways. */
.report-table-fixed { table-layout: fixed; min-width: 56rem; }
.report-table-fixed td { overflow-wrap: anywhere; }

/* Forms whose fields must all share one font and size (inputs, selects and rich-text editors). */
.uniform-fields .form-control, .uniform-fields .form-select, .uniform-fields .editor-wrap .ql-container,
.uniform-fields .editor-wrap .ql-editor, .uniform-fields .editor-wrap .ql-editor * { font-family: var(--bs-body-font-family); font-size: 1rem; }
.list-group { --bs-list-group-bg: var(--surface); --bs-list-group-border-color: var(--line); }

.rich-content { overflow-wrap: anywhere; }
.rich-content p:last-child { margin-bottom: 0; }
.rich-content img { max-width: 100%; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline > li { position: relative; padding: 0 0 1.25rem 1.5rem; border-left: 2px solid var(--line); margin-left: .4rem; }
.timeline > li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline > li::before { content: ""; position: absolute; left: -7px; top: .3rem; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.timeline .meta { color: var(--muted); font-size: .8rem; }

.editor-wrap .ql-toolbar { border-radius: .4rem .4rem 0 0; background: var(--surface-2); }
.editor-wrap .ql-toolbar.ql-snow, .editor-wrap .ql-container.ql-snow { border-color: var(--line); }
.editor-wrap .ql-container { border-radius: 0 0 .4rem .4rem; min-height: 140px; font-size: 1rem; font-family: inherit; }
[data-bs-theme="dark"] .ql-snow .ql-stroke { stroke: var(--text); }
[data-bs-theme="dark"] .ql-snow .ql-fill { fill: var(--text); }
[data-bs-theme="dark"] .ql-snow .ql-picker { color: var(--text); }
[data-bs-theme="dark"] .ql-snow .ql-picker-options { background: var(--surface-2); }
[data-bs-theme="dark"] .ql-editor.ql-blank::before { color: var(--muted); }
[data-bs-theme="dark"] .ql-snow .ql-tooltip { background: var(--surface-2); color: var(--text); border-color: var(--line); box-shadow: none; }

.login-wrap { max-width: 420px; margin: 6vh auto 0; }
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand .brand-mark { font-weight: 700; letter-spacing: .12em; font-size: 1.6rem; color: var(--brand-text); }
.login-brand .sub { color: var(--muted); }

.rating-input { display: flex; gap: .5rem; flex-wrap: wrap; }
.rating-input input { display: none; }
.rating-input label { border: 1px solid var(--line); border-radius: .5rem; padding: .5rem .9rem; cursor: pointer; background: var(--surface); }
.rating-input input:checked + label { background: var(--brand); color: #fff; border-color: var(--brand); }

.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-2); --bs-btn-hover-border-color: var(--brand-2); --bs-btn-active-bg: var(--brand-2); --bs-btn-active-border-color: var(--brand-2); }
.nav-tabs { --bs-nav-tabs-border-color: var(--line); --bs-nav-tabs-link-active-bg: var(--page); --bs-nav-tabs-link-active-border-color: var(--line) var(--line) var(--page); }
.nav-tabs .nav-link { color: var(--muted); }
.nav-tabs .nav-link.active { color: var(--brand-text); font-weight: 600; }
.pagination { --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); }

.empty { color: var(--muted); padding: 1.5rem; text-align: center; }

/* Sortable table headers (see site.js) */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--bs-body-color); }
th.sortable::after { content: "↕"; margin-left: .35rem; opacity: .35; font-size: .85em; }
th.sortable[aria-sort="ascending"]::after { content: "↑"; opacity: 1; }
th.sortable[aria-sort="descending"]::after { content: "↓"; opacity: 1; }
th.sortable .sort-link { color: inherit; text-decoration: none; }
