/****************************************************************************
 * VIS IT Checks Monitoring & Evidence System — styles
 * Visual language matched to the VIS Community Programs admin / VIS Asset &
 * Data Register / VIS Internal Control Library suite: navy #0b233f / gold
 * #f8981d, Archivo + IBM Plex Sans, soft-tint pill chips, lit-edge elevation.
 * Layout: persistent icon sidebar (desktop) collapsing to an off-canvas
 * drawer (mobile), in the pattern of Linear/Asana/Todoist rather than a
 * horizontal tab bar that runs out of room as sections are added.
 ****************************************************************************/

:root {
    --vis-navy: #0b233f;
    --nav-bg: #0b233f;
    --vis-blue: #002c76;
    --vis-gold: #f8981d;
    --vis-gold-2: #e08516;
    --vis-white: #ffffff;
    --vis-green: #1f9d6b;
    --vis-red: #d8504d;
    --vis-orange: #d9591d;

    --vis-gold-light: rgba(248, 152, 29, 0.14);
    --vis-green-light: rgba(31, 157, 107, 0.12);
    --vis-red-light: rgba(216, 80, 77, 0.12);
    --vis-blue-light: rgba(0, 44, 118, 0.10);
    --vis-orange-light: rgba(217, 89, 29, 0.14);
    --vis-gold-text: #c97a12;
    --vis-green-text: #136b49;
    --vis-red-text: #a33b39;
    --vis-blue-text: #274d86;
    --vis-orange-text: #a8430f;

    --grey-bg: #e9edf3;
    --grey-border: #ecf0f4;
    --border2: #d1d5db;
    --card-bg: #ffffff;
    --surface-2: #f4f6f9;

    --text-dark: #1a1a2e;
    --text-muted: #5d6b7e;
    --text-muted-2: #8a98a9;

    --font-sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --font-head: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

    --fs-label: 0.6875rem;
    --fs-sm: 0.75rem;
    --fs-base: 0.875rem;

    --r-btn: 10px;
    --r-sm: 12px;
    --card-radius: 16px;
    --r-lg: 20px;
    --r-shell: 22px;
    --pill: 999px;

    --card-shadow: 0 1px 2px rgba(11, 35, 63, 0.04), 0 8px 20px -6px rgba(11, 35, 63, 0.09);
    --card-shadow-hover: 0 2px 6px rgba(11, 35, 63, 0.06), 0 18px 34px -10px rgba(11, 35, 63, 0.15);
    --shadow-modal: 0 12px 24px rgba(11, 35, 63, 0.12), 0 40px 80px -16px rgba(11, 35, 63, 0.28);
    --shadow-shell: 0 20px 60px -20px rgba(11, 35, 63, 0.35);
    --edge-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.6);

    --focus: 0 0 0 3px rgba(0, 44, 118, 0.10);
    --focus-gold: 0 0 0 3px rgba(248, 152, 29, 0.28);

    --dur-fast: 140ms;
    --dur-base: 200ms;
    --dur-slow: 320ms;
    --ease: cubic-bezier(0.32, 0.72, 0, 1);

    --sidebar-w: 236px;
    --mobile-topbar-h: 56px;

    --chip-high-bg: var(--vis-red-light);
    --chip-high-fg: var(--vis-red-text);
    --chip-medium-bg: var(--vis-gold-light);
    --chip-medium-fg: var(--vis-gold-text);
    --chip-low-bg: var(--vis-green-light);
    --chip-low-fg: var(--vis-green-text);
    --chip-neutral-bg: var(--surface-2);
    --chip-neutral-fg: var(--text-muted);
    --chip-orange-bg: var(--vis-orange-light);
    --chip-orange-fg: var(--vis-orange-text);
    --chip-internal-bg: var(--vis-blue-light);
    --chip-internal-fg: var(--vis-blue-text);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: 1.5;
    background: var(--grey-bg);
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--font-head); }

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(11, 35, 63, 0.15); border-radius: var(--pill); }
*::-webkit-scrollbar-thumb:hover { background: rgba(11, 35, 63, 0.26); }

