/* =========================================================
   Geekee Hub — brand-themed design system
   Palette extracted from geekee.co.uk:
     Primary blue #2559c5  |  Deep navy #163873
     Backgrounds: #ffffff / #f9fafb / #f1f5f9
   Fraunces (display) + Inter (body) + JetBrains Mono (code)
   ========================================================= */

:root {
    /* Brand */
    --brand:         #2559c5;
    --brand-hover:   #1e47a0;
    --brand-deep:    #163873;
    --brand-tint:    #e8efff;
    --brand-line:    #c9d7f4;

    /* Surfaces (light theme) */
    --bg-app:        #f9fafb;
    --bg-card:       #ffffff;
    --bg-subtle:     #f1f5f9;
    --bg-hover:      #f3f6fb;
    --bg-sidebar:    #163873;
    --bg-sidebar-h:  #1d4688;

    /* Ink */
    --ink-0: #0f172a;   /* primary text */
    --ink-1: #334155;   /* body */
    --ink-2: #64748b;   /* secondary */
    --ink-3: #94a3b8;   /* tertiary / placeholders */
    --ink-inv: #ffffff;
    --ink-inv-soft: rgba(255, 255, 255, 0.72);
    --ink-inv-dim:  rgba(255, 255, 255, 0.55);

    /* Borders */
    --border:      #e2e8f0;
    --border-soft: #edf0f5;
    --border-mid:  #cbd5e1;

    /* Semantics */
    --warn:     #d97706;
    --warn-soft:#fef3c7;
    --critical: #dc2626;
    --critical-soft: #fee2e2;
    --ok:       #059669;
    --ok-soft:  #d1fae5;
    --info:     #2563eb;

    /* Typography */
    --font-display: 'Fraunces', Georgia, serif;
    --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, monospace;

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow:    0 4px 12px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 20px 40px -8px rgba(15, 23, 42, 0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font-body);
    background: var(--bg-app);
    color: var(--ink-0);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--ink-0); }
h1 { font-family: var(--font-display); font-weight: 500; font-size: 2rem; letter-spacing: -0.02em; }
h2 { font-family: var(--font-display); font-weight: 500; font-size: 1.5rem; letter-spacing: -0.015em; }
h3 { font-size: 1rem; }
a  { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--font-mono); font-size: 0.875em; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: var(--ink-0); }

/* ---------- Shell ---------- */

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-sidebar);
    color: var(--ink-inv);
    padding: 24px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand {
    padding: 4px 10px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.brand-logo {
    max-width: 140px;
    height: auto;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

.nav-label {
    text-transform: uppercase;
    font-size: 0.66rem;
    letter-spacing: 0.14em;
    color: var(--ink-inv-dim);
    padding: 18px 12px 8px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink-inv-soft);
    cursor: pointer;
    transition: all 0.12s ease;
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
    border: 1px solid transparent;
}
.nav-item:hover {
    background: var(--bg-sidebar-h);
    color: var(--ink-inv);
    text-decoration: none;
}
.nav-item.active {
    background: var(--brand);
    color: var(--ink-inv);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.nav-item .icon { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-sidebar-h);
}
.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--brand);
    display: grid; place-items: center;
    font-weight: 600; font-size: 0.8rem; color: white;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 0.82rem; font-weight: 600; color: var(--ink-inv); }
.user-role { font-size: 0.7rem; color: var(--ink-inv-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.logout-btn {
    background: none; border: none; color: var(--ink-inv-dim); cursor: pointer; padding: 4px;
}
.logout-btn:hover { color: #fca5a5; }

/* ---------- Main ---------- */

.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-app);
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 10;
}
.search-wrap { flex: 1; max-width: 560px; position: relative; }
.search-input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: all 0.15s ease;
    font-size: 16px;  /* prevents iOS auto-zoom on focus */
    -webkit-appearance: none;
    appearance: none;
}
/* Hide the iOS Safari search-input native cancel (x) button */
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration { -webkit-appearance: none; }
.search-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 16px; height: 16px; }
.kbd {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    font-family: var(--font-mono); font-size: 0.7rem; color: var(--ink-3);
    background: var(--bg-subtle); padding: 2px 6px; border-radius: 4px;
    border: 1px solid var(--border);
}
.search-results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    max-height: 440px; overflow-y: auto; z-index: 20;
}
.search-result {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; cursor: pointer;
    border-bottom: 1px solid var(--border-soft);
}
.search-result:hover { background: var(--bg-hover); }
.search-result:last-child { border-bottom: none; }
.search-result-type {
    font-size: 0.65rem; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--brand); padding: 2px 8px;
    background: var(--brand-tint); border-radius: 4px; font-weight: 600;
}
.search-result-title { flex: 1; font-weight: 500; color: var(--ink-0); }
.search-result-meta  { font-size: 0.75rem; color: var(--ink-2); }

