:root {
  --bg: #dfe3ea;
  --bg-2: #eceff4;
  --card: rgba(250, 251, 253, 0.94);
  --ink: #12151c;
  --muted: #5f6776;
  --line: rgba(28, 35, 48, 0.12);
  --brand: #7a6230;
  --brand-d: #5e4a22;
  --brass: #a6873d;
  --ok: #2f6b3a;
  --warn: #9a5b12;
  --bad: #9b2c2c;
  --side: #10131a;
  --side-ink: #c9d0db;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(16, 22, 34, 0.08);
  --font: "Source Sans 3", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --display: "Cormorant Garamond", "Times New Roman", Georgia, serif;
}

* { box-sizing: border-box }
html { -webkit-text-size-adjust: 100% }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15.5px;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0.01em;
  color: var(--ink);
  background:
    radial-gradient(1100px 560px at 8% -8%, rgba(166, 135, 61, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(40, 55, 85, 0.08), transparent 50%),
    linear-gradient(165deg, var(--bg-2), var(--bg));
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  font-kerning: normal;
}
a { color: var(--brand-d); text-decoration: none }
a:hover { text-decoration: underline }
h1, h2, .brand, .auth-kicker, .auth-title, .stat b, .sum div b {
  font-family: var(--display);
  font-feature-settings: "kern" 1, "liga" 1;
}
h1 {
  font-size: clamp(1.65rem, 2.8vw, 2.15rem);
  margin: 0 0 6px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
h2 {
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  margin: 0 0 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.25;
}
.muted, small {
  color: var(--muted);
  letter-spacing: 0.015em;
}
.nav-label { letter-spacing: 0.02em }

.layout { display: flex; min-height: 100vh; position: relative }
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(20, 17, 14, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(176, 141, 62, 0.25);
}
.brand {
  font-family: var(--display);
  font-weight: 600;
  color: #f7f1e6;
  font-size: 1.45rem;
  padding: 0 10px 20px;
  letter-spacing: 0.01em;
  line-height: 1.15;
}
.brand span { color: var(--brass); font-weight: 500; font-style: italic; margin-left: 0.28em }
.brand-inline { padding: 0; font-size: 1.2rem; color: #f7f1e6 }
.brand-inline span { color: var(--brass) }

.nav-toggle {
  width: 42px; height: 42px;
  border: 1px solid rgba(176, 141, 62, 0.35);
  border-radius: 10px;
  background: transparent;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 0;
}
.nav-toggle span {
  display: block;
  width: 18px; height: 2px;
  background: #f7f1e6;
  border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}
.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg) }
.nav-open .nav-toggle span:nth-child(2) { opacity: 0 }
.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg) }

.side {
  width: 248px;
  background:
    linear-gradient(180deg, rgba(176, 141, 62, 0.08), transparent 28%),
    var(--side);
  color: var(--side-ink);
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(176, 141, 62, 0.18);
  z-index: 50;
}
.side nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto }
.side a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--side-ink);
  margin: 0;
  font-weight: 500;
  font-size: 0.95rem;
}
.side a.on, .side a:hover {
  background: rgba(176, 141, 62, 0.14);
  color: #fff8ec;
  text-decoration: none;
}
.side a.on { box-shadow: none }
.nav-check {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brass);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-check::before {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 2px solid #14110e;
  border-bottom: 2px solid #14110e;
  transform: rotate(-45deg) translateY(-0.5px);
  margin-top: -1px;
}
.who {
  margin-top: auto;
  font-size: 13px;
  padding: 14px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #f0e8db;
}
.who-name { font-weight: 600; margin-bottom: 2px }
.who small { color: #a89c8c; display: block; margin-bottom: 8px }
.who-link {
  display: inline-block !important;
  padding: 4px 0 !important;
  margin-right: 12px !important;
  color: var(--brass) !important;
  background: none !important;
  box-shadow: none !important;
}
.side-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12, 10, 8, 0.45);
  z-index: 45;
}