.hidden { display: none !important; }

/* ==================== App frame / sidebar ====================
 * The whole app sits as one soft, rounded, shadowed panel floating on the
 * muted page canvas (sidebar + content sharing one outer silhouette) rather
 * than a flat edge-to-edge web page — on mobile that framing is dropped in
 * favour of a native-feeling full-bleed layout with the sidebar as an
 * off-canvas drawer instead. Note: body's own background (further up this
 * file) already covers the canvas colour — the login screen paints over it
 * with its own full-bleed navy anyway. */

.app-frame {
    display: flex;
    height: 100vh;
    padding: 14px;
    gap: 14px;
    box-sizing: border-box;
}

.sidebar {
    position: relative;
    width: var(--sidebar-w);
    flex-shrink: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: var(--r-shell);
    background: linear-gradient(176deg,
        color-mix(in srgb, var(--nav-bg) 88%, #5b82c4) 0%,
        var(--nav-bg) 30%,
        color-mix(in srgb, var(--nav-bg) 96%, #000) 100%);
    box-shadow: var(--shadow-shell);
    z-index: 900;
    transition: transform var(--dur-slow) var(--ease);
}

.sidebar-logo {
    display: flex; align-items: center; gap: 10px;
    padding: 1.35rem 1.25rem 1rem;
    flex-shrink: 0;
}
.sidebar-logo img { width: 28px; height: auto; display: block; }
.sidebar-logo span {
    font-family: var(--font-head); font-size: 0.95rem; font-weight: 700;
    color: #fff; letter-spacing: -0.01em; white-space: nowrap;
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.5rem 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
}

.sidebar-nav-group { display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar-nav-group.manager-only {
    padding-top: 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.sidebar-nav-label {
    font-family: var(--font-sans);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.38);
    padding: 0 0.65rem 0.45rem;
}

.sidebar-nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.7rem;
    border-radius: var(--r-sm);
    color: rgba(255, 255, 255, 0.68);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--dur-base) var(--ease), color var(--dur-fast) var(--ease);
}
.sidebar-nav-item svg { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sidebar-nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.sidebar-nav-item.active {
    background: linear-gradient(90deg, rgba(248, 152, 29, 0.20), rgba(248, 152, 29, 0.07));
    color: #fff;
    font-weight: 600;
}
.sidebar-nav-item.active::before {
    content: '';
    position: absolute; left: -0.85rem; top: 0.35rem; bottom: 0.35rem; width: 3px;
    border-radius: var(--pill);
    background: linear-gradient(180deg, var(--vis-gold), var(--vis-gold-2));
    box-shadow: 0 0 10px rgba(248, 152, 29, 0.5);
}

.sidebar-user {
    flex-shrink: 0;
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.9rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-head);
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1 1 auto; }
.user-meta strong { font-size: 0.82rem; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span.role-tag {
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--vis-gold);
}

.sidebar-signout {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; flex-shrink: 0;
    border-radius: var(--r-sm);
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    transition: background var(--dur-base) var(--ease), color var(--dur-fast) var(--ease);
}
.sidebar-signout svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-signout:hover { background: rgba(216, 80, 77, 0.18); color: #fff; }

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(6, 17, 33, 0.5);
    z-index: 890;
}

.mobile-topbar-toggle, .mobile-topbar-logo { display: none; }

/* ==================== Mobile: off-canvas sidebar ====================
 * The floating-card framing (padding/rounded corners/shadow around the whole
 * shell) is a desktop thing — on a phone it just eats screen space, so the
 * sidebar reverts to a true fixed, full-height, square-edged overlay drawer
 * and the content panel goes back to plain full-bleed. */

@media (max-width: 900px) {
    .app-frame { padding: 0; gap: 0; height: auto; min-height: 100vh; }

    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0; height: auto;
        border-radius: 0;
        transform: translateX(-100%);
        width: min(80vw, 300px);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open { display: block; }

    .app-main { height: auto; overflow-y: visible; border-radius: 0 !important; box-shadow: none !important; }

    .mobile-topbar-toggle {
        display: flex; align-items: center; justify-content: center;
        position: fixed; top: 0; left: 0;
        width: var(--mobile-topbar-h); height: var(--mobile-topbar-h);
        z-index: 950;
        background: none; border: none;
        color: var(--vis-navy);
        cursor: pointer;
    }
    .mobile-topbar-toggle svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; }

    .mobile-topbar-logo {
        display: flex; align-items: center; gap: 8px;
        position: fixed; top: 0; left: var(--mobile-topbar-h); right: 0;
        height: var(--mobile-topbar-h);
        background: var(--card-bg);
        border-bottom: 1px solid var(--grey-border);
        padding: 0 1rem;
        z-index: 940;
    }
    .mobile-topbar-logo img { width: 24px; }
    .mobile-topbar-logo strong { font-family: var(--font-head); font-weight: 700; font-size: 0.9rem; color: var(--vis-navy); }

    main { padding-top: calc(var(--mobile-topbar-h) + 1.25rem) !important; }
}

/* ==================== Content area ==================== */

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    background: var(--card-bg);
    border-radius: var(--r-shell);
    box-shadow: var(--card-shadow);
}
main { padding: 1.75rem 2rem 3rem; max-width: 1400px; margin: 0 auto; }

