:root {
  --ink: #1b2430;
  --muted: #6b7787;
  --line: #dfe4ea;
  --bg: #f3f5f8;
  --card: #ffffff;
  --brand: #14532d;
  --brand-2: #1d6b3c;
  --accent: #2563eb;
  --bad: #b42318;
  --ok: #067647;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
}

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

.wrap { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

/* header */
.top { background: #0f2d1f; color: #e8f2ec; border-bottom: 3px solid #38a169; }
.top .wrap { display: flex; align-items: center; gap: 28px; height: 54px; }
.brand { color: #fff; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 9px; }
.brand:hover { text-decoration: none; }
.logo {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 6px;
  background: #38a169; color: #fff; font-weight: 700; font-size: 14px;
}
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { color: #c9dcd1; padding: 6px 11px; border-radius: 6px; font-size: 13.5px; }
.top nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.top nav a.on { background: rgba(255,255,255,.14); color: #fff; }

.who { position: relative; display: flex; align-items: center; gap: 8px; }
.who-name { font-size: 13px; }
.tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; background: rgba(255,255,255,.12); padding: 2px 7px; border-radius: 10px; }
.who:hover::after, .who:focus-within::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 0;
  width: 190px;
  height: 14px;
}
.menu {
  position: absolute; right: 0; top: 100%; margin-top: 8px; min-width: 170px;
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 10px 28px rgba(15, 45, 31, .18);
  padding: 6px; display: none; z-index: 20;
}
.who:hover .menu, .who:focus-within .menu { display: block; }
.menu a, .menu .link {
  display: block; width: 100%; text-align: left; padding: 7px 10px;
  border-radius: 6px; font-size: 13px; color: var(--ink);
  background: none; border: 0; cursor: pointer; font-family: inherit;
}
.menu a:hover, .menu .link:hover { background: var(--bg); text-decoration: none; }

/* layout */
main.wrap { padding: 24px 0 40px; }
.page-head { margin: 0 0 18px; }
.page-head h1 { margin: 0 0 2px; font-size: 21px; font-weight: 650; }
.page-head p { margin: 0; }
.row-between { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 12.5px; }
.wrap-text, .wrap { overflow-wrap: anywhere; }

/* flashes */
.flashes { margin-bottom: 16px; display: grid; gap: 8px; }
.flash { padding: 10px 13px; border-radius: 6px; border: 1px solid; font-size: 13.5px; }
.flash.ok { background: #ecfdf3; border-color: #abefc6; color: #05603a; }
.flash.error { background: #fef3f2; border-color: #fecdca; color: #b42318; }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.cols { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.cols .card { margin-bottom: 0; }
.side .stack { display: grid; gap: 8px; margin-bottom: 12px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; }
.stat .n { display: block; font-size: 24px; font-weight: 650; line-height: 1.15; }
.stat .l { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 3px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; padding: 0 10px 7px; border-bottom: 1px solid var(--line);
}
td { padding: 9px 10px; border-bottom: 1px solid #eef1f5; vertical-align: top; font-size: 13.5px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
table.records td { vertical-align: top; }
table.records .val { display: inline; margin-right: 8px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: 600 13px/1 "Segoe UI", system-ui, sans-serif;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: #c7ced8; background: #f8fafc; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:hover { background: var(--brand); border-color: var(--brand); }
.btn.ghost { background: transparent; }
.btn.danger { background: #fff; border-color: #f0b4ae; color: var(--bad); }
.btn.danger:hover { background: #fef3f2; border-color: #e79b93; }
.btn.tiny { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* pills */
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  background: #eef2f6; color: #3c4a5a; font-size: 11.5px; font-weight: 600;
}
.pill.ok { background: #d1fadf; color: var(--ok); }
.pill.bad { background: #fee4e2; color: var(--bad); }
.pill.off { background: #f0f1f3; color: #7a8494; }

/* forms */
.form label, form label {
  display: block; font-size: 12.5px; font-weight: 600; color: #3c4a5a; margin-bottom: 12px;
}
input[type=text], input[type=password], input[type=number], input:not([type]), select {
  width: 100%; height: 30px; margin-top: 5px; padding: 0 10px;
  border: 1px solid #cfd6df; border-radius: 6px; background: #fff;
  font: 400 13px/1 "Segoe UI", system-ui, sans-serif; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid rgba(37, 99, 235, .35); outline-offset: 0; border-color: #93b4f8; }
label.check { display: flex; align-items: center; gap: 8px; margin-top: 22px; font-weight: 500; }
label.check input { width: auto; height: auto; margin: 0; }
label.check.inline { margin-top: 0; padding-top: 22px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 18px; }
.hint { font-size: 12px; color: var(--muted); margin: -4px 0 14px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 12px 16px 2px; margin: 4px 0 16px; }
legend { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 0 6px; }
.form-actions { display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 6px; }
.form.narrow { max-width: 460px; }
.input-row { display: flex; gap: 10px; }
.inline-form { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.inline-form input { width: auto; flex: 1; margin-top: 0; }
.search { display: flex; gap: 8px; margin-bottom: 14px; max-width: 420px; }
.search input { margin-top: 0; }

/* misc */
.pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 14px; }
.danger-zone { border-color: #f0b4ae; }
.danger-zone .card-head h2 { color: var(--bad); }
.foot { padding: 6px 0 26px; color: var(--muted); font-size: 12px; }

/* auth */
body.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, #17452e 0%, #0d2419 55%, #081710 100%);
}
.auth-card {
  width: min(390px, 100%); background: #fff; border-radius: 12px;
  padding: 28px 28px 22px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.auth-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-head h1 { margin: 0; font-size: 19px; }
.auth-head p { margin: 0; font-size: 12.5px; }
.auth-card .btn.wide { margin-top: 4px; }
.auth-card .small { text-align: center; margin: 14px 0 0; }

@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid4 { grid-template-columns: 1fr 1fr; }
  .top .wrap { gap: 10px; }
  .who-name { display: none; }
}
@media (max-width: 560px) {
  .grid2, .grid4 { grid-template-columns: 1fr; }
  .row-between { flex-direction: column; align-items: stretch; }
}
