:root {
  --bg: #080c10;
  --elev: #0d1319;
  --card: #121a22;
  --hover: #1a2530;
  --border: #243040;
  --text: #e6eef5;
  --muted: #8a9aab;
  --dim: #5a6b7c;
  --accent: #3d9bdc;
  --accent-hi: #6bb8f0;
  --accent-soft: rgba(61, 155, 220, 0.14);
  --green: #3dcf8e;
  --red: #e05a5a;
  --gold: #c9a84c;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --serif: "Libre Baskerville", Georgia, serif;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14.5px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background:
    radial-gradient(ellipse 50% 35% at 15% 0%, rgba(61, 155, 220, 0.1), transparent 50%),
    radial-gradient(ellipse 40% 30% at 85% 10%, rgba(61, 207, 142, 0.06), transparent 45%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, select, textarea {
  background: var(--elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
label { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.3rem; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.muted { color: var(--muted); }
.error { color: var(--red); }
.pos { color: var(--green); }
.neg { color: var(--red); }
.mono { font-family: var(--mono); font-size: 0.85rem; }

.app {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}
.sidebar {
  padding: 1.15rem 0.9rem;
  background: var(--elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 0.6rem; align-items: center; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(145deg, #6bb8f0, #1a4a72);
  box-shadow: 0 0 20px rgba(61, 155, 220, 0.35);
}
.brand h1 { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; }
.brand p { font-size: 0.68rem; color: var(--muted); }

.status {
  display: flex; gap: 0.4rem; align-items: center;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--muted);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.status.ok .status-dot { background: var(--green); }
.status.warn .status-dot { background: var(--gold); }

.nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.nav-btn {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}
.nav-btn:hover { background: var(--hover); color: var(--text); }
.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent-hi);
  font-weight: 500;
}
.sidebar-foot {
  font-size: 0.66rem;
  color: var(--dim);
  line-height: 1.4;
  border-top: 1px solid var(--border);
  padding-top: 0.55rem;
}

.main { padding: 1.3rem 1.5rem 3rem; max-width: 1180px; width: 100%; }
.panel { display: none; }
.panel.active { display: block; animation: fade 0.18s ease; }
@keyframes fade {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-hi);
  margin-bottom: 0.2rem;
}
h2 {
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.lede { color: var(--muted); margin-bottom: 1rem; max-width: 48rem; }

.disclaimer {
  font-size: 0.72rem;
  color: var(--dim);
  border-left: 2px solid var(--gold);
  padding: 0.45rem 0.75rem;
  margin: 0 0 1rem;
  background: rgba(201, 168, 76, 0.06);
  border-radius: 0 8px 8px 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.hint { font-size: 0.76rem; color: var(--dim); margin-bottom: 0.55rem; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.48rem 0.9rem;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 500;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #061018; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hi); }
.btn-ghost { border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.btn-sm { padding: 0.28rem 0.55rem; font-size: 0.78rem; }
.btn-green { background: rgba(61, 207, 142, 0.2); color: var(--green); border: 1px solid rgba(61, 207, 142, 0.35); }
.btn-red { background: rgba(224, 90, 90, 0.15); color: var(--red); border: 1px solid rgba(224, 90, 90, 0.35); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.65rem;
}
.form-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; align-items: center; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}
.metric {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
}
.metric .label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); }
.metric .value { font-family: var(--mono); font-size: 1.15rem; margin-top: 0.15rem; }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
table.data th {
  text-align: left;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
  padding: 0.45rem 0.45rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid rgba(36, 48, 64, 0.7);
  vertical-align: top;
}
table.data tr:hover td { background: var(--hover); }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); }
.sym { font-family: var(--mono); font-weight: 600; color: var(--accent-hi); }

.score-pill {
  display: inline-flex;
  min-width: 2.3rem;
  justify-content: center;
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--hover);
}
.score-pill.hi { background: rgba(61, 207, 142, 0.18); color: var(--green); }
.score-pill.mid { background: rgba(201, 168, 76, 0.16); color: var(--gold); }
.score-pill.lo { background: rgba(90, 107, 124, 0.25); color: var(--muted); }

.flag-list { font-size: 0.72rem; color: var(--muted); max-width: 14rem; }
.ai-box {
  background: var(--elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin-top: 0.5rem;
  font-size: 0.82rem;
}
.ai-box strong { color: var(--accent-hi); }

.composing {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.65rem; padding: 1.5rem; color: var(--muted);
}
.orb {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent-hi);
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  bottom: 1.2rem; right: 1.2rem;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 0.5rem 0.95rem;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 40;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
}
.toast.show { opacity: 1; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
}


/* multi-device mobile */
.menu-btn {
  display: none;
  position: fixed;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 40;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: var(--shadow);
}
#accessUrls {
  font-size: 0.68rem;
  word-break: break-all;
  color: var(--accent-hi);
}
@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    height: 100vh;
    z-index: 30;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 25;
  }
  .main { padding: 1rem 0.85rem 2.5rem; }
  .form-row { grid-template-columns: 1fr 1fr; }
  .table-wrap { margin: 0 -0.25rem; }
  .data { font-size: 0.78rem; }
  .data th, .data td { padding: 0.4rem 0.35rem; }
  .brand h1 { font-size: 1.1rem; }
}
@media (max-width: 520px) {
  .form-row { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
}

/* Server edition */
.import-offer { border-color: var(--accent); background: var(--accent-soft); }
.import-offer p { margin-bottom: 0.75rem; }
.import-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.sign-out { margin: 0.75rem 0 0; align-self: flex-start; }
