/* ==========================================================================
   Epsilon AI — Hub
   Hand-written CSS, no build step and no external requests, so the app works
   on shared hosting exactly as it does locally.
   ========================================================================== */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --border: #e3e6ea;
    --border-strong: #cdd3da;
    --text: #16202c;
    --muted: #5f6c7b;

    --brand: #1f4fd8;
    --brand-dark: #163ba6;
    --brand-soft: #eaf0ff;

    --ok: #12805c;
    --ok-soft: #e4f6ef;
    --warn: #a35b00;
    --warn-soft: #fdf1e0;
    --danger: #c02626;
    --danger-soft: #fdeaea;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-lg: 0 4px 16px rgba(16, 24, 40, .08);

    --sidebar-w: 244px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f141b;
        --surface: #161d26;
        --surface-2: #1b2430;
        --border: #26313f;
        --border-strong: #35424f;
        --text: #e7edf4;
        --muted: #93a1b1;

        --brand: #5b8cff;
        --brand-dark: #7ba3ff;
        --brand-soft: #1a2540;

        --ok: #34c896;
        --ok-soft: #12291f;
        --warn: #e0a35a;
        --warn-soft: #2b2114;
        --danger: #ff7b7b;
        --danger-soft: #2c1717;

        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow-lg: 0 4px 16px rgba(0, 0, 0, .4);
    }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 12px; }

