:root {
  color-scheme: light;
  --bg: #f3efe6;
  --ink: #1c1915;
  --muted: #6f685e;
  --line: #e3dace;
  --card: #fffdf8;
  --side: #1c2420;
  --side-soft: #2a3530;
  --accent: #c6531a;
  --accent-dark: #9b3d12;
  --good: #1d7a4a;
  --good-bg: #e7f5ec;
  --warn: #8a5a12;
  --warn-bg: #fbf1dc;
  --bad: #a33b32;
  --bad-bg: #fdeceb;
  --shadow: 0 16px 40px rgba(48, 36, 18, 0.06);
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Code", Consolas, "Sarasa Mono SC", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

#app[hidden],
#gate[hidden] { display: none !important; }
#app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}
.side {
  background: var(--side);
  color: #edf3ee;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px; }
.brand strong { display: block; font-size: 18px; letter-spacing: 0.04em; }
.brand em { display: block; margin-top: 2px; color: #b7c4bb; font-style: normal; font-size: 12px; }
.mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
  font-weight: 700;
}
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav button, .logout {
  text-align: left;
  border: 0;
  background: transparent;
  color: #d5e0d8;
  border-radius: 10px;
  padding: 10px 12px;
}
.side nav button.active, .side nav button:hover, .logout:hover { background: var(--side-soft); color: white; }
.logout { margin-top: auto; }

main { padding: 28px 32px 56px; max-width: 1180px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.eyebrow { color: var(--muted); font-size: 13px; letter-spacing: 0.08em; }
.top h1 { font-size: 32px; font-weight: 650; letter-spacing: -0.03em; margin-top: 4px; }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.card { padding: 16px 18px; }
.card span, .muted { color: var(--muted); font-size: 13px; }
.card strong { display: block; margin-top: 8px; font-size: 30px; letter-spacing: -0.04em; }
.panel { padding: 18px; margin-top: 14px; }
.panel h2 { font-size: 16px; margin-bottom: 12px; }
.split { display: grid; grid-template-columns: 1.3fr 0.7fr; gap: 14px; }

.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; min-height: 140px; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 150px; justify-content: flex-end; }
.bar i {
  display: block;
  width: 100%;
  max-width: 36px;
  flex: none;
  border-radius: 8px 8px 4px 4px;
  background: #d07a52;
  height: var(--h);
}
.bar b { font-size: 12px; }
.bar em { font-style: normal; color: var(--muted); font-size: 12px; }

.form-grid { display: grid; grid-template-columns: 1.4fr 0.8fr 0.6fr; gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select {
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
input:focus, select:focus { border-color: #c48a68; box-shadow: 0 0 0 3px rgba(198, 83, 26, 0.12); }
.row-actions { display: flex; gap: 8px; align-items: flex-end; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); padding-top: 22px; }
.check input { width: 16px; height: 16px; }

button.primary, button.ghost, button.danger, button.text {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 14px;
}
button.primary { background: var(--accent); color: white; }
button.primary:hover { background: var(--accent-dark); }
button.ghost, button.text { background: white; border-color: var(--line); }
button.danger { background: white; color: var(--bad); border-color: #f0c7c3; }
button:disabled { opacity: 0.6; cursor: wait; }
.form-error { color: var(--bad); min-height: 18px; font-size: 13px; margin-top: 8px; }

.just {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  border-radius: 16px;
  background: #1c2420;
  color: white;
  margin-bottom: 14px;
}
.just span { display: block; color: #b7c4bb; font-size: 12px; margin-bottom: 4px; }
.just code { font-family: var(--mono); font-size: 18px; word-break: break-all; }
.just .actions, .cell-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cell-actions .text,
.cell-actions .danger,
.cell-actions a.text {
  display: inline-block;
  padding: 6px 10px;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
}
.just a { color: #f2c7b0; }
.just button.ghost { color: var(--ink); background: #fffdf8; }

.toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.toolbar input { min-width: min(320px, 100%); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
.clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: var(--mono); }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }
.pill { display: inline-flex; border-radius: 999px; padding: 3px 8px; font-size: 12px; white-space: nowrap; }
.pill.on { background: var(--good-bg); color: var(--good); }
.pill.off { background: #eeeae3; color: #675f55; }
.pill.expired { background: var(--warn-bg); color: var(--warn); }
.tag { display: inline-flex; margin-left: 6px; border-radius: 999px; background: #f6e2d6; color: var(--accent-dark); font-size: 12px; padding: 2px 6px; }

.list { display: flex; flex-direction: column; }
.domain {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.domain:last-child { border-bottom: 0; }
.domain code { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.hero {
  padding: 28px;
  border-radius: 18px;
  background:
    radial-gradient(600px 180px at 100% 0%, rgba(198, 83, 26, 0.16), transparent 60%),
    var(--card);
  border: 1px solid var(--line);
}
.hero h2 { font-size: 28px; letter-spacing: -0.03em; }
.hero p { margin: 8px 0 16px; color: var(--muted); max-width: 62ch; line-height: 1.6; }

.gate-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.gate h1 { font-size: 30px; margin: 14px 0 6px; }
.gate p { color: var(--muted); margin-bottom: 18px; line-height: 1.5; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.pw { display: flex; gap: 8px; }
.pw input { flex: 1; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 21, 0.38);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.dialog {
  width: min(560px, 100%);
  background: var(--card);
  border-radius: 18px;
  padding: 20px;
  border: 1px solid var(--line);
}
.dialog h2 { margin-bottom: 14px; }
.dialog .stack label { color: var(--muted); }

#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(12px);
  background: #1c2420;
  color: white;
  padding: 10px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.notice-body { display: grid; place-items: center; min-height: 100vh; }
.notice { text-align: center; }
.notice .mark { margin: 0 auto 16px; }
.notice h1 { font-size: 32px; }
.notice p { color: var(--muted); margin-top: 8px; }

@media (max-width: 980px) {
  .grid, .split, .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .wide { grid-column: auto; }
}
@media (max-width: 800px) {
  #app { grid-template-columns: 1fr; }
  .side { padding: 14px; }
  .side nav { flex-direction: row; overflow: auto; }
  .side nav button { white-space: nowrap; }
  .logout { margin-top: 0; }
  main { padding: 18px 14px 40px; }
  .grid, .split, .form-grid { grid-template-columns: 1fr; }
  .domain, .just { grid-template-columns: 1fr; display: flex; flex-direction: column; align-items: flex-start; }
  .panel { overflow-x: auto; }
  table { min-width: 920px; }
  .cell-actions { flex-wrap: nowrap; }
  .top h1 { font-size: 26px; }
}