/* ---------- Content ---------- */
.content { padding: 32px; max-width: 1400px; margin: 0 auto; width: 100%; }

.page-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.page-title .eyebrow {
    font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--brand); font-weight: 600; margin-bottom: 6px;
}
.page-title h1 { font-size: 2.25rem; }
.page-title .subtitle { color: var(--ink-2); margin-top: 6px; max-width: 640px; font-size: 0.95rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-card); color: var(--ink-0);
    font-weight: 500; font-size: 0.88rem; cursor: pointer;
    transition: all 0.12s ease; text-decoration: none;
    box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-mid); text-decoration: none; }
.btn-primary {
    background: var(--brand); color: white; border-color: var(--brand);
    font-weight: 600; box-shadow: 0 1px 2px rgba(37, 89, 197, 0.2);
}
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: white; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-1); box-shadow: none; }
.btn-ghost:hover { background: var(--bg-subtle); }
.btn-danger { color: var(--critical); border-color: var(--border); }
.btn-danger:hover { background: var(--critical-soft); border-color: var(--critical); color: var(--critical); }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; }
.btn .icon { width: 14px; height: 14px; }

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: all 0.15s ease;
}
.card-hover { cursor: pointer; }
.card-hover:hover { border-color: var(--brand-line); transform: translateY(-1px); box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.card-title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 500; color: var(--ink-0); }

/* ---------- Stats ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px; margin-bottom: 32px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative; overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.stat-card::before {
    content: ""; position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--brand), var(--brand-deep));
}
.stat-label {
    font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--ink-2); font-weight: 600; margin-bottom: 10px;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 2.4rem; font-weight: 500; line-height: 1;
    color: var(--brand-deep);
    font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.stat-sub { font-size: 0.8rem; color: var(--ink-2); margin-top: 8px; }

/* ---------- Dashboard ---------- */
.dash-grid {
    display: grid; grid-template-columns: 2fr 1fr;
    gap: 20px; margin-bottom: 24px;
}
@media (max-width: 960px) { .dash-grid { grid-template-columns: 1fr; } }

.activity-feed { max-height: 480px; overflow-y: auto; }
.activity-row {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-soft);
    font-size: 0.88rem;
}
.activity-row:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--brand); flex-shrink: 0; }
.activity-dot.update { background: var(--info); }
.activity-dot.delete { background: var(--critical); }
.activity-dot.reveal { background: var(--warn); }
.activity-meta { flex: 1; min-width: 0; }
.activity-desc { color: var(--ink-0); }
.activity-time { font-size: 0.75rem; color: var(--ink-2); margin-top: 2px; }

/* ---------- Distribution ---------- */
.dist-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-size: 0.88rem; }
.dist-label { min-width: 120px; color: var(--ink-0); }
.dist-bar { flex: 1; height: 8px; background: var(--bg-subtle); border-radius: 99px; overflow: hidden; }
.dist-bar-fill { height: 100%; background: var(--brand); border-radius: 99px; transition: width 0.3s ease; }
.dist-count { font-family: var(--font-mono); color: var(--ink-2); font-size: 0.82rem; min-width: 30px; text-align: right; }

/* ---------- Lists / grids ---------- */
.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.company-card { position: relative; overflow: hidden; }
.company-card::before {
    content: ""; position: absolute;
    top: 0; left: 0; bottom: 0; width: 3px;
    background: var(--stripe, var(--brand));
}
.company-card-inner { position: relative; z-index: 1; padding-left: 8px; }
.company-name {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
    color: var(--ink-0);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.25;
}
.company-meta { color: var(--ink-2); font-size: 0.8rem; margin-bottom: 14px; }
.company-stats { display: flex; gap: 14px; font-size: 0.8rem; color: var(--ink-1); }
.company-stat b { color: var(--brand-deep); font-weight: 600; font-family: var(--font-mono); }

.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th {
    text-align: left; font-weight: 600;
    color: var(--ink-2); text-transform: uppercase;
    font-size: 0.7rem; letter-spacing: 0.1em;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
}
.table td { padding: 13px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; color: var(--ink-0); }
.table tr:hover td { background: var(--bg-hover); }
.table tr { cursor: pointer; }

.empty-state { text-align: center; padding: 64px 24px; color: var(--ink-2); }
.empty-state h3 { font-family: var(--font-display); font-size: 1.3rem; color: var(--ink-0); margin-bottom: 8px; font-weight: 500; }

