/* =====================================================================
   STAR OFFICE — "Track Workflow"
   Brand stylesheet. Mobile-first. Light + dark themes via CSS variables.
   Theme is set on <html data-theme="light|dark">; with no attribute the
   device setting (prefers-color-scheme) decides.
   ===================================================================== */

:root {
  /* Brand (from the STAR logo) */
  --brand: #FF6600;
  --brand-strong: #C2410C;        /* buttons/links with white text — passes WCAG AA */
  --brand-soft: #FFF1E6;
  --brand-ring: rgba(255, 102, 0, .28);

  /* Surfaces & text — light */
  --bg: #F6F4F1;
  --surface: #FFFFFF;
  --surface-2: #FBFAF8;
  --border: #E9E4DE;
  --text: #1F1A17;
  --text-muted: #6B625B;
  --shadow: 0 1px 2px rgba(31, 26, 23, .05), 0 4px 16px rgba(31, 26, 23, .06);

  /* Status colours */
  --st-pending: #64748B;
  --st-progress: #2563EB;
  --st-hold: #7C3AED;
  --st-waiting: #0891B2;
  --st-closed: #16A34A;
  --st-reopened: #DB2777;
  --st-overdue: #DC2626;

  /* Category colours (Urgent = amber so it never looks like the brand orange) */
  --cat-normal: #64748B;
  --cat-priority: #2563EB;
  --cat-urgent: #D97706;
  --cat-most-urgent: #DC2626;

  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 256px;
  --topbar-h: 60px;
  --bottomnav-h: 64px;
  --font: "Poppins", "Noto Sans Tamil", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #FF7A1A;
    --brand-strong: #FF7A1A;
    --brand-soft: rgba(255, 122, 26, .14);
    --bg: #121212;
    --surface: #1C1C1E;
    --surface-2: #232326;
    --border: #2F2F33;
    --text: #F2EFEC;
    --text-muted: #A8A29E;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  --brand: #FF7A1A;
  --brand-strong: #FF7A1A;
  --brand-soft: rgba(255, 122, 26, .14);
  --bg: #121212;
  --surface: #1C1C1E;
  --surface-2: #232326;
  --border: #2F2F33;
  --text: #F2EFEC;
  --text-muted: #A8A29E;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
}

/* Make Bootstrap follow our variables */
:root, [data-bs-theme] {
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
  --bs-secondary-color: var(--text-muted);
  --bs-tertiary-bg: var(--surface-2);
  --bs-link-color: var(--brand-strong);
  --bs-link-hover-color: var(--brand);
  --bs-primary: var(--brand-strong);
  --bs-primary-rgb: 194, 65, 12;
  --bs-font-sans-serif: var(--font);
}

html, body { background: var(--bg); color: var(--text); }
body {
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--brand-strong); }
.text-muted { color: var(--text-muted) !important; }
:focus-visible { outline: 3px solid var(--brand-ring); outline-offset: 2px; }

