/* =====================================================================
   GAME Project Management — Design System
   Inspired by visual specs: clean white surface, orange accent,
   soft shadows, large readable cards, mobile-first responsive.
   ===================================================================== */

:root {
    /* Brand */
    --brand-orange:        #F26B2B;
    --brand-orange-600:    #DD5A1F;
    --brand-orange-100:    #FFEDE3;
    --brand-orange-50:     #FFF6F1;
    --brand-black:         #0F1115;

    /* Surfaces */
    --bg:                  #F8F9FB;
    --surface:             #FFFFFF;
    --surface-2:           #F4F5F7;
    --border:              #E7EAEF;
    --border-strong:       #D6DAE0;

    /* Text */
    --text:                #1A1D23;
    --text-2:              #4B5563;
    --text-3:              #6B7280;
    --text-muted:          #9AA3AF;

    /* Status palette (per spec) */
    --status-gray-bg:      #F1F2F5;  --status-gray-fg:    #5B6470;
    --status-blue-bg:      #E5EFFE;  --status-blue-fg:    #1E5FCB;
    --status-yellow-bg:    #FFF4D9;  --status-yellow-fg:  #8C6A00;
    --status-orange-bg:    #FFE6D3;  --status-orange-fg:  #BB4A0F;
    --status-red-bg:       #FFE2E2;  --status-red-fg:     #B22B2B;
    --status-green-bg:     #DBF5E5;  --status-green-fg:   #126B3B;
    --status-purple-bg:    #ECE6FE;  --status-purple-fg:  #5B3CC4;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15, 17, 21, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 17, 21, 0.06), 0 1px 2px rgba(15, 17, 21, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 17, 21, 0.06), 0 2px 4px rgba(15, 17, 21, 0.04);
    --shadow-lg: 0 12px 32px rgba(15, 17, 21, 0.08), 0 4px 12px rgba(15, 17, 21, 0.04);

    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Layout */
    --sidebar-w: 240px;
    --topbar-h:  64px;
    --bottomnav-h: 64px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }

/* ===== App shell ===== */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ===== Sidebar ===== */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 18px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
}
.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 18px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}
.sidebar__brand-mark {
    width: 36px; height: 36px;
    border-radius: 9px;
    background: var(--brand-orange);
    display: grid; place-items: center;
    color: white; font-weight: 800; font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(242,107,43,0.35);
}
.sidebar__brand-mark img { width: 22px; height: 22px; }
.sidebar__brand-name { font-weight: 700; font-size: 15px; color: var(--text); line-height: 1.2; }
.sidebar__brand-tag  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar__link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-weight: 500;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}
.sidebar__link:hover { background: var(--surface-2); color: var(--text); }
.sidebar__link--active {
    background: var(--brand-orange-50);
    color: var(--brand-orange-600);
    font-weight: 600;
}
.sidebar__link--active svg { stroke: var(--brand-orange-600); }
.sidebar__link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar__cta {
    margin-top: auto;
    padding-top: 14px;
}
.sidebar__user {
    display: flex; align-items: center; gap: 10px;
    padding: 10px;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}