.page-header h1 { font-family: var(--font-head); font-weight: 800; font-size: 1.7rem; color: var(--text-dark); margin: 0 0 0.35rem; }
.page-header p { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 1.5rem; max-width: 760px; }

.section { display: none; }
.section.active { display: block; }

/* ==================== Toolbar ==================== */

.panel-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap; }
.panel-toolbar-actions { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.panel-toolbar h2 {
    font-family: var(--font-head);
    font-weight: 600;
    color: var(--vis-navy);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-size: 0.95rem;
    margin: 0;
}

/* ==================== Buttons ==================== */

.btn {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    padding: 0.55rem 1.1rem;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 1.5px rgba(11, 35, 63, 0.06), 0 2px 6px -2px rgba(11, 35, 63, 0.14);
    transition: background var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease),
        color var(--dur-fast) var(--ease), box-shadow var(--dur-base) var(--ease), transform var(--dur-fast) var(--ease);
}

.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(180deg, color-mix(in srgb, var(--vis-gold) 88%, #fff), var(--vis-gold));
    border-color: color-mix(in srgb, var(--vis-gold) 78%, #000);
    color: var(--vis-navy);
    font-weight: 700;
}
.btn-primary:hover:not(:disabled) {
    background: linear-gradient(180deg, var(--vis-gold), var(--vis-gold-2));
    border-color: var(--vis-gold-2);
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 3px 6px -2px rgba(11, 35, 63, 0.12), 0 12px 22px -8px rgba(11, 35, 63, 0.26);
}
.btn-primary:focus-visible { box-shadow: var(--focus-gold); }

.btn-secondary { background: var(--vis-white); color: var(--vis-navy); border: 1px solid var(--border2); box-shadow: none; }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--vis-navy); transform: translateY(-1px); }

.btn-danger { background: var(--vis-white); color: var(--vis-red-text); border: 1px solid var(--vis-red); box-shadow: none; }
.btn-danger:hover:not(:disabled) { background: var(--vis-red-light); border-color: var(--vis-red); }

.btn-issue { background: var(--vis-white); color: var(--vis-orange-text); border: 1px solid var(--vis-orange); box-shadow: none; }
.btn-issue:hover:not(:disabled) { background: var(--vis-orange-light); border-color: var(--vis-orange); }

.btn-sm { font-size: var(--fs-sm); padding: 0.4rem 0.8rem; border-radius: var(--r-btn); }

.status-msg { font-size: 0.8rem; margin-left: 0.75rem; color: var(--vis-green-text); }
.status-msg.error { color: var(--vis-red-text); }

footer.vis-footer { text-align: center; padding: 1.5rem; color: var(--text-muted); font-size: 0.78rem; }

/* ==================== Chips / status pills ==================== */