/* ---------- Buttons ---------- */
.btn { min-height: 44px; border-radius: var(--radius-sm); font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; }
.btn-sm { min-height: 36px; }
.btn-brand { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .btn-brand, :root[data-theme="dark"] .btn-brand:hover { color: #1a0d03; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-brand { color: #1a0d03; } }
.btn-soft { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn-soft:hover { border-color: var(--brand); color: var(--brand-strong); }
.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: 12px; background: transparent; border: 1px solid transparent; color: var(--text); }
.btn-icon:hover { background: var(--surface-2); border-color: var(--border); }

/* ---------- Forms ---------- */
.form-control, .form-select {
  background-color: var(--surface); color: var(--text); border-color: var(--border);
  min-height: 44px; border-radius: var(--radius-sm);
}
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem var(--brand-ring); background-color: var(--surface); color: var(--text); }
.form-label { font-weight: 500; font-size: .9rem; }
.form-check-input { background-color: var(--surface); border: 1.5px solid var(--text-muted); }
.form-check-input:checked { background-color: var(--brand-strong); border-color: var(--brand-strong); }
.required::after { content: " *"; color: var(--st-overdue); }

/* ---------- App shell ---------- */
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: none; flex-direction: column; z-index: 1030;
}
.app-sidebar .brand { display: flex; align-items: center; gap: .65rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.app-sidebar .brand img { width: 40px; height: 40px; }
.brand-name { font-weight: 700; letter-spacing: .04em; line-height: 1.1; }
.brand-tag { font-size: .72rem; color: var(--brand-strong); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.side-nav { padding: .75rem .6rem; overflow-y: auto; flex: 1; }
.side-nav .nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); padding: .9rem .75rem .35rem; }
.side-nav a {
  display: flex; align-items: center; gap: .75rem; padding: .65rem .75rem; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-weight: 500; min-height: 44px;
}
.side-nav a i { font-size: 1.15rem; color: var(--text-muted); width: 1.3rem; text-align: center; }
.side-nav a:hover { background: var(--surface-2); }
.side-nav a.active { background: var(--brand-soft); color: var(--brand-strong); }
.side-nav a.active i { color: var(--brand); }
.side-nav .soon { margin-left: auto; font-size: .65rem; padding: .1rem .45rem; border-radius: 99px; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

.app-topbar {
  position: sticky; top: 0; z-index: 1020; height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .5rem; padding: 0 .75rem;
}
.topbar-brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--text); }
.topbar-brand img { width: 34px; height: 34px; }
.company-switch { max-width: 52vw; font-size: .85rem; font-weight: 600; min-height: 38px; padding-top: .3rem; padding-bottom: .3rem; }
.topbar-search { display: none; flex: 1; max-width: 420px; position: relative; }
.topbar-search i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.topbar-search input { padding-left: 2.4rem; background: var(--surface-2); }
.badge-dot { position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--st-overdue); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center; }

.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--brand-soft); color: var(--brand-strong); display: inline-grid; place-items: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }

.app-main { padding: 1rem .9rem calc(var(--bottomnav-h) + 1.5rem); max-width: 1400px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.35rem; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--text-muted); font-size: .9rem; }

/* Bottom navigation (mobile) */
.bottom-nav {
  position: fixed; inset: auto 0 0 0; height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, 1fr); z-index: 1030;
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--text-muted); font-size: .68rem; font-weight: 500; }
.bottom-nav a i { font-size: 1.3rem; }
.bottom-nav a.active { color: var(--brand-strong); }
.bottom-nav .fab { width: 54px; height: 54px; margin-top: -22px; border-radius: 50%; background: var(--brand-strong); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px var(--brand-ring); justify-self: center; }
.bottom-nav .fab i { font-size: 1.6rem; }

@media (min-width: 992px) {
  .app-sidebar { display: flex; }
  .app-content { margin-left: var(--sidebar-w); }
  .bottom-nav, .topbar-brand { display: none !important; }
  .topbar-search { display: block; }
  .app-topbar { padding: 0 1.5rem; }
  .app-main { padding: 1.5rem 1.75rem 2rem; }
  .page-head h1 { font-size: 1.55rem; }
}