/* ---------- Tags ---------- */
.tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; font-size: 0.72rem;
    border-radius: 99px; font-weight: 500;
    border: 1px solid;
}
.tag-layout { background: var(--bg-subtle); border-color: var(--border); color: var(--ink-1); }
.tag-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-accent { background: var(--brand-tint); border-color: var(--brand-line); color: var(--brand-deep); }
.tag-warn   { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.tag-ok     { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.tag-critical { background: var(--critical-soft); border-color: var(--critical); color: var(--critical); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: 0.78rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--ink-1); margin-bottom: 6px;
}
.form-label .req { color: var(--critical); }

.input, .textarea, .select {
    width: 100%; padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all 0.15s ease;
    font-size: 0.9rem;
}
.input:focus, .textarea:focus, .select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-tint);
}
.textarea { resize: vertical; min-height: 90px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .form-grid-2 { grid-template-columns: 1fr; } }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: grid; place-items: center;
    z-index: 100; padding: 20px;
    animation: fadeIn 0.15s ease;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
    animation: slideUp 0.2s ease;
}
.modal-lg { max-width: 860px; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 500; }
.modal-close { background: none; border: none; color: var(--ink-2); cursor: pointer; padding: 4px; border-radius: 4px; }
.modal-close:hover { color: var(--ink-0); background: var(--bg-subtle); }
.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--bg-app); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Toasts ---------- */
.toasts {
    position: fixed; bottom: 24px; right: 24px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 200; pointer-events: none;
}
.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brand);
    padding: 12px 18px; border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); font-size: 0.88rem; min-width: 240px;
    pointer-events: auto; animation: slideIn 0.2s ease;
    color: var(--ink-0);
}
.toast.error { border-left-color: var(--critical); }
.toast.success { border-left-color: var(--ok); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ---------- Login page ---------- */
.login-page {
    min-height: 100vh;
    display: grid; place-items: center; padding: 24px;
    background:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(37, 89, 197, 0.08), transparent 70%),
        linear-gradient(180deg, #f9fafb 0%, #eef2f9 100%);
}
.login-card {
    width: 100%; max-width: 420px;
    padding: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 48px -16px rgba(22, 56, 115, 0.2);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand-logo {
    max-width: 180px;
    margin: 0 auto 16px;
    display: block;
}
.login-brand h1 { font-family: var(--font-display); font-weight: 500; font-size: 1.6rem; margin-bottom: 4px; color: var(--brand-deep); }
.login-brand .tagline { color: var(--ink-2); font-size: 0.88rem; }
.login-hint {
    margin-top: 16px; text-align: center; font-size: 0.78rem;
    color: var(--ink-2); padding: 10px;
    background: var(--bg-subtle); border-radius: var(--radius-sm);
    border: 1px dashed var(--border-mid);
}
.login-hint code { background: var(--bg-card); padding: 1px 5px; border-radius: 3px; color: var(--brand); }

/* ---------- 2FA / TOTP ---------- */
.otp-inputs { display: flex; gap: 8px; justify-content: center; margin: 16px 0; }
.otp-input {
    width: 44px; height: 54px;
    font-size: 1.4rem; font-family: var(--font-mono); font-weight: 600;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    outline: none;
    transition: all 0.15s ease;
}
.otp-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }

.qr-wrap {
    text-align: center; padding: 20px;
    background: var(--bg-subtle); border-radius: var(--radius);
    margin-bottom: 16px;
}
.qr-wrap canvas { display: block; margin: 0 auto; background: white; padding: 12px; border-radius: 8px; }
.totp-secret {
    display: block; padding: 10px; margin-top: 10px;
    font-family: var(--font-mono); font-size: 0.9rem;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center; letter-spacing: 0.1em;
    user-select: all;
}

/* ---------- Settings ---------- */
.settings-grid { display: grid; gap: 20px; }
.settings-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 0; border-bottom: 1px solid var(--border-soft);
    gap: 16px; flex-wrap: wrap;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-title { font-weight: 600; color: var(--ink-0); }
.settings-row-desc { font-size: 0.85rem; color: var(--ink-2); margin-top: 4px; }

.status-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 99px;
    font-size: 0.75rem; font-weight: 500;
}
.status-active   { background: var(--ok-soft);   color: var(--ok); }
.status-invited  { background: var(--warn-soft); color: var(--warn); }
.status-disabled { background: var(--bg-subtle); color: var(--ink-2); }

/* ---------- Utilities ---------- */
.flex { display: flex; } .flex-col { flex-direction: column; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--ink-2); }
.text-accent { color: var(--brand); }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }

.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap { padding: 48px; text-align: center; color: var(--ink-2); }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

/* ---------- Checklist ---------- */
.checklist-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    transition: all 0.12s ease;
    background: var(--bg-card);
}
.checklist-item:hover { border-color: var(--brand-line); background: var(--bg-hover); }
.checklist-item.done { opacity: 0.6; }
.checklist-item.done .checklist-title { text-decoration: line-through; color: var(--ink-2); }
.checklist-check {
    width: 20px; height: 20px;
    border: 2px solid var(--border-mid);
    border-radius: 5px; cursor: pointer;
    display: grid; place-items: center; flex-shrink: 0;
    transition: all 0.12s ease;
}
.checklist-check.done { background: var(--brand); border-color: var(--brand); color: white; }
.checklist-title { flex: 1; font-size: 0.92rem; }
.checklist-progress {
    height: 5px; background: var(--bg-subtle);
    border-radius: 99px; overflow: hidden;
    margin-top: 8px;
}
.checklist-progress-fill { height: 100%; background: var(--brand); transition: width 0.3s ease; }