.chip {
    flex-shrink: 0;
    display: inline-block;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: var(--fs-label);
    letter-spacing: 0.03em;
    border-radius: var(--pill);
    padding: 0.3rem 0.85rem;
    border: 1px solid transparent;
    white-space: nowrap;
}

.chip-high { background: var(--chip-high-bg); color: var(--chip-high-fg); }
.chip-medium { background: var(--chip-medium-bg); color: var(--chip-medium-fg); }
.chip-low { background: var(--chip-low-bg); color: var(--chip-low-fg); }
.chip-neutral { background: var(--chip-neutral-bg); color: var(--chip-neutral-fg); border-color: var(--grey-border); }
.chip-orange { background: var(--chip-orange-bg); color: var(--chip-orange-fg); }
.chip-internal { background: var(--chip-internal-bg); color: var(--chip-internal-fg); }

.field-label {
    display: block;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: var(--fs-label);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

/* ==================== Form inputs ==================== */

input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="datetime-local"],
select, textarea {
    width: 100%;
    height: 38px;
    border: 1px solid var(--grey-border);
    border-radius: var(--card-radius);
    padding: 0 0.75rem;
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    color: var(--text-dark);
    background: var(--vis-white);
    transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}

textarea { height: auto; resize: vertical; min-height: 4.5rem; padding-top: 0.5rem; padding-bottom: 0.5rem; }

input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--vis-blue) 24%, var(--grey-border)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--vis-blue); box-shadow: var(--focus); }

.field { margin-bottom: 1.1rem; }
.field-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 180px; }

/* ==================== Cards (checks-due, area groups) ==================== */

.area-group { margin-bottom: 1.75rem; }
.area-group-title {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.02rem;
    color: var(--vis-navy);
    margin: 0 0 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.area-group-count { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted-2); font-weight: 500; }

.check-cards { display: flex; flex-direction: column; gap: 0.65rem; }

.check-card {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--edge-highlight), var(--card-shadow);
    padding: 0.9rem 1.1rem 0.9rem 1.35rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    transition: box-shadow var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}
.check-card:hover { box-shadow: var(--edge-highlight), var(--card-shadow-hover); transform: translateY(-1px); }

/* A coloured left edge reads as "this one needs attention" without a heavy
   border framing every card the same way regardless of urgency. */
.check-card::before {
    content: ''; position: absolute; left: 0.5rem; top: 0.7rem; bottom: 0.7rem; width: 3px;
    border-radius: var(--pill);
    background: var(--grey-border);
}
.check-card.is-overdue::before { background: linear-gradient(180deg, var(--vis-red), color-mix(in srgb, var(--vis-red) 70%, #000)); }

.check-card-main { flex: 1 1 320px; min-width: 240px; }
.check-card-name { font-weight: 600; font-size: 0.95rem; color: var(--text-dark); }
.check-card-desc { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.15rem; }
.check-card-meta { font-size: 0.76rem; color: var(--text-muted-2); margin-top: 0.35rem; font-family: var(--font-mono); }

.check-card-actions { display: flex; gap: 0.5rem; align-items: center; flex-shrink: 0; }

/* ==================== Calendar ==================== */

.calendar-nav { display: flex; align-items: center; gap: 0.75rem; }
.calendar-nav h2 { margin: 0; min-width: 11rem; text-align: center; }

.calendar-legend {
    display: flex; flex-wrap: wrap; gap: 1rem;
    font-size: 0.78rem; color: var(--text-muted);
    margin-bottom: 0.75rem;
}
.calendar-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.calendar-dot {
    width: 10px; height: 10px; border-radius: 50%; display: inline-block;
    background: var(--chip-neutral-bg); border: 1px solid var(--chip-neutral-fg);
}
.calendar-dot.chip-high { background: var(--vis-red); border-color: var(--vis-red); }
.calendar-dot.chip-medium { background: var(--vis-gold); border-color: var(--vis-gold-2); }
.calendar-dot.chip-low { background: var(--vis-green); border-color: var(--vis-green); }
.calendar-dot.chip-orange { background: var(--vis-orange); border-color: var(--vis-orange); }
.calendar-dot.chip-internal { background: var(--vis-blue); border-color: var(--vis-blue); }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--grey-border);
    border: 1px solid var(--grey-border);
    border-radius: var(--r-sm);
    overflow: hidden;
}

.calendar-day-header {
    min-width: 0;
    background: var(--vis-navy);
    color: var(--vis-white);
    font-family: var(--font-head);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: center;
    padding: 0.5rem 0;
}

.calendar-day {
    background: var(--card-bg);
    min-height: 108px;
    min-width: 0;
    padding: 0.4rem 0.45rem;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease);
    overflow: hidden;
}
.calendar-day:hover { background: var(--surface-2); }
.calendar-day.is-outside { background: var(--grey-bg); }
.calendar-day.is-outside .calendar-day-num { color: var(--text-muted-2); }
.calendar-day.is-today .calendar-day-num {
    background: var(--vis-gold); color: var(--vis-navy);
    border-radius: var(--pill); padding: 0 0.4rem;
}