.sidebar__user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: grid; place-items: center;
    color: white; font-weight: 600; font-size: 13px;
    flex-shrink: 0;
}
.sidebar__user-name { font-weight: 600; font-size: 13px; color: var(--text); line-height: 1.2; }
.sidebar__user-role { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ===== Top bar ===== */
.topbar {
    min-height: var(--topbar-h);
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: env(safe-area-inset-top) 28px 0 28px;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar__search {
    flex: 1;
    max-width: 560px;
    position: relative;
}
.topbar__search input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    transition: border 0.15s, background 0.15s;
}
.topbar__search input:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--brand-orange);
    box-shadow: 0 0 0 3px var(--brand-orange-100);
}
.topbar__search-icon {
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.topbar__actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar__icon-btn {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: var(--radius);
    color: var(--text-2);
    background: transparent;
    transition: background 0.15s;
    position: relative;
}
.topbar__icon-btn:hover { background: var(--surface-2); }
.topbar__icon-btn svg { width: 20px; height: 20px; }
.topbar__badge {
    position: absolute;
    top: 6px; right: 6px;
    background: var(--brand-orange);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    display: grid; place-items: center;
}

/* ===== Main content ===== */
.main {
    display: flex; flex-direction: column;
    min-width: 0;
}
.content {
    padding: 28px;
    flex: 1;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 22px;
}
.page-title {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
    margin: 0 0 4px 0;
}
.page-subtitle { color: var(--text-3); font-size: 14px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
    border: 1px solid transparent;
    line-height: 1;
    min-height: 40px;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
    background: var(--brand-orange);
    color: white;
    box-shadow: 0 1px 3px rgba(242,107,43,0.35);
}
.btn-primary:hover { background: var(--brand-orange-600); }
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-ghost {
    background: transparent;
    color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger {
    background: var(--status-red-fg);
    color: white;
}
.btn-danger:hover { background: #951f1f; }
.btn--sm { padding: 7px 12px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn--icon { padding: 8px; min-height: 36px; aspect-ratio: 1; }

/* ===== Cards ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card__header {
    padding: 18px 20px 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card__title { font-size: 15px; font-weight: 600; color: var(--text); margin: 0; }
.card__action {
    color: var(--brand-orange);
    font-weight: 500;
    font-size: 13px;
}
.card__action:hover { color: var(--brand-orange-600); }
.card__body { padding: 0 20px 18px 20px; }
.card__footer {
    border-top: 1px solid var(--border);
    padding: 14px 20px;
    text-align: center;
}

/* KPI cards (dashboard) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 18px 16px 18px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}
.kpi:hover { box-shadow: var(--shadow-md); }
.kpi__top {
    display: flex; align-items: center; justify-content: space-between;
    color: var(--text-3);
    font-size: 13px; font-weight: 500;
    margin-bottom: 10px;
}
.kpi__icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: grid; place-items: center;
    background: var(--brand-orange-50);
    color: var(--brand-orange-600);
}
.kpi__value { font-size: 30px; font-weight: 700; line-height: 1.1; color: var(--text); }
.kpi__delta { font-size: 12px; margin-top: 6px; color: var(--text-3); }
.kpi__delta--up   { color: var(--status-green-fg); }
.kpi__delta--down { color: var(--status-red-fg); }

/* ===== Badges ===== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.badge--with-dot::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
}
.badge-gray   { background: var(--status-gray-bg);   color: var(--status-gray-fg);   }
.badge-blue   { background: var(--status-blue-bg);   color: var(--status-blue-fg);   }
.badge-yellow { background: var(--status-yellow-bg); color: var(--status-yellow-fg); }
.badge-orange { background: var(--status-orange-bg); color: var(--status-orange-fg); }
.badge-red    { background: var(--status-red-bg);    color: var(--status-red-fg);    }
.badge-green  { background: var(--status-green-bg);  color: var(--status-green-fg);  }
.badge-purple { background: var(--status-purple-bg); color: var(--status-purple-fg); }

/* ===== Tables ===== */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    font-size: 13.5px;
    border-bottom: 1px solid var(--border);
}
.table th {
    background: var(--surface-2);
    color: var(--text-3);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 0.1s; }
.table tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.table tbody tr.is-overdue { background: var(--status-red-bg); }
.table tbody tr.is-overdue:hover { background: #ffd5d5; }
.table__title { font-weight: 600; color: var(--text); }
.table__meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ===== Forms ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
}
.input, .textarea, .select {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    transition: border 0.15s, box-shadow 0.15s;
}
.textarea {
    height: auto;
    min-height: 96px;
    padding: 10px 12px;
    line-height: 1.5;
    resize: vertical;
}
.input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: var(--brand-orange);
    box-shadow: 0 0 0 3px var(--brand-orange-100);
}
.input--error { border-color: var(--status-red-fg); }
.field-help { font-size: 12px; color: var(--text-3); }
.field-error { font-size: 12px; color: var(--status-red-fg); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.form-grid--full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* ==========================================================================
   Switch — pure-CSS toggle. <label class="switch"> wraps a real <input
   type="checkbox"> (visually hidden but functional) followed by a
   .switch__track + .switch__knob. The checkbox state drives the visuals
   via the adjacent-sibling selector, no JS required.
   ========================================================================== */
.switch {
    --sw-w: 40px;
    --sw-h: 22px;
    --sw-pad: 2px;
    --sw-knob: calc(var(--sw-h) - (var(--sw-pad) * 2));
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.switch input[type="checkbox"] {
    /* Visually hide but keep focusable + clickable */
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
}
.switch__track {
    position: relative;
    flex: none;
    width: var(--sw-w);
    height: var(--sw-h);
    background: var(--border-strong, #d1d5db);
    border-radius: 999px;
    transition: background-color 0.18s ease;
}
.switch__knob {
    position: absolute;
    top: var(--sw-pad);
    left: var(--sw-pad);
    width: var(--sw-knob);
    height: var(--sw-knob);
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: transform 0.18s ease;
}
.switch input[type="checkbox"]:checked ~ .switch__track {
    background: var(--brand-orange, #F26B2B);
}
.switch input[type="checkbox"]:checked ~ .switch__track .switch__knob {
    transform: translateX(calc(var(--sw-w) - var(--sw-knob) - (var(--sw-pad) * 2)));
}
.switch input[type="checkbox"]:focus-visible ~ .switch__track {
    box-shadow: 0 0 0 3px rgba(242, 107, 43, 0.35);
}
.switch input[type="checkbox"]:disabled ~ .switch__track {
    opacity: 0.6;
    cursor: not-allowed;
}
.switch__label { font-size: 14px; color: var(--text, #111); }
.switch.is-locked .switch__track {
    background: var(--status-green-fg, #16a34a);
    cursor: not-allowed;
}
.switch.is-locked .switch__knob {
    transform: translateX(calc(var(--sw-w) - var(--sw-knob) - (var(--sw-pad) * 2)));
}

/* Avatar */
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-grid; place-items: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
    background: var(--text-3);
}
.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar--lg { width: 44px; height: 44px; font-size: 14px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar:not(:first-child) { margin-left: -10px; border: 2px solid var(--surface); }

/* Progress */
.progress {
    height: 6px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    flex: 1;
}
.progress__bar {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-orange), var(--brand-orange-600));
    border-radius: 999px;
    transition: width 0.3s;
}
.progress--green .progress__bar { background: var(--status-green-fg); }
.progress--red   .progress__bar { background: var(--status-red-fg); }

/* Empty state */
.empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-3);
}
.empty__title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty__desc  { font-size: 13.5px; margin-bottom: 18px; }

/* Login */
.auth-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    background:
      radial-gradient(circle at 20% 0%, rgba(242,107,43,0.08) 0%, transparent 45%),
      radial-gradient(circle at 80% 100%, rgba(242,107,43,0.06) 0%, transparent 45%),
      var(--bg);
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 36px;
    border: 1px solid var(--border);
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand img { width: 220px; max-width: 80%; margin: 0 auto 12px; }
.auth-brand__title { font-size: 18px; font-weight: 700; color: var(--text); }
.auth-brand__subtitle { font-size: 13px; color: var(--text-3); margin-top: 4px; }

/* Drawer (task detail) */
.drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 17, 21, 0.45);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.drawer-overlay.is-open { opacity: 1; pointer-events: auto; }
.drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(560px, 100%);
    background: var(--surface);
    z-index: 91;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}
.drawer.is-open { transform: translateX(0); }
.drawer__header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.drawer__body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer__footer {
    border-top: 1px solid var(--border);
    padding: 14px 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 22px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tab {
    padding: 12px 16px;
    color: var(--text-3);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--brand-orange); border-bottom-color: var(--brand-orange); font-weight: 600; }
.tab__count {
    margin-left: 6px;
    background: var(--surface-2);
    color: var(--text-3);
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.tab.is-active .tab__count { background: var(--brand-orange-100); color: var(--brand-orange-600); }

/* Filter chips */
.filters {
    display: flex; flex-wrap: wrap; gap: 10px;
    margin-bottom: 16px;
}

/* Project header */
.project-header { margin-bottom: 22px; }
.project-header__top { display: flex; gap: 14px; align-items: flex-start; }
.project-header__icon {
    width: 56px; height: 56px;
    border-radius: 12px;
    background: var(--brand-orange-50);
    color: var(--brand-orange);
    display: grid; place-items: center;
    flex-shrink: 0;
}
.project-header__title { font-size: 22px; font-weight: 700; margin: 0 0 6px 0; }
.project-header__meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.project-header__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Activity list */
.activity { display: flex; flex-direction: column; gap: 4px; }
.activity__item {
    display: flex; gap: 12px; padding: 10px 0;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}
.activity__item:last-child { border-bottom: none; }
.activity__avatar { flex-shrink: 0; }
.activity__body { flex: 1; min-width: 0; }
.activity__text { font-size: 13.5px; color: var(--text); margin-bottom: 2px; }
.activity__meta { font-size: 12px; color: var(--text-muted); }

/* Comments */
.comment { display: flex; gap: 12px; padding: 14px 0; }
.comment__body { flex: 1; min-width: 0; }
.comment__head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.comment__name { font-weight: 600; font-size: 13px; }
.comment__time { font-size: 12px; color: var(--text-muted); }
.comment__text { font-size: 14px; color: var(--text); white-space: pre-wrap; }

/* Notification dropdown */
.notif-panel {
    position: absolute;
    top: 56px; right: 28px;
    width: 380px;
    max-width: calc(100vw - 56px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 30;
    display: none;
    overflow: hidden;
    max-height: 70vh;
}
.notif-panel.is-open { display: flex; flex-direction: column; }
.notif-panel__head {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.notif-panel__list { overflow-y: auto; flex: 1; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.is-unread { background: var(--brand-orange-50); }
.notif-item__title { font-weight: 600; font-size: 13.5px; margin-bottom: 2px; }
.notif-item__msg { font-size: 13px; color: var(--text-2); }
.notif-item__time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Toast */
.toast-host {
    position: fixed; bottom: 24px; right: 24px;
    z-index: 200;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    background: var(--text);
    color: white;
    padding: 12px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    min-width: 240px;
    max-width: 360px;
    animation: toastIn 0.2s ease-out;
}
.toast--ok { background: var(--status-green-fg); }
.toast--err { background: var(--status-red-fg); }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Mobile bottom nav */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottomnav-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav__inner {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
    height: var(--bottomnav-h);
    align-items: center;
}
.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 500;
}
.bottom-nav__item.is-active { color: var(--brand-orange); }
.bottom-nav__item svg { width: 22px; height: 22px; }
.bottom-nav__plus {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--brand-orange);
    color: white;
    display: grid; place-items: center;
    box-shadow: 0 6px 16px rgba(242,107,43,0.4);
    transform: translateY(-12px);
}
.bottom-nav__plus svg { width: 24px; height: 24px; stroke: white; }

/* Mobile responsive */
@media (max-width: 900px) {
    :root { --topbar-h: 56px; }
    .app { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .topbar { padding: 0 16px; }
    .content { padding: 16px 16px calc(var(--bottomnav-h) + 24px) 16px; }
    .page-title { font-size: 22px; }
    .bottom-nav { display: flex; }
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr {
        margin-bottom: 8px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 10px 12px;
    }
    .table td {
        border-bottom: none;
        padding: 4px 0;
        display: flex;
        justify-content: space-between;
        gap: 8px;
        font-size: 13px;
    }
    .table td::before {
        content: attr(data-label);
        color: var(--text-3);
        font-size: 12px;
        font-weight: 500;
    }
    .table td:first-child::before { content: none; }
    .table td:first-child { font-weight: 600; font-size: 14.5px; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
    .table-wrap { background: transparent; border: none; box-shadow: none; }
    .drawer { width: 100%; }
    .topbar__search { display: none; }
}

/* ===== Utilities ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.flex-1 { flex: 1; min-width: 0; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--text-3); }
.text-strong { font-weight: 600; color: var(--text); }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; } .mb-8 { margin-bottom: 32px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-dashboard { grid-template-columns: 2fr 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .grid-dashboard { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr; } .grid-2 { grid-template-columns: 1fr; } }
.cursor-pointer { cursor: pointer; }
.no-wrap { white-space: nowrap; }

/* PWA install banner */
.pwa-banner {
    position: fixed;
    bottom: 80px; left: 16px; right: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    display: none;
    align-items: center; gap: 12px;
    z-index: 50;
}
.pwa-banner.is-visible { display: flex; }
@media (min-width: 901px) {
    .pwa-banner { bottom: 24px; right: 24px; left: auto; max-width: 360px; }
}
/* ==========================================================================
   GAME PM — design system additions (appended to app.css)
   These add the missing classes referenced by views without colliding with the
   existing rules.  Brand: #F26B2B / #0F1115 / #FFFFFF.
   ========================================================================== */

:root {
  --orange: #F26B2B;
  --orange-soft: rgba(242, 107, 43, 0.12);
  --orange-strong: #d75a1d;
  --ink: #0F1115;
  --ink-2: #1a1d23;
  --paper: #ffffff;
  --paper-2: #f7f7f8;
  --line: #e5e7eb;
  --line-2: #d8dbe0;
  --muted: #6b7280;
  --muted-2: #9aa0a6;
  --green: #16a34a;
  --green-soft: rgba(22, 163, 74, 0.12);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.12);
  --yellow: #d97706;
  --yellow-soft: rgba(217, 119, 6, 0.12);
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.12);
  --shadow-sm: 0 1px 2px rgba(15,17,21,.06);
  --shadow-md: 0 4px 12px rgba(15,17,21,.08);
  --shadow-lg: 0 12px 32px rgba(15,17,21,.12);
  --radius: 12px;
  --radius-lg: 16px;
}

/* --- Flash messages ----------------------------------------------------- */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-weight: 500;
  border: 1px solid transparent;
}
.flash-success { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.flash-error   { background: var(--red-soft);   color: var(--red);   border-color: var(--red); }
.flash-info    { background: var(--blue-soft);  color: var(--blue);  border-color: var(--blue); }
.flash-warning { background: var(--yellow-soft); color: var(--yellow); border-color: var(--yellow); }

/* --- Buttons (extra variants) ------------------------------------------- */
.btn-tiny {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--line);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.btn-tiny:hover { background: var(--paper); border-color: var(--line-2); }
.btn-lg {
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 10px;
}
.btn-block { display: block; width: 100%; }
.btn-ok    { background: var(--green); color:#fff; border:1px solid var(--green); }
.btn-ok:hover { filter: brightness(.95); }

/* --- Form fields -------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1; }
.field__label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field__input,
input.field__input,
select.field__input,
textarea.field__input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field__input:focus,
input.field__input:focus,
select.field__input:focus,
textarea.field__input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-soft);
}
.field__input:disabled { background: var(--paper-2); color: var(--muted); cursor: not-allowed; }
.field__hint { font-size: 12px; color: var(--muted); }
.field-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.field-row > .field { min-width: 140px; }

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* --- KPI cards (dashboard) --------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.kpi-card__label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi-card__value { font-size: 28px; font-weight: 700; color: var(--ink); margin-top: 4px; line-height: 1.2; }
.kpi-card__sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-card--accent { background: var(--ink); color: #fff; border-color: var(--ink); }
.kpi-card--accent .kpi-card__label,
.kpi-card--accent .kpi-card__sub   { color: rgba(255,255,255,.7); }
.kpi-card--accent .kpi-card__value { color: #fff; }
.kpi-card--warn   { border-left: 3px solid var(--yellow); }
.kpi-card--ok     { border-left: 3px solid var(--green); }
.kpi-card--alert  { border-left: 3px solid var(--red); }

/* --- Project list rows -------------------------------------------------- */
.proj-list { display: flex; flex-direction: column; gap: 10px; }
.proj-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.proj-row:hover { border-color: var(--orange); box-shadow: var(--shadow-md); }
.proj-row__main { flex: 1; min-width: 0; }
.proj-row__title { font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.proj-row__meta  { font-size: 12px; color: var(--muted); display:flex; gap:10px; flex-wrap:wrap; }
.proj-row__badges { display: flex; gap: 6px; flex-wrap: wrap; }
.proj-row__progress {
  flex: 0 0 120px;
  height: 6px;
  background: var(--paper-2);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.proj-row__progress > span {
  display:block; height:100%;
  background: var(--orange);
  border-radius: 3px;
  transition: width .3s ease;
}

/* --- Task list ---------------------------------------------------------- */
.task-list { display: flex; flex-direction: column; gap: 6px; }
/* Card-style task rows (used in My Tasks list as <a class="task-row">). */
/* Scoped with :not(tr) so we don't break <tr class="task-row"> table rows. */
.task-row:not(tr) {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.task-row:not(tr):hover { background: var(--paper-2); border-color: var(--line-2); }
.task-row.is-overdue:not(tr) { border-left: 3px solid var(--red); }
.task-row.is-done    { opacity: .6; }
.task-row.is-done .task-row__title { text-decoration: line-through; }
.task-row__title { flex: 1; min-width: 0; font-weight: 500; }
.task-row__meta  { font-size: 12px; color: var(--muted); }

.task-checkbox {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--line-2); background: var(--paper);
  cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s ease;
}
.task-checkbox:hover { border-color: var(--orange); }
.check-circle { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-2); display:inline-flex;align-items:center;justify-content:center;color:transparent; }
.check-circle.is-done { border-color: var(--green); background: var(--green); color:#fff; }

/* --- Activity list ------------------------------------------------------ */
.activity-list {
  display: flex; flex-direction: column;
  border-top: 1px solid var(--line);
}
.activity-list__item {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.activity-list__icon {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 50%; background: var(--orange-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--orange); font-weight: 600; font-size: 12px;
}
.activity-list__body { flex: 1; min-width: 0; }
.activity-list__text { font-size: 14px; color: var(--ink); }
.activity-list__time { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* --- Tabs --------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__tab {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  transition: color .15s ease, border-color .15s ease;
}
.tabs__tab:hover { color: var(--ink); }
.tabs__tab.is-active { color: var(--orange); border-bottom-color: var(--orange); }

/* --- Reports grid ------------------------------------------------------- */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.report-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.report-card:hover { border-color: var(--orange); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.report-card__icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--orange-soft);
  color: var(--orange);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.report-card__title { font-weight: 600; color: var(--ink); }
.report-card__desc  { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* --- Filter bar --------------------------------------------------------- */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.filter-input,
.filter-select {
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
}
.filter-input { flex: 1; min-width: 180px; }
.filter-input:focus,
.filter-select:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }

/* --- Data tables -------------------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}
.data-table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.data-table tbody tr:hover { background: var(--paper-2); }
.data-table .row-clickable { cursor: pointer; }
.data-table--tasks .data-table-status { font-size: 12px; }
/* Task table column widths: title flexes, secondary cols are sized so the row
   fills the full container width on desktop instead of bunching to the left. */
.data-table--tasks { table-layout: auto; width: 100%; }
.data-table--tasks th:nth-child(1),
.data-table--tasks td:nth-child(1) { width: auto; min-width: 220px; }
.data-table--tasks th:nth-child(2),
.data-table--tasks td:nth-child(2) { width: 18%; min-width: 140px; }
.data-table--tasks th:nth-child(3),
.data-table--tasks td:nth-child(3) { width: 12%; min-width: 110px; }
.data-table--tasks th:nth-child(4),
.data-table--tasks td:nth-child(4) { width: 10%; min-width: 90px; }
.data-table--tasks th:nth-child(5),
.data-table--tasks td:nth-child(5) { width: 14%; min-width: 110px; white-space: nowrap; }
.data-table--perms input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--orange);
  cursor: pointer;
}
.data-table--perms input[type="checkbox"]:disabled { opacity: .55; cursor: not-allowed; }

/* --- Calendar ----------------------------------------------------------- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-head {
  background: var(--paper-2);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  text-align: center;
}
.cal-cell {
  background: var(--paper);
  min-height: 90px;
  padding: 6px 8px;
  display: flex; flex-direction: column;
  gap: 4px;
  position: relative;
}
.cal-cell--out { background: var(--paper-2); color: var(--muted); }
.cal-cell--today { background: var(--orange-soft); }
.cal-cell__num { font-size: 13px; font-weight: 600; }
.cal-cell--today .cal-cell__num { color: var(--orange); }
.cal-event {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--orange-soft);
  color: var(--orange);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.cal-event:hover { background: var(--orange); color: #fff; }
.cal-more { font-size: 11px; color: var(--muted); cursor: pointer; }
.calendar-list { display: none; }
.calendar-list__day {
  padding: 12px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.calendar-list__day h4 { margin: 0 0 8px; font-size: 14px; }

@media (max-width: 700px) {
  .calendar-grid { display: none; }
  .calendar-list { display: block; }
}

/* --- Comments ----------------------------------------------------------- */
.comment-form {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 16px;
}
.comment-form textarea {
  min-height: 80px;
  padding: 10px 12px;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-family: inherit;
  resize: vertical;
}
.comment-form textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.comment-list { display: flex; flex-direction: column; gap: 12px; }
.comment-body {
  padding: 12px 14px;
  background: var(--paper-2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.comment-body__head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.comment-body__name { font-weight: 600; }
.comment-body__time { color: var(--muted); font-size: 12px; }
.comment-body__text { font-size: 14px; color: var(--ink); white-space: pre-wrap; line-height: 1.5; }

/* --- Avatar stack ------------------------------------------------------- */
.avatar-sm {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  border: 2px solid var(--paper);
  flex-shrink: 0;
}
.avatar-stack { display: inline-flex; }
.avatar-stack > .avatar-sm { margin-left: -8px; }
.avatar-stack > .avatar-sm:first-child { margin-left: 0; }
.avatar-more {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--paper-2);
  color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  border: 2px solid var(--paper);
  margin-left: -8px;
}

/* --- Notification panel ------------------------------------------------- */
.notif-panel {
  position: absolute;
  top: 56px; right: 16px;
  width: 360px; max-width: calc(100vw - 32px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: none;
}
.notif-panel.is-open { display: block; }
.notif-panel__head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.notif-panel__head h4 { margin: 0; font-size: 14px; }
.notif-panel__list { max-height: 60vh; overflow-y: auto; }
.notif-empty { padding: 24px; text-align: center; color: var(--muted); }

/* --- Bottom nav (mobile) ------------------------------------------------ */
.bottom-nav__item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  transition: color .15s ease;
}
.bottom-nav__item.is-active { color: var(--orange); }
.bottom-nav__item svg { width: 22px; height: 22px; }
.bottom-nav__fab {
  width: 56px; height: 56px;
  min-width: 56px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin-top: -22px;
  box-shadow: 0 6px 16px rgba(242,107,43,.35), 0 2px 4px rgba(0,0,0,.15);
  flex: 0 0 auto;
  align-self: flex-start;
  border: 3px solid var(--surface);
}
.bottom-nav__fab svg {
  width: 26px; height: 26px;
  stroke: #fff;
  stroke-width: 2.4;
  display: block;
}
.bottom-nav__fab.is-active { background: var(--orange-strong); }

/* --- PWA install button ------------------------------------------------- */
.pwa-install {
  position: fixed;
  right: 16px; bottom: 80px;
  background: var(--orange); color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 40;
}
@media (min-width: 901px) {
  .pwa-install { bottom: 16px; }
}

/* --- Drawer (right slideout) ------------------------------------------- */
.drawer.is-open {
  position: fixed; inset: 0;
  background: rgba(15,17,21,.4);
  z-index: 60;
  display: flex;
  justify-content: flex-end;
  animation: drawerFade .15s ease;
}
@keyframes drawerFade { from { opacity: 0; } to { opacity: 1; } }
.drawer__sheet {
  width: 100%; max-width: 480px;
  background: var(--paper);
  height: 100vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: drawerSlide .2s ease;
}
@keyframes drawerSlide { from { transform: translateX(20px); } to { transform: translateX(0); } }
.drawer__head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--paper); z-index: 1;
}
.drawer__body { padding: 16px; }
.drawer__close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

/* --- Inline form / button group ---------------------------------------- */
.inline-form { display: inline-flex; align-items: center; gap: 6px; }
.btn-group { display: inline-flex; gap: 6px; }

/* --- Badges & due labels ------------------------------------------------ */
.badge-pill {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--paper-2);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-success { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.badge-muted   { background: var(--paper-2); color: var(--muted); border-color: var(--line); }
.due-label {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--paper-2);
  color: var(--muted);
}
.due-label.is-overdue { background: var(--red-soft); color: var(--red); }
.due-label.is-today   { background: var(--yellow-soft); color: var(--yellow); }
.due-label.is-soon    { background: var(--blue-soft); color: var(--blue); }

/* --- Meta grid (key/value pairs) --------------------------------------- */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px;
  padding: 12px 0;
}
.meta-grid > div { font-size: 14px; }
.meta-grid > div > strong { display:block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-bottom: 2px; }

/* --- Helpers ------------------------------------------------------------ */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.link { color: var(--orange); text-decoration: none; }
.link:hover { text-decoration: underline; }
.empty { padding: 48px 24px; text-align: center; }
.empty h3 { margin: 0 0 6px; }

/* --- Error pages -------------------------------------------------------- */
.error-card {
  max-width: 480px;
  margin: 60px auto;
  padding: 40px 32px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-md);
}
.error-mark {
  font-size: 64px;
  font-weight: 700;
  color: var(--orange);
  line-height: 1;
  margin-bottom: 12px;
}

/* --- Auth layout -------------------------------------------------------- */
.auth-body { background: var(--ink); min-height: 100vh; margin: 0; }
.auth-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
/* Note: .auth-card already exists in app.css; below adds dark theme on auth-body */
.auth-body .auth-card {
  background: var(--paper);
  width: 100%;
  max-width: 420px;
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

/* --- Sub-card (for nested editors) ------------------------------------- */
.card--sub {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--paper-2);
}
.task-rows .card--sub:last-child { margin-bottom: 0; }

/* --- Form grid (multi-section forms) ----------------------------------- */
.form-grid > section { margin-bottom: 18px; }
.form-grid > .form-actions { margin-top: 8px; }

/* --- Switch overrides removed — see top-of-file definition. -------- */

/* (intentionally removed older conflicting overrides — see
   "v2 layout overhaul" block at end of file) */

/* --- Misc fixes -------------------------------------------------------- */
.muted code, code {
  background: var(--paper-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--orange); }

/* ==========================================================================
   v2 LAYOUT OVERHAUL — desktop-first responsive system
   - Desktop (>=1024px): persistent left sidebar, top bar with search,
     content max-width 1440px, 4-col KPI grid, 3-col dashboard body.
   - Tablet  (768-1023px): sidebar collapses to icon rail / hamburger,
     2-col KPI grid, 2-col body grid.
   - Mobile  (<768px): hamburger sidebar drawer, bottom nav bar,
     1-col stacks for KPI / body grids, full-width cards.
   This block intentionally lives at the end so its rules win the cascade.
   ========================================================================== */

:root {
    --content-pad-x: 28px;
    --content-pad-y: 24px;
    --gap: 20px;
}

/* ----- App shell ----- */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
}

/* ----- Sidebar ----- */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    z-index: 30;
}
.sidebar__brand {
    display: flex; align-items: center; gap: 12px;
    padding: 4px 6px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}
.sidebar__brand-mark {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: var(--surface-2);
    display: grid; place-items: center;
    flex-shrink: 0;
    box-shadow: none;
    overflow: hidden;
    padding: 2px;
}
.sidebar__brand-mark img {
    width: 100%; height: 100%;
    object-fit: contain;
}
.sidebar__brand-text { line-height: 1.15; }
.sidebar__brand-name {
    font-weight: 800; font-size: 16px;
    letter-spacing: 0.3px;
    color: var(--text);
}
.sidebar__brand-tag {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 2px;
}

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar__link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-2);
    font-weight: 500;
    font-size: 14px;
    transition: background .15s, color .15s;
    text-decoration: none;
}
.sidebar__link:hover {
    background: var(--surface-2);
    color: var(--text);
}
.sidebar__link--active {
    background: var(--brand-orange-50);
    color: var(--brand-orange-600);
    font-weight: 600;
}
.sidebar__icon { display: inline-flex; }
.sidebar__icon svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar__link--active svg { stroke: var(--brand-orange-600); }

.sidebar__cta {
    margin-top: 10px;
    margin-bottom: 4px;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 11px 14px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(242,107,43,.30);
}

.sidebar__user {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.sidebar__user .user-card {
    display: flex; align-items: center; gap: 10px;
    padding: 6px;
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
    transition: background .15s;
}
.sidebar__user .user-card:hover { background: var(--surface-2); }
.sidebar__user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.sidebar__user-name {
    font-weight: 600; font-size: 13px;
    color: var(--text); line-height: 1.2;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 130px;
}
.sidebar__user-role { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ----- Topbar ----- */
.topbar {
    /* iOS standalone PWA: extend bar under status bar / Dynamic Island and pad with safe-area inset */
    min-height: var(--topbar-h);
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px;
    padding: env(safe-area-inset-top) var(--content-pad-x) 0 var(--content-pad-x);
    box-sizing: border-box;
    position: sticky; top: 0; z-index: 25;
}
.topbar__menu, .sidebar-toggle {
    display: none;
    width: 40px; height: 40px;
    border-radius: 10px;
    align-items: center; justify-content: center;
    background: transparent;
    color: var(--text-2);
    border: 1px solid transparent;
    cursor: pointer;
}
.topbar__menu:hover, .sidebar-toggle:hover { background: var(--surface-2); border-color: var(--border); }
.topbar__title--mobile { display: none; }
.topbar__search {
    flex: 1;
    max-width: 520px;
    position: relative;
}
.topbar__search input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    transition: background .15s, border-color .15s, box-shadow .15s;
}
.topbar__search input::placeholder { color: var(--text-3); }
.topbar__search input:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--brand-orange);
    box-shadow: 0 0 0 3px var(--brand-orange-100);
}
.topbar__search-icon {
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
    display: inline-flex;
}
.topbar__actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar__icon-btn {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: 10px;
    color: var(--text-2);
    background: transparent;
    transition: background .15s;
    position: relative;
    cursor: pointer;
    border: 1px solid transparent;
}
.topbar__icon-btn:hover { background: var(--surface-2); border-color: var(--border); }
.topbar__icon-btn svg { width: 20px; height: 20px; }
.topbar__badge {
    position: absolute;
    top: 4px; right: 4px;
    background: var(--brand-orange);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: grid; place-items: center;
    border: 2px solid var(--surface);
}
.topbar__cta {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px;
    font-weight: 600;
    font-size: 14px;
    border-radius: 10px;
    height: 40px;
}
.topbar__avatar {
    margin-left: 4px;
    display: inline-flex;
    border-radius: 50%;
    transition: box-shadow .15s;
}
.topbar__avatar:hover { box-shadow: 0 0 0 3px var(--brand-orange-100); }

