/* ============================================================
   COMMON — Variables, Reset, Typography
   Loaded on ALL devices before desktop.css / mobile.css
   ============================================================ */

/* Row burger dropdown (task row actions) */
.rb-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    font-size: .8125rem;
    color: var(--clr-text);
    text-decoration: none;
    transition: background .12s;
    cursor: pointer;
    white-space: nowrap;
}
.rb-item:hover { background: var(--clr-surface-2); }
.rb-item.rb-danger { color: var(--clr-danger); }
.rb-item.rb-danger:hover { background: rgba(239, 68, 68, .08); }
.rb-item svg { flex-shrink: 0; opacity: .7; }

/* Task modal — lateral drawer (slides in from the right, like Supplier/Product edit) */
.task-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    display: none;
    padding: 0;
}
.task-modal-overlay.open { display: block; }
.task-modal {
    position: fixed;
    top: 0; right: -600px;
    width: 560px; max-width: 100vw;
    height: 100vh;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-left: 1px solid var(--clr-border);
    border-radius: 0;
    display: flex; flex-direction: column;
    box-shadow: -4px 0 24px rgba(0,0,0,.18);
    transition: right .25s cubic-bezier(.4,0,.2,1);
}
.task-modal-overlay.open .task-modal { right: 0; }
.tm-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    flex-shrink: 0;
}
.tm-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: var(--clr-text);
    word-wrap: break-word;
}
.tm-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.tm-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.tm-card {
    padding: .875rem 1rem;
    border: 1px solid var(--clr-border);
    border-radius: 6px;
    background: var(--clr-surface);
}
.tm-card-title {
    font-size: .85rem;
    font-weight: 600;
    color: var(--clr-text);
    margin-bottom: .5rem;
}
@media (max-width: 640px) {
    .task-modal { width: 100vw; right: -100vw; }
}

/* ── Light theme (default) ──────────────────────────────────── */
:root {
    /* Brand */
    --clr-primary:        #2563eb;
    --clr-primary-hover:  #1d4ed8;
    --clr-primary-light:  #eff6ff;
    --clr-accent:         #0ea5e9;

    /* Sidebar — always dark in light mode */
    --clr-sidebar-bg:     #0f172a;
    --clr-sidebar-text:   #94a3b8;
    --clr-sidebar-active: #ffffff;
    --clr-sidebar-hover:  #1e293b;
    --clr-sidebar-border: #1e293b;
    --clr-sidebar-label:  #5a7899;

    /* Surface */
    --clr-bg:             #f1f5f9;
    --clr-surface:        #ffffff;
    --clr-surface-2:      #f8fafc;
    --clr-border:         #e2e8f0;
    --clr-thead-bg:       #e4e9f1;

    /* Text */
    --clr-text:           #0f172a;
    --clr-text-muted:     #64748b;
    --clr-text-light:     #94a3b8;

    /* Status */
    --clr-success:        #10b981;
    --clr-warning:        #f59e0b;
    --clr-danger:         #ef4444;
    --clr-info:           #3b82f6;

    /* Status backgrounds */
    --clr-success-bg:     #ecfdf5;
    --clr-warning-bg:     #fffbeb;
    --clr-danger-bg:      #fef2f2;
    --clr-info-bg:        #eff6ff;

    /* Status text (varies per theme) */
    --clr-success-text:   #065f46;
    --clr-warning-text:   #92400e;
    --clr-danger-text:    #991b1b;
    --clr-info-text:      #1e40af;

    /* Focus ring */
    --clr-focus-ring:     rgba(37,99,235,.14);

    /* Radius */
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   16px;
    --radius-full: 9999px;

    /* Shadow */
    --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 12px rgba(0,0,0,.08);
    --shadow-lg:  0 10px 30px rgba(0,0,0,.12);

    /* Typography */
    --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
    --font-mono:  'JetBrains Mono', monospace;

    /* Transitions */
    --transition: 150ms ease;
}

