:root {
    color-scheme: dark;
    --bg: #07110f;
    --surface: #0d1a17;
    --surface-2: #12231f;
    --line: #284139;
    --text: #edf7f2;
    --muted: #94aaa1;
    --accent: #52e0a4;
    --accent-strong: #20bd7c;
    --danger: #ff736d;
    --warning: #f2c66d;
    --radius: 14px;
    --shadow: 0 18px 55px rgba(0, 0, 0, .34);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 8% -10%, rgba(42, 191, 132, .15), transparent 34rem),
        linear-gradient(180deg, #091512 0, var(--bg) 28rem);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .25rem; font-size: clamp(1.55rem, 3vw, 2.1rem); letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 1.15rem; letter-spacing: -.015em; }
.eyebrow { margin-bottom: .3rem; color: var(--accent); font: 700 .7rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .17em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 1.25rem clamp(1rem, 4vw, 3.5rem);
    border-bottom: 1px solid rgba(82, 224, 164, .14);
    background: rgba(7, 17, 15, .86);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar h1 { margin: 0; }
.session-box { display: flex; align-items: center; gap: 1rem; font-size: .88rem; }
.session-box .muted { font-size: .78rem; }

.dashboard { width: min(1440px, calc(100% - 2rem)); margin: 1.5rem auto 3rem; display: grid; gap: 1.15rem; }
.panel {
    padding: clamp(1rem, 2.5vw, 1.5rem);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(155deg, rgba(18, 35, 31, .95), rgba(11, 25, 21, .95));
    box-shadow: 0 9px 30px rgba(0, 0, 0, .15);
}
.controls-panel { border-color: rgba(82, 224, 164, .35); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading > p { margin: 0; text-align: right; font-size: .84rem; }

label { display: grid; gap: .45rem; color: #bed1c9; font-size: .82rem; font-weight: 650; }
input, select {
    min-height: 42px;
    width: 100%;
    padding: .68rem .8rem;
    color: var(--text);
    border: 1px solid #36564c;
    border-radius: 9px;
    outline: none;
    background: #081410;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(82, 224, 164, .13); }
input::placeholder { color: #637a71; }

.inline-form { display: flex; align-items: end; gap: .75rem; }
.inline-form label { min-width: 150px; }
.inline-form.compact label { min-width: 130px; }
.lookup-form { max-width: 760px; }
.input-action { display: grid; grid-template-columns: 1fr auto; gap: .65rem; }
.action-grid { display: grid; grid-template-columns: minmax(240px, 1.25fr) minmax(130px, .55fr) minmax(120px, .45fr) minmax(260px, 1.3fr) auto; align-items: end; gap: .75rem; }
.reason-field { grid-column: auto; }

.button {
    min-height: 42px;
    padding: .68rem 1rem;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--text);
    background: var(--surface-2);
    font-weight: 750;
    white-space: nowrap;
    transition: transform .12s, border-color .12s, background .12s;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible { outline: 3px solid rgba(82, 224, 164, .35); outline-offset: 2px; }
.button-primary { color: #032117; background: var(--accent); }
.button-primary:hover { background: #70ebba; }
.button-secondary { border-color: #40685b; }
.button-secondary:hover, .button-quiet:hover { border-color: var(--accent); background: #163129; }
.button-danger { color: #fff; border-color: rgba(255, 115, 109, .45); background: #6b2828; }
.button-danger:hover { background: #87312f; }
.button-quiet { min-height: 34px; padding: .45rem .7rem; border-color: #314d44; background: transparent; }
.button-block { width: 100%; }
.button-small { min-height: 30px; padding: .35rem .58rem; font-size: .76rem; }

.alert { padding: .82rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: #10251f; }
.alert-error { color: #ffd0cc; border-color: #713b39; background: #311b1a; }
.alert-success { color: #c6ffe5; border-color: #276447; }

.secret-result { margin-top: 1rem; padding: 1rem; border: 1px dashed var(--warning); border-radius: 10px; background: #211e12; }
.result-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--warning); }
pre { margin: .8rem 0 0; color: #fff1bf; font: 600 .86rem/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.lookup-result { margin-top: 1rem; display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: .65rem; }
.lookup-item { padding: .75rem; border: 1px solid var(--line); border-radius: 9px; background: #091612; }
.lookup-item span { display: block; margin-bottom: .2rem; color: var(--muted); font-size: .72rem; }
.lookup-item strong { font: 600 .82rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th, td { padding: .72rem .68rem; border-bottom: 1px solid rgba(53, 84, 74, .62); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
tbody tr:hover { background: rgba(82, 224, 164, .035); }
td code { color: #bfe9d8; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.empty { padding: 2rem; color: var(--muted); text-align: center; }
.row-actions { display: flex; gap: .4rem; }
.status { display: inline-block; padding: .25rem .48rem; border: 1px solid var(--line); border-radius: 999px; font-size: .7rem; font-weight: 750; }
.status-active { color: #aaf5d1; border-color: #2b7453; }
.status-pending { color: #ffe3a4; border-color: #765f2f; }
.status-disabled, .status-expired { color: #b6c1bc; border-color: #53615b; }
.status-revoked { color: #ffb3ae; border-color: #7c3b3a; }

footer { padding: 1.5rem; color: #61776e; text-align: center; font-size: .75rem; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 1rem; }
.login-card { width: min(430px, 100%); padding: clamp(1.6rem, 5vw, 2.35rem); border: 1px solid rgba(82, 224, 164, .3); border-radius: 18px; background: rgba(13, 26, 23, .95); box-shadow: var(--shadow); }
.brand-mark { display: grid; width: 48px; height: 48px; margin-bottom: 1.35rem; place-items: center; border: 1px solid var(--accent); border-radius: 12px; color: var(--accent); font: 800 .88rem ui-monospace, monospace; }
.login-card > .muted { margin-bottom: 1.5rem; font-size: .9rem; }
.stack { display: grid; gap: 1rem; }
.security-note { margin: 1.15rem 0 0; color: #6f857c; text-align: center; font-size: .75rem; }

@media (max-width: 1050px) {
    .action-grid { grid-template-columns: 1fr 1fr; }
    .reason-field { grid-column: 1 / -1; }
    .action-grid .button { justify-self: start; }
    .lookup-result { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
    .topbar { position: static; align-items: flex-start; }
    .session-box { align-items: flex-end; flex-direction: column; gap: .45rem; text-align: right; }
    .session-box .muted { display: none; }
    .dashboard { width: min(100% - 1rem, 1440px); margin-top: .5rem; }
    .section-heading, .responsive-heading { align-items: flex-start; flex-direction: column; }
    .section-heading > p { text-align: left; }
    .inline-form, .inline-form.compact { align-items: stretch; flex-direction: column; }
    .inline-form label, .inline-form.compact label { min-width: 0; }
    .input-action { grid-template-columns: 1fr; }
    .action-grid { grid-template-columns: 1fr; }
    .reason-field { grid-column: auto; }
    .action-grid .button { width: 100%; }
    .lookup-result { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