/* ----- Main + content ----- */
.main {
    display: flex; flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
}
.content {
    padding: var(--content-pad-y) var(--content-pad-x);
    flex: 1;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

/* ----- Page header ----- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.page-header__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-title {
    margin: 0 0 4px;
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.page-title .wave { display: inline-block; transform: translateY(-1px); margin-left: 4px; }
.page-sub {
    margin: 0;
    color: var(--text-3);
    font-size: 14px;
}
.date-pill {
    display: inline-flex; align-items: center;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    box-shadow: var(--shadow-xs);
}

/* ----- KPI grid (4 → 2 → 1) ----- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap);
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: var(--shadow-xs);
    display: flex; flex-direction: column;
    transition: box-shadow .15s, transform .05s;
}
.kpi-card:hover { box-shadow: var(--shadow-sm); }
.kpi-card__head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.kpi-card__label {
    font-size: 13px; font-weight: 500;
    color: var(--text-3);
}
.kpi-card__icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: grid; place-items: center;
    flex-shrink: 0;
}
.kpi-card__icon--orange { background: var(--brand-orange-100); color: var(--brand-orange-600); }
.kpi-card__icon--yellow { background: var(--status-yellow-bg); color: var(--status-yellow-fg); }
.kpi-card__icon--green  { background: var(--status-green-bg);  color: var(--status-green-fg); }
.kpi-card__icon--blue   { background: var(--status-blue-bg);   color: var(--status-blue-fg); }
.kpi-card__value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.5px;
}
.kpi-card__hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-3);
}

/* ----- Dashboard grid (3 cols → 2 → 1) ----- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--gap);
    align-items: start;
}

/* ----- Cards ----- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.card__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
}
.card__head h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}
.card__head .link {
    font-size: 13px; font-weight: 500;
    color: var(--brand-orange-600);
    text-decoration: none;
    flex-shrink: 0;
}
.card__head .link:hover { text-decoration: underline; }
.card__body { padding: 14px 20px 18px; }

/* ----- Activity list (override earlier compact spec) ----- */
.activity-list {
    list-style: none;
    margin: 0; padding: 0;
    display: flex; flex-direction: column;
    border-top: 0;
}
.activity-list__item {
    display: flex; gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.activity-list__item:last-child { border-bottom: 0; }
.activity-list__icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: grid; place-items: center;
    flex-shrink: 0;
    color: #fff;
    font-weight: 700;
    font-size: 12px;
}
.activity-list__body { flex: 1; min-width: 0; }
.activity-list__text {
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
}
.activity-list__text strong {
    font-weight: 600;
    color: var(--text);
}
.activity-list__text span {
    color: var(--text-2);
    margin-left: 4px;
}
.activity-list__time {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 2px;
}

/* ----- Deadline list ----- */
.deadline-list {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column;
    gap: 4px;
}
.deadline-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 10px;
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
    transition: background .15s;
}
.deadline-row:hover { background: var(--surface-2); }
.deadline-row__icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--brand-orange-50);
    color: var(--brand-orange-600);
    display: grid; place-items: center;
    flex-shrink: 0;
}
.deadline-row__main { flex: 1; min-width: 0; }
.deadline-row__title {
    font-size: 14px; font-weight: 600;
    color: var(--text);
    overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap;
}
.deadline-row__meta {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 2px;
}

