/* ==========================================================================
   TMS design system — DEPDev Region IV-A
   Tokens → base → shell → components → pages → motion → print
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/inter/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/inter/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --------------------------------------------------------------- Tokens */
:root {
  --tms-primary: #17365d;
  --tms-primary-700: #10284a;
  --tms-primary-interactive: #2457a7;
  --tms-primary-interactive-hover: #1d4889;
  --tms-primary-soft: #e8eef8;
  --tms-accent: #d4a64a;
  --tms-accent-soft: #fbf3e2;
  --tms-bg: #f5f7fb;
  --tms-surface: #ffffff;
  --tms-surface-2: #f8fafc;
  --tms-surface-3: #eef2f7;
  --tms-text: #1f2937;
  --tms-text-muted: #64748b;
  --tms-border: #e2e8f0;
  --tms-border-strong: #cbd5e1;

  --tms-success: #15803d;
  --tms-success-soft: #e7f6ec;
  --tms-warning: #b45309;
  --tms-warning-soft: #fdf2e3;
  --tms-danger: #b91c1c;
  --tms-danger-soft: #fdecec;
  --tms-info: #0369a1;
  --tms-info-soft: #e5f2fa;
  --tms-neutral: #475569;
  --tms-neutral-soft: #eef1f5;

  --tms-sidebar-bg: #17365d;
  --tms-sidebar-text: #c9d5e8;
  --tms-sidebar-text-strong: #ffffff;
  --tms-sidebar-hover: rgba(255, 255, 255, 0.07);
  --tms-sidebar-active: rgba(255, 255, 255, 0.12);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow-2: 0 4px 12px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-3: 0 12px 28px rgba(15, 23, 42, 0.14), 0 4px 10px rgba(15, 23, 42, 0.08);
  --focus-ring: 0 0 0 3px rgba(36, 87, 167, 0.35);

  --motion-fast: 120ms;
  --motion-base: 200ms;
  --motion-slow: 320ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(0.3, 0, 0, 1.2);

  --sidebar-w: 264px;
  --sidebar-rail-w: 76px;
  --topbar-h: 64px;

  /* Bootstrap mapping */
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: 0.9375rem;
  --bs-body-color: var(--tms-text);
  --bs-body-bg: var(--tms-bg);
  --bs-primary: var(--tms-primary-interactive);
  --bs-primary-rgb: 36, 87, 167;
  --bs-link-color: var(--tms-primary-interactive);
  --bs-link-color-rgb: 36, 87, 167;
  --bs-link-hover-color: var(--tms-primary-interactive-hover);
  --bs-border-color: var(--tms-border);
  --bs-border-radius: var(--radius-sm);
  --bs-border-radius-lg: var(--radius-md);
  --bs-secondary-color: var(--tms-text-muted);
  --bs-emphasis-color: #0f172a;
  --bs-heading-color: #0f172a;
  --bs-tertiary-bg: var(--tms-surface-2);
  color-scheme: light;
}

:root[data-bs-theme="dark"] {
  --tms-primary: #8fb3ea;
  --tms-primary-700: #b8cff3;
  --tms-primary-interactive: #5b8fe0;
  --tms-primary-interactive-hover: #79a5ea;
  --tms-primary-soft: #1b2a44;
  --tms-accent: #e3b866;
  --tms-accent-soft: #3a2f19;
  --tms-bg: #0d1420;
  --tms-surface: #141d2c;
  --tms-surface-2: #182234;
  --tms-surface-3: #1f2b40;
  --tms-text: #e5e9f0;
  --tms-text-muted: #9aa8bc;
  --tms-border: #263349;
  --tms-border-strong: #33435f;
  --tms-success: #4ade80;
  --tms-success-soft: #12301f;
  --tms-warning: #fbbf62;
  --tms-warning-soft: #3a2a12;
  --tms-danger: #f87171;
  --tms-danger-soft: #3a1717;
  --tms-info: #5ec2f2;
  --tms-info-soft: #10283a;
  --tms-neutral: #a3b1c4;
  --tms-neutral-soft: #1e293b;
  --tms-sidebar-bg: #0f1a2c;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 14px 32px rgba(0, 0, 0, 0.55);
  --bs-body-color: var(--tms-text);
  --bs-body-bg: var(--tms-bg);
  --bs-emphasis-color: #f8fafc;
  --bs-heading-color: #f1f5f9;
  --bs-border-color: var(--tms-border);
  --bs-secondary-color: var(--tms-text-muted);
  --bs-tertiary-bg: var(--tms-surface-2);
  --bs-primary-rgb: 91, 143, 224;
  --bs-link-color: var(--tms-primary-interactive);
  --bs-link-color-rgb: 91, 143, 224;
  color-scheme: dark;
}

/* ----------------------------------------------------------------- Base */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--bs-body-font-family);
  background: var(--tms-bg);
  color: var(--tms-text);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
