:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #17202b;
  --muted: #5d6877;
  --line: #dce1e8;
  --accent: #087f5b;
  --accent-strong: #06694b;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success-bg: #eaf8f2;
  --radius: 12px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: inherit; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:active, .button:active { transform: translateY(1px); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 38%, transparent); outline-offset: 2px; }

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 10; transform: translateY(-150%); background: var(--surface); padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { transform: none; }
.app-shell { min-height: 100dvh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; padding: 24px 16px; background: #18231f; color: #e8f2ee; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; font-weight: 760; letter-spacing: -.02em; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; background: #28a77c; color: #10231c; font-weight: 850; }
.nav { display: grid; gap: 3px; margin-top: 34px; }
.nav a { padding: 10px 12px; border-radius: 8px; color: #afbeb8; text-decoration: none; transition: background-color .15s ease, color .15s ease; }
.nav a:hover { color: #f5faf8; background: #24332e; }
.nav a.active { color: #ffffff; background: #2c3e37; box-shadow: inset 3px 0 #35ba8b; }
.sidebar-footer { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid #34443e; }
.account-email { display: block; overflow: hidden; margin-bottom: 7px; color: #c7d2ce; font-size: 13px; text-overflow: ellipsis; }
.text-button { padding: 0; border: 0; background: none; color: #91a39c; }
.text-button:hover { color: white; }
.main { min-width: 0; width: 100%; max-width: 1500px; padding: 38px clamp(22px, 4vw, 64px) 72px; }
.page-header { margin-bottom: 28px; }
.page-header h1 { margin: 0; font-size: clamp(28px, 3vw, 40px); line-height: 1.15; letter-spacing: -.035em; }
.page-header p, .section-heading p, .lede { margin: 8px 0 0; color: var(--muted); }
.section-block { margin-top: 22px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.section-heading { margin-bottom: 20px; }
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.section-heading p { max-width: 70ch; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric { min-height: 126px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; justify-content: space-between; }
.metric span { color: var(--muted); }
.metric strong { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 28px; letter-spacing: -.04em; }
.status-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--line); }
.status-list > div { padding: 16px; background: var(--surface); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.state { display: inline-flex; width: fit-content; padding: 4px 8px; border-radius: 7px; font-size: 12px; font-weight: 750; white-space: nowrap; }
.state.good { color: #086445; background: var(--success-bg); }
.state.bad { color: #a02016; background: var(--danger-bg); }

label { display: grid; gap: 7px; color: #394453; font-size: 13px; font-weight: 680; }
input, select { min-width: 0; width: 100%; min-height: 42px; padding: 9px 11px; color: var(--text); border: 1px solid #bdc5d0; border-radius: 8px; background: var(--surface); }
input::placeholder { color: #778292; }
input:focus, select:focus { border-color: var(--accent); outline: 3px solid color-mix(in srgb, var(--accent) 20%, transparent); }
.check { display: flex; align-items: center; align-self: end; min-height: 42px; gap: 8px; white-space: nowrap; }
.check input { width: 18px; min-height: 18px; accent-color: var(--accent); }
.inline-create { display: grid; grid-template-columns: .7fr 1.4fr 1fr 1fr auto auto; align-items: end; gap: 10px; padding: 16px; border-radius: 9px; background: var(--surface-2); }
.endpoint-create { grid-template-columns: 2fr 1fr auto auto; }
.admin-create { grid-template-columns: 1fr 1fr auto; }
.records { display: grid; gap: 8px; margin-top: 14px; }
.record { display: grid; grid-template-columns: .7fr 1.4fr 1fr 1fr auto auto; align-items: end; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.record:last-child { border-bottom: 0; }
.endpoint-record { grid-template-columns: 2fr 1fr auto auto auto; }
.record-actions, .actions { display: flex; align-items: center; gap: 7px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 13px; border: 1px solid transparent; border-radius: 8px; font-weight: 740; text-decoration: none; cursor: pointer; white-space: nowrap; }
.button.primary { color: #ffffff; background: var(--accent); }
.button.primary:hover { background: var(--accent-strong); }
.button.secondary { color: var(--text); border-color: #b9c2cd; background: var(--surface); }
.button.secondary:hover { border-color: #7e8997; }
.button.danger { color: var(--danger); border-color: #efb7b2; background: var(--danger-bg); }
.button.danger:hover { border-color: #d68f88; }
.notice { margin: 0 0 18px; padding: 12px 14px; border-radius: 8px; font-weight: 620; }
.notice.success { color: #075d41; border: 1px solid #9dd8c1; background: var(--success-bg); }
.notice.error { color: #922018; border: 1px solid #efb7b2; background: var(--danger-bg); }
.empty { padding: 28px; border-radius: 9px; color: var(--muted); background: var(--surface-2); text-align: center; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 760; }
tbody tr:last-child td { border-bottom: 0; }
.number, code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
code { font-size: 12px; }
.wrap { overflow-wrap: anywhere; word-break: break-word; }

.public-page { min-height: 100dvh; background: #18231f; }
.auth-shell { min-height: 100dvh; padding: 24px; display: grid; place-items: center; }
.auth-panel { width: min(100%, 470px); padding: clamp(26px, 5vw, 44px); border-radius: 16px; background: var(--surface); box-shadow: 0 24px 70px rgb(4 18 13 / .28); }
.auth-brand { margin-bottom: 52px; color: var(--text); }
.auth-panel h1 { margin: 4px 0 0; font-size: 36px; line-height: 1.1; letter-spacing: -.04em; }
.eyebrow { margin: 0 0 10px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.stack-form { display: grid; gap: 17px; margin-top: 28px; }
.stack-form .button { margin-top: 4px; }
.secret-block { display: grid; gap: 6px; margin: 24px 0; padding: 16px; border-radius: 9px; background: var(--surface-2); }
.secret-block dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.secret-block dd { margin: 0 0 10px; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-create, .record { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-actions { align-self: end; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 16px; }
  .nav { display: flex; gap: 4px; margin-top: 18px; overflow-x: auto; padding-bottom: 4px; }
  .nav a { flex: 0 0 auto; }
  .sidebar-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
  .account-email { margin: 0; }
  .main { padding: 28px 16px 52px; }
  .metric-grid, .status-list, .inline-create, .record { grid-template-columns: 1fr; }
  .section-block { padding: 18px; }
  .record { padding: 18px 0; }
  .record-actions .button { flex: 1; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101614;
    --surface: #18201d;
    --surface-2: #202a26;
    --text: #edf4f1;
    --muted: #a5b2ad;
    --line: #33413c;
    --accent: #3fbd8e;
    --accent-strong: #56c99d;
    --danger: #ff9b92;
    --danger-bg: #38201e;
    --success-bg: #17392d;
  }
  input, select { border-color: #52605b; }
  .button.primary { color: #092018; }
  .button.secondary { border-color: #5c6a65; }
  .state.good, .notice.success { color: #92e0c1; }
  .state.bad, .notice.error { color: #ffaaa3; }
  .auth-panel { box-shadow: 0 24px 70px rgb(0 0 0 / .38); }
}

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