/* ---------- Fields ---------- */
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 16px; }
.field-item { background: var(--bg-subtle); border: 1px solid var(--border-soft); padding: 12px 14px; border-radius: var(--radius-sm); }
.field-label { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }
.field-value { color: var(--ink-0); font-size: 0.9rem; word-break: break-word; }
.field-value.empty { color: var(--ink-3); font-style: italic; }

.pwd-display {
    font-family: var(--font-mono);
    background: var(--bg-subtle); border: 1px solid var(--border);
    padding: 10px 12px; border-radius: var(--radius-sm);
    letter-spacing: 0.05em;
    display: flex; align-items: center; gap: 8px;
}
.pwd-display .pwd-val { flex: 1; user-select: all; color: var(--ink-0); }

/* Article rendering */
.article-content { line-height: 1.7; font-size: 0.95rem; color: var(--ink-1); }
.article-content h2 { font-family: var(--font-display); margin: 24px 0 12px; color: var(--ink-0); }
.article-content h3 { margin: 20px 0 10px; color: var(--ink-0); }
.article-content p { margin: 0 0 14px; }
.article-content ul, .article-content ol { padding-left: 24px; margin-bottom: 14px; }
.article-content code { background: var(--bg-subtle); padding: 2px 6px; border-radius: 4px; color: var(--brand-deep); }
.article-content pre { background: var(--bg-subtle); padding: 14px; border-radius: var(--radius-sm); overflow-x: auto; border: 1px solid var(--border); }
.article-content a { color: var(--brand); }

.filter-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.filter-bar .input { max-width: 320px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
    padding: 10px 16px; color: var(--ink-2);
    background: none; border: none; cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 500; font-size: 0.9rem; margin-bottom: -1px;
}
.tab:hover { color: var(--ink-0); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ============================================================
   Mobile
   ============================================================ */

/* Hamburger button - hidden on desktop */
.mobile-menu-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    cursor: pointer;
    color: var(--ink-0);
}
.mobile-menu-btn:hover { background: var(--bg-subtle); }

/* Sidebar backdrop (tap to close) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 49;
    animation: fadeIn 0.15s ease;
}

/* Close button inside sidebar - hidden on desktop */
.sidebar-close {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    position: absolute;
    top: 16px;
    right: 16px;
}
.sidebar-close:hover { background: rgba(255, 255, 255, 0.2); }

@media (max-width: 900px) {
    /* Shell becomes single column, sidebar slides in from the left */
    .app-shell { grid-template-columns: 1fr; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 50;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.open ~ .sidebar-backdrop { display: block; }
    .sidebar-close { display: block; }

    /* Show the hamburger in the topbar */
    .mobile-menu-btn { display: inline-flex; align-items: center; }

    /* Topbar compresses */
    .topbar {
        padding: 10px 14px;
        gap: 10px;
    }
    .topbar .btn-ghost { display: none; } /* hide the "Home" text button on mobile */
    .search-wrap { max-width: none; }
    .search-input { padding: 9px 12px 9px 34px; font-size: 0.9rem; }
    .search-icon  { left: 10px; width: 14px; height: 14px; }
    .kbd { display: none; }

    /* Content */
    .content { padding: 16px; }

    /* Headings scale down */
    .page-title h1 { font-size: 1.6rem; }
    .page-header   { flex-direction: column; align-items: stretch; gap: 12px; }
    .page-header .flex { flex-wrap: wrap; }

    /* Stat grid - two per row on small screens */
    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-bottom: 20px;
    }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 1.8rem; }
    .stat-label { font-size: 0.65rem; margin-bottom: 6px; }

    /* Dashboard two-column becomes one */
    .dash-grid { grid-template-columns: 1fr; gap: 14px; }

    /* Company cards full width */
    .list-grid { grid-template-columns: 1fr; gap: 10px; }

    /* Tables scroll horizontally inside their card */
    .card { overflow-x: auto; }
    .table thead th,
    .table td {
        white-space: nowrap;
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    /* Tabs scroll horizontally instead of wrapping */
    .tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .tab {
        white-space: nowrap;
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    /* Filter bar stacks vertically */
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar .input,
    .filter-bar .select { max-width: none; }

    /* Company header stacks */
    .company-header { flex-direction: row; align-items: center; gap: 12px; }
    .company-logo-lg { width: 56px; height: 56px; font-size: 1.2rem; }

    /* Photo grid tighter */
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
    .photo-tile img { height: 120px; }

    /* Checklist items */
    .checklist-item { padding: 10px 12px; }
    .checklist-item form { flex-shrink: 0; }

    /* Task cards */
    .task-card { padding: 14px; }
    .task-header { flex-direction: column; align-items: flex-start; gap: 6px; }
    .task-status { font-size: 0.65rem; }

    /* Form grids collapse */
    .form-grid-2 { grid-template-columns: 1fr; gap: 10px; }

    /* Modals fill more of the screen */
    .modal-backdrop { padding: 12px; }
    .modal { max-height: calc(100vh - 24px); }
    .modal-header { padding: 14px 18px; }
    .modal-body   { padding: 16px 18px; }
    .modal-footer { padding: 12px 18px; flex-wrap: wrap; }
    .modal-footer .btn { flex: 1; justify-content: center; }

    /* Login page */
    .login-page  { padding: 16px; }
    .login-card  { padding: 24px; }
    .login-brand h1 { font-size: 1.4rem; }

    /* OTP boxes shrink to fit */
    .otp-input { width: 36px; height: 46px; font-size: 1.1rem; }

    /* Field grid goes single column */
    .field-grid { grid-template-columns: 1fr; gap: 10px; }

    /* Settings rows stack */
    .settings-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 14px 0;
    }
    .settings-row > div:first-child { min-width: 0; }

    /* Hide the "Password" column on passwords table is not needed; kept as-is */

    /* User chip in sidebar footer - tighten */
    .user-chip { gap: 8px; padding: 8px 10px; }
    .user-name { font-size: 0.78rem; }

    /* Modal input controls sized so iOS doesn't zoom */
    .input, .textarea, .select { font-size: 16px; }

    /* Flash messages stack their action */
    .flash { flex-wrap: wrap; gap: 8px; }
    .flash .btn { margin-left: 0; }
}