h1, h2, h3, h4, h5, h6 { font-weight: 650; letter-spacing: -0.01em; color: var(--bs-heading-color); }
.tabular { font-variant-numeric: tabular-nums; }
.text-muted, .text-secondary { color: var(--tms-text-muted) !important; }
a { text-underline-offset: 2px; }
:focus-visible { outline: none; box-shadow: var(--focus-ring) !important; border-radius: var(--radius-sm); }
.skip-link {
  position: absolute; left: var(--space-4); top: -60px; z-index: 2000;
  background: var(--tms-primary); color: #fff; padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm);
  transition: top var(--motion-base) var(--ease-standard);
}
.skip-link:focus { top: var(--space-3); color: #fff; }
.visually-hidden-focusable:not(:focus) { position: absolute !important; }

/* Bootstrap component tuning */
.btn { --bs-btn-font-weight: 550; --bs-btn-border-radius: var(--radius-sm); min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; transition: transform var(--motion-fast) var(--ease-standard), box-shadow var(--motion-fast) var(--ease-standard), background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast); }
.btn-sm { min-height: 34px; --bs-btn-padding-x: 0.65rem; }
.btn-lg { min-height: 48px; }
.btn:not(:disabled):not(.btn-link):hover { transform: translateY(-1px); box-shadow: var(--shadow-1); }
.btn:not(:disabled):active { transform: scale(0.98); }
.btn-primary {
  --bs-btn-bg: var(--tms-primary-interactive); --bs-btn-border-color: var(--tms-primary-interactive);
  --bs-btn-hover-bg: var(--tms-primary-interactive-hover); --bs-btn-hover-border-color: var(--tms-primary-interactive-hover);
  --bs-btn-active-bg: var(--tms-primary); --bs-btn-active-border-color: var(--tms-primary);
  --bs-btn-disabled-bg: var(--tms-primary-interactive); --bs-btn-disabled-border-color: var(--tms-primary-interactive);
}
.btn-outline-primary {
  --bs-btn-color: var(--tms-primary-interactive); --bs-btn-border-color: var(--tms-border-strong);
  --bs-btn-hover-bg: var(--tms-primary-soft); --bs-btn-hover-color: var(--tms-primary-interactive); --bs-btn-hover-border-color: var(--tms-primary-interactive);
  --bs-btn-active-bg: var(--tms-primary-soft); --bs-btn-active-color: var(--tms-primary-interactive); --bs-btn-active-border-color: var(--tms-primary-interactive);
}
.btn-light, .btn-subtle {
  --bs-btn-bg: var(--tms-surface); --bs-btn-color: var(--tms-text); --bs-btn-border-color: var(--tms-border);
  --bs-btn-hover-bg: var(--tms-surface-2); --bs-btn-hover-color: var(--tms-text); --bs-btn-hover-border-color: var(--tms-border-strong);
  --bs-btn-active-bg: var(--tms-surface-3); --bs-btn-active-border-color: var(--tms-border-strong); --bs-btn-active-color: var(--tms-text);
}
.btn-success { --bs-btn-bg: var(--tms-success); --bs-btn-border-color: var(--tms-success); --bs-btn-hover-bg: #116a33; --bs-btn-hover-border-color: #116a33; }
.btn-danger { --bs-btn-bg: var(--tms-danger); --bs-btn-border-color: var(--tms-danger); --bs-btn-hover-bg: #9a1717; --bs-btn-hover-border-color: #9a1717; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.btn.is-loading { pointer-events: none; position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: rgba(255,255,255,.9) rgba(255,255,255,.9) rgba(255,255,255,.25) rgba(255,255,255,.25);
  animation: tms-spin 700ms linear infinite;
}
.btn-light.is-loading::after, .btn-subtle.is-loading::after, .btn-outline-primary.is-loading::after { border-color: var(--tms-primary-interactive) var(--tms-primary-interactive) transparent transparent; }

.form-control, .form-select {
  min-height: 42px; border-color: var(--tms-border-strong); border-radius: var(--radius-sm);
  background-color: var(--tms-surface); color: var(--tms-text);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
textarea.form-control { min-height: 96px; }
.form-control:focus, .form-select:focus { border-color: var(--tms-primary-interactive); box-shadow: var(--focus-ring); }
.form-label { font-weight: 600; font-size: 0.875rem; margin-bottom: 0.35rem; color: var(--tms-text); }
.form-text { color: var(--tms-text-muted); font-size: 0.8125rem; }
.form-check-input:checked { background-color: var(--tms-primary-interactive); border-color: var(--tms-primary-interactive); }
.form-check-input:focus { box-shadow: var(--focus-ring); border-color: var(--tms-primary-interactive); }
.form-switch .form-check-input { width: 2.4em; height: 1.3em; }
.is-invalid { border-color: var(--tms-danger) !important; }
.invalid-feedback { color: var(--tms-danger); font-weight: 500; }
.required::after { content: " *"; color: var(--tms-danger); }
.field-shake { animation: tms-shake 320ms var(--ease-standard) 1; }
@media (max-width: 575.98px) { .form-control, .form-select { font-size: 16px; } }

.card { --bs-card-border-color: var(--tms-border); --bs-card-bg: var(--tms-surface); --bs-card-border-radius: var(--radius-md); --bs-card-cap-bg: transparent; box-shadow: var(--shadow-1); }
.card-header { border-bottom-color: var(--tms-border); padding: var(--space-4) var(--space-5); font-weight: 650; }
.card-body { padding: var(--space-5); }
.dropdown-menu { --bs-dropdown-border-color: var(--tms-border); --bs-dropdown-bg: var(--tms-surface); --bs-dropdown-link-color: var(--tms-text); --bs-dropdown-link-hover-bg: var(--tms-surface-2); --bs-dropdown-link-active-bg: var(--tms-primary-soft); --bs-dropdown-link-active-color: var(--tms-primary-interactive); border-radius: var(--radius-md); box-shadow: var(--shadow-3); padding: 6px; animation: tms-pop var(--motion-base) var(--ease-standard); }
.dropdown-item { border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; display: flex; align-items: center; gap: 0.6rem; min-height: 40px; }
.modal { --bs-modal-border-radius: var(--radius-lg); --bs-modal-bg: var(--tms-surface); --bs-modal-border-color: var(--tms-border); }
.modal-content { box-shadow: var(--shadow-3); }
.modal-header, .modal-footer { border-color: var(--tms-border); }
.modal-footer { position: sticky; bottom: 0; background: var(--tms-surface); z-index: 2; }
.modal.fade .modal-dialog { transform: translateY(14px) scale(0.98); transition: transform var(--motion-slow) var(--ease-standard); }
.modal.show .modal-dialog { transform: none; }
.offcanvas { --bs-offcanvas-bg: var(--tms-surface); --bs-offcanvas-border-color: var(--tms-border); }
.table { --bs-table-bg: transparent; --bs-table-color: var(--tms-text); --bs-table-border-color: var(--tms-border); --bs-table-hover-bg: var(--tms-surface-2); }
.nav-tabs { --bs-nav-tabs-border-color: var(--tms-border); --bs-nav-tabs-link-active-bg: transparent; --bs-nav-tabs-link-active-border-color: transparent; }
.nav-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; color: var(--tms-text-muted); font-weight: 600; padding: 0.7rem 0.9rem; min-height: 44px; display: inline-flex; align-items: center; gap: 0.4rem; }
.nav-tabs .nav-link:hover { color: var(--tms-text); }
.nav-tabs .nav-link.active { color: var(--tms-primary-interactive); border-bottom-color: var(--tms-primary-interactive); background: transparent; }
.pagination { --bs-pagination-color: var(--tms-text); --bs-pagination-bg: var(--tms-surface); --bs-pagination-border-color: var(--tms-border); --bs-pagination-active-bg: var(--tms-primary-interactive); --bs-pagination-active-border-color: var(--tms-primary-interactive); --bs-pagination-hover-bg: var(--tms-surface-2); --bs-pagination-disabled-bg: var(--tms-surface-2); }
.pagination .page-link { min-width: 40px; min-height: 40px; display: flex; align-items: center; justify-content: center; }
.alert { border-radius: var(--radius-md); border-width: 1px; }
.badge { font-weight: 600; }
.tooltip { --bs-tooltip-bg: #0f172a; --bs-tooltip-font-size: 0.8rem; }

/* Tom Select alignment with the theme */
.ts-wrapper .ts-control { min-height: 42px; border-color: var(--tms-border-strong); border-radius: var(--radius-sm); background: var(--tms-surface); color: var(--tms-text); }
.ts-wrapper.focus .ts-control { border-color: var(--tms-primary-interactive); box-shadow: var(--focus-ring); }
.ts-wrapper.multi .ts-control > div { background: var(--tms-primary-soft); color: var(--tms-primary-interactive); border-radius: var(--radius-pill); border: 0; padding: 2px 10px; font-weight: 550; }
.ts-dropdown { border-radius: var(--radius-md); box-shadow: var(--shadow-3); border-color: var(--tms-border); background: var(--tms-surface); color: var(--tms-text); z-index: 1090; }
.ts-dropdown .active { background: var(--tms-primary-soft); color: var(--tms-text); }
.ts-dropdown .option { padding: 8px 12px; }
.ts-opt { display: flex; align-items: center; gap: 10px; }
.ts-opt small { color: var(--tms-text-muted); display: block; line-height: 1.2; }
.is-invalid + .ts-wrapper .ts-control, .ts-wrapper.is-invalid .ts-control { border-color: var(--tms-danger); }
.flatpickr-calendar { border-radius: var(--radius-md); box-shadow: var(--shadow-3); font-family: var(--bs-body-font-family); }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--tms-primary-interactive); border-color: var(--tms-primary-interactive); }

/* ---------------------------------------------------------------- Shell */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1035;
  background: var(--tms-sidebar-bg); color: var(--tms-sidebar-text);
  display: flex; flex-direction: column;
  transition: width var(--motion-slow) var(--ease-standard), transform var(--motion-slow) var(--ease-standard);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; height: var(--topbar-h); padding: 0 var(--space-5); color: #fff; text-decoration: none; flex-shrink: 0; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.sidebar-brand:hover { color: #fff; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(145deg, var(--tms-accent), #b8862f); display: grid; place-items: center; color: #17365d; font-weight: 800; font-size: 0.95rem; flex-shrink: 0; letter-spacing: -0.02em; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; background: #fff; }
