:root {
  --bg: #14120f;
  --fg: #f4f2ed;
  --muted: #aca498;
  --label: #cec6b6;
  --line: #3c3730;
  --paper: #1c1a16;
  --paper-head: rgba(0, 0, 0, 0.2);
  --paper-hover: #211e18;
  --danger: #d17b64;
  --danger-line: #6b3a2e;
  --danger-bg: rgba(209, 123, 100, 0.08);
  --up: #b9c99f;
  --up-bg: rgba(185, 201, 159, 0.1);
  --focus: #f4f2ed;
  --mono: "Cascadia Code", "Cascadia Mono", Consolas, "Segoe UI Mono", ui-monospace, monospace;
  --sans: "Segoe UI Variable Text", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--fg); text-underline-offset: 2px; }
a:hover { text-decoration: underline; }

code {
  font-family: var(--mono);
  font-size: 0.87em;
  color: #d7d1c3;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- header / nav ---------- */

.top {
  display: flex;
  align-items: stretch;
  gap: 28px;
  padding: 0 24px;
  height: 56px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }

.logo {
  display: flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  color: var(--fg);
}
.logo:hover { text-decoration: none; }

.tag {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  align-self: center;
}

.top nav { display: flex; align-items: stretch; gap: 24px; }
.top nav a {
  display: flex;
  align-items: center;
  height: 100%;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  border-bottom: 2px solid transparent;
}
.top nav a:hover { color: var(--fg); text-decoration: none; }
.top nav a[aria-current="page"] {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

.who {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
.user { font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* ---------- page shell ---------- */

.wrap { width: min(1080px, calc(100% - 48px)); margin: 36px auto 80px; }

.pagehead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 28px;
}
.pagehead h1 { margin: 0 0 4px; }
.pagehead .lede { margin: 0; }

h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }

.lede { color: var(--muted); font-size: 14px; max-width: 60ch; }

.crumb { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--fg); }

/* ---------- sections (the core "settings card" building block) ---------- */

.section {
  border: 1px solid var(--line);
  background: var(--paper);
  margin: 0 0 24px;
}

.section-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-head);
}
.section-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: normal;
  text-transform: none;
}
.section-header p {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--muted);
  max-width: 62ch;
}

.section-body { padding: 20px; }
.section-body.flush { padding: 0; }

.section-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--paper-head);
}

.section-footer.standalone { border: 1px solid var(--line); margin-bottom: 24px; }

.section.danger { border-color: var(--danger-line); background: var(--danger-bg); }
.section.danger .section-header {
  border-bottom-color: var(--danger-line);
  background: rgba(209, 123, 100, 0.1);
}
.section.danger .section-header h2 { color: var(--danger); }

/* standalone heading used above a section, e.g. group label outside cards */
h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg);
  font: 13.5px/1 var(--sans);
  cursor: pointer;
  text-decoration: none;
  border-radius: 0;
  white-space: nowrap;
}
.btn:hover { background: var(--paper-hover); text-decoration: none; }

.btn-lg { min-height: 42px; padding: 0 20px; font-size: 14.5px; }

.btn-solid {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
  font-weight: 600;
}
.btn-solid:hover { background: #fff; }

.btn-danger {
  color: var(--danger);
  border-color: var(--danger-line);
  background: rgba(209, 123, 100, 0.06);
}
.btn-danger:hover { background: rgba(209, 123, 100, 0.14); }

.inline { display: inline; margin: 0; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- tables ---------- */

.tablewrap { overflow-x: auto; }
.sheet { width: 100%; border-collapse: collapse; }
.sheet th,
.sheet td {
  text-align: left;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.sheet thead th {
  font: 600 12px/1 var(--sans);
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--paper-head);
  border-bottom: 1px solid var(--line);
}
.sheet tbody tr:hover td { background: var(--paper-hover); }
.sheet tbody tr:last-child td { border-bottom: 0; }
.sheet .name { font-weight: 600; text-decoration: none; font-size: 14.5px; }
.sheet .name:hover { text-decoration: underline; }
.sheet td code { font-size: 13px; }

.sub { color: var(--muted); font-size: 13px; margin: 3px 0 0; }
.end { text-align: right; white-space: nowrap; }

.st {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
}
.st::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}
.st.up { color: var(--up); }
.st.down { color: var(--danger); }

/* ---------- empty state ---------- */

.empty-state {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.empty-state a { color: var(--fg); }

/* ---------- flash / alerts ---------- */

.flash {
  margin: 0 0 20px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  background: var(--paper);
  font-size: 13.5px;
}
.flash.err { color: #f0c6ba; border-color: var(--danger-line); border-left-color: var(--danger); background: var(--danger-bg); }
.flash.ok { color: #d7e2c6; border-color: #3d4a30; border-left-color: var(--up); background: var(--up-bg); }

/* ---------- login ---------- */

.center {
  display: flex;
  justify-content: center;
  padding-top: 8vh;
}
.auth { width: min(380px, 100%); }
.host {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 10px;
}
.auth h1 { margin: 0 0 22px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- forms ---------- */

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13.5px;
  color: var(--label);
}
label.span2 { grid-column: 1 / -1; }
label.check {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--fg);
  min-height: 36px;
}
label.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--fg); }

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"] {
  appearance: none;
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 12px;
  font: 15px/1.3 var(--sans);
  min-height: 42px;
}
input[type="number"] { font-family: var(--mono); }
input::placeholder { color: #6b6558; }

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
}

.hint { font-size: 13px; color: var(--muted); margin: 12px 0 0; max-width: 62ch; }

/* key/value read-only rows */
.meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 0; }
.meta dt {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 5px;
}
.meta dd { margin: 0; font-size: 14px; }

.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-actions input[type="text"] { max-width: 260px; }
.form-actions-top { margin-top: 18px; }

.note { color: var(--muted); font-size: 13.5px; }

/* ---------- project stub / embed ---------- */

.embed {
  display: block;
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--line);
  background: #000;
}

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .wrap { width: calc(100% - 32px); margin-top: 24px; }
  .top { padding: 10px 16px; height: auto; flex-wrap: wrap; row-gap: 10px; }
  .top nav { height: auto; gap: 18px; }
  .top nav a { height: 32px; border-bottom-width: 2px; }
  .who { width: 100%; margin-left: 0; justify-content: space-between; }
  .pagehead { flex-direction: column; align-items: flex-start; }
  .fields, .meta { grid-template-columns: 1fr; }
  .end { text-align: left; }
  .row-actions { justify-content: flex-start; }
  .sheet th, .sheet td { padding: 12px 14px; }
  .center { padding-top: 6vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