/* ── Dark theme ──────────────────────────────────────────────── */
[data-theme="dark"] {
    /* Brand — slightly brighter on dark background */
    --clr-primary:        #4f86f7;
    --clr-primary-hover:  #3b72f0;
    --clr-primary-light:  #1a2d50;
    --clr-accent:         #38bdf8;

    /* Sidebar — deeper than main bg to create separation */
    --clr-sidebar-bg:     #010409;
    --clr-sidebar-text:   #8b949e;
    --clr-sidebar-active: #e6edf3;
    --clr-sidebar-hover:  #161b22;
    --clr-sidebar-border: #21262d;
    --clr-sidebar-label:  #6b7d8d;

    /* Surface */
    --clr-bg:             #0d1117;
    --clr-surface:        #161b22;
    --clr-surface-2:      #1c2128;
    --clr-border:         #30363d;
    --clr-thead-bg:       #22272e;

    /* Text — high contrast on dark */
    --clr-text:           #e6edf3;
    --clr-text-muted:     #8b949e;
    --clr-text-light:     #484f58;

    /* Status backgrounds — dark tinted */
    --clr-success-bg:     #0a2d1a;
    --clr-warning-bg:     #2d1f00;
    --clr-danger-bg:      #2d0e0e;
    --clr-info-bg:        #0d1d35;

    /* Status text — bright enough on dark backgrounds */
    --clr-success-text:   #3fb950;
    --clr-warning-text:   #d29922;
    --clr-danger-text:    #f85149;
    --clr-info-text:      #58a6ff;

    /* Focus ring — brighter on dark */
    --clr-focus-ring:     rgba(79,134,247,.22);

    /* Shadows — stronger on dark */
    --shadow-sm:  0 1px 3px rgba(0,0,0,.4),  0 1px 2px rgba(0,0,0,.3);
    --shadow-md:  0 4px 12px rgba(0,0,0,.5);
    --shadow-lg:  0 10px 30px rgba(0,0,0,.7);
}

/* ── Notification Dropdown ───────────────────────────────────── */

.notif-wrap { position: relative; }

.notif-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: -8px;
    width: 340px;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    flex-direction: column;
    overflow: hidden;
}
.notif-dropdown.open { display: flex; }

/* Backdrop for the mobile sheet — inert on desktop, where the dropdown is a
   small popover anchored to the bell and needs no layering cue. */
.notif-scrim { display: none; }

.notif-dd-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--clr-border);
    flex-shrink: 0;
}
.notif-dd-title { font-weight: 600; font-size: .875rem; }

.notif-mark-all {
    font-size: .75rem;
    color: var(--clr-primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.notif-mark-all:hover { text-decoration: underline; }

.notif-list { overflow-y: auto; max-height: 360px; }

.notif-empty-dd {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    padding: 2rem 1rem;
    color: var(--clr-text-muted);
    font-size: .8125rem;
}
.notif-empty-dd svg { opacity: .4; }

.notif-dd-item {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--clr-border);
    text-decoration: none;
    color: var(--clr-text);
    transition: background var(--transition);
    cursor: pointer;
    position: relative;
}
/* The item is an <a>; on touch the tapped one was rendering underlined
   (title, message and timestamp all at once) because nothing pinned the
   decoration for the active/visited states. */
.notif-dd-item,
.notif-dd-item:hover,
.notif-dd-item:active,
.notif-dd-item:focus,
.notif-dd-item:visited { text-decoration: none; color: inherit; }
.notif-dd-item:last-child { border-bottom: none; }
.notif-dd-item:hover { background: var(--clr-surface-2); }
.notif-dd-item.unread { background: rgba(37,99,235,.04); }
[data-theme="dark"] .notif-dd-item.unread { background: rgba(79,134,247,.07); }

.notif-dd-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--clr-primary);
    margin-top: .35rem;
    flex-shrink: 0;
    transition: opacity var(--transition);
}
.notif-dd-item:not(.unread) .notif-dd-dot { opacity: 0; }