.brand-text { line-height: 1.15; overflow: hidden; white-space: nowrap; }
.brand-text strong { display: block; font-size: 1rem; letter-spacing: 0.02em; }
.brand-text span { font-size: 0.72rem; color: var(--tms-sidebar-text); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-3); scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.nav-group-label { font-size: 0.68rem; letter-spacing: 0.09em; text-transform: uppercase; color: rgba(201, 213, 232, 0.6); padding: var(--space-4) var(--space-3) var(--space-2); font-weight: 650; white-space: nowrap; }
.nav-group-label:first-child { padding-top: var(--space-1); }
.side-link {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 0 var(--space-3); min-height: 44px;
  color: var(--tms-sidebar-text); text-decoration: none; border-radius: var(--radius-sm); font-weight: 550; font-size: 0.9rem;
  transition: background-color var(--motion-fast), color var(--motion-fast); white-space: nowrap;
}
.side-link i { font-size: 1.15rem; width: 22px; text-align: center; flex-shrink: 0; }
.side-link:hover { background: var(--tms-sidebar-hover); color: var(--tms-sidebar-text-strong); }
.side-link.active { background: var(--tms-sidebar-active); color: #fff; }
.side-link.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--tms-accent); }
.sidebar-foot { padding: var(--space-3); border-top: 1px solid rgba(255, 255, 255, 0.07); font-size: 0.72rem; color: rgba(201, 213, 232, 0.6); white-space: nowrap; overflow: hidden; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left var(--motion-slow) var(--ease-standard); }
.topbar {
  position: sticky; top: 0; z-index: 1030; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-6);
  background: color-mix(in srgb, var(--tms-surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--tms-border);
}
.topbar-title { font-weight: 650; font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-search { max-width: 380px; flex: 1; position: relative; }
.topbar-search .form-control { padding-left: 38px; background: var(--tms-surface-2); border-color: var(--tms-border); }
.topbar-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--tms-text-muted); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: var(--radius-pill); border: 1px solid var(--tms-border); background: var(--tms-surface); color: var(--tms-text); min-height: 44px; }
.user-chip:hover { border-color: var(--tms-border-strong); }
.user-chip .uc-name { font-weight: 600; font-size: 0.875rem; line-height: 1.1; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .uc-sub { font-size: 0.72rem; color: var(--tms-text-muted); }
.content { padding: var(--space-6); flex: 1; width: 100%; max-width: 1680px; margin: 0 auto; }
.content.content-narrow { max-width: 1240px; }
.app-footer { padding: var(--space-4) var(--space-6); color: var(--tms-text-muted); font-size: 0.8rem; border-top: 1px solid var(--tms-border); display: flex; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }

/* Collapsed rail (desktop): icons only, centred, labels shown as tooltips */
.sidebar-nav { overflow-x: hidden; }
.sidebar-collapsed .sidebar { width: var(--sidebar-rail-w); }
.sidebar-collapsed .main { margin-left: var(--sidebar-rail-w); }
.sidebar-collapsed .brand-text, .sidebar-collapsed .sidebar-foot span { opacity: 0; pointer-events: none; }
.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; gap: 0; }
.sidebar-collapsed .brand-text { width: 0; }
.sidebar-collapsed .sidebar-nav { padding-left: 12px; padding-right: 12px; }
.sidebar-collapsed .side-link { justify-content: center; padding: 0; gap: 0; width: 52px; margin: 0 auto 2px; }
.sidebar-collapsed .side-link span { display: none; }
.sidebar-collapsed .side-link i { width: auto; font-size: 1.25rem; }
.sidebar-collapsed .side-link.active::before { left: -12px; }
.sidebar-collapsed .nav-group-label { font-size: 0; height: 1px; padding: 0; margin: 10px 8px; background: rgba(255, 255, 255, 0.1); }
.sidebar-collapsed .nav-group-label:first-child { display: none; }
.brand-text, .side-link span, .nav-group-label { transition: opacity var(--motion-base) var(--ease-standard); }

/* Mobile: sidebar becomes an off-canvas panel */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); width: min(86vw, 300px); box-shadow: var(--shadow-3); }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 1034; opacity: 0; pointer-events: none; transition: opacity var(--motion-slow); }
  .sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .main, .sidebar-collapsed .main { margin-left: 0; }
  .sidebar-collapsed .sidebar { width: min(86vw, 300px); }
  .sidebar-collapsed .brand-text, .sidebar-collapsed .nav-group-label { opacity: 1; }
  .sidebar-collapsed .brand-text { width: auto; }
  .sidebar-collapsed .sidebar-brand { justify-content: flex-start; padding: 0 var(--space-5); gap: 12px; }
  .sidebar-collapsed .side-link { justify-content: flex-start; padding: 0 var(--space-3); gap: 12px; width: auto; margin: 0; }
  .sidebar-collapsed .side-link span { display: inline; }
  .sidebar-collapsed .side-link i { width: 22px; font-size: 1.15rem; }
  .sidebar-collapsed .nav-group-label { font-size: 0.68rem; height: auto; padding: var(--space-4) var(--space-3) var(--space-2); margin: 0; background: none; }
  .sidebar-collapsed .nav-group-label:first-child { display: block; }
  .mail-status { left: 16px; }
  .topbar { padding: 0 var(--space-4); padding-left: max(var(--space-4), env(safe-area-inset-left)); padding-right: max(var(--space-4), env(safe-area-inset-right)); }
  .content { padding: var(--space-4); padding-left: max(var(--space-4), env(safe-area-inset-left)); padding-right: max(var(--space-4), env(safe-area-inset-right)); }
}

/* Floating "New task" button on phones */
.fab { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 1025; width: 56px; height: 56px; border-radius: 18px; box-shadow: var(--shadow-3); font-size: 1.4rem; }

/* ---------------------------------------------------------- Page header */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap; }
.page-header h1 { font-size: 1.5rem; line-height: 2rem; margin: 0; }
.page-header .subtitle { color: var(--tms-text-muted); margin: 2px 0 0; font-size: 0.9rem; }
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.breadcrumb { --bs-breadcrumb-divider-color: var(--tms-text-muted); --bs-breadcrumb-item-active-color: var(--tms-text-muted); font-size: 0.8125rem; margin-bottom: 4px; }
@media (max-width: 575.98px) {
  .page-header { align-items: stretch; }
  .page-header h1 { font-size: 1.3rem; }
  .page-actions { width: 100%; }
  .page-actions > .btn, .page-actions > .btn-group { flex: 1; }
}