.calendar-day-num { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 600; color: var(--text-dark); display: inline-block; }
.calendar-day-events { display: flex; flex-direction: column; gap: 0.2rem; margin-top: 0.3rem; }

.calendar-event {
    font-size: 0.68rem;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid transparent;
}
.calendar-event-more { font-size: 0.68rem; color: var(--text-muted); font-family: var(--font-mono); }

.calendar-detail-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid var(--grey-border); }
.calendar-detail-row:last-child { border-bottom: none; }
.calendar-detail-row .calendar-event { flex-shrink: 0; max-width: 180px; }
.calendar-detail-meta { font-size: 0.78rem; color: var(--text-muted); }

@media (max-width: 720px) {
    .calendar-grid { grid-template-columns: repeat(7, minmax(78px, 1fr)); overflow-x: auto; }
    .calendar-day { min-height: 84px; }
}

.empty-state {
    text-align: center;
    padding: 2.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    background: var(--card-bg);
    border: 1px dashed var(--border2);
    border-radius: var(--card-radius);
}
.empty-state-icon {
    width: 40px; height: 40px; margin: 0 auto 0.85rem;
    color: var(--text-muted-2);
}
.empty-state-icon svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ==================== Tab bar (segmented filter, e.g. Manage Tasks by frequency) ==================== */

.tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--grey-border);
    padding-bottom: 0.6rem;
}

button.tab-btn {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: none;
    border: 1px solid transparent;
    border-radius: var(--pill);
    padding: 0.4rem 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: background var(--dur-base) var(--ease), color var(--dur-fast) var(--ease);
}
button.tab-btn:hover { background: var(--surface-2); color: var(--text-dark); }
button.tab-btn.active { background: var(--vis-navy); color: #fff; }
button.tab-btn .tab-count {
    font-family: var(--font-mono); font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.18); border-radius: var(--pill); padding: 0.05rem 0.4rem;
}
button.tab-btn:not(.active) .tab-count { background: var(--surface-2); color: var(--text-muted-2); }

/* ==================== Filter bar ==================== */

.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    background: var(--surface-2);
    border-radius: var(--card-radius);
    padding: 1rem 1.1rem;
    margin-bottom: 1.25rem;
}
.filter-bar .field { margin-bottom: 0; min-width: 160px; }
.filter-bar .field label { margin-bottom: 0.25rem; }

/* ==================== Data table ==================== */

.table-wrap {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--edge-highlight), var(--card-shadow);
    overflow-x: auto;
}

table.data-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
table.data-table th {
    text-align: left;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: var(--fs-label);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--grey-border);
    white-space: nowrap;
}
table.data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--grey-border); color: var(--text-dark); vertical-align: top; }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--surface-2); }
table.data-table td.note-cell { max-width: 320px; white-space: pre-wrap; font-size: 0.8rem; color: var(--text-muted); }

/* Keeps row action buttons (e.g. Start / Complete / Edit on Tasks) side by side on one
   line instead of the browser's default inline wrap stacking them vertically. */
