@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
    /* Expert Group brand */
    --bg: #ffffff;            /* Brilliant White */
    --panel: #ffffff;         /* card / surface */
    --ink: #18222C;           /* Mirage — primary text */
    --muted: #808C9E;         /* Medium Gray 02 — captions, hints */
    --line: #DCE5F4;          /* Light Gray 02 — borders */
    --brand: #E63946;         /* Amaranth — primary action */
    --brand-dark: #BA202C;    /* Cardinal — hover/active */
    --sidebar: #283747;       /* Fiord — sidebar */
    --sidebar-ink: #CFD9EA;   /* Light Gray 01 — inactive sidebar text */
    --ok: #15803d;
    --bad: #BA202C;           /* Cardinal — aligned with brand */
    --warn: #b45309;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Manrope', 'Arial', 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

h1 { font-size: 1.55rem; margin: 0 0 1rem; font-weight: 700; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; font-weight: 700; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--sidebar);
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0;
}

.content { flex: 1; padding: 2rem 2.5rem; max-width: 1100px; }

.brand { padding: 0 1.5rem 1.5rem; }
.brand-logo { display: block; max-width: 160px; height: auto; }
.brand-sub { font-size: .75rem; color: var(--sidebar-ink); margin-top: .55rem; letter-spacing: .04em; text-transform: uppercase; opacity: .8; }

.nav { list-style: none; margin: 0; padding: 0; flex: 1; }
.nav-item {
    display: block;
    padding: .6rem 1.5rem;
    color: var(--sidebar-ink);
    border-left: 3px solid transparent;
}
.nav-item:hover { background: #1f2c39; text-decoration: none; color: #fff; }
.nav-item.active {
    background: #1f2c39;
    color: #fff;
    border-left-color: var(--brand);
    font-weight: 600;
}

.sidebar-foot { padding: 1rem 1.5rem 0; border-top: 1px solid #1f2c39; }
.signed-in-as {
    font-size: .82rem;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.signout { font-size: .82rem; color: #94a3b8; }

/* ---- Page chrome ---- */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.page-head h1, .page-head h2 { margin: 0; }
.page-intro { color: var(--muted); margin: -.5rem 0 1.25rem; }
.loading, .empty { color: var(--muted); padding: 1rem 0; }
.notice { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 2rem; }

.subsection { margin-top: 2.25rem; }

/* ---- Cards ---- */
.cards { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    min-width: 180px;
}
.card-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.card-value { font-size: 1.6rem; font-weight: 700; margin-top: .25rem; }
.card-value.ok { color: var(--ok); }
.card-value.bad { color: var(--bad); }
.card-sub { font-size: .8rem; font-weight: 400; color: var(--muted); margin-left: .4rem; }

.quick-links { display: flex; gap: .75rem; flex-wrap: wrap; }

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    border: 1px solid var(--brand);
    border-radius: 6px;
    padding: .5rem 1rem;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: #f4f7fc; color: var(--ink); border-color: #c5d2e8; }
.btn-link { background: none; border: none; color: var(--brand); padding: .5rem 0; font-weight: 600; }
.btn-link:hover { background: none; text-decoration: underline; }

/* ---- Tables ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}
.data-table th, .data-table td {
    text-align: left;
    padding: .65rem .9rem;
    border-bottom: 1px solid var(--line);
}
.data-table thead th {
    background: #f4f7fc;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.clickable:hover { background: #f4f7fc; }
.row-actions { text-align: right; }
.kv-table th { width: 200px; }

.mono { font-family: "Cascadia Mono", "Consolas", monospace; font-size: .85rem; }
.truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-ok { background: #dcfce7; color: var(--ok); }
.badge-bad { background: #fee2e2; color: var(--bad); }
.badge-muted { background: var(--line); color: var(--muted); }

.detail-row td { background: #f4f7fc; }
.detail { display: flex; flex-direction: column; gap: .4rem; padding: .25rem 0; }
.detail-label { font-weight: 600; color: var(--muted); margin-right: .4rem; }
.detail pre {
    background: var(--sidebar);
    color: var(--sidebar-ink);
    padding: .75rem;
    border-radius: 6px;
    overflow-x: auto;
    font-size: .8rem;
    margin: .15rem 0 .5rem;
}

/* ---- Forms ---- */
.form { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1.5rem; max-width: 560px; }
.field { margin-bottom: 1rem; }
.field > label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .88rem; }
.field-hint { display: block; margin-top: .35rem; color: var(--muted); font-size: .78rem; }
.readonly-value { padding: .5rem 0; color: var(--muted); }
.input {
    width: 100%;
    padding: .5rem .65rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: .9rem;
    background: #fff;
    color: var(--ink);
    font-family: inherit;
}
.input:focus { outline: 2px solid #fbcfd2; border-color: var(--brand); }
.form-actions { display: flex; gap: .75rem; margin-top: 1.25rem; }
.validation-message { color: var(--bad); font-size: .82rem; display: block; margin-top: .25rem; }

.filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}
.filters .field { margin-bottom: 0; }
.filters .input { min-width: 170px; }
.field-actions { display: flex; align-items: flex-end; }

/* ---- Alerts ---- */
.alert { border-radius: 8px; padding: .85rem 1rem; margin-bottom: 1.25rem; }
.alert-error { background: #fee2e2; border: 1px solid #fecaca; color: var(--bad); }
.alert-ok { background: #dcfce7; border: 1px solid #bbf7d0; color: var(--ok); }
.alert-key { background: #fef9c3; border: 1px solid #fde68a; color: var(--warn); }
.key-box {
    margin-top: .6rem;
    font-size: .9rem;
    background: #fff;
    color: var(--ink);
}

/* ---- Pager ---- */
.pager { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.pager-info { color: var(--muted); font-size: .85rem; }

/* ---- Setup page (anonymous /setup/{token}) ---- */
.setup-wrap {
    max-width: 480px;
    margin: 3.5rem auto;
    padding: 0 1.5rem;
}
.setup-logo {
    display: block;
    height: 40px;
    width: auto;
    margin: 0 auto 2rem;
}