/* --------------------------------------------------------------- Badges */
.st-badge, .pr-badge, .dl-chip {
  display: inline-flex; align-items: center; gap: 5px; border-radius: var(--radius-pill);
  font-size: 0.75rem; font-weight: 650; padding: 3px 9px; line-height: 1.35; white-space: nowrap; border: 1px solid transparent;
}
.st-badge i, .pr-badge i, .dl-chip i { font-size: 0.8em; }
.st-new { background: var(--tms-neutral-soft); color: var(--tms-neutral); border-color: color-mix(in srgb, var(--tms-neutral) 22%, transparent); }
.st-progress { background: var(--tms-info-soft); color: var(--tms-info); border-color: color-mix(in srgb, var(--tms-info) 22%, transparent); }
.st-done { background: var(--tms-success-soft); color: var(--tms-success); border-color: color-mix(in srgb, var(--tms-success) 22%, transparent); }
.pr-badge { background: var(--tms-accent-soft); color: #8a5a07; border-color: color-mix(in srgb, var(--tms-accent) 45%, transparent); }
:root[data-bs-theme="dark"] .pr-badge { color: var(--tms-accent); }
.dl-overdue, .dl-today { background: var(--tms-danger-soft); color: var(--tms-danger); border-color: color-mix(in srgb, var(--tms-danger) 25%, transparent); }
.dl-soon { background: var(--tms-warning-soft); color: var(--tms-warning); border-color: color-mix(in srgb, var(--tms-warning) 25%, transparent); }
.dl-ok { background: var(--tms-surface-2); color: var(--tms-text-muted); border-color: var(--tms-border); }
.dl-done { background: var(--tms-success-soft); color: var(--tms-success); }
.dl-none { background: var(--tms-surface-2); color: var(--tms-text-muted); }
.id-chip { font-size: 0.72rem; font-weight: 700; color: var(--tms-text-muted); background: var(--tms-surface-3); border-radius: var(--radius-sm); padding: 2px 7px; letter-spacing: 0.02em; }

/* -------------------------------------------------------------- Avatars */
.avatar { --hue: 215; width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; color: hsl(var(--hue) 55% 28%); background: hsl(var(--hue) 70% 90%);
  border: 2px solid var(--tms-surface); overflow: hidden; }
:root[data-bs-theme="dark"] .avatar { color: hsl(var(--hue) 80% 85%); background: hsl(var(--hue) 35% 28%); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 26px; height: 26px; font-size: 0.65rem; }
.avatar-lg { width: 44px; height: 44px; font-size: 0.9rem; }
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar { margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-more { background: var(--tms-surface-3) !important; color: var(--tms-text-muted) !important; }

/* ---------------------------------------------------------- Filter bar */
.toolbar { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-bottom: var(--space-4); }
.toolbar .search { position: relative; flex: 1 1 260px; max-width: 420px; }
.toolbar .search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--tms-text-muted); pointer-events: none; }
.toolbar .search .form-control { padding-left: 38px; }
.toolbar .search .btn-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; width: 36px; height: 36px; color: var(--tms-text-muted); border-radius: var(--radius-sm); }
.view-switch { display: inline-flex; background: var(--tms-surface); border: 1px solid var(--tms-border); border-radius: var(--radius-md); padding: 3px; gap: 2px; }
.view-switch a { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; min-height: 36px; border-radius: 7px; color: var(--tms-text-muted); text-decoration: none; font-weight: 600; font-size: 0.875rem; transition: background-color var(--motion-fast), color var(--motion-fast); }
.view-switch a:hover { color: var(--tms-text); background: var(--tms-surface-2); }
.view-switch a.active { background: var(--tms-primary-soft); color: var(--tms-primary-interactive); }
.filter-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 10px; background: var(--tms-primary-interactive); color: #fff; font-size: 0.7rem; padding: 0 6px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 var(--space-4); }
.active-filters .chip { display: inline-flex; align-items: center; gap: 6px; background: var(--tms-primary-soft); color: var(--tms-primary-interactive); border-radius: var(--radius-pill); padding: 3px 4px 3px 11px; font-size: 0.8rem; font-weight: 600; }
.active-filters .chip a { color: inherit; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; text-decoration: none; }
.active-filters .chip a:hover { background: rgba(36, 87, 167, 0.15); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 0.8125rem; color: var(--tms-text-muted); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-new { background: var(--tms-neutral); } .sw-progress { background: var(--tms-info); } .sw-done { background: var(--tms-success); } .sw-soon { background: var(--tms-warning); } .sw-danger { background: var(--tms-danger); }

/* --------------------------------------------------------------- Board */
.board { display: grid; grid-template-columns: repeat(3, minmax(280px, 1fr)); gap: var(--space-4); align-items: start; }
.board-col { background: var(--tms-surface-2); border: 1px solid var(--tms-border); border-radius: var(--radius-lg); display: flex; flex-direction: column; min-height: 240px; max-height: calc(100vh - 230px); transition: background-color var(--motion-base), border-color var(--motion-base), box-shadow var(--motion-base); }
.board-col-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 12px; border-top: 4px solid var(--col-color, var(--tms-neutral)); border-radius: var(--radius-lg) var(--radius-lg) 0 0; background: var(--tms-surface-2); }
.board-col-head h2 { font-size: 0.95rem; margin: 0; display: flex; align-items: center; gap: 8px; }
.board-col-head h2 i { color: var(--col-color); }
.col-count { font-variant-numeric: tabular-nums; background: var(--tms-surface); border: 1px solid var(--tms-border); border-radius: var(--radius-pill); font-size: 0.75rem; font-weight: 700; padding: 1px 9px; color: var(--tms-text-muted); transition: transform var(--motion-base) var(--ease-emphasized); }
.col-count.bump { animation: tms-bump 420ms var(--ease-emphasized); }
.board-col[data-status="newly assigned"] { --col-color: var(--tms-neutral); }
.board-col[data-status="in progress"] { --col-color: var(--tms-info); }
.board-col[data-status="completed"] { --col-color: var(--tms-success); }
.board-list { padding: 4px 12px 12px; overflow-y: auto; flex: 1; min-height: 120px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; }
.board-col.drop-target { background: color-mix(in srgb, var(--col-color) 7%, var(--tms-surface-2)); border-color: color-mix(in srgb, var(--col-color) 55%, transparent); border-style: dashed; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--col-color) 30%, transparent); }
.board-empty { text-align: center; color: var(--tms-text-muted); font-size: 0.85rem; padding: 26px 10px; border: 1.5px dashed var(--tms-border-strong); border-radius: var(--radius-md); margin-top: 2px; }
.board-more { font-size: 0.8rem; text-align: center; padding: 6px 0 2px; }