/* ----- Project summary list ----- */
.summary-list {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column; gap: 6px;
}
.summary-list__item:not(:last-child) { padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.summary-row {
    display: block;
    color: inherit;
    text-decoration: none;
}
.summary-row__head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px;
}
.summary-row__title {
    font-size: 14px; font-weight: 600;
    color: var(--text);
    overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}
.summary-row__sub {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 2px;
}
.summary-row__progress {
    display: flex; align-items: center; gap: 8px;
    margin-top: 8px;
}
.summary-row__progress .progress { flex: 1; }
.summary-row__pct {
    font-size: 12px; font-weight: 600;
    color: var(--text-2);
    flex-shrink: 0;
}
.summary-row__foot {
    display: flex; align-items: center; gap: 12px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-3);
}
.summary-row__health { display: inline-flex; align-items: center; gap: 5px; }
.summary-row__health .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}
.summary-row__health.status-on-track   { color: var(--status-green-fg); }
.summary-row__health.status-at-risk    { color: var(--status-yellow-fg); }
.summary-row__health.status-late,
.summary-row__health.status-critical   { color: var(--status-red-fg); }
.summary-row__count { display: inline-flex; align-items: center; }
.summary-row__date  { margin-left: auto; }

/* Progress bar */
.progress {
    height: 6px;
    background: var(--surface-2);
    border-radius: 999px;
    overflow: hidden;
    flex: 1;
}
.progress__fill {
    height: 100%;
    background: var(--brand-orange);
    border-radius: inherit;
    transition: width .3s ease;
}