.notif-dd-body    { flex: 1; min-width: 0; }
.notif-dd-title-t { font-size: .8125rem; font-weight: 600; margin-bottom: .15rem;
                    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-dd-msg     { font-size: .75rem; color: var(--clr-text-muted);
                    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-dd-time    { font-size: .6875rem; color: var(--clr-text-light); margin-top: .25rem; }

.notif-dd-del {
    flex-shrink: 0;
    width: 24px; height: 24px; border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; cursor: pointer;
    color: var(--clr-text-light);
    opacity: 0;
    transition: opacity var(--transition), background var(--transition), color var(--transition);
}
.notif-dd-item:hover .notif-dd-del { opacity: 1; }
.notif-dd-del:hover { background: var(--clr-danger-soft, rgba(239,68,68,.12)); color: var(--clr-danger); }
@media (hover:none) { .notif-dd-del { opacity: 1; } }

.notif-view-all {
    display: block;
    text-align: center;
    padding: .75rem;
    font-size: .8125rem;
    color: var(--clr-primary);
    text-decoration: none;
    border-top: 1px solid var(--clr-border);
    font-weight: 500;
    flex-shrink: 0;
    transition: background var(--transition);
}
.notif-view-all:hover { background: var(--clr-surface-2); }

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-sans);
    color: var(--clr-text);
    background: var(--clr-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--clr-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ── Utility classes ───────────────────────────────────────────── */

.text-muted   { color: var(--clr-text-muted); }
.text-light   { color: var(--clr-text-light); }
.text-primary { color: var(--clr-primary); }
.text-success { color: var(--clr-success); }
.text-warning { color: var(--clr-warning); }
.text-danger  { color: var(--clr-danger); }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.fs-xs  { font-size: .75rem; }
.fs-sm  { font-size: .875rem; }
.fs-md  { font-size: 1rem; }
.fs-lg  { font-size: 1.125rem; }
.fs-xl  { font-size: 1.25rem; }
.fs-2xl { font-size: 1.5rem; }

.mt-auto { margin-top: auto; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-4 { margin-bottom: 1rem; }

.gap-1 { gap: .25rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Cards ──────────────────────────────────────────────────────── */

.card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 1.5rem; }

/* Mirror image of .card-header — same padding and divider, so a card's action
   row (Save / Cancel) sits inset exactly like the status badge in the header
   instead of hugging the card edge. Views that set their own inline padding
   (company_form) keep it: inline styles win. */
.card-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .625rem;
    background: var(--clr-surface-2, transparent);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--clr-text);
}

/* ── Buttons ─────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .625rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1;
}

.btn-primary {
    background: var(--clr-primary);
    color: #fff;
    border-color: var(--clr-primary);
}
.btn-primary:hover {
    background: var(--clr-primary-hover);
    border-color: var(--clr-primary-hover);
    text-decoration: none;
}

.btn-outline {
    background: transparent;
    color: var(--clr-primary);
    border-color: var(--clr-primary);
}
.btn-outline:hover {
    background: var(--clr-primary-light);
    text-decoration: none;
}

.btn-ghost {
    background: transparent;
    color: var(--clr-text-muted);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--clr-surface-2);
    color: var(--clr-text);
    text-decoration: none;
}

.btn-danger {
    background: var(--clr-danger);
    color: #fff;
    border-color: var(--clr-danger);
}
.btn-danger:hover { opacity: .9; }

.btn-sm { padding: .4rem .875rem; font-size: .8125rem; }
.btn-lg { padding: .875rem 1.75rem; font-size: 1rem; }

/* ── Page-header action buttons ───────────────────────────────────
   Single convention for every "New / Add / Import / Export" button that
   lives in a .page-header. Markup contract:
       <a|button class="btn btn-primary btn-sm hdr-act-btn">
           <svg class="hdr-act-ico" width="14" height="14" ...></svg>
           <span class="btn-text">New Product</span>
       </a>
   On mobile these collapse to a 38x38 icon-only square (see mobile.css),
   matching the filter funnel, so every page's header looks identical. */
.hdr-act-btn { display: inline-flex; align-items: center; gap: .35rem; }
.hdr-act-ico { display: block; flex-shrink: 0; }

/* ── Segmented tool group (utility actions like Automation / Rules / Import / Export) ──
   Wrap secondary .btn buttons in a .tool-group so they read as one cohesive
   toolbar (shared border, thin dividers) instead of floating ghost buttons. */
.tool-group {
    display: inline-flex;
    align-items: stretch;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.tool-group > .btn {
    border: none;
    border-right: 1px solid var(--clr-border);
    border-radius: 0;
    background: transparent;
    color: var(--clr-text-muted);
    padding: .45rem .8rem;
    font-size: .8125rem;
    gap: .4rem;
}
.tool-group > .btn:last-child { border-right: none; }
.tool-group > .btn:hover {
    background: var(--clr-surface-2);
    color: var(--clr-text);
}

/* ── Filter dropdown component (shared: Tasks / My Board / Suppliers) ──
   Radio single-select dropdown styled like the Tasks filter bar. JS lives in
   app.js (tbToggleDd / tbCloseAllDds / tbSelectFilter). Markup: a .tb-dd-wrap
   holding a `.btn.btn-ghost.tb-dd-btn` trigger + a `.tb-dd` menu with a hidden
   input `id="tb-flt-<name>"` that tbSelectFilter submits from its closest form. */
.tb-dd-wrap { position: relative; }
.tb-dd-btn { font-size: .8125rem; padding: .35rem .65rem; display: inline-flex; align-items: center; white-space: nowrap; }
.tb-dd {
    position: absolute; right: 0; top: calc(100% + 4px); z-index: 200;
    min-width: 180px; max-height: 280px; overflow-y: auto;
    background: var(--clr-surface); border: 1px solid var(--clr-border);
    border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: .25rem 0;
}
.tb-dd-title {
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--clr-text-light); padding: .4rem .75rem .25rem;
}
.tb-dd-item {
    display: flex; align-items: center; gap: .45rem; cursor: pointer;
    padding: .4rem .75rem; font-size: .8125rem; color: var(--clr-text);
}
.tb-dd-item:hover { background: var(--clr-surface-2); }
.tb-dd-radio {
    display: inline-block; width: 12px; height: 12px; border-radius: 50%;
    border: 2px solid var(--clr-border); flex-shrink: 0; box-sizing: border-box;
}
.tb-dd-radio.active { background: var(--clr-primary); border-color: var(--clr-primary); }

/* ── Compact form control ──────────────────────────────────────── */
.form-control-xs { padding: .25rem .5rem; font-size: .8125rem; }

/* ── Form controls ───────────────────────────────────────────────── */

.form-group { display: flex; flex-direction: column; gap: .375rem; }

.form-label {
    font-size: .8125rem;
    font-weight: 500;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.form-control {
    width: 100%;
    padding: .625rem .875rem;
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-md);
    background: var(--clr-surface);
    color: var(--clr-text);
    font-size: .9375rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px var(--clr-focus-ring);
}
.form-control::placeholder { color: var(--clr-text-light); }

.form-error {
    font-size: .8125rem;
    color: var(--clr-danger);
}

.form-hint {
    font-size: .8rem;
    color: var(--clr-text-light);
    line-height: 1.4;
}

.form-label.required::after {
    content: ' *';
    color: var(--clr-danger);
}

.has-error .form-control {
    border-color: var(--clr-danger);
}
.has-error .form-control:focus {
    box-shadow: 0 0 0 3px rgba(239,68,68,.15);
}

/* ── Tabs ─────────────────────────────────────────────────── */

.tabs {
    display: flex;
    gap: .375rem;
    border-bottom: 1px solid var(--clr-border);
}

.tab {
    padding: .5rem 1rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--clr-text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition);
    white-space: nowrap;
}
.tab:hover  { color: var(--clr-text); text-decoration: none; }
.tab.active { color: var(--clr-primary); border-bottom-color: var(--clr-primary); }