.task-card {
  position: relative; background: var(--tms-surface); border: 1px solid var(--tms-border); border-radius: var(--radius-md);
  padding: 12px 12px 10px 14px; box-shadow: var(--shadow-1); cursor: pointer;
  transition: box-shadow var(--motion-fast) var(--ease-standard), transform var(--motion-fast) var(--ease-standard), border-color var(--motion-fast);
}
.task-card::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--tone, transparent); }
.task-card:has(.dropdown-menu.show), .task-card.menu-open { z-index: 30; }
/* Card menus are moved to <body> while open so the scrolling column can never cut them off. */
.dropdown-menu.tc-floating { z-index: 1060; min-width: 220px; }
.dropdown-menu.tc-floating.tc-placing { visibility: hidden; animation: none; }
.task-card:hover { box-shadow: var(--shadow-2); border-color: var(--tms-border-strong); transform: translateY(-1px); }
.task-card:focus-visible { box-shadow: var(--focus-ring), var(--shadow-2) !important; }
.task-card.tone-overdue, .task-card.tone-today { --tone: var(--tms-danger); background: color-mix(in srgb, var(--tms-danger-soft) 45%, var(--tms-surface)); }
.task-card.tone-soon { --tone: var(--tms-warning); background: color-mix(in srgb, var(--tms-warning-soft) 45%, var(--tms-surface)); }
.task-card.tone-progress { --tone: var(--tms-info); }
.task-card.tone-new { --tone: var(--tms-neutral); }
.task-card.tone-done { --tone: var(--tms-success); }
.tc-top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.tc-title { font-weight: 650; font-size: 0.9rem; line-height: 1.35; color: var(--tms-text); margin: 0 0 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.tc-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.tc-icons { display: inline-flex; gap: 10px; color: var(--tms-text-muted); font-size: 0.78rem; font-weight: 600; }
.tc-icons span { display: inline-flex; gap: 4px; align-items: center; }
.tc-names { font-size: 0.78rem; color: var(--tms-text-muted); margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-done { font-size: 0.76rem; color: var(--tms-success); font-weight: 600; margin-top: 6px; display: flex; gap: 5px; align-items: center; }
.tc-handle { margin-left: auto; color: var(--tms-text-muted); border: 0; background: transparent; width: 32px; height: 32px; border-radius: var(--radius-sm); display: inline-grid; place-items: center; cursor: grab; touch-action: none; }
.tc-handle:hover { background: var(--tms-surface-3); color: var(--tms-text); }
.tc-menu { border: 0; background: transparent; width: 32px; height: 32px; border-radius: var(--radius-sm); color: var(--tms-text-muted); display: inline-grid; place-items: center; }
.tc-menu:hover { background: var(--tms-surface-3); color: var(--tms-text); }

/* SortableJS states */
.sortable-ghost { opacity: 0.35; background: var(--tms-primary-soft) !important; border-style: dashed !important; box-shadow: none !important; }
.sortable-ghost > * { visibility: hidden; }
.sortable-drag, .sortable-fallback { opacity: 1 !important; transform: rotate(1.5deg) scale(1.02); box-shadow: var(--shadow-3) !important; cursor: grabbing; }
.task-card.settle { animation: tms-settle 420ms var(--ease-emphasized); }
.task-card.flash { animation: tms-flash 1100ms var(--ease-standard); }
.task-card.enter { animation: tms-enter 260ms var(--ease-standard) both; }

/* Mobile board: one column at a time, chosen with the segmented control */
.board-tabs { display: none; }
@media (max-width: 991.98px) {
  .board-tabs { display: flex; gap: 4px; background: var(--tms-surface); border: 1px solid var(--tms-border); border-radius: var(--radius-md); padding: 3px; margin-bottom: var(--space-3); position: sticky; top: calc(var(--topbar-h) + 6px); z-index: 5; box-shadow: var(--shadow-1); }
  .board-tabs button { flex: 1; border: 0; background: transparent; border-radius: 7px; min-height: 42px; font-weight: 650; font-size: 0.82rem; color: var(--tms-text-muted); display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 6px; transition: background-color var(--motion-fast), color var(--motion-fast); }
  .board-tabs button .n { font-variant-numeric: tabular-nums; background: var(--tms-surface-3); border-radius: 10px; padding: 0 7px; font-size: 0.72rem; }
  .board-tabs button.active { background: var(--tms-primary-soft); color: var(--tms-primary-interactive); }
  .board { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: var(--space-3); scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 calc(var(--space-4) * -1); padding: 0 var(--space-4); }
  .board::-webkit-scrollbar { display: none; }
  .board-col { flex: 0 0 100%; scroll-snap-align: center; max-height: none; }
  .board-col-head { position: static; }
}

/* ------------------------------------------------------------ Calendar */
.calendar-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-4); }
.calendar-card { padding: var(--space-4); }
.fc { --fc-border-color: var(--tms-border); --fc-today-bg-color: var(--tms-accent-soft); --fc-page-bg-color: var(--tms-surface); --fc-neutral-bg-color: var(--tms-surface-2); --fc-list-event-hover-bg-color: var(--tms-surface-2); font-size: 0.85rem; }
.fc .fc-toolbar-title { font-size: 1.1rem; font-weight: 650; }
.fc .fc-button { background: var(--tms-surface); color: var(--tms-text); border: 1px solid var(--tms-border); font-weight: 600; text-transform: capitalize; box-shadow: none !important; min-height: 38px; }
.fc .fc-button:hover { background: var(--tms-surface-2); color: var(--tms-text); border-color: var(--tms-border-strong); }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { background: var(--tms-primary-soft); color: var(--tms-primary-interactive); border-color: var(--tms-primary-interactive); }
.fc .fc-daygrid-day-number, .fc .fc-col-header-cell-cushion { color: var(--tms-text); text-decoration: none; }
.fc-event { border-radius: 6px; border: 0 !important; padding: 2px 6px; font-weight: 600; cursor: pointer; }
.fc-event .fc-event-main { color: inherit; }
.ev-new { background: var(--tms-neutral-soft) !important; color: var(--tms-neutral) !important; box-shadow: inset 3px 0 0 var(--tms-neutral); }
.ev-progress { background: var(--tms-info-soft) !important; color: var(--tms-info) !important; box-shadow: inset 3px 0 0 var(--tms-info); }
.ev-done { background: var(--tms-success-soft) !important; color: var(--tms-success) !important; box-shadow: inset 3px 0 0 var(--tms-success); }
.ev-warning { background: var(--tms-warning-soft) !important; color: var(--tms-warning) !important; box-shadow: inset 3px 0 0 var(--tms-warning); }
.ev-danger { background: var(--tms-danger-soft) !important; color: var(--tms-danger) !important; box-shadow: inset 3px 0 0 var(--tms-danger); }
.fc-list-event .fc-list-event-dot { display: none; }
.day-panel .list-group-item { border-color: var(--tms-border); background: var(--tms-surface); color: var(--tms-text); }
@media (max-width: 1199.98px) { .calendar-wrap { grid-template-columns: 1fr; } }

/* -------------------------------------------------------- Task drawer */
.task-drawer { --bs-offcanvas-width: min(620px, 100vw); }
.task-drawer .offcanvas-header { border-bottom: 1px solid var(--tms-border); padding: 14px 18px; gap: 10px; }
.task-drawer .offcanvas-body { padding: 0; }
.panel-head { padding: 18px 20px 0; }
.panel-head h2 { font-size: 1.2rem; line-height: 1.4; margin: 6px 0 10px; word-break: break-word; }
.panel-tabs { padding: 0 12px; position: sticky; top: 0; background: var(--tms-surface); z-index: 3; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.panel-tabs::-webkit-scrollbar { display: none; }
.panel-tabs .nav-link { white-space: nowrap; }
.panel-section { padding: 18px 20px 24px; }
.detail-grid { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px 16px; font-size: 0.9rem; }
.detail-grid dt { color: var(--tms-text-muted); font-weight: 600; font-size: 0.8125rem; padding-top: 2px; }
.detail-grid dd { margin: 0; }
.instructions { background: var(--tms-surface-2); border: 1px solid var(--tms-border); border-radius: var(--radius-md); padding: 14px 16px; white-space: normal; word-break: break-word; line-height: 1.6; }
.output-box { background: var(--tms-success-soft); border: 1px solid color-mix(in srgb, var(--tms-success) 30%, transparent); border-radius: var(--radius-md); padding: 14px 16px; line-height: 1.6; word-break: break-word; }
.person-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.person-row small { color: var(--tms-text-muted); display: block; line-height: 1.2; }
.file-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--tms-border); border-radius: var(--radius-md); padding: 8px 10px 8px 12px; background: var(--tms-surface); margin-bottom: 8px; transition: border-color var(--motion-fast), background-color var(--motion-fast); }
.file-row:hover { border-color: var(--tms-border-strong); background: var(--tms-surface-2); }
.file-row > i { font-size: 1.4rem; color: var(--tms-primary-interactive); }
.file-row .fname { font-weight: 600; font-size: 0.875rem; word-break: break-all; }
.file-row small { color: var(--tms-text-muted); }
@media (max-width: 575.98px) { .detail-grid { grid-template-columns: 1fr; gap: 2px; } .detail-grid dd { margin-bottom: 10px; } }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--tms-border); }
.timeline li { position: relative; padding: 0 0 18px 40px; }
.timeline .dot { position: absolute; left: 4px; top: 2px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; background: var(--tms-surface); border: 2px solid var(--dot, var(--tms-neutral)); color: var(--dot, var(--tms-neutral)); }
.timeline li.t-new { --dot: var(--tms-neutral); }
.timeline li.t-progress { --dot: var(--tms-info); }
.timeline li.t-done { --dot: var(--tms-success); }
.timeline .t-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 0.85rem; }
.timeline .t-who { font-weight: 650; }
.timeline .t-when { color: var(--tms-text-muted); font-size: 0.78rem; }
.timeline .t-body { margin-top: 6px; background: var(--tms-surface-2); border: 1px solid var(--tms-border); border-radius: var(--radius-md); padding: 10px 12px; font-size: 0.875rem; line-height: 1.55; word-break: break-word; }

