:root {
  --red: #d5232a;
  --red-dark: #a91b21;
  --ink: #1c2330;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ok: #157347;
  --warn: #b45309;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
main { max-width: 1240px; margin: 0 auto; padding: 20px; }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--ink);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .sub { font-size: 11px; color: #9aa3b2; }
.logo {
  background: var(--red); color: #fff; font-weight: 800;
  width: 34px; height: 34px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px;
}
.logo.big { width: 52px; height: 52px; font-size: 28px; margin-bottom: 8px; }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar nav a { color: #cfd5df; font-weight: 600; }
.topbar nav a.on { color: #fff; border-bottom: 2px solid var(--red); padding-bottom: 3px; }
.who { font-size: 13px; color: #fff; }
.who em { display: block; font-style: normal; font-size: 11px; color: #9aa3b2; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, var(--ink) 0%, #2a3446 60%, var(--red-dark) 130%);
  padding: 20px;
}
.login-card {
  background: var(--card); border-radius: 14px; padding: 36px 34px;
  width: 100%; max-width: 400px; box-shadow: 0 18px 50px rgba(0,0,0,.35);
  text-align: center;
}
.login-brand h1 { font-size: 24px; }
.login-brand h1 span { color: var(--red); }
.login-brand p { color: var(--muted); margin: 6px 0 22px; }
.login-card form { text-align: left; }
.login-card label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 13px; }
.login-card input {
  width: 100%; margin-top: 5px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}
.linklike {
  background: none; border: none; color: var(--red); cursor: pointer;
  font-size: 13px; margin-top: 14px; width: 100%;
}
.linklike:hover { text-decoration: underline; }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; border: 1px solid var(--line); background: #fff;
  color: var(--ink); border-radius: 8px; padding: 8px 16px;
  font-weight: 600; font-size: 13px; cursor: pointer;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.full { width: 100%; }
.btn.small { padding: 5px 12px; font-size: 12px; }
.btn.tiny { padding: 2px 8px; font-size: 12px; }
.btn.ghost { background: transparent; color: inherit; }
.topbar .btn.ghost { color: #cfd5df; border-color: #4a5568; }

/* ---------- flashes ---------- */
.flashes { max-width: 1240px; margin: 12px auto 0; padding: 0 20px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-weight: 600; }
.flash.ok { background: #d9f2e5; color: var(--ok); }
.flash.error { background: #fde3e4; color: var(--red-dark); }

/* ---------- stats ---------- */
.stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 20px; min-width: 130px;
}
.stat b { font-size: 24px; display: block; }
.stat b.small { font-size: 14px; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.ok b { color: var(--ok); }
.stat.warn b { color: var(--warn); }
.stat.alert { border-color: var(--red); background: #fff5f5; }
.stat.alert b { color: var(--red); }
.stat.wide { flex: 1; min-width: 260px; }
.tiny { font-size: 11px; color: var(--muted); display: inline-block; }
.okc { color: var(--ok); font-weight: 700; }
.badc { color: var(--red-dark); font-weight: 700; }

/* ---------- panels & forms ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 22px; margin-bottom: 18px;
}
.panel h2 { font-size: 16px; margin-bottom: 14px; }
.panel.slim { padding: 12px 22px; }
.panel summary { cursor: pointer; font-weight: 600; }
.notice {
  background: #fff8e6; border: 1px solid #f2d98c; color: #7a5b0b;
  padding: 10px 14px; border-radius: 8px; margin-bottom: 12px;
}
.entry-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; align-items: end;
}
.entry-form label { font-weight: 600; font-size: 13px; }
.entry-form .opt { color: var(--muted); font-weight: 400; font-size: 11px; }
.entry-form input, .entry-form select,
.search-form input, .search-form select,
.inline-row input {
  width: 100%; margin-top: 5px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
  background: #fff;
}
.search-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search-form input[type=text] { flex: 2; min-width: 220px; }
.search-form select, .search-form input[type=month] { flex: 1; min-width: 140px; width: auto; margin-top: 0; }
.search-form input { margin-top: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table-wrap.tall { max-height: 420px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line);
  background: var(--card); position: sticky; top: 0;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.strong { font-weight: 700; }
td.empty { text-align: center; color: var(--muted); padding: 26px; }
.chip {
  background: #eef1f5; border-radius: 999px; padding: 3px 10px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge {
  border: none; border-radius: 999px; padding: 4px 12px; font-size: 12px;
  font-weight: 700; white-space: nowrap;
}
button.badge { cursor: pointer; }
.badge.up { background: #d9f2e5; color: var(--ok); }
.badge.pend { background: #fdeeda; color: var(--warn); }
.inline { display: inline; }
.inline-row { display: flex; gap: 8px; align-items: center; }
.inline-row input { margin-top: 0; max-width: 200px; }
.audit-cell span { display: block; }
.row-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.row-between h2 { margin-bottom: 0; }

@media (max-width: 720px) {
  .topbar { flex-direction: column; gap: 10px; }
  .stats { flex-direction: column; }
}