/* ----- Bottom nav (mobile only) ----- */
/* The markup in views/partials/bottom_nav.php nests items as direct children
   of .bottom-nav (no .bottom-nav__inner wrapper), so .bottom-nav itself must
   be the flex container. */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 30;
    box-sizing: border-box;
    padding: 0 max(8px, env(safe-area-inset-left)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-right));
    align-items: stretch;
    justify-content: space-between;
    gap: 0;
    /* IMPORTANT: no overflow:hidden — the FAB extends above the bar with margin-top: -16px */
    overflow: visible;
}
.bottom-nav > * {
    min-width: 0;
    flex: 1 1 0;
    box-sizing: border-box;
}
.bottom-nav__fab {
    flex: 0 0 auto;
    /* keep fab visually above the row even though it sits inline */
    position: relative;
    z-index: 2;
}
.bottom-nav__inner { display: flex; align-items: center; height: var(--bottomnav-h); }

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

/* Tablet — collapse sidebar, narrower padding ----------------------------- */
@media (max-width: 1023px) {
    :root {
        --content-pad-x: 20px;
        --content-pad-y: 20px;
    }
    .app {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: var(--shadow-lg);
        z-index: 70;
        /* iOS standalone PWA: avoid status bar / Dynamic Island */
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        box-sizing: border-box;
    }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-overlay {
        position: fixed; inset: 0;
        background: rgba(15,17,21,.45);
        z-index: 65;
        animation: fadeIn .2s;
    }
    @keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

    .topbar__menu, .sidebar-toggle { display: inline-flex; }
    .topbar__title--mobile {
        display: block;
        font-size: 17px;
        font-weight: 700;
        margin: 0;
        color: var(--text);
        flex-shrink: 0;
    }
    .topbar__search { display: none; }

    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
}