/* Comments */
.comment { display: flex; gap: 10px; margin-bottom: 14px; animation: tms-enter 240ms var(--ease-standard) both; }
.comment-bubble { background: var(--tms-surface-2); border: 1px solid var(--tms-border); border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md); padding: 9px 12px; flex: 1; min-width: 0; }
.comment-bubble .c-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.8rem; margin-bottom: 3px; flex-wrap: wrap; }
.comment-bubble .c-head strong { font-weight: 650; }
.comment-bubble .c-text { font-size: 0.875rem; line-height: 1.55; word-break: break-word; }
.comment.mine .comment-bubble { background: var(--tms-primary-soft); border-color: color-mix(in srgb, var(--tms-primary-interactive) 22%, transparent); }
.composer { position: sticky; bottom: 0; background: var(--tms-surface); border-top: 1px solid var(--tms-border); padding: 12px 20px max(12px, env(safe-area-inset-bottom)); }
.composer textarea { resize: none; min-height: 44px; max-height: 160px; }

/* ------------------------------------------------------------ Dropzone */
.dropzone { border: 1.5px dashed var(--tms-border-strong); border-radius: var(--radius-md); padding: 18px; text-align: center; background: var(--tms-surface-2); cursor: pointer; transition: border-color var(--motion-fast), background-color var(--motion-fast); }
.dropzone:hover, .dropzone.over { border-color: var(--tms-primary-interactive); background: var(--tms-primary-soft); }
.dropzone i { font-size: 1.6rem; color: var(--tms-primary-interactive); }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-list { list-style: none; padding: 0; margin: 10px 0 0; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--tms-border); border-radius: var(--radius-sm); margin-bottom: 6px; font-size: 0.85rem; background: var(--tms-surface); animation: tms-enter 200ms var(--ease-standard) both; }
.file-list li.bad { border-color: var(--tms-danger); color: var(--tms-danger); }
.file-list li .sz { color: var(--tms-text-muted); margin-left: auto; white-space: nowrap; }

/* ---------------------------------------------------------- KPI tiles */
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border-radius: var(--radius-md); background: var(--tms-surface); border: 1px solid var(--tms-border); box-shadow: var(--shadow-1); text-decoration: none; color: var(--tms-text); height: 100%; position: relative; overflow: hidden; transition: transform var(--motion-fast), box-shadow var(--motion-fast), border-color var(--motion-fast); }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); color: var(--tms-text); border-color: var(--tms-border-strong); }
.kpi .k-label { font-size: 0.8rem; font-weight: 650; color: var(--tms-text-muted); display: flex; align-items: center; gap: 8px; }
.kpi .k-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--k-soft, var(--tms-primary-soft)); color: var(--k-color, var(--tms-primary-interactive)); font-size: 0.95rem; }
.kpi .k-value { font-size: 1.85rem; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .k-foot { font-size: 0.78rem; color: var(--tms-text-muted); }
.kpi.k-danger { --k-color: var(--tms-danger); --k-soft: var(--tms-danger-soft); }
.kpi.k-warning { --k-color: var(--tms-warning); --k-soft: var(--tms-warning-soft); }
.kpi.k-success { --k-color: var(--tms-success); --k-soft: var(--tms-success-soft); }
.kpi.k-info { --k-color: var(--tms-info); --k-soft: var(--tms-info-soft); }
.kpi.k-neutral { --k-color: var(--tms-neutral); --k-soft: var(--tms-neutral-soft); }
.kpi.k-accent { --k-color: #8a5a07; --k-soft: var(--tms-accent-soft); }
.chart-card .card-body { position: relative; }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--tms-text-muted); font-size: 0.875rem; text-align: center; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--tms-border); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list li > .st-badge, .mini-list li > .dl-chip { flex-shrink: 0; }
.min-w-0 { min-width: 0; }
.mini-list a { color: var(--tms-text); text-decoration: none; font-weight: 600; font-size: 0.875rem; }
.mini-list a:hover { color: var(--tms-primary-interactive); }

/* --------------------------------------------------------------- Tables */
.table-card { overflow: hidden; }
.table-tms { margin: 0; font-size: 0.875rem; }
.table-tms thead th { position: sticky; top: 0; z-index: 1; background: var(--tms-surface-2); color: var(--tms-text-muted); font-weight: 650; font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; border-bottom: 1px solid var(--tms-border); padding: 10px 14px; white-space: nowrap; }
.table-tms thead th a { color: inherit; text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
.table-tms tbody td { padding: 12px 14px; vertical-align: top; border-color: var(--tms-border); }
.table-tms tbody a { text-decoration: none; }
.table-tms tbody a:hover { text-decoration: underline; }
.table-tms tbody tr { transition: background-color var(--motion-fast); }
.table-tms tbody tr:hover { background: var(--tms-surface-2); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll .sticky-col { position: sticky; left: 0; background: var(--tms-surface); z-index: 2; box-shadow: 1px 0 0 var(--tms-border); }
.table-scroll .sticky-col-2 { position: sticky; left: var(--sticky-left, 220px); background: var(--tms-surface); z-index: 2; box-shadow: 1px 0 0 var(--tms-border); }
.table-scroll thead .sticky-col, .table-scroll thead .sticky-col-2 { background: var(--tms-surface-2); z-index: 3; }
.week-cell { min-width: 160px; font-size: 0.8rem; }
.week-cell ul { padding-left: 16px; margin: 0; }
.cell-clip { max-width: 360px; }
.rating { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; font-weight: 750; font-variant-numeric: tabular-nums; }
.rating-5, .rating-4 { background: var(--tms-success-soft); color: var(--tms-success); }
.rating-3 { background: var(--tms-info-soft); color: var(--tms-info); }
.rating-2 { background: var(--tms-warning-soft); color: var(--tms-warning); }
.rating-1 { background: var(--tms-danger-soft); color: var(--tms-danger); }

/* Mobile card list (replaces wide tables on phones) */
.card-list { display: none; }
@media (max-width: 767.98px) {
  .table-desktop { display: none; }
  .card-list { display: flex; flex-direction: column; gap: 10px; }
}
.row-card { background: var(--tms-surface); border: 1px solid var(--tms-border); border-radius: var(--radius-md); padding: 14px; box-shadow: var(--shadow-1); }
.row-card .rc-title { font-weight: 650; margin: 4px 0 8px; word-break: break-word; }
.row-card dl { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 4px 10px; margin: 0; font-size: 0.83rem; }
.row-card dt { color: var(--tms-text-muted); font-weight: 600; }
.row-card dd { margin: 0; word-break: break-word; }

/* ------------------------------------------------------------ Empty state */
.empty-state { text-align: center; padding: 48px 20px; color: var(--tms-text-muted); }
.empty-state .es-icon { width: 64px; height: 64px; border-radius: 18px; background: var(--tms-primary-soft); color: var(--tms-primary-interactive); display: grid; place-items: center; font-size: 1.6rem; margin: 0 auto 14px; }
.empty-state h3 { font-size: 1.05rem; color: var(--tms-text); margin-bottom: 4px; }

/* ------------------------------------------------------------ Skeleton */
.skeleton { position: relative; overflow: hidden; background: var(--tms-surface-3); border-radius: var(--radius-sm); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent); animation: tms-shimmer 1.3s infinite; }
:root[data-bs-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent); }
.sk-line { height: 12px; margin-bottom: 10px; }
.sk-title { height: 20px; width: 70%; margin-bottom: 16px; }
.sk-block { height: 90px; margin-bottom: 14px; }

