:root {
    --bg: #0b0e12;
    --surface: #131820;
    --surface-raised: #191f28;
    --line: #2a323e;
    --text: #f4f6f8;
    --muted: #9ca8b7;
    --accent: #69BE3F;
    --accent-dark: #4d982b;
    --good: #67d69b;
    --warning: #f1c65b;
    --danger: #ff7a7a;
    --radius: 16px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
    font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 20% -10%, rgba(105, 190, 63, .14), transparent 33rem),
        var(--bg);
    color: var(--text);
}

a { color: inherit; }

button, input { font: inherit; }

.skip-link {
    position: fixed;
    top: .5rem;
    left: .5rem;
    z-index: 10;
    transform: translateY(-160%);
    padding: .65rem .9rem;
    background: var(--text);
    color: var(--bg);
    border-radius: 8px;
}

.skip-link:focus { transform: translateY(0); }

.topbar {
    min-height: 68px;
    padding: 0 clamp(1rem, 4vw, 3rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    background: rgba(11, 14, 18, .88);
    backdrop-filter: blur(16px);
}

.wordmark {
    text-decoration: none;
    font-weight: 850;
    letter-spacing: -.04em;
    font-size: 1.25rem;
}

.wordmark span { color: var(--accent); font-weight: 600; }

.account-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--muted);
    font-size: .9rem;
}

.account-menu a, .link-button {
    color: var(--muted);
    text-decoration: none;
}

.account-menu a:hover, .link-button:hover { color: var(--text); }
.account-menu form { margin: 0; }
.account-name { color: var(--text); }

.link-button {
    appearance: none;
    border: 0;
    background: none;
    padding: 0;
    cursor: pointer;
}

.page-shell {
    width: min(100% - 2rem, 1040px);
    margin: 0 auto;
    padding: clamp(2rem, 6vw, 4.5rem) 0;
}

.page-shell.wide { width: min(100% - 2rem, 1320px); }

.page-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 2rem;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .5rem; font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -.045em; line-height: 1; }
h2 { margin-bottom: 0; font-size: 1.35rem; letter-spacing: -.025em; }