/* --- Environment ribbon --------------------------------------------------- */
.env-ribbon {
    background: repeating-linear-gradient(45deg, var(--warn) 0 12px, #8f4f00 12px 24px);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-align: center;
    padding: 4px 8px;
}

/* --- Shell ---------------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1rem; border-bottom: 1px solid var(--border); }
.brand-mark {
    width: 32px; height: 32px; flex: 0 0 32px;
    display: grid; place-items: center;
    background: var(--brand); color: #fff;
    border-radius: 8px; font-weight: 700; font-size: 18px;
}
.brand-mark-lg { width: 48px; height: 48px; font-size: 26px; margin: 0 auto .75rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14px; }
.brand-text small { color: var(--muted); font-size: 11px; }

.nav { flex: 1; overflow-y: auto; padding: .6rem .5rem; }
.nav-link {
    display: flex; align-items: center; gap: .6rem;
    padding: .5rem .65rem; margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--text); font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-link svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-divider { padding: 1rem .65rem .3rem; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }

.sidebar-foot { padding: .75rem; border-top: 1px solid var(--border); display: grid; gap: .5rem; }
.user-chip { display: flex; align-items: center; gap: .55rem; color: var(--text); padding: .3rem; border-radius: var(--radius-sm); }
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.user-chip span { display: flex; flex-direction: column; line-height: 1.25; overflow: hidden; }
.user-chip strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip small { color: var(--muted); }
.avatar {
    width: 30px; height: 30px; flex: 0 0 30px;
    display: grid !important; place-items: center;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 50%; font-weight: 700; font-size: 13px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: .75rem;
    padding: .85rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; flex: 1; min-width: 0; }
.topbar-actions { display: flex; gap: .5rem; }

.icon-btn {
    display: none;
    background: none; border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: .35rem; cursor: pointer; color: var(--text);
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.content { flex: 1; padding: 1.5rem; max-width: 1400px; width: 100%; }

.footer {
    display: flex; justify-content: space-between; gap: 1rem;
    padding: 1rem 1.5rem; color: var(--muted); font-size: 12px;
    border-top: 1px solid var(--border);
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .5rem .85rem;
    font: inherit; font-weight: 550; font-size: 13.5px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    cursor: pointer; white-space: nowrap;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.link { color: var(--brand); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link-danger { color: var(--danger); }

/* --- Alerts --------------------------------------------------------------- */
.alert {
    padding: .75rem 1rem; margin-bottom: 1rem;
    border: 1px solid var(--border); border-left-width: 3px;
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.alert-success { border-left-color: var(--ok); background: var(--ok-soft); }
.alert-error   { border-left-color: var(--danger); background: var(--danger-soft); }
.alert-warning { border-left-color: var(--warn); background: var(--warn-soft); }
.alert-info    { border-left-color: var(--brand); background: var(--brand-soft); }
.alert ul { margin: .5rem 0 .25rem; padding-left: 1.2rem; }
.alert ul.tight li { margin-bottom: .2rem; }

/* --- Panels & layout ------------------------------------------------------ */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.15rem 1.15rem;
    margin-bottom: 1.25rem;
}
.panel-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
    padding-bottom: .7rem; margin-bottom: .9rem;
    border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 14.5px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.25rem; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.toolbar p { margin: 0; max-width: 60ch; }

/* --- Stats ---------------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat {
    display: flex; flex-direction: column; gap: .15rem;
    padding: 1rem 1.1rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    color: var(--text);
}
a.stat:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 680; line-height: 1.15; letter-spacing: -.02em; }
.stat-value-sm { font-size: 17px; }
.stat-note { font-size: 12px; color: var(--muted); }
.stat-ok .stat-value { color: var(--ok); }
.stat-danger .stat-value { color: var(--danger); }
.stat-warn .stat-value { color: var(--warn); }
.stat-static { cursor: default; }

/* --- Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel .table-wrap { border: 0; box-shadow: none; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); font-weight: 650;
    padding: .6rem .85rem; border-bottom: 1px solid var(--border);
    background: var(--surface-2); white-space: nowrap;
}
.table td { padding: .65rem .85rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td small { display: block; color: var(--muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .num small { text-align: right; }
.table-compact td, .table-compact th { padding: .45rem .7rem; }
.nowrap { white-space: nowrap; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions form { display: inline; margin-left: .5rem; }
.row-warn { background: var(--warn-soft); }

.result-count { color: var(--muted); font-size: 12.5px; margin-bottom: .5rem; }

/* --- Badges --------------------------------------------------------------- */
.badge {
    display: inline-block; padding: .1rem .45rem;
    font-size: 11px; font-weight: 650; text-transform: capitalize;
    border-radius: 4px; border: 1px solid var(--border-strong);
    background: var(--surface-2); color: var(--muted);
}
.badge-confirmed, .badge-active { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.badge-draft { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.badge-cancelled, .badge-inactive { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.badge-completed, .badge-archived { background: var(--surface-2); color: var(--muted); }

/* --- Forms ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; border: 0; padding: 0; }
.field > span, .field legend { font-size: 12.5px; font-weight: 600; color: var(--text); padding: 0; }
.field input, .field select, .field textarea, .filters input, .filters select {
    font: inherit; font-size: 13.5px;
    padding: .5rem .6rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    width: 100%;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus,
.filters input:focus, .filters select:focus {
    outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand);
}
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.hint { color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.field-error { color: var(--danger); font-size: 12px; margin: 0; font-weight: 550; }

.check-inline { display: flex; align-items: center; gap: .4rem; font-size: 13.5px; white-space: nowrap; }
.check-inline input { width: auto; }

.stack { display: grid; gap: 0; }

.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
.form-main { min-width: 0; }
.form-aside { min-width: 0; }
.sticky { position: sticky; top: 5rem; }
.form-narrow { max-width: 780px; }
.form-actions { display: flex; gap: .6rem; margin-bottom: 1.5rem; }

.filters {
    display: flex; flex-wrap: wrap; gap: .55rem; align-items: center;
    margin-bottom: 1.25rem; padding: .85rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.filters input[type="search"] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; flex: 0 1 190px; }
.push-right { margin-left: auto; }

.inline-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; padding-top: 1rem; border-top: 1px solid var(--border); margin-top: 1rem; }
.inline-form .field { margin-bottom: 0; flex: 0 1 150px; }

.danger-zone {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    padding: 1rem 1.15rem; margin-bottom: 2rem;
    border: 1px solid var(--danger); border-radius: var(--radius);
    background: var(--danger-soft);
}
.danger-zone small { display: block; color: var(--muted); }

/* --- Lists ---------------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; }
.timeline li { display: grid; grid-template-columns: 62px 1fr auto; gap: .75rem; align-items: start; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .time { font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.timeline .time small { font-weight: 400; color: var(--muted); }
.timeline .body { display: flex; flex-direction: column; min-width: 0; }
.timeline .body small { color: var(--muted); }

.load-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.load-list li { display: grid; grid-template-columns: minmax(90px, 1.2fr) 2fr auto; gap: .7rem; align-items: center; font-size: 13px; }
.load-num { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.bar { height: 7px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand); }
.bar span.warn { background: var(--warn); }
.bar span.over { background: var(--danger); }
.bar-cell { min-width: 130px; }

.date-list { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; display: grid; gap: 1px; }
.date-list li { display: flex; align-items: center; gap: .6rem; padding: .3rem .4rem; border-radius: 4px; font-size: 13px; }
.date-list li:nth-child(odd) { background: var(--surface-2); }
.date-list li.past { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.date-list li.today { background: var(--brand-soft); font-weight: 600; }
.date-list .n { width: 26px; color: var(--muted); font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }
.date-list em { color: var(--brand); font-style: normal; font-size: 11px; font-weight: 700; }

.definition { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: .35rem 1rem; margin: 0; font-size: 13.5px; }
.definition dt { color: var(--muted); font-size: 12.5px; }
.definition dd { margin: 0; }

.notes { white-space: pre-wrap; font-size: 13.5px; color: var(--text); background: var(--surface-2); padding: .75rem; border-radius: var(--radius-sm); }

/* --- Detail header -------------------------------------------------------- */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.detail-head h2 { font-size: 20px; margin: .3rem 0 .15rem; }
.detail-actions { display: flex; gap: .5rem; }

/* --- Empty states --------------------------------------------------------- */
.empty-state {
    text-align: center; padding: 3rem 1.5rem;
    background: var(--surface); border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}
.empty-state h2 { font-size: 17px; margin-bottom: .4rem; }
.empty-state p { color: var(--muted); max-width: 48ch; margin: 0 auto 1rem; }
.empty-ok h2 { color: var(--ok); }
.empty { color: var(--muted); text-align: center; padding: 1.25rem 0; margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.quick-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }

/* --- Centered pages (login, setup) --------------------------------------- */
body.centered { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; align-content: center; }
body.centered .env-ribbon { position: fixed; top: 0; left: 0; right: 0; }
.card-centered { width: 100%; max-width: 420px; }
.login { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 2rem 1.75rem; }
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand h1 { font-size: 19px; }
.login-brand p { color: var(--muted); font-size: 12.5px; margin: .2rem 0 0; }
.login-foot { text-align: center; color: var(--muted); font-size: 11.5px; margin: 1rem 0 0; }

.setup { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 1.75rem; }
.card-centered:has(.setup) { max-width: 620px; }
.setup h1 { font-size: 19px; margin-bottom: .6rem; }
.setup-steps { padding-left: 1.2rem; display: grid; gap: .5rem; margin: 1rem 0; }
.setup code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: .05rem .3rem; font-size: 12.5px; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 1080px) {
    .form-layout { grid-template-columns: minmax(0, 1fr); }
    .sticky { position: static; }
}

@media (max-width: 860px) {
    .icon-btn { display: block; }
    .sidebar {
        position: fixed; z-index: 40; left: 0; top: 0;
        transform: translateX(-100%); transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: translateX(0); }
    .content { padding: 1rem; }
    .topbar { padding: .75rem 1rem; }
    .cal-week { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .cal-month { font-size: 10px; }
    .cal-cell { min-height: 72px; }
}

@media print {
    .sidebar, .topbar, .filters, .footer, .form-actions, .danger-zone, .quick-actions, .env-ribbon { display: none !important; }
    body { background: #fff; }
    .panel, .table-wrap { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}

/* --- Releases -------------------------------------------------------------- */
.env-card .definition { font-size: 13px; }
.version {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 4px; padding: .05rem .35rem;
}
.text-danger { color: var(--danger); font-weight: 600; }
.rollback-form { display: flex; gap: .3rem; align-items: center; justify-content: flex-end; }
.rollback-form input[type="text"] {
    font: inherit; font-size: 11px; padding: .2rem .35rem;
    border: 1px solid var(--border-strong); border-radius: 4px;
    background: var(--surface); color: var(--text);
}
/* The pre-flight checklist. Each row carries its state in the colour of the
   mark and in a word for screen readers, never in colour alone. */
.preflight { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .1rem; }
.preflight li {
    display: grid; grid-template-columns: 1.4rem 1fr; gap: .55rem;
    align-items: start; padding: .5rem .6rem; border-radius: 6px;
}
.preflight-mark {
    display: grid; place-items: center; width: 1.4rem; height: 1.4rem;
    border-radius: 50%; font-size: 12px; font-weight: 700; line-height: 1;
}
.preflight-body { display: grid; gap: .1rem; font-size: 13px; }
.preflight-body strong { font-weight: 600; }
.preflight-fix { font-size: 12.5px; color: var(--text); opacity: .85; }

.preflight-pass .preflight-mark { background: var(--ok-soft); color: var(--ok); }
.preflight-warn { background: var(--warn-soft); }
.preflight-warn .preflight-mark { background: var(--warn); color: #fff; }
.preflight-fail { background: var(--danger-soft); }
.preflight-fail .preflight-mark { background: var(--danger); color: #fff; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px;
    padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Releasing is a deliberate act, so its form is laid out to be read rather
   than skimmed past: fields stacked, confirmation last, button after it. */
.release-form { display: grid; gap: .7rem; max-width: 26rem; margin-top: 1rem; }
.release-form .field { display: grid; gap: .25rem; }
.release-form input[type="text"] {
    font: inherit; padding: .45rem .55rem;
    border: 1px solid var(--border-strong); border-radius: 5px;
    background: var(--surface); color: var(--text);
}
.release-form button { justify-self: start; }
.release-alt { margin-top: 1.4rem; border-top: 1px solid var(--border); padding-top: .8rem; }
.release-alt summary { cursor: pointer; font-size: 13px; }
.release-alt p { margin: .5rem 0 .7rem; }

.config-problem {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
    background: var(--danger-soft); border-left: 3px solid var(--danger);
    padding: .6rem .75rem; border-radius: var(--radius-sm); overflow-wrap: anywhere;
}

/* --- App tiles ------------------------------------------------------------- */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: .9rem;
    margin-bottom: 1.6rem;
}

.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .95rem 1rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    position: relative;
}
.tile:hover { box-shadow: var(--shadow-lg); border-color: var(--border-strong); }

.tile-head { display: flex; align-items: flex-start; gap: .7rem; }
.tile-mark {
    width: 38px; height: 38px; flex: 0 0 38px;
    display: grid; place-items: center;
    border-radius: 9px;
    color: #fff; font-weight: 700; font-size: 14px; letter-spacing: -.02em;
}
.tile-title { display: flex; flex-direction: column; min-width: 0; }
.tile-title a { color: var(--text); font-weight: 650; font-size: 14.5px; }
.tile-title a:hover { color: var(--brand); text-decoration: none; }
.tile-title small { color: var(--muted); line-height: 1.4; }

.tile-links { display: flex; flex-wrap: wrap; gap: .35rem; }
.tile-link {
    font-size: 11.5px; font-weight: 600;
    padding: .2rem .5rem;
    border: 1px solid var(--border); border-radius: 999px;
    color: var(--muted);
}
.tile-link:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.tile-link.is-primary { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.tile-foot {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: .55rem;
    display: grid;
    gap: .4rem;
}

/* --- One stored login, wherever it appears -------------------------------- */
.cred {
    display: flex; align-items: center; gap: .5rem;
    padding: .35rem .1rem;
    font-size: 12.5px;
}
.cred + .cred { border-top: 1px dashed var(--border); }
.cred-who { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.cred-user { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cred-label { color: var(--muted); font-size: 11px; }
.cred-actions { display: flex; gap: .25rem; flex: 0 0 auto; flex-wrap: wrap; }

/*
 * Inside a tile there is no room for the buttons beside the username: four of
 * them and an email address do not fit in 280px, and the row clipped rather
 * than wrapped. Stack them under it there, and keep the side-by-side layout
 * for the vault list, which has the whole width to play with.
 */
.tile .cred { flex-direction: column; align-items: stretch; gap: .35rem; }
.tile .cred-actions { justify-content: flex-start; }

.mini {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    border-radius: var(--radius-sm);
    font: 600 11.5px/1 var(--font);
    padding: .38rem .5rem;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: .3rem;
}
.mini:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.mini[disabled] { opacity: .5; cursor: not-allowed; }
.mini.is-done { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.mini svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* The revealed secret. Monospace because it will be read character by
   character, and selectable because it will also be dragged into a field. */
.secret {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    background: var(--warn-soft);
    border: 1px solid var(--warn);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: .3rem .45rem;
    word-break: break-all;
    user-select: all;
}
.secret-timer { font-size: 11px; color: var(--warn); font-weight: 600; }

/* --- Vault lock state ------------------------------------------------------ */
.lockbar {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: .55rem .8rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    margin-bottom: 1rem;
    font-size: 12.5px;
}
.lockbar.is-locked { border-color: var(--border-strong); background: var(--surface-2); }
.lockbar.is-open { border-color: var(--ok); background: var(--ok-soft); }
.lockbar strong { font-size: 13px; }
.lockbar .spacer { margin-left: auto; }
.lock-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* --- Access matrix --------------------------------------------------------- */
.matrix-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.matrix { border-collapse: separate; border-spacing: 0; font-size: 12.5px; min-width: 100%; }
.matrix th, .matrix td { padding: .4rem .55rem; border-bottom: 1px solid var(--border); text-align: center; }
.matrix thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--surface-2);
    font-size: 11px; font-weight: 700;
    white-space: nowrap;
    /* Column headers are app names, which are long and numerous; turning them
       keeps the grid readable without a horizontal scroll per app. */
    writing-mode: vertical-rl; transform: rotate(180deg);
    height: 11rem; vertical-align: bottom;
    /* A long app name still has to end somewhere; the full one is on the
       cell's title attribute. */
    max-height: 11rem; overflow: hidden; text-overflow: ellipsis;
}
.matrix tbody th {
    position: sticky; left: 0; z-index: 1;
    background: var(--surface);
    text-align: left; white-space: nowrap;
    border-right: 1px solid var(--border);
    font-weight: 600;
}
.matrix tbody tr:hover th, .matrix tbody tr:hover td { background: var(--surface-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--border-strong); }
.dot.is-use { background: var(--brand); }
.dot.is-manage { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.is-expired { background: var(--warn); }

/* A cell can carry three facts at once: the level, the environment when it is
   not both, and whether it came from a role. Stacked rather than spelled out,
   because the matrix's whole value is being readable at a glance. */
.cell-grant { display: inline-flex; align-items: center; gap: 2px; }
.env-flag {
    font-size: 8.5px; font-weight: 800; letter-spacing: .02em;
    color: var(--warn); line-height: 1;
}
.via-role { font-size: 6px; color: var(--muted); line-height: 1; align-self: flex-start; }

/* --- The launch page ------------------------------------------------------- */
.launching { text-align: center; padding: 4rem 1rem; }
.launching .spinner {
    width: 34px; height: 34px; margin: 0 auto 1rem;
    border: 3px solid var(--border); border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Token, shown exactly once --------------------------------------------- */
.token-box {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    background: var(--surface-2);
    border: 1px dashed var(--brand);
    border-radius: var(--radius-sm);
    padding: .6rem .7rem;
    word-break: break-all;
    user-select: all;
}

/* --- Strength meter -------------------------------------------------------- */
.strength { display: flex; gap: 3px; margin-top: .35rem; }
.strength span { height: 4px; flex: 1; border-radius: 2px; background: var(--border); }
.strength[data-score="1"] span:nth-child(-n+1) { background: var(--danger); }
.strength[data-score="2"] span:nth-child(-n+2) { background: var(--warn); }
.strength[data-score="3"] span:nth-child(-n+3) { background: var(--brand); }
.strength[data-score="4"] span { background: var(--ok); }

/* --- Small print ----------------------------------------------------------- */
.hint { color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; }
.section-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
    color: var(--muted); font-weight: 700; margin: 0 0 .5rem;
}

/* --- Detail header, with a mark ------------------------------------------- */
.detail-header {
    display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.detail-header h2 { font-size: 20px; }
.detail-header .push-right { display: flex; gap: .5rem; margin-left: auto; }
.detail-header p { margin: .1rem 0 0; }

dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }

/* --- Passkeys -------------------------------------------------------------- */
.login-or {
    display: flex; align-items: center; gap: .6rem;
    margin: .9rem 0 .7rem; color: var(--muted); font-size: 11.5px;
}
.login-or::before, .login-or::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

/* One line of feedback for a flow that happens in a browser dialog we cannot
   see. Without it a dismissed prompt is indistinguishable from a broken
   button. */
.tt-status {
    margin-top: .75rem;
    padding: .45rem .6rem;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
}
.tt-status.is-ok    { border-color: var(--ok);     background: var(--ok-soft);     color: var(--ok); }
.tt-status.is-error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.tt-status.is-warn  { border-color: var(--warn);   background: var(--warn-soft);   color: var(--warn); }

#passkey-add { padding-top: .75rem; }

.passkey-list { list-style: none; margin: .6rem 0 0; padding: 0; }
.passkey-list li {
    display: flex; align-items: center; gap: .5rem;
    padding: .45rem 0;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
}
.passkey-list li span { flex: 1; }
.passkey-list small { color: var(--muted); }