/* Mobile — single column + bottom nav ------------------------------------- */
@media (max-width: 767px) {
    :root {
        --content-pad-x: 16px;
        --content-pad-y: 16px;
        --gap: 14px;
    }
    .main { padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 8px); }
    .topbar { padding: 0 12px; gap: 10px; }
    .topbar__cta {
        padding: 0;
        width: 40px; height: 40px;
    }
    .topbar__cta span { display: none; }
    .topbar__avatar { display: none; }

    .page-title { font-size: 22px; }
    .page-header { gap: 8px; }
    .page-header__actions { width: 100%; }

    .kpi-grid { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }

    .bottom-nav { display: flex; }
    .bottom-nav__inner { display: flex; align-items: center; }

    /* Stack data tables (preserved from earlier behaviour) */
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr {
        margin-bottom: 8px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--surface);
    }
    .data-table tbody td {
        border: none;
        padding: 8px 12px;
        display: flex;
        justify-content: space-between;
        gap: 12px;
    }
    .data-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-3);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: .04em;
    }
    .data-table tbody td.text-right { justify-content: flex-end; }

    .card__head { padding: 16px 16px 12px; }
    .card__body { padding: 12px 16px 14px; }
    .kpi-card { padding: 16px; }
    .kpi-card__value { font-size: 28px; }
}

