:root {
  --ink: #172433;
  --ink-soft: #24364c;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e2d8c8;
  --accent: #b8612d;
  --sea: #1d6a62;
  --sea-soft: #e6f3f1;
  --gold: #8a5a12;
  --gold-soft: #f8ecd4;
  --danger: #8d2f2f;
  --danger-soft: #f8e4e1;
  --info: #234e78;
  --info-soft: #e5eef7;
  --muted: #667588;
  --ok: #1d6a62;
  --shadow: 0 16px 40px rgba(23, 36, 51, 0.06);
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--sea); }
a:hover { color: var(--ink); }

.desk { min-height: 100vh; display: flex; }
.guest { min-height: 100vh; }

.sidebar {
  width: 248px;
  flex: 0 0 248px;
  background: var(--ink);
  color: #f6f1e7;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  margin-bottom: 28px;
  padding: 0 8px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 600;
}
.brand strong { display: block; font-family: var(--serif); font-size: 1.25rem; letter-spacing: -0.03em; }
.brand span { color: #c9bfb0; font-size: 0.78rem; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a {
  color: #efe7da;
  text-decoration: none;
  border-radius: 10px;
  padding: 9px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.side-nav a:hover { background: rgba(255, 255, 255, 0.06); color: white; }
.side-nav a.is-active { background: #2c4158; color: white; }

.side-foot { margin-top: auto; padding: 16px 8px 0; color: #c9bfb0; font-size: 0.82rem; }
.side-foot form { margin-top: 8px; }
.side-foot button, .linkish {
  background: none;
  border: 0;
  color: #f6f1e7;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 28px 0;
}
.topbar-text { min-width: 0; }
.topbar-action { margin-left: auto; flex: none; }
.topbar h1 {
  font-family: var(--serif);
  font-size: 1.8rem;
  margin: 0;
  letter-spacing: -0.03em;
}
.content { padding: 18px 28px 48px; }

.menu-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  width: 40px;
  height: 40px;
}

.card, .stat, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.panel { padding: 18px; }
.stat { padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 0.82rem; }
.stat .v { font-family: var(--serif); font-size: 2rem; line-height: 1.1; margin-top: 4px; }
.stat .s { color: var(--muted); font-size: 0.82rem; }

.grid-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 14px; }
.stack { display: grid; gap: 14px; }

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 12px;
}
.section-title h2 { font-size: 1.05rem; margin: 0; font-family: var(--serif); }

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #ece7de;
  color: var(--ink-soft);
}
.tone-ok { background: var(--sea-soft); color: var(--sea); }
.tone-warn { background: var(--gold-soft); color: var(--gold); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-muted { background: #ece7de; color: #5d6b7c; }

.meter { height: 8px; background: #efe8dc; border-radius: 99px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--sea); }
.meter.hot span { background: var(--accent); }

table.plain { width: 100%; }
table.plain th { color: var(--muted); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.02em; }
table.plain td, table.plain th { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.plain tr:last-child td { border-bottom: 0; }

.banner, .alert {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.banner { background: var(--gold-soft); color: var(--gold); }
.form-shell { max-width: 760px; }
.help-note { color: var(--muted); font-size: 0.92rem; }
code, .mono, textarea.code { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
textarea.code { min-height: 220px; }

.gate {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}
.gate-copy {
  background: var(--ink);
  color: #f6f1e7;
  padding: 64px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.gate-copy h1 { font-family: var(--serif); font-size: 4rem; margin: 12px 0; letter-spacing: -0.04em; }
.gate-form { display: grid; place-items: center; padding: 32px 20px; }
.gate-card { width: min(420px, 100%); }

.preview-frame {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}
.empty { color: var(--muted); padding: 12px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.record-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.record-actions form { margin: 0; }
.view-switch { display: flex; flex-wrap: wrap; gap: 8px; }
.proxy-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: -4px 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #faf7f2;
}
.port-report { white-space: pre-line; }
.proxy-card span { display: block; color: var(--muted); font-size: 0.75rem; }
.proxy-card strong { font-weight: 600; word-break: break-word; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: white; }
.btn-accent:hover { background: #9c4f22; color: white; }
.btn-ink { background: var(--ink); border-color: var(--ink); color: white; }
.btn-ink:hover { background: var(--ink-soft); color: white; }

.offcanvas.nav-drawer { background: var(--ink); color: #f6f1e7; width: 260px; }

@media (max-width: 1100px) {
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 991px) {
  .sidebar { display: none !important; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .gate { grid-template-columns: 1fr; }
  .gate-copy { padding: 32px 24px; min-height: auto; }
  .gate-copy h1 { font-size: 3rem; }
}
@media (max-width: 640px) {
  .grid-stats { grid-template-columns: 1fr; }
  .proxy-card { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 1.45rem; }
}