.eyebrow {
    margin-bottom: .55rem;
    color: var(--accent);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.muted { color: var(--muted); line-height: 1.55; }
.refresh-state { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.refresh-error { color: var(--danger); }

.door-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.bulk-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
}

.bulk-actions {
    margin-bottom: 1rem;
    padding: 1rem 1.15rem;
    border: 1px solid rgba(105,190,63,.28);
    border-radius: var(--radius);
    background: rgba(105,190,63,.07);
}

.section-label { margin: 0 0 .3rem; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.compact { margin-bottom: 0; font-size: .9rem; }
.button-row { display: flex; gap: .7rem; }

.door-card, .empty-state {
    padding: 1.35rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(255,255,255,.025), transparent 60%), var(--surface);
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
}

.empty-state { grid-column: 1 / -1; text-align: center; padding: 3.5rem 1.5rem; }

.door-card-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.door-kicker { margin-bottom: .3rem; color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .6rem;
    border: 1px solid;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 750;
}

.badge::before { content: ''; width: .42rem; height: .42rem; border-radius: 50%; background: currentColor; }
.badge-online { color: var(--good); border-color: rgba(103,214,155,.3); background: rgba(103,214,155,.07); }
.badge-offline { color: var(--danger); border-color: rgba(255,122,122,.3); background: rgba(255,122,122,.07); }

.status-rows { margin: 1.35rem 0; border-top: 1px solid var(--line); }
.status-row { display: flex; align-items: center; justify-content: space-between; padding: .72rem 0; border-bottom: 1px solid var(--line); }
.status-label { color: var(--muted); font-size: .88rem; }
.status-value { font-weight: 700; font-size: .9rem; }
.status-value.normal { color: var(--good); }
.status-value.warning { color: var(--warning); }
.status-value.danger { color: var(--danger); }

.door-card-footer { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: .72rem 1rem;
    border: 1px solid transparent;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 760;
    cursor: pointer;
}

.button-primary { background: var(--accent); color: #071004; }
.button-primary:hover { background: #7bce52; }
.button-secondary { color: var(--text); border-color: var(--line); background: var(--surface-raised); }
.button-secondary:hover { border-color: #465161; background: #202833; }
.button-danger { color: #fff; background: #b33d43; }
.button-danger:hover { background: #ca484f; }
.button-disabled { background: var(--surface-raised); color: #74808e; border-color: var(--line); cursor: not-allowed; }

.control-dialog { width: min(100% - 2rem, 560px); padding: 0; border: 1px solid var(--line); border-radius: 20px; color: var(--text); background: var(--surface); box-shadow: 0 30px 100px rgba(0,0,0,.6); }
.control-dialog::backdrop { background: rgba(3,5,8,.78); backdrop-filter: blur(4px); }
.dialog-card { padding: 1.4rem; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.icon-button { width: 2.2rem; height: 2.2rem; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: transparent; font-size: 1.4rem; cursor: pointer; }
.duration-options { display: grid; grid-template-columns: repeat(5, 1fr); gap: .55rem; margin: 1.4rem 0; padding: 0; border: 0; }
.duration-options legend { margin-bottom: .6rem; font-size: .82rem; font-weight: 700; }
.duration-options input { position: absolute; opacity: 0; pointer-events: none; }
.duration-options span { display: grid; min-height: 48px; place-items: center; padding: .55rem; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: var(--surface-raised); font-size: .8rem; font-weight: 700; cursor: pointer; }
.duration-options input:checked + span { border-color: var(--accent); color: var(--text); background: rgba(105,190,63,.13); box-shadow: 0 0 0 2px rgba(105,190,63,.12); }
.custom-duration { margin: -.4rem 0 1.2rem; }
.custom-duration > label { display: block; margin-bottom: .45rem; font-size: .82rem; font-weight: 700; }
.duration-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.duration-inputs input, .duration-inputs select { width: 100%; padding: .75rem; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: #0d1117; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .7rem; margin-top: 1.4rem; }
.toast { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 20; max-width: min(420px, calc(100% - 2.5rem)); padding: .9rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-raised); box-shadow: 0 15px 50px rgba(0,0,0,.4); }
.toast-error { border-color: rgba(255,122,122,.35); }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: min(100%, 420px); padding: clamp(1.5rem, 6vw, 2.5rem); border: 1px solid var(--line); border-radius: 20px; background: rgba(19,24,32,.94); box-shadow: 0 30px 90px rgba(0,0,0,.36); }
.auth-card h1 { font-size: 2.2rem; }
.brand-mark { width: 3rem; height: 3rem; display: grid; place-items: center; margin-bottom: 1.5rem; border-radius: 12px; background: var(--accent); color: #171105; font-weight: 900; letter-spacing: -.08em; }

.stacked-form { display: grid; gap: 1rem; margin-top: 1.5rem; }
.stacked-form label { display: grid; gap: .45rem; font-size: .86rem; font-weight: 650; }
.stacked-form input { width: 100%; padding: .8rem .85rem; border: 1px solid var(--line); border-radius: 10px; outline: none; background: #0d1117; color: var(--text); }
.stacked-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(105,190,63,.12); }

.alert { margin: 1.25rem 0; padding: .85rem 1rem; border-radius: 10px; line-height: 1.4; }
.alert-error { color: #ffd4d4; border: 1px solid rgba(255,122,122,.28); background: rgba(255,122,122,.08); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
code { color: #c3cbd6; font-size: .75rem; }
.outcome { font-weight: 750; text-transform: capitalize; }
.outcome-succeeded, .outcome-observed { color: var(--good); }
.outcome-denied, .outcome-failed { color: var(--danger); }
.empty-table { padding: 3rem; text-align: center; color: var(--muted); }

.skeleton { border-radius: 8px; background: linear-gradient(90deg, #1d242d 25%, #252e39 50%, #1d242d 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
.skeleton-title { width: 50%; height: 1.4rem; margin-bottom: 2rem; }
.skeleton-line { height: 1rem; margin: .8rem 0; }
.skeleton-line.short { width: 68%; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 680px) {
    .door-grid { grid-template-columns: 1fr; }
    .page-heading { align-items: start; flex-direction: column; gap: .8rem; }
    .topbar { align-items: flex-start; padding-top: 1rem; padding-bottom: 1rem; }
    .account-menu { align-items: flex-end; flex-direction: column; gap: .45rem; }
    .account-name { display: none; }
    .bulk-actions { align-items: stretch; flex-direction: column; }
    .button-row { display: grid; grid-template-columns: 1fr 1fr; }
    .duration-options { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