/* Very small screens - single column stat grid */
@media (max-width: 420px) {
    .stat-grid { grid-template-columns: 1fr; }
    .page-title h1 { font-size: 1.4rem; }
}

/* ---------- Checklist/task item UI with inline edit ---------- */
.item-row {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    margin-bottom: 8px;
    transition: border-color 0.12s;
}
.item-row:hover { border-color: var(--brand-line); }
.item-row details summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.item-row details summary::-webkit-details-marker { display: none; }
.item-row details[open] summary { border-bottom: 1px solid var(--border-soft); }
.item-main { flex: 1; min-width: 0; }
.item-title {
    font-weight: 500; color: var(--ink-0); font-size: 0.95rem;
}
.item-desc-preview {
    font-size: 0.82rem;
    color: var(--ink-2);
    margin-top: 4px;
    line-height: 1.5;
    white-space: pre-wrap;
}
.item-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}
.item-edit-chip {
    font-size: 0.75rem;
    color: var(--ink-2);
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 99px;
    background: var(--bg-subtle);
}
.item-row details summary:hover .item-edit-chip { color: var(--brand); border-color: var(--brand-line); }
.item-edit-form {
    padding: 16px;
    background: var(--bg-subtle);
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

/* Task checklist rows - tick button + expandable details */
.task-checklist-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-soft);
}
.task-checklist-row:last-child { border-bottom: none; }
.task-checklist-row .task-checklist-body {
    flex: 1;
    min-width: 0;
}
.task-checklist-body summary {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    list-style: none;
}
.task-checklist-body summary::-webkit-details-marker { display: none; }
.task-checklist-body summary > div { flex: 1; min-width: 0; }
.task-checklist-body summary .item-edit-chip {
    flex-shrink: 0;
    align-self: flex-start;
}
.task-checklist-body .checklist-title.done-text {
    text-decoration: line-through;
    color: var(--ink-2);
}
.task-checklist-body[open] .item-edit-form {
    margin-top: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
}
.task-checklist-row.done .checklist-title { color: var(--ink-2); }

/* ---------- Roles management ---------- */
.role-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    margin-bottom: 10px;
    transition: border-color 0.12s;
}
.role-row:hover { border-color: var(--brand-line); }
.role-meta { flex: 1; min-width: 0; }
.role-label {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--ink-0);
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
}
.role-desc {
    font-size: 0.85rem;
    color: var(--ink-2);
    margin-top: 4px;
}
.role-perms-summary {
    margin-top: 10px;
    display: flex; flex-wrap: wrap; gap: 4px;
}
.perm-chip {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 99px;
    font-family: var(--font-mono);
    border: 1px solid;
}
.perm-chip.perm-full { color: var(--ok);       border-color: var(--ok);       background: var(--ok-soft); }
.perm-chip.perm-some { color: var(--brand);    border-color: var(--brand-line); background: var(--brand-tint); }
.perm-chip.perm-none { color: var(--ink-3);    border-color: var(--border);   background: var(--bg-subtle); }

.role-actions { display: flex; gap: 6px; flex-shrink: 0; }