.task-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    white-space: nowrap;
}

.task-title-link { color: var(--text-dark); text-decoration: none; cursor: pointer; }
.task-title-link:hover strong { color: var(--vis-blue); text-decoration: underline; }

/* Sub-header divider row used to break a long table into groups (e.g. Tasks by due month) */
table.data-table tr.table-group-row td {
    background: var(--surface-2);
    font-family: var(--font-head);
    font-weight: 700;
    font-size: var(--fs-label);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--vis-navy);
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--grey-border);
}

/* ==================== Summary tiles (dashboard stats, compliance) ==================== */

.tile-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.tile {
    flex: 1 1 200px;
    position: relative;
    overflow: hidden;
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--edge-highlight), var(--card-shadow);
    padding: 1.1rem 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    transition: box-shadow var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}
.tile:hover { box-shadow: var(--edge-highlight), var(--card-shadow-hover); transform: translateY(-1px); }

/* Each stat gets its own soft colour identity instead of every tile reading
   identically — a quiet tint, not a loud block, so it still reads calm when
   there's genuinely nothing overdue. */
.tile-bad { background: linear-gradient(165deg, var(--vis-red-light), var(--card-bg) 65%); }
.tile-warn { background: linear-gradient(165deg, var(--vis-gold-light), var(--card-bg) 65%); }
.tile-good { background: linear-gradient(165deg, var(--vis-green-light), var(--card-bg) 65%); }