/* ---------- Cards ---------- */
.card-so { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-so .card-head { padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-so .card-head h2 { font-size: 1rem; font-weight: 600; margin: 0; display: flex; gap: .5rem; align-items: center; }
.card-so .card-body { padding: 1.1rem; }

.stat { padding: 1rem; display: flex; gap: .85rem; align-items: center; }
.stat .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; background: var(--brand-soft); color: var(--brand-strong); flex-shrink: 0; }
.stat .num { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat .lbl { font-size: .8rem; color: var(--text-muted); }

.welcome {
  background: radial-gradient(120% 140% at 100% 0%, var(--brand-soft) 0%, transparent 60%), var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; display: flex; gap: 1rem; align-items: center;
}
.welcome img.mark { width: 64px; height: 64px; opacity: .95; }

/* ---------- Lists that become cards on mobile ---------- */
.so-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.so-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; padding: .7rem .9rem; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.so-table td { padding: .75rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.so-table tr:last-child td { border-bottom: 0; }
@media (max-width: 767.98px) {
  .so-table thead { display: none; }
  .so-table, .so-table tbody, .so-table tr, .so-table td { display: block; width: 100%; }
  .so-table tr { padding: .75rem .9rem; border-bottom: 1px solid var(--border); }
  .so-table td { border: 0; padding: .2rem 0; display: flex; justify-content: space-between; gap: 1rem; }
  .so-table td[data-label]::before { content: attr(data-label); color: var(--text-muted); font-size: .8rem; flex-shrink: 0; }
  .so-table td.cell-main { display: block; }
  .so-table td.cell-main::before { display: none; }
}

/* ---------- Badges ---------- */
.badge-so { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 600; padding: .25rem .6rem; border-radius: 99px; border: 1px solid currentColor; background: color-mix(in srgb, currentColor 10%, transparent); white-space: nowrap; }
.role-admin { color: var(--brand-strong); }
.role-manager { color: var(--st-hold); }
.role-user { color: var(--st-pending); }
.is-active { color: var(--st-closed); }
.is-inactive { color: var(--st-overdue); }

/* Progress bar */
.progress-so { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress-so > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #FFA14D); border-radius: 99px; transition: width .8s ease; }

/* Empty state */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty img { width: 72px; opacity: .35; margin-bottom: .75rem; filter: grayscale(30%); }

/* Skeleton loader */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; min-height: 14px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* Modal / dropdown theming */
.modal-content, .dropdown-menu { background: var(--surface); color: var(--text); border-color: var(--border); border-radius: var(--radius); }
.dropdown-item { color: var(--text); min-height: 40px; display: flex; align-items: center; gap: .6rem; }
.dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.modal-header, .modal-footer { border-color: var(--border); }
:root[data-theme="dark"] .btn-close { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-close { filter: invert(1); } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; position: relative; overflow: hidden; }
.login-wrap::before {
  content: ""; position: absolute; width: 900px; height: 900px; right: -380px; top: -420px; border-radius: 50%;
  background: radial-gradient(circle, var(--brand-soft) 0%, transparent 65%); pointer-events: none;
}
.login-card { width: 100%; max-width: 420px; position: relative; padding: 2rem 1.5rem; text-align: center; }
.login-logo { width: 132px; height: 132px; margin: 0 auto 1rem; display: block; animation: rise .7s ease both; }
.login-title { font-size: 1.9rem; font-weight: 800; letter-spacing: .08em; margin: 0; }
.login-tag { color: var(--brand-strong); font-weight: 600; letter-spacing: .3em; text-transform: uppercase; font-size: .8rem; margin-bottom: 1.75rem; }
.btn-google { width: 100%; min-height: 52px; background: #fff; color: #1f1f1f; border: 1px solid #DADCE0; font-weight: 600; border-radius: 12px; }
.btn-google:hover { background: #F8F9FA; color: #1f1f1f; border-color: #c6c8cb; }
.btn-google img { width: 20px; height: 20px; }
.login-flow { display: flex; justify-content: center; gap: .4rem; margin-top: 1.5rem; flex-wrap: wrap; }
.login-flow span { font-size: .72rem; color: var(--text-muted); border: 1px solid var(--border); padding: .25rem .6rem; border-radius: 99px; background: var(--surface); }
.privacy-note { font-size: .78rem; color: var(--text-muted); margin-top: 1.25rem; line-height: 1.5; }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }

/* Toasts */
.toast-stack { position: fixed; right: 1rem; bottom: calc(var(--bottomnav-h) + 1rem); z-index: 1090; display: grid; gap: .5rem; }
@media (min-width: 992px) { .toast-stack { bottom: 1rem; } }
.toast-so { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: 12px; box-shadow: var(--shadow); padding: .75rem 1rem; min-width: 240px; max-width: 360px; animation: rise .3s ease both; }
.toast-so.success { border-left-color: var(--st-closed); }
.toast-so.error { border-left-color: var(--st-overdue); }
.toast-so.warning { border-left-color: var(--cat-urgent); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.min-w-0 { min-width: 0; }

/* =====================================================================
   Module 3 — Works
   ===================================================================== */
.st-pending { color: var(--st-pending); } .st-progress { color: var(--st-progress); } .st-hold { color: var(--st-hold); }
.st-waiting { color: var(--st-waiting); } .st-closed { color: var(--st-closed); } .st-reopened { color: var(--st-reopened); }
.st-overdue { color: var(--st-overdue); }
.cat-normal { color: var(--cat-normal); } .cat-priority { color: var(--cat-priority); }
.cat-urgent { color: var(--cat-urgent); } .cat-most-urgent { color: var(--cat-most-urgent); }
:root[data-theme="dark"] .st-pending, :root[data-theme="dark"] .cat-normal { color: #94A3B8; }
:root[data-theme="dark"] .st-progress, :root[data-theme="dark"] .cat-priority { color: #60A5FA; }
:root[data-theme="dark"] .st-hold { color: #A78BFA; } :root[data-theme="dark"] .st-waiting { color: #22D3EE; }
:root[data-theme="dark"] .st-closed { color: #4ADE80; } :root[data-theme="dark"] .st-reopened { color: #F472B6; }
:root[data-theme="dark"] .st-overdue, :root[data-theme="dark"] .cat-most-urgent { color: #F87171; }
:root[data-theme="dark"] .cat-urgent { color: #FBBF24; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .st-pending, :root:not([data-theme="light"]) .cat-normal { color: #94A3B8; }
  :root:not([data-theme="light"]) .st-progress, :root:not([data-theme="light"]) .cat-priority { color: #60A5FA; }
  :root:not([data-theme="light"]) .st-hold { color: #A78BFA; } :root:not([data-theme="light"]) .st-waiting { color: #22D3EE; }
  :root:not([data-theme="light"]) .st-closed { color: #4ADE80; } :root:not([data-theme="light"]) .st-reopened { color: #F472B6; }
  :root:not([data-theme="light"]) .st-overdue, :root:not([data-theme="light"]) .cat-most-urgent { color: #F87171; }
  :root:not([data-theme="light"]) .cat-urgent { color: #FBBF24; } }

/* Tabs (pills that scroll on phones) */
.tabs-so { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; margin-bottom: 1rem; scrollbar-width: none; }
.tabs-so::-webkit-scrollbar { display: none; }
.tabs-so a { flex-shrink: 0; display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 500; font-size: .88rem; min-height: 40px; }
.tabs-so a.active { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.tabs-so .count { font-size: .72rem; font-weight: 700; padding: .05rem .45rem; border-radius: 99px; background: var(--surface-2); color: var(--text-muted); }
.tabs-so a.active .count { background: rgba(255,255,255,.25); color: #fff; }

/* Work cards */
.work-list { display: grid; gap: .75rem; }
.work-card { display: block; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: transform .12s ease, border-color .12s; }
.work-card:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); color: var(--text); }
.work-card.cat-l-priority { border-left-color: var(--cat-priority); } .work-card.cat-l-urgent { border-left-color: var(--cat-urgent); }
.work-card.cat-l-most_urgent { border-left-color: var(--cat-most-urgent); } .work-card.is-closed { opacity: .72; }
.work-card.is-overdue { background: linear-gradient(90deg, color-mix(in srgb, var(--st-overdue) 7%, var(--surface)), var(--surface) 60%); }
.work-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; font-weight: 600; color: var(--brand-strong); }
.work-title { font-weight: 600; font-size: 1rem; margin: .15rem 0 .35rem; }
.work-meta { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .8rem; color: var(--text-muted); align-items: center; }
.work-meta i { margin-right: .2rem; }
.due-chip { font-weight: 600; } .due-chip.over { color: var(--st-overdue); }
.people { display: inline-flex; align-items: center; gap: .3rem; }
.people .avatar { width: 22px; height: 22px; font-size: .6rem; }

/* Form helpers */
.cat-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
@media (min-width: 576px) { .cat-picker { grid-template-columns: repeat(4, 1fr); } }
.cat-picker label { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .7rem .4rem; border: 2px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; font-size: .88rem; background: var(--surface); text-align: center; min-height: 72px; justify-content: center; }
.cat-picker label i { font-size: 1.3rem; }
.cat-picker label small { font-weight: 400; font-size: .7rem; color: var(--text-muted); }
.cat-picker input:checked + label { border-color: currentColor; background: color-mix(in srgb, currentColor 9%, var(--surface)); }
.cat-picker input:focus-visible + label { outline: 3px solid var(--brand-ring); }
.form-section { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 600; margin: 1.25rem 0 .6rem; display: flex; align-items: center; gap: .5rem; }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Attachments picker */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; background: var(--surface-2); transition: border-color .15s, background .15s; }
.dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .dz-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: .6rem; }
.file-list { display: grid; gap: .4rem; margin-top: .6rem; text-align: left; }
.file-item { display: flex; align-items: center; gap: .6rem; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.file-item .fi-icon { font-size: 1.5rem; flex-shrink: 0; }
.file-item .fi-body { flex: 1; min-width: 0; }
.file-item .fi-name { font-size: .86rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item .fi-size { font-size: .72rem; color: var(--text-muted); }
.file-item .progress-so { margin-top: .3rem; height: 5px; }
.file-item .progress-so > span { transition: width .15s linear; }
.file-item.done .progress-so > span { background: var(--st-closed); }

/* Attachment gallery (read-only) */
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; margin-top: .6rem; }
.att { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.att a { color: var(--text); text-decoration: none; }
.att .att-thumb { aspect-ratio: 4/3; display: grid; place-items: center; background: var(--surface-2); overflow: hidden; }
.att .att-thumb img { width: 100%; height: 100%; object-fit: cover; }
.att .att-thumb i { font-size: 2.2rem; }
.att .att-name { font-size: .74rem; padding: .35rem .5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-wide { grid-column: 1 / -1; padding: .5rem; }
.att-wide audio, .att-wide video { width: 100%; max-height: 260px; border-radius: 8px; }

/* Work detail */
.work-hero { padding: 1.1rem; }
.work-hero h1 { font-size: 1.3rem; font-weight: 700; margin: .25rem 0 .5rem; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem 1rem; }
@media (min-width: 768px) { .kv { grid-template-columns: repeat(4, 1fr); } }
.kv dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 500; font-size: .92rem; }
.details-text { white-space: pre-wrap; word-break: break-word; line-height: 1.6; }
.big-progress { display: flex; align-items: center; gap: .75rem; }
.big-progress .progress-so { flex: 1; height: 12px; }
.big-progress strong { font-size: 1.1rem; min-width: 3.2rem; text-align: right; }

/* Timeline */
.tl-date { position: sticky; top: calc(var(--topbar-h) + 4px); z-index: 2; display: inline-block; margin: .75rem 0 .5rem; padding: .25rem .75rem; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); font-size: .78rem; font-weight: 600; box-shadow: var(--shadow); }
.tl { position: relative; padding-left: 1.6rem; }
.tl::before { content: ""; position: absolute; left: .55rem; top: .3rem; bottom: .3rem; width: 2px; background: var(--border); }
.tl-item { position: relative; margin-bottom: .9rem; }
.tl-dot { position: absolute; left: -1.6rem; top: .55rem; width: 1.15rem; height: 1.15rem; border-radius: 50%; background: var(--surface); border: 2px solid currentColor; display: grid; place-items: center; font-size: .6rem; }
.tl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .7rem .85rem; }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; font-size: .85rem; }
.tl-head .who { font-weight: 600; }
.tl-time { margin-left: auto; font-size: .74rem; color: var(--text-muted); }
.tl-body { margin-top: .4rem; font-size: .9rem; }
.tl-foot { margin-top: .45rem; display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .74rem; color: var(--text-muted); }
.tl-foot a { color: var(--text-muted); }
.status-arrow { font-size: .8rem; color: var(--text-muted); }

/* Sticky action bar on phones for the work detail page */
.action-bar { position: sticky; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 8px); z-index: 5; display: flex; gap: .5rem; padding: .5rem; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.action-bar .btn { flex: 1; }
@media (min-width: 992px) { .action-bar { bottom: 1rem; } }

.pager { display: flex; justify-content: center; gap: .4rem; margin-top: 1rem; flex-wrap: wrap; }

/* =====================================================================
   Module 5 — Documents + preview
   ===================================================================== */
.preview-content { background: #0f0f10; color: #f2efec; border-color: #2f2f33; }
.preview-content .modal-header { border-color: #2f2f33; }
.preview-content .btn-close { filter: invert(1); }
.preview-content .btn-soft { background: #232326; color: #f2efec; border-color: #3a3a3f; }
.preview-body { position: relative; display: grid; place-items: center; min-height: 60vh; }
.preview-body img { max-width: 100%; max-height: 80vh; object-fit: contain; }
.preview-body iframe { width: 100%; height: 82vh; border: 0; background: #fff; }
.pv-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 1.2rem; z-index: 2; }
.pv-prev { left: 8px; } .pv-next { right: 8px; }

.doc-card { display: flex; gap: .85rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: transform .12s ease, border-color .12s; }
.doc-card:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); color: var(--text); }
.doc-card.unread { border-left: 4px solid var(--brand); background: color-mix(in srgb, var(--brand) 4%, var(--surface)); }
.doc-card.unread .doc-title { font-weight: 700; }
.doc-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; font-size: 1.3rem; background: var(--brand-soft); color: var(--brand-strong); }
.doc-title { font-weight: 600; margin-bottom: .1rem; }
.doc-snippet { font-size: .85rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.doc-files { display: inline-flex; gap: .25rem; font-size: .95rem; }
.seen-tick { color: var(--st-closed); } .unseen-tick { color: var(--text-muted); }
.recip { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.recip:last-child { border-bottom: 0; }
.people-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .4rem; max-height: 300px; overflow: auto; padding: 2px; }
.people-picker label { display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; min-height: 48px; background: var(--surface); }
.people-picker label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.people-picker .form-check-input { margin: 0; flex-shrink: 0; }
.people-picker .avatar { width: 28px; height: 28px; font-size: .7rem; }

/* =====================================================================
   Module 6 — Dashboards
   Chart series colours: validated categorical palette (fixed order, separate
   light/dark steps — passes colour-blind checks for up to 3 series).
   ===================================================================== */
:root { --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --grid: #ECE8E3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --grid: #2A2A2E; } }
:root[data-theme="dark"] { --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --grid: #2A2A2E; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: baseline; }

.dash-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.dash-hero .avatar-lg { width: 56px; height: 56px; }
.dash-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-left: auto; }
@media (max-width: 575.98px) { .dash-actions { width: 100%; } .dash-actions .btn { flex: 1; } }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .65rem; }
@media (min-width: 768px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1200px) { .stat-grid.g7 { grid-template-columns: repeat(7, 1fr); } .stat-grid.g7 .stat { flex-direction: column; align-items: flex-start; gap: .5rem; } }
.stat-grid .stat { color: inherit; text-decoration: none; height: 100%; }
.stat-grid a.stat:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); }
.stat .ico.danger { color: var(--st-overdue); background: color-mix(in srgb, var(--st-overdue) 12%, transparent); }
.stat .num.danger { color: var(--st-overdue); }

.lp-item { display: flex; align-items: center; gap: .7rem; padding: .6rem .9rem; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.lp-item:last-child { border-bottom: 0; }
.lp-item:hover { background: var(--surface-2); color: var(--text); }
.lp-item .lp-bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--cat-urgent); flex-shrink: 0; }
.lp-item.over .lp-bar { background: var(--st-overdue); }
.card-danger { border-color: color-mix(in srgb, var(--st-overdue) 35%, var(--border)); }
.card-danger .card-head { background: color-mix(in srgb, var(--st-overdue) 7%, var(--surface)); border-radius: var(--radius) var(--radius) 0 0; }

.hbar { display: grid; grid-template-columns: 9.5rem 1fr 2rem; align-items: center; gap: .6rem; padding: .3rem 0; font-size: .85rem; }
.hbar .track { display: block; height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; background: var(--brand-strong); border-radius: 99px; width: 0; transition: width .8s ease; }
.hbar .val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-box { position: relative; height: 230px; }
.chart-box.tall { height: 300px; }
.act { display: flex; gap: .65rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.act:last-child { border-bottom: 0; }
.act .avatar { width: 30px; height: 30px; font-size: .7rem; }
.act-text { font-size: .86rem; min-width: 0; }
.act-text .snip { color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.num-cell { font-variant-numeric: tabular-nums; text-align: right; }
.viewing-banner { background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--border)); border-radius: var(--radius-sm); padding: .55rem .9rem; font-size: .88rem; }

/* =====================================================================
   Module 7 — Reports
   ===================================================================== */
:root { --series-4: #eda100; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --series-4: #c98500; } }
:root[data-theme="dark"] { --series-4: #c98500; }
.ms .form-select { min-height: 44px; }
.ms-menu { max-height: 320px; overflow: auto; min-width: 240px; }
.ms-menu .dropdown-item { gap: .55rem; cursor: pointer; border-radius: 8px; white-space: normal; }
.ms-menu .form-check-input { margin: 0; flex-shrink: 0; }
@media (min-width: 768px) {
  .report-wrap { overflow-x: auto; }
  .report-table th, .report-table td { white-space: nowrap; }
  .report-register td:nth-child(3), .report-long td:nth-child(3), .report-closed td:nth-child(3), .report-closed td:last-child { white-space: normal; min-width: 220px; }
  .report-table tfoot td { border-top: 2px solid var(--text); background: var(--surface-2); }
}
@media (max-width: 767.98px) { .report-table tfoot { display: block; } .report-table tfoot tr { background: var(--surface-2); } }

/* =====================================================================
   Module 8 — Board, calendar, checklist
   ===================================================================== */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 86vw); gap: .8rem; overflow-x: auto; padding-bottom: .5rem; scroll-snap-type: x mandatory; }
@media (min-width: 992px) { .kanban { grid-auto-flow: initial; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: visible; } }
.kcol { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 300px; scroll-snap-align: start; }
.kcol-head { display: flex; align-items: center; gap: .5rem; padding: .7rem .85rem; font-weight: 600; font-size: .92rem; border-bottom: 1px solid var(--border); }
.kcount { margin-left: auto; font-size: .75rem; padding: .05rem .5rem; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); }
.kcol-body { padding: .6rem; display: grid; gap: .55rem; align-content: start; flex: 1; border-radius: 0 0 var(--radius) var(--radius); transition: background .15s; }
.kcol-body.can-drop { background: color-mix(in srgb, var(--brand) 5%, transparent); outline: 2px dashed color-mix(in srgb, var(--brand) 40%, transparent); outline-offset: -6px; }
.kcol-body.over { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.kcard { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .7rem; box-shadow: var(--shadow); }
.kcard[draggable=true] { cursor: grab; } .kcard.dragging { opacity: .45; }
.kcard.cat-l-priority { border-left-color: var(--cat-priority); } .kcard.cat-l-urgent { border-left-color: var(--cat-urgent); } .kcard.cat-l-most_urgent { border-left-color: var(--cat-most-urgent); }
.kcard.is-overdue { background: linear-gradient(90deg, color-mix(in srgb, var(--st-overdue) 7%, var(--surface)), var(--surface) 70%); }
.kcard-title { display: block; font-weight: 600; font-size: .9rem; color: var(--text); text-decoration: none; margin: .25rem 0; }
.kcard .work-meta { font-size: .75rem; }
.kmove { margin-top: .45rem; }
@media (min-width: 992px) { .kmove { display: none; } }
.kempty { text-align: center; color: var(--text-muted); font-size: .8rem; padding: 1.5rem 0; }

.cal { overflow: hidden; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: .5rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; text-align: center; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-day { min-height: 64px; border: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); color: var(--text); padding: .3rem; text-align: left; display: flex; flex-direction: column; gap: .2rem; font: inherit; min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.empty { background: var(--surface-2); }
.cal-day.sun .dnum { color: var(--st-overdue); }
.cal-day .dnum { font-size: .8rem; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.cal-day.today .dnum { background: var(--brand-strong); color: #fff; }
.cal-day.sel { box-shadow: inset 0 0 0 2px var(--brand); }
.cchips { display: none; }
.cdots { display: flex; align-items: center; gap: .25rem; font-size: .7rem; color: var(--text-muted); }
.cdot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); } .cdot.over { background: var(--st-overdue); }
@media (min-width: 992px) {
  .cal-day { min-height: 118px; cursor: pointer; }
  .cchips { display: grid; gap: 3px; }
  .cdots { display: none; }
}
.cchip { display: block; font-size: .72rem; line-height: 1.25; padding: .15rem .35rem; border-radius: 5px; background: var(--surface-2); border-left: 3px solid var(--border); color: var(--text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cchip.cat-l-priority { border-left-color: var(--cat-priority); } .cchip.cat-l-urgent { border-left-color: var(--cat-urgent); } .cchip.cat-l-most_urgent { border-left-color: var(--cat-most-urgent); }
.cchip.over { background: color-mix(in srgb, var(--st-overdue) 12%, var(--surface)); color: var(--st-overdue); }
.cchip.done { opacity: .55; text-decoration: line-through; }
.cchip .ctime { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cmore { font-size: .7rem; color: var(--brand-strong); font-weight: 600; padding-left: .35rem; }
.cl-item label { cursor: pointer; }
.bulk-bar { position: sticky; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 8px); z-index: 6; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .6rem .8rem; background: var(--surface); border: 1px solid var(--brand); border-radius: 14px; box-shadow: var(--shadow); margin-top: .75rem; }
@media (min-width: 992px) { .bulk-bar { bottom: 1rem; } }
.work-pick { position: absolute; top: .7rem; right: .8rem; width: 22px; height: 22px; z-index: 2; }

/* ---------- Module 9: app install & notifications ---------- */
.app-nudge { display: flex; align-items: center; gap: .75rem; background: var(--brand-soft); border: 1px solid var(--brand-ring); border-radius: 14px; padding: .75rem .9rem; }
.app-nudge > .bi { font-size: 1.35rem; color: var(--brand-strong); flex-shrink: 0; }
:root[data-theme="dark"] .app-nudge > .bi { color: var(--brand); }
.dev-row { display: flex; align-items: flex-start; gap: .85rem; padding: .9rem 0; border-top: 1px solid var(--border); }
.dev-row:first-child { border-top: 0; padding-top: 0; }
.dev-row > .bi { font-size: 1.4rem; color: var(--text-muted); width: 1.6rem; text-align: center; flex-shrink: 0; }
.dev-row .state { font-size: .8rem; }
.dev-row .state.on { color: var(--st-closed); }
.dev-row .state.off { color: var(--text-muted); }
.dev-row .state.bad { color: var(--st-overdue); }
@media (max-width: 575.98px) {
  .app-nudge { display: grid; grid-template-columns: auto 1fr auto; align-items: start; }
  .app-nudge > [data-nudge-close] { grid-column: 3; grid-row: 1; margin: -.3rem -.35rem 0 0; }
  .app-nudge > .btn-brand { grid-column: 1 / -1; grid-row: 2; width: 100%; }
}