.perm-matrix {
    display: flex; flex-direction: column; gap: 12px;
}
.perm-section {
    padding: 12px 14px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
}
.perm-section-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-0);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.perm-section-boxes {
    display: flex; flex-wrap: wrap; gap: 12px;
    align-items: center;
}
.perm-box {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.85rem;
    color: var(--ink-1);
    font-family: var(--font-mono);
    cursor: pointer;
    user-select: none;
}
.perm-box input[type=checkbox] {
    width: 16px; height: 16px; cursor: pointer;
}
.perm-all-btn { margin-left: auto; font-size: 0.75rem; }

/* Responsive tweaks for roles */
@media (max-width: 700px) {
    .role-row { flex-direction: column; gap: 10px; }
    .role-actions { align-self: flex-end; }
    .perm-section-boxes { flex-direction: column; align-items: flex-start; gap: 8px; }
    .perm-all-btn { margin-left: 0; }
}

/* ---------- Rack visualization ---------- */
.rack-viz {
    display: grid;
    grid-auto-rows: 32px;
    gap: 2px;
    background: var(--ink-0);
    padding: 10px;
    border-radius: var(--radius);
    border: 2px solid var(--ink-0);
    max-width: 380px;
}
.rack-empty {
    background: repeating-linear-gradient(45deg, rgba(255,255,255,0.02), rgba(255,255,255,0.02) 4px, rgba(255,255,255,0.06) 4px, rgba(255,255,255,0.06) 8px);
    color: rgba(255,255,255,0.3);
    font-size: 0.7rem;
    padding: 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 2px;
    font-family: var(--font-mono);
}
.rack-item {
    background: var(--color, #3b82f6);
    color: white;
    border-radius: 3px;
    padding: 6px 8px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.82rem;
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
    overflow: hidden;
}
/* Light backgrounds (white, yellow, pale colours) use dark text */
.rack-item-light { color: #0f172a; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }
.rack-item-light .rack-item-title { color: #0f172a; }
.rack-item-light .rack-u-label    { color: rgba(15,23,42,0.6); }
.rack-item-light .rack-item-meta  { color: rgba(15,23,42,0.7); }
.rack-item-light .rack-item-delete button { background: rgba(0,0,0,0.15); color: #0f172a; }
.rack-item-light .rack-item-delete button:hover { background: rgba(220,38,38,0.9); color: white; }
.rack-u-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: rgba(255,255,255,0.7);
    flex-shrink: 0;
    min-width: 50px;
}
.rack-empty .rack-u-label { color: rgba(255,255,255,0.4); }
.rack-item-body { flex: 1; min-width: 0; }
.rack-item-title {
    font-weight: 500;
    color: white;
    text-decoration: none;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
a.rack-item-title:hover { text-decoration: underline; }
.rack-item-meta {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.8);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rack-item-delete {
    margin: 0;
    opacity: 0;
    transition: opacity 0.12s;
}
.rack-item:hover .rack-item-delete { opacity: 1; }
.rack-item-delete button {
    background: rgba(0,0,0,0.3);
    color: white;
    border: none;
    border-radius: 3px;
    width: 20px; height: 20px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}
.rack-item-delete button:hover { background: rgba(220,38,38,0.9); }
@media (max-width: 900px) {
    .rack-viz { max-width: 100%; }
}

/* Drag-and-drop states */
.rack-item[draggable="true"] { cursor: grab; }
.rack-item[draggable="true"]:active { cursor: grabbing; }
.rack-item[draggable="true"] .rack-item-title,
.rack-item[draggable="true"] a.rack-item-title {
    /* Don't block the drag when starting from the title */
    pointer-events: auto;
}
.rack-item-dragging {
    opacity: 0.4;
}
.rack-drop-target {
    outline: 2px dashed #fbbf24;
    outline-offset: -2px;
    background: rgba(251,191,36,0.15);
}
.rack-empty.rack-drop-target {
    background: rgba(251,191,36,0.2);
    color: rgba(255,255,255,0.9);
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    border: 1px solid;
}
.flash-success { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.flash-error   { background: var(--critical-soft); border-color: var(--critical); color: var(--critical); }
.flash-info    { background: var(--brand-tint); border-color: var(--brand-line); color: var(--brand-deep); }

/* ---------- Company logo ---------- */
.company-logo {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    object-position: center;
    background: white;
    border: 1px solid var(--border);
    flex-shrink: 0;
    padding: 4px;
    box-sizing: border-box;
}
.company-logo-lg {
    width: 72px;
    height: 72px;
    border-radius: var(--radius);
    padding: 6px;
}
.company-logo-placeholder {
    display: grid; place-items: center;
    font-family: var(--font-display);
    font-weight: 600; color: white;
    background: var(--brand);
    padding: 0;  /* placeholder shows initials, not a image -- no padding needed */
}

.company-header {
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 8px;
}
.company-list-row {
    display: flex; align-items: center; gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    text-decoration: none;
    color: inherit;
    transition: all 0.12s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.company-list-row:hover { border-color: var(--brand-line); transform: translateY(-1px); box-shadow: var(--shadow); text-decoration: none; }
.company-list-row.is-favourited { border-color: #fbbf24; box-shadow: 0 0 0 1px #fbbf24; }
.company-fav-star {
    position: absolute;
    top: 8px;
    right: 10px;
    font-size: 1.1rem;
    color: #fbbf24;
    line-height: 1;
    pointer-events: none;
}

/* Favourite toggle button on company detail page */
.btn.fav-toggle { font-weight: 500; }
.btn.fav-toggle.fav-on { border-color: #fbbf24; color: #d97706; }
.btn.fav-toggle.fav-on:hover { background: #fef3c7; }
.btn.fav-toggle span[aria-hidden] { font-size: 1.1rem; line-height: 1; margin-right: 4px; }
@media (max-width: 520px) {
    .btn-text-hide-sm { display: none; }
}

/* Quick-access company cards (favourites, most-viewed on dashboard) */
.dash-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
@media (max-width: 900px) {
    .dash-grid-2 { grid-template-columns: 1fr; }
}
.quick-company-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}
.quick-company {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: inherit;
    background: var(--bg-card);
    transition: all 0.12s ease;
    text-align: center;
    min-width: 0;
}
.quick-company:hover { border-color: var(--brand-line); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.quick-company img,
.quick-company-badge {
    width: 44px; height: 44px;
    border-radius: 8px;
    object-fit: contain;
    background: var(--bg-subtle);
}
.quick-company-badge {
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 600; font-size: 0.9rem;
    letter-spacing: -0.02em;
}
.quick-company-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ink-0);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
    max-width: 100%;
}
.quick-company-meta {
    font-size: 0.7rem;
    color: var(--ink-3);
    font-family: var(--font-mono);
}

/* ---------- Checklist new-item rows ---------- */
.checklist-new-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: start;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
}
.checklist-new-row > .input {
    grid-column: 1 / 2;
}
.checklist-new-row details {
    grid-column: 1 / 2;
    margin-top: 2px;
}
.checklist-new-row details summary {
    font-size: 0.8rem;
    color: var(--ink-2);
    cursor: pointer;
    padding: 2px 0;
    list-style: none;
    user-select: none;
}
.checklist-new-row details summary::-webkit-details-marker { display: none; }
.checklist-new-row details[open] summary { color: var(--brand); }
.checklist-new-row details textarea {
    margin-top: 6px;
    font-size: 0.88rem;
}
.checklist-new-remove {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    align-self: start;
    color: var(--ink-3);
    font-size: 18px;
    line-height: 1;
    padding: 6px 10px;
}
.checklist-new-remove:hover { color: var(--critical); background: var(--critical-soft); }

/* ---------- Searchable combobox ---------- */
.combobox {
    position: relative;
    width: 100%;
}
.combobox-input {
    width: 100%;
    padding-right: 32px;  /* room for clear button */
}
.combobox-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 0;
    width: 22px; height: 22px;
    border-radius: 50%;
    color: var(--ink-3);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.combobox-clear:hover { background: var(--bg-subtle); color: var(--ink-0); }
.combobox-list {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    max-height: 280px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 50;
}
.combobox-list.open { display: block; }
.combobox.open .combobox-input {
    border-color: var(--brand-line);
    box-shadow: 0 0 0 2px var(--brand-tint);
}
.combobox-item {
    padding: 9px 12px;
    font-size: 0.92rem;
    cursor: pointer;
    color: var(--ink-0);
    border-bottom: 1px solid var(--border-soft);
}
.combobox-item:last-child { border-bottom: 0; }
.combobox-item:hover,
.combobox-item.highlight {
    background: var(--brand-tint);
    color: var(--brand);
}
.combobox-item mark {
    background: var(--warn-soft, #fef3c7);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}
.combobox-empty {
    padding: 12px;
    color: var(--ink-3);
    font-size: 0.9rem;
    font-style: italic;
}

/* ---------- Live search dropdown (header search) ---------- */
.header-search-wrap {
    position: relative;
    flex: 1;
    max-width: 520px;
}
.live-search-results {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0; right: 0;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
}
.live-search-results.open { display: block; }
.live-search-group {
    padding: 6px 0;
    border-bottom: 1px solid var(--border-soft);
}
.live-search-group:last-child { border-bottom: 0; }
.live-search-group-label {
    padding: 6px 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-3);
}
.live-search-item {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--ink-0);
    border-left: 3px solid transparent;
}
.live-search-item:hover,
.live-search-item.highlight {
    background: var(--brand-tint);
    color: var(--brand);
    border-left-color: var(--brand);
    text-decoration: none;
}
.live-search-item-title { font-weight: 500; font-size: 0.92rem; }
.live-search-item-meta  { font-size: 0.78rem; color: var(--ink-3); margin-top: 2px; }
.live-search-all {
    display: block;
    padding: 10px 12px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--brand);
    border-top: 1px solid var(--border-soft);
    text-decoration: none;
    background: var(--bg-subtle);
}
.live-search-all:hover { background: var(--brand-tint); }
.live-search-empty {
    padding: 18px;
    text-align: center;
    color: var(--ink-3);
    font-size: 0.88rem;
}
.live-search-loading {
    padding: 12px;
    text-align: center;
    color: var(--ink-3);
    font-size: 0.85rem;
}

/* ---------- Photo grid ---------- */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.photo-tile {
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.12s ease;
    position: relative;
}
.photo-tile:hover { border-color: var(--brand-line); box-shadow: var(--shadow); }
.photo-tile img {
    width: 100%;
    height: 160px;
    object-fit: contain;
    object-position: center;
    background: var(--bg-subtle);
    display: block;
    cursor: zoom-in;
}
.photo-caption {
    padding: 8px 10px;
    font-size: 0.82rem;
    color: var(--ink-1);
    border-top: 1px solid var(--border-soft);
    background: var(--bg-card);
}

/* Inline caption editor */
.photo-caption-edit {
    border-top: 1px solid var(--border-soft);
}
.photo-caption-edit summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 0.82rem;
    color: var(--ink-1);
    background: var(--bg-card);
    border-top: none;
}
.photo-caption-edit summary::-webkit-details-marker { display: none; }
.photo-caption-edit summary:hover { background: var(--bg-subtle); }
.photo-caption-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.photo-caption-pencil {
    display: flex;
    align-items: center;
    color: var(--ink-3);
    opacity: 0.6;
    transition: opacity 0.12s, color 0.12s;
}
.photo-caption-edit summary:hover .photo-caption-pencil {
    opacity: 1;
    color: var(--brand);
}
.photo-caption-form {
    padding: 10px;
    background: var(--bg-subtle);
    display: flex;
    gap: 6px;
    border-top: 1px solid var(--border-soft);
}
.photo-caption-form .input {
    flex: 1;
    font-size: 0.85rem;
}
.photo-meta {
    font-size: 0.72rem;
    color: var(--ink-2);
    padding: 4px 10px 8px;
    background: var(--bg-card);
    border-top: none;
}
.photo-delete {
    position: absolute; top: 6px; right: 6px;
    background: rgba(220, 38, 38, 0.9); color: white;
    border: none; border-radius: 4px; padding: 4px 6px;
    cursor: pointer; opacity: 0; transition: opacity 0.12s;
}
.photo-tile:hover .photo-delete { opacity: 1; }

/* ---------- Lightbox ---------- */
.lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.9);
    display: grid; place-items: center;
    z-index: 1000; padding: 40px;
    cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lightbox-caption {
    position: absolute; bottom: 24px; left: 50%;
    transform: translateX(-50%);
    color: white; padding: 8px 16px;
    background: rgba(0,0,0,0.6); border-radius: 6px;
    font-size: 0.9rem;
}

/* ---------- Task ---------- */
.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 10px;
    transition: all 0.12s ease;
    box-shadow: var(--shadow-sm);
}
.task-card:hover { border-color: var(--brand-line); }
.task-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 6px;
}
.task-title {
    font-family: var(--font-display);
    font-size: 1.05rem; font-weight: 500;
    color: var(--ink-0);
    text-decoration: none;
}
.task-title:hover { color: var(--brand); text-decoration: none; }
.task-status {
    font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
    padding: 2px 8px; border-radius: 99px;
    font-weight: 600;
}
.task-status.open        { background: var(--brand-tint); color: var(--brand-deep); }
.task-status.in_progress { background: var(--warn-soft);  color: var(--warn); }
.task-status.completed   { background: var(--ok-soft);    color: var(--ok); }
.task-status.cancelled   { background: var(--bg-subtle);  color: var(--ink-2); }

.task-meta {
    font-size: 0.8rem; color: var(--ink-2);
    display: flex; gap: 12px; flex-wrap: wrap;
}

.task-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
}
.task-item:last-child { border-bottom: none; }
.task-item.done .task-item-title { text-decoration: line-through; color: var(--ink-2); }
.task-item-title { flex: 1; color: var(--ink-0); }
.task-item-completed-info {
    font-size: 0.72rem; color: var(--ink-2); margin-top: 2px;
}

.completion-bar {
    height: 6px; background: var(--bg-subtle);
    border-radius: 99px; overflow: hidden;
    margin: 8px 0;
}
.completion-bar-fill {
    height: 100%; background: var(--brand);
    transition: width 0.3s ease;
}

/* Back link */
.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.8rem; color: var(--ink-2);
    margin-bottom: 12px;
}
.back-link:hover { color: var(--brand); }

/* File input styling */
.file-input { font-size: 0.88rem; padding: 8px; }
