:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --ink: #232823;
  --muted: #69716b;
  --line: #dfddd5;
  --green: #28523d;
  --green-soft: #e6efe8;
  --terracotta: #a9583c;
  --danger: #8f2f2f;
  --warn: #8a5a12;
  --info: #245a77;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex: 0 0 230px; background: var(--green); color: #f4f1ea;
  padding: 22px 16px; display: flex; flex-direction: column; gap: 22px;
}
.brand { font-size: 21px; font-weight: 700; letter-spacing: .2px; color: #fff; }
.brand small { display: block; font-size: 11px; font-weight: 500; opacity: .72; letter-spacing: .4px; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  color: #e8eee9; padding: 9px 11px; border-radius: 8px; font-size: 14px;
}
.nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.17); color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: #d6e2d9; }
.sidebar-foot form { margin-top: 8px; }
.main { flex: 1; min-width: 0; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 650; }
.topbar .who { color: var(--muted); font-size: 13px; }
.content { padding: 24px 28px 48px; max-width: 1400px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
.metric { font-size: 28px; font-weight: 700; color: var(--green); line-height: 1.1; }
.metric-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .35px; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.mono { font-family: Consolas, "SFMono-Regular", monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  font-weight: 600; border: 1px solid transparent;
}
.badge-neutral { background: #eef0ed; color: #424a43; }
.badge-ok { background: #e2efe5; color: #20573a; }
.badge-warn { background: #f8eed7; color: var(--warn); }
.badge-danger { background: #f6e2e2; color: var(--danger); }
.badge-info { background: #e2edf4; color: var(--info); }
.badge-muted { background: #f1f0ec; color: #7a7f79; }
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; font-size: 14px; }
.flash.ok { background: #e9f4ec; border-color: #b9d9c4; color: #1f5438; }
.flash.err { background: #f9e9e9; border-color: #e4bdbd; color: #7c2c2c; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid #cfcec6; border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #a9c8b4; border-color: var(--green); }
.field { min-width: 180px; flex: 1; }
.field-narrow { min-width: 110px; flex: 0 0 130px; }
.btn {
  display: inline-block; border: 1px solid var(--green); background: var(--green);
  color: #fff; padding: 9px 14px; border-radius: 8px; font: inherit; font-weight: 600;
  cursor: pointer; min-height: 38px;
}
.btn:hover { background: #1e402f; text-decoration: none; }
.btn.secondary { background: #fff; color: var(--green); }
.btn.secondary:hover { background: var(--green-soft); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: #742424; }
.btn.small { padding: 5px 10px; min-height: 30px; font-size: 13px; }
.btn.link { background: transparent; border: 0; color: var(--green); padding: 0; min-height: 0; font-weight: 600; }
.inline { display: inline; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.section-title h2 { margin: 0; font-size: 16px; }
.kv { display: grid; grid-template-columns: 190px 1fr; gap: 7px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.qr { background: #fff; padding: 10px; border: 1px solid var(--line); border-radius: 8px; display: inline-block; }
.qr svg { width: 200px; height: 200px; display: block; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 430px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.auth-card h1 { margin: 0 0 6px; font-size: 24px; color: var(--green); }
.auth-card p.lead { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.auth-card .btn { width: 100%; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 14px 0; }
.recovery-codes code { background: #f3f1eb; padding: 8px; border-radius: 6px; text-align: center; font-size: 14px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { display: inline; }
details summary { cursor: pointer; color: var(--green); font-size: 13px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; }
.tabs a.active { background: var(--green); color: #fff; border-color: var(--green); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
@media (max-width: 980px) {
  .shell { display: block; }
  .sidebar { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .content { padding: 18px 14px 40px; }
  .topbar { padding: 12px 14px; }
}

.payload-pre {
  max-height: 520px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f5f0;
  color: #232823;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}


/* Public legal pages */
.auth-wrap-wide {
  align-items: start;
  padding: 32px 18px 64px;
}
.auth-card-legal {
  max-width: 780px;
  padding: 32px 30px 40px;
}
.auth-card-legal h1 {
  font-size: 28px;
}
.auth-card-legal .lead {
  margin-bottom: 22px;
}
.legal-status-note {
  padding: 12px 14px;
  margin: 0 0 22px;
  border: 1px solid #d8b9a8;
  border-radius: 10px;
  background: #fbf4ef;
  color: #5d4336;
  font-size: 14px;
  line-height: 1.6;
}
.legal-content-section {
  margin-top: 26px;
}
.legal-content-section h2 {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 18px;
  line-height: 1.35;
}
.legal-content-section h3 {
  margin: 18px 0 7px;
  font-size: 15px;
}
.legal-content-section p,
.legal-content-section li,
.legal-content-section address {
  font-size: 14.5px;
  line-height: 1.72;
}
.legal-content-section p {
  margin: 0 0 10px;
}
.legal-content-section ul {
  padding-left: 1.25rem;
  margin: 0 0 12px;
}
.legal-content-section address {
  margin: 0 0 12px;
  font-style: normal;
}
.legal-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 14px;
}
.legal-links a,
.public-legal-link a,
.legal-content-section a {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
.public-legal-link {
  padding-top: 22px;
  margin-top: 26px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
@media (max-width: 520px) {
  .auth-wrap-wide {
    padding: 16px 10px 48px;
  }
  .auth-card-legal {
    padding: 24px 18px 32px;
    border-radius: 12px;
  }
}