/* ── Badges ──────────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .625rem;
    border-radius: var(--radius-full);
    font-size: .75rem;
    font-weight: 600;
    line-height: 1;
}

.badge-success { background: var(--clr-success-bg); color: var(--clr-success-text); }
.badge-warning { background: var(--clr-warning-bg); color: var(--clr-warning-text); }
.badge-danger  { background: var(--clr-danger-bg);  color: var(--clr-danger-text); }
.badge-info    { background: var(--clr-info-bg);    color: var(--clr-info-text); }
.badge-neutral { background: var(--clr-surface-2);  color: var(--clr-text-muted); }
.badge-purple  { background: #f3e8ff; color: #7c3aed; }
.badge-accent  { background: #e0f2fe; color: #0369a1; }

[data-theme="dark"] .badge-purple { background: #2d1b4e; color: #c084fc; }
[data-theme="dark"] .badge-accent { background: #0c2233; color: #38bdf8; }

/* ── Priority badges (Asana-style) ────────────────────────────────── */
.priority-urgent { background:#fee2e2; color:#b91c1c; }
.priority-high   { background:#ffedd5; color:#c2410c; }
.priority-medium { background:#fef3c7; color:#92400e; }
.priority-low    { background:#d1fae5; color:#047857; }
.priority-none   { background: var(--clr-surface-2); color: var(--clr-text-muted); }

[data-theme="dark"] .priority-urgent { background:#3b0d0d; color:#fca5a5; }
[data-theme="dark"] .priority-high   { background:#3a1d05; color:#fdba74; }
[data-theme="dark"] .priority-medium { background:#3a2a05; color:#fcd34d; }
[data-theme="dark"] .priority-low    { background:#052e21; color:#6ee7b7; }
[data-theme="dark"] .priority-none   { background: var(--clr-surface-2); color: var(--clr-text-muted); }

/* ── Priority dots — Urgent red / High orange / Medium yellow /
      Low green / None grey. Diameter ≈ capital-letter height. ──── */
.prio-dot {
    display:inline-block; width:.68em; height:.68em; border-radius:50%;
    flex-shrink:0; vertical-align:baseline; box-sizing:border-box;
}
.prio-dot-urgent { background:#ef4444; border:1.5px solid #b91c1c; }
.prio-dot-high   { background:#FF7500; border:1.5px solid #c2410c; }
.prio-dot-medium { background:#FFC300; border:1.5px solid #b45309; }
.prio-dot-low    { background:#10b981; border:1.5px solid #047857; }
.prio-dot-none   { background:#64748b; border:1.5px solid #475569; }

/* ── Priority dropdown (custom, replaces native priority selects) ── */
.prio-dd-wrap { position:relative; display:inline-block; }
.prio-dd-btn {
    display:inline-flex; align-items:center; gap:.4rem;
    background:transparent; border:1px solid transparent; border-radius:6px;
    padding:.2rem .45rem; font-size:.8125rem; font-weight:500;
    color:var(--clr-text-muted); cursor:pointer; white-space:nowrap;
    font-family:inherit; line-height:1.4;
}
.prio-dd-btn:hover { border-color:var(--clr-border); background:var(--clr-surface-2); }
.prio-dd-menu {
    display:none; position:absolute; left:0; top:calc(100% + 4px); z-index:120;
    min-width:130px; background:var(--clr-surface); border:1px solid var(--clr-border);
    border-radius:8px; box-shadow:0 8px 24px rgba(0,0,0,.15); padding:.25rem 0;
}
.prio-dd-menu.open { display:block; }
.prio-dd-item {
    display:flex; align-items:center; gap:.5rem; width:100%;
    background:none; border:none; text-align:left; cursor:pointer;
    padding:.4rem .75rem; font-size:.8125rem; color:var(--clr-text);
    font-family:inherit;
}
.prio-dd-item:hover { background:var(--clr-surface-2); }
.prio-dd-item.active { font-weight:600; }

/* ── Tasks table row sizing (list + archive share the same look) ──
   Header + single-line rows are exactly 45px; rows with a notes/meta
   line below the title grow naturally beyond that. */
.tasks-table th,
.tasks-table td { height:45px; padding-top:.25rem; padding-bottom:.25rem; }
/* Static priority chip used in the archive to mirror the list's dot look */
.prio-static { display:inline-flex; align-items:center; gap:.4rem; font-size:.8125rem; font-weight:500; color:var(--clr-text-muted); white-space:nowrap; }

/* ── Task subtask progress bar ─────────────────────────────────── */
.task-progress { display:flex; flex-direction:column; gap:.2rem; min-width:90px; }
.task-progress-bar {
    height:6px; background:var(--clr-surface-2); border-radius:3px;
    overflow:hidden; position:relative;
}
.task-progress-bar span {
    display:block; height:100%;
    background:linear-gradient(90deg, var(--clr-primary, #6366f1), #8b5cf6);
    border-radius:3px; transition:width .3s;
}
.task-progress-text { font-size:.72rem; color:var(--clr-text-muted); white-space:nowrap; }

/* ── Alerts ──────────────────────────────────────────────────────── */

.alert {
    padding: .875rem 1.125rem;
    border-radius: var(--radius-md);
    font-size: .9rem;
    display: flex;
    align-items: flex-start;
    gap: .625rem;
}

.alert-danger  { background: var(--clr-danger-bg);  color: var(--clr-danger-text);  border-left: 4px solid var(--clr-danger); }
.alert-success { background: var(--clr-success-bg); color: var(--clr-success-text); border-left: 4px solid var(--clr-success); }
.alert-warning { background: var(--clr-warning-bg); color: var(--clr-warning-text); border-left: 4px solid var(--clr-warning); }
.alert-info    { background: var(--clr-info-bg);    color: var(--clr-info-text);    border-left: 4px solid var(--clr-info); }

/* ── Divider ─────────────────────────────────────────────────────── */

.divider {
    border: none;
    border-top: 1px solid var(--clr-border);
    margin: 1.5rem 0;
}

/* ── Avatar ──────────────────────────────────────────────────────── */

.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--clr-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .8125rem;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar-sm { width: 30px; height: 30px; font-size: .75rem; }
.avatar-xs { width: 22px; height: 22px; font-size: .6rem; font-weight: 700; border-radius: var(--radius-full); background: var(--clr-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ── Stat card ───────────────────────────────────────────────────── */

.stat-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-top: 3px solid var(--sc-color, var(--clr-border));
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem 1.375rem;
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: .5rem;
    row-gap: .35rem;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    text-decoration: none !important;
    color: inherit !important;
}

a.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.sc-icon {
    color: var(--sc-color, var(--clr-text-muted));
    margin: 0;
    opacity: .85;
    width: fit-content;
    grid-column: 1; grid-row: 1;
    align-self: center;
    display: inline-flex;
}
.stat-card .stat-label { grid-column: 2; grid-row: 1; align-self: center; }
.stat-card .stat-value,
.stat-card .stat-delta { grid-column: 1 / -1; }

.stat-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--clr-text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--sc-color, var(--clr-text));
    line-height: 1.1;
}

.stat-delta {
    font-size: .8rem;
    font-weight: 500;
    color: var(--clr-text-muted);
    display: flex;
    align-items: center;
    gap: .25rem;
    margin-top: .125rem;
}

.stat-delta.up       { color: var(--clr-success); }
.stat-delta.down     { color: var(--clr-danger); }
.sc-delta-warn       { color: var(--clr-danger) !important; }
.sc-delta-ok         { color: var(--clr-success) !important; }

/* Stat card color variants */
.sc-blue   { --sc-color: #3b82f6; }
.sc-green  { --sc-color: #10b981; }
.sc-cyan   { --sc-color: #06b6d4; }
.sc-orange { --sc-color: #f59e0b; }
.sc-purple { --sc-color: #8b5cf6; }
.sc-red    { --sc-color: #ef4444; }

/* ── Shared Activity Trend Widget (Dashboard + Activity) ──────────── */
.trend-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .875rem;
    margin-bottom: .75rem;
}
.trend-legend-item {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .75rem;
    color: var(--clr-text-muted);
}
.trend-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}
.trend-orient-toggle {
    display: inline-flex;
    margin-left: auto;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm, 4px);
    overflow: hidden;
}
.trend-orient-btn {
    background: transparent;
    border: none;
    padding: .3rem .45rem;
    color: var(--clr-text-muted);
    cursor: pointer;
    line-height: 0;
    transition: background .12s, color .12s;
}
.trend-orient-btn + .trend-orient-btn { border-left: 1px solid var(--clr-border); }
.trend-orient-btn:hover { background: var(--clr-surface-alt, rgba(0,0,0,.04)); color: var(--clr-text); }
.trend-orient-btn.is-active {
    background: var(--clr-primary, #3b82f6);
    color: #fff;
}

/* Horizontal trend chart (HTML/CSS, full-width per row) */
.trend-h { display: flex; flex-direction: column; gap: .55rem; padding: .25rem 0; }
.trend-h-row { display: flex; align-items: center; gap: .625rem; }
.trend-h-label {
    flex: 0 0 62px;
    width: 62px;
    min-width: 62px;
    max-width: 62px;
    text-align: right;
    font-size: .75rem;
    color: var(--clr-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
}
.trend-h-label.is-today { color: var(--clr-primary, #3b82f6); font-weight: 700; }
.trend-h-track {
    flex: 1 1 auto;
    height: 14px;
    border-radius: 3px;
    background: var(--clr-border);
    display: flex;
    overflow: hidden;
    min-width: 0;
}
.trend-h-seg { display: block; height: 100%; transition: width .25s ease; }
.trend-h-total {
    flex: 0 0 32px;
    text-align: right;
    font-size: .72rem;
    color: var(--clr-text-muted);
    font-variant-numeric: tabular-nums;
}

/* ── Status counter bar (Team Board, Personal Board) ─────────────── */

.status-counter-bar {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.status-step {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-top: 3px solid var(--ss-color, var(--clr-border));
    border-radius: var(--radius-md);
    padding: .75rem 1rem .625rem;
    flex: 0 0 128px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: .15rem;
}

.status-count {
    font-size: 1.625rem;
    font-weight: 800;
    color: var(--ss-color, var(--clr-text));
    line-height: 1.15;
}

.status-step-label {
    font-size: .625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--clr-text-muted);
    white-space: nowrap;
}

.ss-todo        { --ss-color: #64748b; }
.ss-in_progress { --ss-color: #10b981; }

/* ── Sidebar nav item ────────────────────────────────────────────── */

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem 1rem;
    border-radius: var(--radius-md);
    color: var(--clr-sidebar-text);
    font-size: .875rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--clr-sidebar-hover);
    color: var(--clr-sidebar-active);
    text-decoration: none;
}

.nav-item.active {
    background: var(--clr-primary);
    color: #fff;
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: .75;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.nav-badge {
    margin-left: auto;
    background: var(--clr-danger, #dc3545);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: .1rem .4rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1.2;
    flex-shrink: 0;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.35); color: #fff; }
/* Badge inside nav-group-toggle: sits BEFORE chevron, so don't push to far right with auto */
.nav-badge.nav-badge-group {
    margin-left: auto;
    margin-right: .4rem;
}
.nav-badge.nav-badge-group + .nav-chevron { margin-left: 0; }
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .nav-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    margin-left: 0;
    padding: 0 4px;
    font-size: .55rem;
    min-width: 14px;
}

.nav-section-label {
    font-size: .6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--clr-sidebar-label);
    padding: .625rem 1rem .25rem;
}

/* ── Collapsible nav group ───────────────────────────────────────── */

.nav-group-toggle {
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    justify-content: flex-start;
}

.nav-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin-left: auto;
    opacity: .5;
    transition: transform var(--transition);
}

.nav-group-items {
    display: none;
    padding-left: .625rem;
    margin-top: .125rem;
}

.nav-group.nav-group-open .nav-chevron { transform: rotate(180deg); }
.nav-group.nav-group-open .nav-group-items { display: block; }

.nav-sub-item {
    font-size: .8125rem;
    padding: .5rem .875rem;
    gap: .6rem;
}

.nav-icon-sm {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: .7;
}

.nav-sub-item.active .nav-icon-sm,
.nav-sub-item:hover .nav-icon-sm { opacity: 1; }

/* ── Trial / Subscription banner ────────────────────────────────── */

.trial-banner {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem 1.25rem;
    font-size: .82rem;
    font-weight: 500;
}
.trial-banner-warn {
    background: #fef3c7;
    color: #92400e;
    border-bottom: 1px solid #fde68a;
}
.trial-banner-urgent {
    background: #fee2e2;
    color: #991b1b;
    border-bottom: 1px solid #fca5a5;
}
[data-theme="dark"] .trial-banner-warn  { background: #422006; color: #fde68a; border-color: #78350f; }
[data-theme="dark"] .trial-banner-urgent { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
.trial-banner-link {
    margin-left: auto;
    font-weight: 600;
    text-decoration: underline;
    color: inherit;
    white-space: nowrap;
}
.trial-banner-link:hover { opacity: .8; }

/* ── Theme toggle button ─────────────────────────────────────────── */

#themeToggle svg { display: none; }
#themeToggle svg.theme-icon-active { display: block; }

/* ── Form grid utilities (responsive via mobile.css override) ───── */

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* ── Print ───────────────────────────────────────────────────────── */

@media print {
    :root {
        --clr-bg: #fff; --clr-surface: #fff; --clr-border: #d1d5db;
        --clr-text: #000; --clr-text-muted: #374151; --clr-text-light: #6b7280;
    }
    body { background: #fff !important; }
    .sidebar, .topbar, .sidebar-overlay,
    #searchOverlay, #helpOverlay, #notifDropdown,
    .btn-primary, .btn-outline, .btn-ghost, .btn-danger,
    [class*="quick-add"], [class*="quick-log"],
    .bulk-bar, #coms-update-banner,
    form[method="POST"]:not(.print-include),
    .chat-input-area, .chat-delete-btn,
    nav, [class*="notif-btn"], .theme-toggle { display: none !important; }
    .main-content { margin: 0 !important; padding: 1rem 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #d1d5db !important; page-break-inside: avoid; }
    a[href]::after { content: none !important; }
    @page { margin: 1.5cm; }
}

/* ── Brand logo (sidebar + auth) ─────────────────────────────── */
.sidebar-logo .brand { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; flex: 1; min-width: 0; }
.sidebar-logo .brand-icon { flex-shrink: 0; width: 36px; height: 36px; border-radius: 8px; display: block; }
.sidebar-logo .brand-text { min-width: 0; }
.auth-logo .brand-icon { width: 80px; height: 80px; border-radius: 18px; display: block; margin: 0 auto .75rem; }

/* ── Sidebar collapse toggle ─────────────────────────────────── */
.sidebar-collapse-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .75rem;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    color: var(--clr-sidebar-text);
    font-size: .75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), padding var(--transition);
    margin-bottom: .5rem;
}
.sidebar-collapse-btn:hover { background: var(--clr-sidebar-hover); color: var(--clr-sidebar-active); }
.sidebar-collapse-btn .sb-chev-right { display: none; }
.sidebar-collapse-btn .sb-collapse-text { flex: 1; text-align: left; }

/* ── Collapsed sidebar (desktop only) ────────────────────────── */
.app-wrapper.sidebar-collapsed .sidebar { width: 64px; }
.app-wrapper.sidebar-collapsed .main-content { margin-left: 64px; }

.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .sidebar-logo { padding: 1.5rem .5rem 1rem; }
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .sidebar-logo .logo-mark,
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .sidebar-logo .logo-sub { display: none; }

.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .sidebar-nav { padding: .5rem .35rem; }
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .nav-item { padding: .55rem .35rem; gap: 0; position: relative; }
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .nav-item > span,
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .nav-item .nav-chevron,
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .nav-group-items { display: none; }
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .nav-item:not(.nav-group-toggle) {
    font-size: 0;
}
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .nav-item .nav-icon { margin: 0 auto; }

/* Show text label as native browser tooltip via title attribute (added by JS) */
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .nav-section-label { display: none; }

.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .sidebar-quickbar { flex-wrap: wrap; justify-content: center; padding: .5rem .25rem; gap: 4px; }
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .sidebar-user { padding: .5rem; }
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .sidebar-user-info { display: none; }
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .sidebar-footer form { text-align: center; }

.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .sidebar-collapse-btn { padding: .45rem; }
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .sidebar-collapse-btn .sb-collapse-text { display: none; }
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .sidebar-collapse-btn .sb-chev-left { display: none; }
.app-wrapper.sidebar-collapsed:not(.sidebar-hover-expand) .sidebar-collapse-btn .sb-chev-right { display: block; }

/* Notification dropdown anchored beside collapsed sidebar */
.app-wrapper.sidebar-collapsed .notif-dropdown--sidebar { left: 56px; }

/* Hover-to-expand: sidebar temporarily opens full width over the page
   without shifting .main-content (which stays pinned at 64px margin) */
.app-wrapper.sidebar-collapsed.sidebar-hover-expand .sidebar {
    width: var(--sidebar-width);
    z-index: 200;
    box-shadow: 2px 0 16px rgba(0,0,0,.18);
}
