:root {
  color-scheme: dark;
  --bg: #0f1417;
  --sidebar: #151c20;
  --surface: #1b2429;
  --surface-raised: #202b31;
  --surface-soft: #182126;
  --border: #2c393f;
  --border-strong: #3b4b53;
  --text: #edf3f3;
  --muted: #91a1a7;
  --accent: #45d3b0;
  --accent-strong: #299f84;
  --accent-soft: rgba(69, 211, 176, .12);
  --amber: #efb56f;
  --danger: #e78287;
  --danger-soft: #40272b;
  --ok-soft: #1d493d;
  --shadow: 0 14px 38px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #84e8cf; }
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.8rem; letter-spacing: 0; }
h2 { font-size: 1.1rem; letter-spacing: 0; }
p { margin-top: 0; }

.app-layout { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; width: 248px; display: flex; flex-direction: column; justify-content: space-between; padding: 24px 16px 16px; background: var(--sidebar); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .75rem; min-height: 40px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-mark { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border: 1px solid var(--accent); border-radius: 8px; color: var(--accent); font-size: .78rem; font-weight: 800; letter-spacing: .08em; }
.brand-copy { display: grid; gap: .05rem; }
.brand-copy strong { font-size: .98rem; }
.brand-copy small { color: var(--muted); font-size: .7rem; }
.sidebar-label { margin: 2rem .7rem .65rem; color: #6f8087; font-size: .67rem; font-weight: 800; letter-spacing: .12em; }
.sidebar-nav { display: grid; gap: .25rem; }
.nav-link { display: grid; grid-template-columns: 30px 1fr; align-items: center; min-height: 42px; padding: .55rem .7rem .55rem .55rem; border: 1px solid transparent; border-left: 3px solid transparent; border-radius: 6px; color: #b6c3c6; font-weight: 600; }
.nav-link:hover { background: var(--surface-soft); color: var(--text); }
.nav-link.active { background: var(--accent-soft); border-color: rgba(69, 211, 176, .2); border-left-color: var(--accent); color: var(--text); }
.nav-index { color: #65777d; font: 700 .68rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.nav-link.active .nav-index { color: var(--accent); }
.sidebar-footer { display: grid; gap: .9rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.service-status { display: flex; align-items: center; gap: .6rem; padding: .7rem .75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-soft); }
.service-status > span:last-child { display: grid; gap: .05rem; }
.service-status small { color: var(--muted); font-size: .7rem; }
.service-status strong { font-size: .84rem; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(69, 211, 176, .1); }
.logout-button { width: 100%; justify-content: flex-start; gap: .5rem; border-color: transparent; background: transparent; color: var(--muted); }
.logout-button:hover { background: var(--surface-soft); color: var(--text); }
.app-main { width: 100%; min-height: 100vh; margin-left: 248px; }

.container { width: min(1380px, calc(100% - 64px)); margin: 0 auto; padding: 40px 0 72px; }
.container.narrow { width: min(440px, calc(100% - 32px)); padding-top: 10vh; }
.page-head, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.15rem; }
.page-head > div:first-child { min-width: 0; }
.page-head p { max-width: 760px; margin: .45rem 0 0; }
.section-head { margin-bottom: .8rem; }
.card { margin-bottom: 1.1rem; padding: 1.15rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.login-card { padding: 1.8rem; }
.login-card h1 { margin-bottom: .35rem; }
.muted, small { color: var(--muted); }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; margin: 0 0 1.2rem; }
.metric { min-height: 112px; padding: 1rem 1.05rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.metric span { display: block; color: var(--muted); font-size: .82rem; }
.metric strong { display: block; margin-top: .35rem; color: var(--text); font-size: 1.9rem; font-weight: 750; }
.stack { display: grid; gap: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

label { display: grid; gap: .4rem; font-weight: 650; }
input, select, textarea, button, .button { font: inherit; }
input, select, textarea { width: 100%; padding: .67rem .75rem; border: 1px solid var(--border-strong); border-radius: 6px; background: #12191d; color: var(--text); }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #6f8087; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type="checkbox"] { accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: .45rem; font-weight: 500; }
.check input { width: auto; }

button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: .52rem .78rem; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-raised); color: var(--text); cursor: pointer; font-weight: 650; line-height: 1.2; white-space: nowrap; }
button:hover, .button:hover { border-color: #5a6d75; background: #29373e; color: var(--text); }
button:focus-visible, .button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { border-color: var(--accent-strong); background: var(--accent); color: #071411; }
.primary:hover { border-color: var(--accent); background: #75e4c8; color: #071411; }
.danger { border-color: #744349; background: var(--danger-soft); color: #ffbfc1; }
.danger:hover { border-color: var(--danger); background: #533036; color: #ffe2e3; }
.link-button { min-height: 32px; padding: .25rem .35rem; border: 0; background: transparent; }

.notice, .error { margin-bottom: 1rem; padding: .75rem .9rem; border-radius: 6px; }
.notice { border: 1px solid #2f705f; background: var(--ok-soft); color: #b7f2df; }
.error { border: 1px solid #82454b; background: var(--danger-soft); color: #ffd1d2; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 7px; }
table { width: 100%; min-width: 680px; border-collapse: collapse; }
th, td { padding: .78rem .85rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .025); }
th { color: var(--muted); font-size: .72rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
td { color: #d9e2e3; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.actions form { display: flex; flex-wrap: wrap; gap: .4rem; }
.minutes { width: 76px; }
.pill { display: inline-block; padding: .2rem .52rem; border-radius: 999px; background: #2b3940; color: #c9d6d8; font-size: .78rem; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: #a9f1d8; }
.pill.off { background: #3a2b30; color: #d7afb3; }
.inline-form { display: grid; grid-template-columns: 2fr 1fr 110px auto auto; gap: .65rem; align-items: end; }
code { color: #a6e8d5; font: .9em ui-monospace, SFMono-Regular, Consolas, monospace; }

/* Account setup keeps the form dense while separating the choices that matter. */
.account-form { max-width: 1080px; }
.form-section { min-width: 0; margin: 0; padding: 1.15rem 0; border: 0; border-top: 1px solid var(--border); }
.form-section:first-of-type { padding-top: .15rem; border-top: 0; }
.form-section legend { display: flex; align-items: center; gap: .65rem; width: 100%; margin-bottom: .55rem; padding: 0; color: var(--text); font-size: 1.08rem; font-weight: 750; }
.step-number { display: inline-grid; width: 28px; height: 28px; place-items: center; border: 1px solid var(--accent-strong); border-radius: 6px; color: var(--accent); font: 700 .7rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.section-help { max-width: 820px; margin: 0 0 1rem; color: var(--muted); font-size: .88rem; }
.field-note { min-height: 1.3em; font-weight: 500; }
.account-enabled { align-content: start; padding-top: 2rem; }
.account-enabled small { margin-left: 1.35rem; font-weight: 500; }
.provider-panel[hidden] { display: none; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .55rem; }
.section-heading h2 { margin: 0; }
.mode-tag { padding: .2rem .48rem; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--accent); font-size: .7rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.advanced-section { padding-bottom: .35rem; }
.advanced-section summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; list-style: none; color: var(--text); font-size: 1.08rem; font-weight: 750; }
.advanced-section summary::-webkit-details-marker { display: none; }
.advanced-section summary::after { content: '+'; color: var(--accent); font-size: 1.3rem; font-weight: 400; }
.advanced-section[open] summary::after { content: '−'; }
.advanced-section summary small { margin-left: auto; font-size: .8rem; font-weight: 500; }
.advanced-content { padding-top: 1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; padding-top: .3rem; border-top: 1px solid var(--border); }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-form button, .inline-form .check { align-self: center; }
}

@media (max-width: 900px) {
  .app-layout { display: block; }
  .sidebar { position: static; width: 100%; min-height: 0; padding: 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-main { display: grid; gap: 1rem; }
  .sidebar-label { display: none; }
  .sidebar-nav { display: flex; overflow-x: auto; gap: .3rem; padding-bottom: 1px; }
  .nav-link { min-width: max-content; grid-template-columns: 25px auto; border-left: 1px solid transparent; border-bottom: 3px solid transparent; }
  .nav-link.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  .sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; padding-top: .85rem; }
  .logout-button { width: auto; }
  .app-main { margin-left: 0; }
  .container { width: min(100% - 32px, 1380px); padding: 28px 0 56px; }
}

@media (max-width: 560px) {
  h1 { font-size: 1.55rem; }
  .page-head, .section-head { align-items: flex-start; flex-direction: column; }
  .page-head .button, .page-head > .button { width: 100%; }
  .metrics, .grid.two, .inline-form { grid-template-columns: 1fr; }
  .card { padding: .9rem; }
  .login-card { padding: 1.25rem; }
  .account-enabled { padding-top: 0; }
  .advanced-section summary { align-items: flex-start; }
  .advanced-section summary small { display: none; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button, .form-actions button { width: 100%; }
  .actions { min-width: 0; }
  .actions form { width: 100%; }
}