/* Small phones — extra tight ------------------------------------------------ */
@media (max-width: 380px) {
    .topbar__cta { display: none; }
}

/* Force-show desktop layout when wide enough ---------------------------------*/
@media (min-width: 1024px) {
    .bottom-nav { display: none !important; }
    .sidebar { transform: none !important; }
    .topbar__menu, .sidebar-toggle { display: none !important; }
}

/* ==========================================================================
   Global footer (v3)
   ========================================================================== */
.app-footer {
    margin-top: auto;
    padding: 18px 24px 22px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    background: transparent;
}
.app-footer a {
    color: var(--brand-orange);
    text-decoration: none;
    font-weight: 600;
}
.app-footer a:hover { color: var(--brand-orange-600); text-decoration: underline; }

/* Push footer above bottom-nav on mobile */
@media (max-width: 767px) {
    .app-footer {
        padding-bottom: calc(18px + var(--bottomnav-h, 64px) + env(safe-area-inset-bottom, 0px));
    }
}

/* Auth footer (login page) — anchor to bottom of viewport */
.app-footer--auth {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 14px 18px;
    background: transparent;
    border-top: 0;
}

/* Comment form layout polish */
.comment-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.comment-form textarea.field__input { width: 100%; min-height: 88px; resize: vertical; }
.comment-form__actions { display: flex; justify-content: flex-end; }

