:root {
  --brand:      #C2562E;
  --brand-hi:   #d96a41;
  --bg:         #0e0e0e;
  --surface:    #161616;
  --card-bg:    #1a1a1a;
  --border:     #2a2a2a;
  --text:       #f0ece8;
  --muted:      #9a9a9a;
  --danger:     #c0392b;
  --ok:         #2e7d5b;
  --radius:     12px;
  --transition: 0.2s ease;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

a { color: var(--brand-hi); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: var(--surface);
  border-bottom: 3px solid var(--brand);
}
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--brand); color: #fff; font-weight: 800; letter-spacing: -1px;
}
.brand-mark-lg { width: 68px; height: 68px; font-size: 1.6rem; border-radius: 16px; margin: 0 auto 0.5rem; }
.brand-text { font-weight: 600; padding-left: 0.8rem; border-left: 1px solid var(--border); color: var(--muted); letter-spacing: 0.02em; }
.brand-logo { height: 54px; width: auto; display: block; margin: -6px 0; }
.hero-logo { width: 260px; max-width: 100%; height: auto; margin: 0 auto 1.2rem; display: block; }
.nav { display: flex; align-items: center; gap: 1.1rem; }
.nav a { color: var(--text); }
.nav-user { color: var(--muted); font-size: 0.9rem; }
.inline { display: inline; }

/* ── Layout ── */
.container { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 2rem 1.5rem; min-width: 0; }
.shell { flex: 1; display: flex; align-items: stretch; }
.shell > .container { margin: 0; max-width: 1180px; }

/* ── Sidebar ── */
.sidebar { flex: 0 0 220px; background: var(--surface); border-right: 1px solid var(--border); padding: 1.4rem 0.8rem; }
.sidebar-group + .sidebar-group { margin-top: 1.3rem; }
.sidebar-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0 0.7rem 0.35rem; }
.sidebar a { display: block; padding: 0.42rem 0.7rem; border-radius: 8px; color: var(--text); font-size: 0.93rem; }
.sidebar a:hover { background: var(--card-bg); text-decoration: none; }
.sidebar a.active { background: #2a1a12; color: var(--brand-hi); box-shadow: inset 3px 0 0 var(--brand); }

/* ── Hero / auth cards ── */
.hero { flex: 1; display: flex; align-items: center; justify-content: center; padding: 3rem 1.5rem; }
.hero-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2.5rem; max-width: 460px; width: 100%;
  text-align: center;
}
.hero-card h1 { margin-bottom: 0.5rem; }
.lead { color: var(--text); margin-bottom: 1.5rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hero-card .btn { margin-bottom: 1rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.6rem 1.1rem; border-radius: 9px; border: 1px solid transparent;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hi); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--brand); }
.btn-danger { background: transparent; border-color: var(--danger); color: #e6796d; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-lg { padding: 0.8rem 1.5rem; font-size: 1.05rem; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ── Flash messages ── */
.flash { padding: 0.8rem 1rem; border-radius: 9px; margin-bottom: 1rem; border: 1px solid var(--border); }
.flash-info    { background: #14232e; border-color: #1d3a4d; }
.flash-success { background: #13291f; border-color: #1e4633; }
.flash-error   { background: #2a1513; border-color: #4d1f1a; }

/* ── Cards / grid ── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.2rem; }
.card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.3rem; transition: border-color var(--transition), transform var(--transition);
}
a.card:hover { border-color: var(--brand); transform: translateY(-3px); text-decoration: none; }
a.card { color: var(--text); }
.card-alert { border-color: var(--brand); background: #221510; }
.card h3 { margin-bottom: 0.3rem; }
.card .meta { color: var(--muted); font-size: 0.85rem; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.6rem; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--surface); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tr:last-child td { border-bottom: none; }

/* ── Forms ── */
.form-row { margin-bottom: 1rem; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }
input[type=text], input[type=email], input[type=search], input[type=date], input[type=number], input[type=tel], input[type=file], textarea, select {
  width: 100%; padding: 0.6rem 0.8rem; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px; font: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }

/* ── Record pages (HR) ── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.9rem 1rem; }
.form-grid .form-row { margin: 0; }
.form-grid .span-2 { grid-column: span 2; }
.section { margin-bottom: 1.6rem; scroll-margin-top: 1rem; }
.section > h2 { font-size: 1.15rem; margin-bottom: 0.7rem; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.section-note { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.8rem; }
.jump { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.lock { font-size: 0.75rem; color: var(--muted); border: 1px dashed var(--border); border-radius: 999px; padding: 0.1rem 0.5rem; font-weight: 400; }
.checklist { list-style: none; }
.checklist li { display: grid; grid-template-columns: auto 1fr auto; gap: 0.4rem 0.8rem; align-items: center; padding: 0.55rem 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: none; }
.checklist input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); }
.checklist .hint { grid-column: 2 / -1; color: var(--muted); font-size: 0.8rem; margin-top: -0.3rem; }
.checklist .when { display: flex; gap: 0.4rem; align-items: center; }
.checklist .when input { width: auto; padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.secret { font-family: ui-monospace, monospace; letter-spacing: 0.04em; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.2rem; }
dl.facts dt { color: var(--muted); font-size: 0.85rem; }
@media (max-width: 640px) { .form-grid .span-2 { grid-column: auto; } }

/* ── Badges ── */
.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; border: 1px solid var(--border); }
.badge-admin { background: #2a1a12; border-color: var(--brand); color: var(--brand-hi); }
.badge-viewonly { background: #2a1513; border-color: #4d1f1a; color: #e6796d; }
.badge-ok { background: #13291f; border-color: #1e4633; color: #6bbf95; }

/* ── Footer ── */
.site-footer { text-align: center; padding: 1.2rem; font-size: 0.8rem; color: var(--muted); border-top: 1px solid var(--border); }

/* ── Utilities ── */
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none; }
.copybox { display: flex; gap: 0.5rem; }
.copybox input { font-family: ui-monospace, monospace; font-size: 0.85rem; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { flex: none; display: flex; gap: 0.2rem; overflow-x: auto; padding: 0.5rem 1rem; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-group { display: flex; align-items: center; gap: 0.2rem; }
  .sidebar-group + .sidebar-group { margin-top: 0; padding-left: 0.5rem; border-left: 1px solid var(--border); }
  .sidebar-label { display: none; }
  .sidebar a { white-space: nowrap; }
  .sidebar a.active { box-shadow: inset 0 -2px 0 var(--brand); }
}

@media (max-width: 640px) {
  .site-header { flex-wrap: wrap; padding: 0.8rem 1rem; }
  .brand-logo { height: 42px; }
  .container { padding: 1.5rem 1rem; }
  th, td { white-space: normal; }
}