/* ---------------------------------------------------------- Progress bar */
.top-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 2100; background: linear-gradient(90deg, var(--tms-primary-interactive), var(--tms-accent)); box-shadow: 0 0 8px rgba(36, 87, 167, 0.5); transition: width 300ms var(--ease-standard), opacity 300ms; opacity: 0; }
.top-progress.on { opacity: 1; }

/* --------------------------------------------------------------- Toasts */
.toast-region { position: fixed; bottom: max(20px, env(safe-area-inset-bottom)); right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.tms-toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; background: var(--tms-surface); border: 1px solid var(--tms-border); border-left: 4px solid var(--t-color, var(--tms-info)); border-radius: var(--radius-md); padding: 12px 12px 14px 14px; box-shadow: var(--shadow-3); position: relative; overflow: hidden; animation: tms-toast-in var(--motion-slow) var(--ease-standard) both; }
.tms-toast.out { animation: tms-toast-out var(--motion-base) var(--ease-standard) both; }
.tms-toast > i { color: var(--t-color); font-size: 1.15rem; margin-top: 1px; }
.tms-toast .t-msg { flex: 1; font-size: 0.875rem; font-weight: 550; line-height: 1.45; }
.tms-toast .t-close { border: 0; background: transparent; color: var(--tms-text-muted); width: 28px; height: 28px; border-radius: var(--radius-sm); margin: -4px -4px 0 0; }
.tms-toast .t-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--t-color); opacity: 0.35; width: 100%; transform-origin: left; animation: tms-bar linear forwards; }
.tms-toast:hover .t-bar, .tms-toast:focus-within .t-bar { animation-play-state: paused; }
.tms-toast.success { --t-color: var(--tms-success); }
.tms-toast.error { --t-color: var(--tms-danger); }
.tms-toast.warning { --t-color: var(--tms-warning); }
.tms-toast.info { --t-color: var(--tms-info); }
@media (max-width: 575.98px) { .toast-region { top: auto; bottom: max(16px, env(safe-area-inset-bottom)); right: 16px; left: 16px; width: auto; } }