.tile-icon {
    width: 40px; height: 40px; flex-shrink: 0;
    border-radius: var(--pill);
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--vis-navy);
}
.tile-icon svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tile-icon.is-bad { background: var(--vis-red); color: #fff; }
.tile-icon.is-warn { background: var(--vis-gold); color: var(--vis-navy); }
.tile-icon.is-good { background: var(--vis-green); color: #fff; }
.tile-body { min-width: 0; }
.tile-label { font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 0.25rem; }
.tile-value { font-family: var(--font-head); font-size: 1.6rem; font-weight: 800; color: var(--vis-navy); line-height: 1.1; }
.tile-value.is-good { color: var(--vis-green-text); }
.tile-value.is-warn { color: var(--vis-gold-text); }
.tile-value.is-bad { color: var(--vis-red-text); }

/* ==================== Modal ==================== */

.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(6, 17, 33, 0.55);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
    z-index: 1000;
}
.modal-overlay.hidden { display: none; }

.modal-panel {
    background: var(--card-bg);
    border-radius: var(--r-lg);
    box-shadow: var(--edge-highlight), var(--shadow-modal);
    width: 100%; max-width: 640px; max-height: 90vh;
    display: flex; flex-direction: column; overflow: hidden;
}

.modal-header {
    position: relative;
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.1rem 1.4rem;
    background:
        radial-gradient(130% 100% at 0% 0%, rgba(248, 152, 29, 0.12), transparent 58%),
        linear-gradient(158deg, color-mix(in srgb, var(--nav-bg) 80%, #35557f) 0%, var(--nav-bg) 58%, color-mix(in srgb, var(--nav-bg) 88%, #000) 100%);
}
.modal-header::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
    background: linear-gradient(90deg, transparent, rgba(248, 152, 29, 0.85) 22%, rgba(248, 152, 29, 0.85) 78%, transparent);
}
.modal-header h3 {
    position: relative; margin: 0; padding-left: 14px;
    font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; color: var(--vis-white);
}
.modal-header h3::before {
    content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 1.05em; border-radius: var(--pill);
    background: linear-gradient(180deg, var(--vis-gold), var(--vis-gold-2));
    box-shadow: 0 0 10px rgba(248, 152, 29, 0.5);
}
.modal-close {
    position: relative; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--r-sm); font-size: 1.3rem; line-height: 1; color: rgba(255, 255, 255, 0.92);
    cursor: pointer; padding: 0;
    transition: background var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
}
.modal-close:hover { background: rgba(248, 152, 29, 0.20); border-color: rgba(248, 152, 29, 0.55); color: var(--vis-white); }

.modal-body { padding: 1.4rem; overflow-y: auto; background: var(--card-bg); }

.modal-footer {
    position: relative;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1rem 1.4rem;
    background: var(--card-bg);
    border-top: 1px solid var(--grey-border);
    box-shadow: var(--edge-highlight), 0 -10px 20px -14px rgba(11, 35, 63, 0.20);
}
.modal-footer-actions { display: flex; gap: 0.6rem; }

.readonly-block {
    background: var(--surface-2);
    border: 1px solid var(--grey-border);
    border-radius: var(--r-sm);
    padding: 0.75rem 0.9rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.readonly-block strong { color: var(--text-dark); }

/* ==================== Toasts ==================== */

.toast-container {
    position: fixed;
    top: 1.25rem; right: 1.25rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: min(360px, calc(100vw - 2.5rem));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    background: var(--card-bg);
    border: 1px solid var(--grey-border);
    border-left: 3px solid var(--vis-blue);
    border-radius: var(--r-sm);
    box-shadow: var(--edge-highlight), var(--shadow-modal);
    padding: 0.75rem 0.9rem;
    font-size: 0.83rem;
    color: var(--text-dark);
    animation: toast-in var(--dur-slow) var(--ease);
}
.toast.is-leaving { animation: toast-out var(--dur-base) var(--ease) forwards; }
.toast.toast-success { border-left-color: var(--vis-green); }
.toast.toast-error { border-left-color: var(--vis-red); }
.toast-icon { width: 18px; height: 18px; flex-shrink: 0; margin-top: 0.1rem; color: var(--vis-blue); }
.toast.toast-success .toast-icon { color: var(--vis-green-text); }
.toast.toast-error .toast-icon { color: var(--vis-red-text); }
.toast-icon svg { width: 100%; height: 100%; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toast-message { flex: 1 1 auto; line-height: 1.4; }
.toast-close { flex-shrink: 0; background: none; border: none; color: var(--text-muted-2); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0.1rem; }
.toast-close:hover { color: var(--text-dark); }

@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(16px); } }

/* ==================== Login screen ==================== */

.login-screen {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--vis-navy);
    background: linear-gradient(176deg, color-mix(in srgb, var(--nav-bg) 88%, #5b82c4) 0%, var(--nav-bg) 55%, color-mix(in srgb, var(--nav-bg) 96%, #000) 100%);
    padding: 1.5rem;
}
.login-card {
    background: var(--card-bg);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-modal);
    width: 100%; max-width: 420px;
    padding: 2rem;
}
.login-card img { width: 48px; margin-bottom: 1rem; }
.login-card h1 { font-size: 1.3rem; margin: 0 0 0.3rem; }
.login-card p.subtitle { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 1.5rem; }
.login-candidate {
    width: 100%;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface-2);
    border: 1px solid var(--grey-border);
    border-radius: var(--r-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 0.6rem;
    cursor: pointer;
    font-family: var(--font-sans);
    text-align: left;
    transition: border-color var(--dur-base) var(--ease), background var(--dur-base) var(--ease);
}
.login-candidate:hover { border-color: var(--vis-blue); background: var(--vis-blue-light); }
.login-candidate strong { font-size: 0.88rem; color: var(--text-dark); display: block; }
.login-candidate span { font-size: 0.74rem; color: var(--text-muted-2); }
.login-note {
    margin-top: 1.25rem;
    font-size: 0.74rem;
    color: var(--vis-gold-text);
    background: var(--vis-gold-light);
    border-radius: var(--r-sm);
    padding: 0.6rem 0.75rem;
}

/* ==================== Small screens: general layout give ==================== */

@media (max-width: 640px) {
    main { padding-left: 1rem; padding-right: 1rem; }
    .page-header h1 { font-size: 1.4rem; }
    .modal-panel { max-width: 100% !important; }
    .tile-row { gap: 0.6rem; }
    .tile { flex: 1 1 140px; padding: 0.85rem 0.9rem; }
}