/* === Member picker (project create) ============================== */
.member-picker { display: flex; flex-direction: column; gap: 10px; }
.member-picker__row { display: flex; gap: 8px; align-items: stretch; }
.member-picker__select { flex: 1; min-width: 0; }
.member-picker__row .btn { flex: 0 0 auto; white-space: nowrap; }
.member-picker__chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  min-height: 36px; padding: 6px;
  border: 1px dashed var(--border, #d1d5db);
  border-radius: 8px; background: var(--surface-2, #f9fafb);
}
.member-picker__chips:empty::before { content: ""; }
.member-picker__empty {
  font-size: 13px; color: var(--text-muted, #6b7280);
  padding: 4px 6px; align-self: center;
}
.member-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 10px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #d1d5db);
  border-radius: 999px;
  font-size: 13px; line-height: 1.2;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.member-chip__name { font-weight: 500; }
.member-chip__role { color: var(--text-muted, #6b7280); }
.member-chip__remove {
  appearance: none; background: transparent; border: 0; cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1; color: var(--text-muted, #6b7280);
  transition: background 0.15s, color 0.15s;
}
.member-chip__remove:hover { background: #fee2e2; color: #b91c1c; }
.member-chip.is-owner { background: #eef2ff; border-color: #c7d2fe; }
.member-chip.is-owner .member-chip__role::before { content: "Owner · "; font-weight: 600; color: #4338ca; }
.member-chip.is-owner .member-chip__remove { display: none; }
@media (max-width: 540px) {
  .member-picker__row { flex-direction: column; }
  .member-picker__row .btn { width: 100%; }
}

/* ===== Status badge palette (BEM, used by helpers.php status_badge()) ===== */
/* All variants share .badge base styles defined above. */
.badge--slate        { background: #F1F5F9; color: #334155; }
.badge--slate-light  { background: #F8FAFC; color: #64748B; }
.badge--orange       { background: #FFF1E8; color: #C2410C; }
.badge--purple       { background: #F3E8FF; color: #6B21A8; }
.badge--amber        { background: #FEF3C7; color: #92400E; }
.badge--red          { background: #FEE2E2; color: #B91C1C; }
.badge--emerald      { background: #D1FAE5; color: #047857; }

/* ===== Task row left-edge stripe (visual stage indicator) ===== */
/* Applies to <tr class="task-row …"> rows in project task lists and to .task-row cards. */
.task-row.todo,
tr.task-row.todo > td:first-child            { box-shadow: inset 4px 0 0 0 #64748B; }
.task-row.in-progress,
tr.task-row.in-progress > td:first-child     { box-shadow: inset 4px 0 0 0 #F26B2B; }
.task-row.review,
tr.task-row.review > td:first-child          { box-shadow: inset 4px 0 0 0 #7C3AED; }
.task-row.waiting,
tr.task-row.waiting > td:first-child         { box-shadow: inset 4px 0 0 0 #F59E0B; }
.task-row.blocked,
tr.task-row.blocked > td:first-child         { box-shadow: inset 4px 0 0 0 #DC2626; }
.task-row.complete,
tr.task-row.complete > td:first-child        { box-shadow: inset 4px 0 0 0 #059669; }
.task-row.archived,
tr.task-row.archived > td:first-child        { box-shadow: inset 4px 0 0 0 #94A3B8; }

/* Task drawer status select */
.task-status-control {
    display: flex; align-items: center; gap: 8px;
    margin-top: 4px;
}
.task-status-control select {
    padding: 4px 26px 4px 10px;
    border: 1px solid var(--line, #e2e8f0);
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    cursor: pointer;
}
.task-status-control select:focus {
    outline: 2px solid #F26B2B;
    outline-offset: 1px;
}

/* ===== iOS Add-to-Home-Screen instructions sheet ===== */
.ios-sheet { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: center; }
.ios-sheet__backdrop { position: absolute; inset: 0; background: rgba(15,17,21,0.55); backdrop-filter: blur(2px); }
.ios-sheet__panel {
    position: relative;
    width: 100%; max-width: 480px;
    background: #fff;
    border-radius: 16px 16px 0 0;
    padding: 24px 20px 28px;
    box-shadow: 0 -8px 32px rgba(15,17,21,0.18);
    animation: iosSheetIn .25s ease-out;
}
@keyframes iosSheetIn { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.ios-sheet__panel h3 { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
.ios-sheet__panel p  { margin: 4px 0; color: #475569; font-size: 14px; line-height: 1.5; }
.ios-sheet__panel ol { margin: 12px 0; padding-left: 22px; color: #1e293b; }
.ios-sheet__panel ol li { margin: 8px 0; line-height: 1.5; }
.ios-sheet__hint { font-size: 12px; color: #64748B; margin-top: 12px; }
.ios-sheet__close {
    position: absolute; top: 8px; right: 12px;
    width: 32px; height: 32px;
    border: none; background: transparent;
    font-size: 24px; line-height: 1; color: #94A3B8;
    cursor: pointer;
}
.ios-sheet__ok { display: block; width: 100%; margin-top: 16px; }
@media (min-width: 640px) {
    .ios-sheet { align-items: center; }
    .ios-sheet__panel { border-radius: 16px; }
}

/* ==========================================================================
   PROJECT PRIORITY COLOR-CODING
   ========================================================================== */

/* Color tokens (one per priority tier) */
:root {
    --prio-low:     #64748B; /* slate */
    --prio-low-bg:  rgba(100, 116, 139, .12);
    --prio-normal:  #38BDF8; /* sky-blue (neutral middle that reads as "default") */
    --prio-normal-bg: rgba(56, 189, 248, .12);
    --prio-high:    #F59E0B; /* amber */
    --prio-high-bg: rgba(245, 158, 11, .14);
    --prio-urgent:  #EF4444; /* red */
    --prio-urgent-bg: rgba(239, 68, 68, .14);
}

/* Pill (used inline next to project names + in tables) */
.priority-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px; font-weight: 600;
    letter-spacing: .02em;
    text-transform: capitalize;
    border: 1px solid transparent;
    line-height: 1.4;
    white-space: nowrap;
}
.priority-pill::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}
.priority-pill--low     { color: var(--prio-low);    background: var(--prio-low-bg);    border-color: rgba(100,116,139,.25); }
.priority-pill--normal  { color: var(--prio-normal); background: var(--prio-normal-bg); border-color: rgba(56,189,248,.30); }
.priority-pill--high    { color: var(--prio-high);   background: var(--prio-high-bg);   border-color: rgba(245,158,11,.30); }
.priority-pill--urgent  { color: var(--prio-urgent); background: var(--prio-urgent-bg); border-color: rgba(239,68,68,.32); }

/* Inline dot used next to titles */
.priority-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
    box-shadow: 0 0 0 2px rgba(255,255,255,.6);
}
.priority-dot--low     { background: var(--prio-low); }
.priority-dot--normal  { background: var(--prio-normal); }
.priority-dot--high    { background: var(--prio-high); }
.priority-dot--urgent  { background: var(--prio-urgent); animation: prioPulse 2s ease-in-out infinite; }
@keyframes prioPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.45); }
    50%      { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* Left accent stripe on rows / cards (table rows) */
tr.priority-row {
    position: relative;
}
tr.priority-row > td:first-child {
    border-left: 4px solid transparent;
    padding-left: calc(var(--td-pad-x, 16px) - 4px);
}
tr.priority-row[data-priority="low"]    > td:first-child { border-left-color: var(--prio-low); }
tr.priority-row[data-priority="normal"] > td:first-child { border-left-color: var(--prio-normal); }
tr.priority-row[data-priority="high"]   > td:first-child { border-left-color: var(--prio-high); }
tr.priority-row[data-priority="urgent"] > td:first-child { border-left-color: var(--prio-urgent); }

/* List-item rows (dashboard summary, etc.) */
li.priority-row,
.summary-list__item.priority-row {
    position: relative;
    border-left: 3px solid transparent;
    padding-left: 12px;
    transition: border-color .15s ease;
}
.summary-list__item.priority-row[data-priority="low"]    { border-left-color: var(--prio-low); }
.summary-list__item.priority-row[data-priority="normal"] { border-left-color: var(--prio-normal); }
.summary-list__item.priority-row[data-priority="high"]   { border-left-color: var(--prio-high); }
.summary-list__item.priority-row[data-priority="urgent"] { border-left-color: var(--prio-urgent); }

/* Project header accent — top-left corner ribbon for the page */
.page-header.priority-row {
    position: relative;
    padding-left: 16px;
    border-left: 4px solid transparent;
    border-radius: 0 8px 8px 0;
}
.page-header.priority-row[data-priority="low"]    { border-left-color: var(--prio-low); }
.page-header.priority-row[data-priority="normal"] { border-left-color: var(--prio-normal); }
.page-header.priority-row[data-priority="high"]   { border-left-color: var(--prio-high); }
.page-header.priority-row[data-priority="urgent"] { border-left-color: var(--prio-urgent); }

/* Mobile (stacked cards via data-label) — keep the accent visible */
@media (max-width: 767px) {
    tr.priority-row > td:first-child {
        border-left-width: 4px;
    }
    tr.priority-row {
        border-left: 4px solid transparent;
        background-clip: padding-box;
    }
    tr.priority-row[data-priority="low"]    { border-left-color: var(--prio-low); }
    tr.priority-row[data-priority="normal"] { border-left-color: var(--prio-normal); }
    tr.priority-row[data-priority="high"]   { border-left-color: var(--prio-high); }
    tr.priority-row[data-priority="urgent"] { border-left-color: var(--prio-urgent); }
}