main {
  flex: 1;
  padding: clamp(16px, 3vw, 32px);
  max-width: 1280px;
  min-width: 0;
  width: 100%;
}
.head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(14px, 2.5vw, 22px);
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat b {
  display: block;
  font-family: var(--display);
  font-size: clamp(1.5rem, 3vw, 1.85rem);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.stat span { color: var(--muted); font-size: 13px; letter-spacing: 0.02em }

table { width: 100%; border-collapse: collapse; font-size: 14.5px }
th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top }
tr:last-child td { border-bottom: 0 }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(55, 42, 28, 0.08);
  color: #4a4036;
  white-space: nowrap;
}
.badge.ok { background: #e4f2e6; color: var(--ok) }
.badge.warn { background: #f8ecd8; color: var(--warn) }
.badge.bad { background: #f6e2e2; color: var(--bad) }
.badge.info { background: #efe6d2; color: var(--brand-d) }

.btn {
  display: inline-block;
  border: 1px solid var(--line);
  background: #fffdf9;
  color: var(--ink);
  padding: 9px 14px;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  min-height: 40px;
}
.btn:hover { background: #f3eee4; text-decoration: none }
.btn.primary {
  background: linear-gradient(180deg, #a57c22, var(--brand));
  border-color: transparent;
  color: #fffdf8;
  box-shadow: 0 8px 20px rgba(139, 105, 20, 0.25);
}
.btn.primary:hover { background: linear-gradient(180deg, #8b6914, var(--brand-d)) }
.btn.danger { color: var(--bad); border-color: #e7c4c4 }
.btn.danger:hover { background: #fbf0f0 }
.btn.sm { padding: 5px 10px; font-size: 12.5px; min-height: 32px }
form.inline { display: inline }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; letter-spacing: 0.025em }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(55, 42, 28, 0.18);
  border-radius: 10px;
  font: inherit;
  background: #fffdf9;
  color: var(--ink);
  min-height: 42px;
}
textarea { min-height: 96px; resize: vertical }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(176, 141, 62, 0.35);
  border-color: var(--brass);
}
input[type=checkbox] { width: auto; min-height: auto }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 14px;
}
.grid .full { grid-column: 1 / -1 }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px }
.checks label { font-weight: 400; display: flex; gap: 6px; align-items: center; margin: 0 }

.flash {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}
.flash.ok { background: #e8f4ea; color: #1f4d28; border-color: #cfe5d3 }
.flash.err { background: #f8e8e8; color: #6f1d1d; border-color: #ebcfcf }
.flash.warn { background: #f7edd9; color: #6d4210; border-color: #ead7b0 }

.bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px }
.bar input, .bar select { width: auto; min-width: min(100%, 160px); flex: 1 1 160px }
.pw { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all }
.sum { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 14px }
.sum div span { display: block; font-size: 12px; color: var(--muted) }
.sum div b { font-size: 17px; font-family: var(--display) }
.pre { white-space: pre-wrap }
.row-actions { white-space: nowrap }
.empty { color: var(--muted); padding: 6px 0 }

/* Auth / login */
body.auth {
  display: block;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 20% 10%, rgba(176, 141, 62, 0.22), transparent 55%),
    linear-gradient(145deg, #1a1612 0%, #0e0c0a 55%, #241c14 100%);
}
.auth-shell {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  min-height: 100vh;
  max-width: 1180px;
  margin: 0 auto;
}
.auth-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 6vw, 64px);
  color: #f7f1e6;
  position: relative;
  overflow: hidden;
}
.auth-visual::before {
  content: "";
  position: absolute;
  inset: 12% 18%;
  border: 1px solid rgba(176, 141, 62, 0.28);
  border-radius: 28px;
  transform: rotate(-4deg);
  pointer-events: none;
}
.auth-visual-inner { position: relative; z-index: 1; max-width: 420px }
.auth-kicker {
  font-family: var(--display);
  font-size: clamp(2.6rem, 5.5vw, 3.8rem);
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.auth-title {
  font-family: var(--display);
  font-size: clamp(3rem, 6.5vw, 4.6rem);
  margin: 2px 0 18px;
  color: var(--brass);
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.auth-tag {
  margin: 0;
  color: #c9bba8;
  font-size: 1.05rem;
  max-width: 32ch;
  letter-spacing: 0.04em;
  line-height: 1.5;
}
.auth-box {
  align-self: center;
  background: rgba(255, 252, 247, 0.96);
  padding: clamp(22px, 4vw, 36px);
  border-radius: 20px;
  width: calc(100% - 32px);
  max-width: 420px;
  margin: 24px auto;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(176, 141, 62, 0.2);
}
.auth-box .brand { color: var(--ink); padding-bottom: 8px }
.auth-box .brand span { color: var(--brand) }
.brand.big { font-size: clamp(1.55rem, 3.2vw, 1.9rem); letter-spacing: 0.01em }
.auth-box .grid { grid-template-columns: 1fr }
.auth-lead { color: var(--muted); margin: 0 0 16px; font-size: 0.95rem }
.auth-foot { margin: 16px 0 0; font-size: 0.9rem }

details.card > summary {
  cursor: pointer;
  font-family: var(--display);
  font-weight: 650;
  list-style: none;
}
details.card > summary::-webkit-details-marker { display: none }

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr }
  .auth-visual { min-height: 34vh; padding: 36px 24px 12px }
  .auth-visual::before { inset: 10% 10% 18% }
  .auth-box { margin-top: 0; margin-bottom: 32px }
}

@media (max-width: 860px) {
  .topbar { display: flex }
  .layout { flex-direction: column }
  .side {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    height: 100%;
    width: min(86vw, 300px);
    transform: translateX(-105%);
    transition: transform .25s ease;
    padding-top: 18px;
  }
  .nav-open .side { transform: translateX(0) }
  .nav-open .side-backdrop { display: block }
  .side .brand { display: none }
  main { padding: 14px }
  .row-actions { white-space: normal }
  .row-actions .btn, .row-actions form { margin-bottom: 4px }
  th { font-size: 10px; padding: 8px 6px }
  td { padding: 8px 6px }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr }
  .bar input, .bar select, .bar .btn { width: 100%; min-width: 0; flex: 1 1 100% }
  .sum { gap: 14px }
  .btn { width: auto }
  .auth-box { width: calc(100% - 20px); padding: 18px; border-radius: 16px }
}

@media (min-width: 1400px) {
  main { max-width: 1360px; padding-right: 40px }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