/* ------------------------------------------------------------- Auth pages */
/* Layout, brand panel and form of the auth pages: see css/auth.css */
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 46px; }
.pw-toggle { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--tms-text-muted); width: 42px; height: 40px; border-radius: var(--radius-sm); }
.caps-warning { display: none; color: var(--tms-warning); font-size: 0.8rem; margin-top: 6px; }
.caps-warning.show { display: flex; gap: 6px; align-items: center; }
.otp-inputs { display: flex; gap: 8px; justify-content: space-between; }
.otp-inputs input { width: 100%; max-width: 54px; height: 58px; text-align: center; font-size: 1.5rem; font-weight: 700; border: 1px solid var(--tms-border-strong); border-radius: var(--radius-md); background: var(--tms-surface); color: var(--tms-text); font-variant-numeric: tabular-nums; transition: border-color var(--motion-fast), box-shadow var(--motion-fast), transform var(--motion-fast); }
.otp-inputs input:focus { outline: none; border-color: var(--tms-primary-interactive); box-shadow: var(--focus-ring); transform: translateY(-1px); }
.otp-inputs input.filled { border-color: var(--tms-primary-interactive); background: var(--tms-primary-soft); }
.otp-timer { font-variant-numeric: tabular-nums; }
/* --------------------------------------------------------- Admin bits */
.perm-matrix th, .perm-matrix td { vertical-align: middle; }
.perm-matrix .form-check-input { width: 1.25em; height: 1.25em; }
.link-tree { list-style: none; padding-left: 0; margin: 0; }
.link-tree ul { list-style: none; padding-left: 26px; border-left: 2px solid var(--tms-border); margin-left: 12px; }
.link-tree li > .lt-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); }
.link-tree li > .lt-row:hover { background: var(--tms-surface-2); }
.code-pill { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.78rem; background: var(--tms-surface-3); border-radius: var(--radius-sm); padding: 2px 7px; color: var(--tms-text); }
.stat-inline { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.85rem; color: var(--tms-text-muted); }
.stat-inline strong { color: var(--tms-text); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- Motion */
@keyframes tms-spin { to { transform: rotate(360deg); } }
@keyframes tms-shimmer { to { transform: translateX(100%); } }
@keyframes tms-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* Uses translate/scale (not transform) so it never overrides Popper's positioning of menus. */
@keyframes tms-pop { from { opacity: 0; translate: 0 -4px; scale: 0.98; } to { opacity: 1; translate: 0 0; scale: 1; } }
@keyframes tms-settle { 0% { transform: scale(1.03); } 60% { transform: scale(0.995); } 100% { transform: none; } }
@keyframes tms-flash { 0% { box-shadow: 0 0 0 0 rgba(36, 87, 167, 0.45), var(--shadow-1); } 70% { box-shadow: 0 0 0 10px rgba(36, 87, 167, 0), var(--shadow-1); } 100% { box-shadow: var(--shadow-1); } }
@keyframes tms-bump { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes tms-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
@keyframes tms-toast-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes tms-toast-out { to { opacity: 0; transform: translateX(24px); } }
@keyframes tms-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes tms-fade { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: tms-fade var(--motion-base) var(--ease-standard) both; }
.view-enter { animation: tms-enter 240ms var(--ease-standard) both; }
@media (max-width: 575.98px) {
  @keyframes tms-toast-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
  @keyframes tms-toast-out { to { opacity: 0; transform: translateY(16px); } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .skeleton::after { display: none; }
  .btn:not(:disabled):hover, a.kpi:hover, .task-card:hover { transform: none; }
}

/* --------------------------------------------------------------- Print */
@media print {
  .sidebar, .topbar, .app-footer, .fab, .toolbar, .page-actions, .no-print, .toast-region, .board-tabs { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .card { box-shadow: none; border-color: #999; }
  .table-desktop { display: block !important; }
  .card-list { display: none !important; }
  a { color: #000; text-decoration: none; }
}

/* Top bar on phones: long page titles shrink with an ellipsis */
.topbar > a.d-lg-none { min-width: 0; flex: 1 1 auto; }
.topbar > a.d-lg-none .topbar-title { min-width: 0; }
.topbar > .ms-auto { flex-shrink: 0; }
.link-tree li > .lt-row { flex-wrap: wrap; }
@media (max-width: 575.98px) {
  .link-tree ul { padding-left: 12px; margin-left: 6px; }
  .view-switch { flex-wrap: wrap; }
}
:root[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #08172d; --bs-btn-hover-color: #08172d; --bs-btn-active-color: #08172d; --bs-btn-disabled-color: #08172d; }
:root[data-bs-theme="dark"] .fab { color: #08172d; }

/* Background email sending indicator */
.mail-status {
  position: fixed; bottom: 20px; left: calc(var(--sidebar-w) + 20px); z-index: 1085;
  display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px 10px 12px;
  background: var(--tms-surface); color: var(--tms-text); border: 1px solid var(--tms-border);
  border-radius: var(--radius-pill); box-shadow: var(--shadow-3); font-size: 0.85rem; font-weight: 600;
  opacity: 0; transform: translateY(14px); pointer-events: none;
  transition: opacity var(--motion-base) var(--ease-standard), transform var(--motion-base) var(--ease-standard), left var(--motion-slow) var(--ease-standard);
}
.sidebar-collapsed .mail-status { left: calc(var(--sidebar-rail-w) + 20px); }
.mail-status.on { opacity: 1; transform: none; }
.mail-status > i { color: var(--tms-primary-interactive); font-size: 1rem; }
.mail-status .ms-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--tms-primary-soft); border-top-color: var(--tms-primary-interactive); animation: tms-spin 700ms linear infinite; }
@media (max-width: 991.98px) { .mail-status { left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); } }
@media print { .mail-status { display: none !important; } }

/* Modals whose header/body/footer sit inside a <form>: keep the body scrollable
   (Bootstrap's scrollable modal only works when .modal-body is a direct child). */
.modal-dialog-scrollable .modal-content > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; max-height: 100%; overflow: hidden; }
.modal-dialog-scrollable .modal-content > form > .modal-body { overflow-y: auto; overscroll-behavior: contain; }
.modal-content > form > .modal-footer { flex-shrink: 0; }

/* Email Queue tabs and deadline reminders */
.queue-tabs .nav-link { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--tms-text-muted); }
.queue-tabs .nav-link.active { color: var(--tms-primary-interactive); }
.reminder-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.reminder-filters .rf {
  --rf: var(--tms-primary-interactive); display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-height: 56px;
  background: var(--tms-surface); border: 1px solid var(--tms-border); border-radius: var(--radius-md); color: var(--tms-text);
  text-decoration: none; font-weight: 600; box-shadow: var(--shadow-1);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast), transform var(--motion-fast);
}
.reminder-filters .rf i { color: var(--rf); font-size: 1.15rem; }
.reminder-filters .rf .rf-n { margin-left: auto; font-size: 1.15rem; font-weight: 750; color: var(--rf); font-variant-numeric: tabular-nums; }
.reminder-filters .rf:hover { border-color: var(--tms-border-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.reminder-filters .rf.active { border-color: var(--rf); box-shadow: 0 0 0 1px var(--rf), var(--shadow-2); background: color-mix(in srgb, var(--rf) 6%, var(--tms-surface)); }
.reminder-filters .f-soon { --rf: var(--tms-warning); }
.reminder-filters .f-today { --rf: #c2410c; }
.reminder-filters .f-overdue { --rf: var(--tms-danger); }
@media (max-width: 767.98px) { .reminder-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.reminder-table tr.rem-overdue td:first-child { box-shadow: inset 3px 0 0 var(--tms-danger); }
.reminder-table tr.rem-today td:first-child { box-shadow: inset 3px 0 0 #c2410c; }
.reminder-table tr.rem-soon td:first-child { box-shadow: inset 3px 0 0 var(--tms-warning); }
.reminder-table tr.rem-flash td { animation: rem-flash 1.6s var(--ease-standard); }
@keyframes rem-flash { 0% { background: color-mix(in srgb, var(--tms-success) 16%, transparent); } 100% { background: transparent; } }
.btn-buzz.buzzing { animation: tms-buzz 0.5s linear; }
@keyframes tms-buzz { 0%, 100% { transform: none; } 15% { transform: translateX(-3px) rotate(-3deg); } 30% { transform: translateX(3px) rotate(3deg); } 45% { transform: translateX(-3px) rotate(-2deg); } 60% { transform: translateX(3px) rotate(2deg); } 75% { transform: translateX(-1px); } }
.btn-warning.is-loading::after { border-color: #1f2937 #1f2937 transparent transparent; }

/* Forgot / reset password */
.auth-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem; margin-bottom: 14px; background: var(--tms-primary-soft); color: var(--tms-primary-interactive); }
.auth-icon-success { background: var(--tms-success-soft); color: var(--tms-success); animation: tms-pop-in 420ms var(--ease-standard) both; }
.auth-icon-danger { background: var(--tms-danger-soft); color: var(--tms-danger); }
.auth-swap { animation: tms-enter 320ms var(--ease-standard) both; }
@keyframes tms-pop-in { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: none; } }
.pw-meter { height: 6px; border-radius: 99px; background: var(--tms-surface-3); overflow: hidden; }
.pw-meter span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--tms-danger); transition: width var(--motion-base) var(--ease-standard), background-color var(--motion-base); }
.pw-meter span.fair { background: var(--tms-warning); }
.pw-meter span.strong { background: var(--tms-success); }
.pw-rules { list-style: none; padding: 0; margin: 10px 0 4px; display: grid; gap: 4px; font-size: 0.82rem; color: var(--tms-text-muted); }
.pw-rules li { display: flex; align-items: center; gap: 8px; transition: color var(--motion-fast); }
.pw-rules li.ok { color: var(--tms-success); }
.pw-rules li.bad { color: var(--tms-danger); }

/* Delegate to staff (TMS 2.1) */
.deleg-row { display: flex; align-items: flex-start; gap: 8px; margin: 2px 0 6px 18px; padding: 8px 10px; border-radius: var(--radius-md); background: color-mix(in srgb, #6d28d9 6%, var(--tms-surface)); border: 1px solid color-mix(in srgb, #6d28d9 18%, var(--tms-border)); animation: tms-enter 260ms var(--ease-standard) both; }
.deleg-row .avatar { margin-top: 1px; }
.deleg-row .btn-icon { width: 32px; height: 32px; min-height: 32px; }
.deleg-arrow { color: #6d28d9; margin-top: 4px; }
.deleg-note { margin-top: 4px; color: var(--tms-text); background: var(--tms-surface); border-radius: var(--radius-sm); padding: 4px 8px; }
.deleg-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.7rem; font-weight: 650; line-height: 1; padding: 4px 8px; border-radius: var(--radius-pill); background: color-mix(in srgb, #6d28d9 10%, var(--tms-surface)); color: #6d28d9; border: 1px solid color-mix(in srgb, #6d28d9 25%, transparent); }
:root[data-bs-theme="dark"] .deleg-arrow, :root[data-bs-theme="dark"] .deleg-badge { color: #c4b5fd; }
.delegate-form .ts-wrapper { min-width: 0; }
/* Deadline Reminders (TMS 2.2): the Remind / Buzz column stays visible when the table scrolls sideways. */
.reminder-table th:last-child, .reminder-table td:last-child { position: sticky; right: 0; z-index: 1; background: var(--tms-surface); box-shadow: -8px 0 12px -10px rgba(15, 23, 42, 0.25); }
.reminder-table tr.rem-flash td:last-child { background: var(--tms-surface); }
