:root {
  --ground: #f4f2ff;
  --card: #ffffff;
  --ink: #1e1b4b;
  --muted: #6b6893;
  --line: #e5e1f8;
  --indigo-deep: #312e81;
  --indigo: #4f46e5;
  --indigo-hover: #4338ca;
  --violet: #7c3aed;
  --violet-soft: #ede9fe;
  --indigo-soft: #e0e7ff;
  --on-dark-muted: #c7d2fe;
  --ok-bg: #e0e7ff; --ok-fg: #3730a3;
  --wait-bg: #fef3c7; --wait-fg: #92400e;
  --bad-bg: #ffe4e6; --bad-fg: #9f1239;
  --review-bg: #ede9fe; --review-fg: #5b21b6;
  --neutral-bg: #eeedf5; --neutral-fg: #4b4870;
  --brand: linear-gradient(135deg, #312e81 0%, #4f46e5 55%, #7c3aed 100%);
  --shadow: 0 8px 24px rgba(49, 46, 129, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--indigo); }
a:hover { color: var(--indigo-hover); }
.boot { padding: 48px; color: var(--muted); }

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.login-brand {
  background: var(--brand);
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-brand .mark {
  width: 56px; height: 56px; border-radius: 18px;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25);
  display: grid; place-items: center; font-size: 26px; font-weight: 800;
}
.login-brand h1 { font-size: 40px; line-height: 1.1; margin: 0 0 12px; font-weight: 800; }
.login-brand p { color: var(--on-dark-muted); font-size: 17px; margin: 0; max-width: 420px; }
.login-form-wrap { display: grid; place-items: center; padding: 32px 20px; }
.login-form { width: 100%; max-width: 380px; }
.login-form h2 { font-size: 28px; margin: 0 0 6px; font-weight: 800; }
.login-form .sub { color: var(--muted); margin: 0 0 28px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px; flex-shrink: 0;
  background: var(--brand);
  color: #fff;
  padding: 24px 16px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; }
.sidebar .brand .mark {
  width: 40px; height: 40px; border-radius: 13px;
  background: rgba(255,255,255,.16); display: grid; place-items: center; font-weight: 800;
}
.sidebar .brand strong { display: block; font-size: 16px; }
.sidebar .brand span { color: var(--on-dark-muted); font-size: 12.5px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
  color: #fff; text-decoration: none; font-weight: 600;
  min-height: 44px;
}
.nav a:hover { background: rgba(255,255,255,.10); color: #fff; }
.nav a.active { background: rgba(255,255,255,.18); font-weight: 800; }
.nav svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav .badge {
  margin-left: auto; background: #fff; color: var(--indigo);
  font-size: 12px; font-weight: 800; border-radius: 10px; padding: 1px 8px;
}
.sidebar .me {
  margin-top: auto; padding: 14px 12px; border-radius: 14px; background: rgba(255,255,255,.10);
  display: flex; align-items: center; gap: 10px;
}
.sidebar .me .who { flex: 1; min-width: 0; }
.sidebar .me strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .me span { font-size: 12px; color: var(--on-dark-muted); }
.sidebar .me button {
  background: none; border: 0; color: #fff; cursor: pointer; padding: 8px; border-radius: 10px; min-width: 40px; min-height: 40px;
}
.sidebar .me button:hover { background: rgba(255,255,255,.14); }

main { flex: 1; min-width: 0; padding: 32px 40px 48px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: 30px; font-weight: 800; margin: 0; line-height: 1.15; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; font-weight: 600; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Building blocks ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 20px; }
.card h2 { font-size: 17px; margin: 0 0 4px; font-weight: 800; }
.card .card-sub { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.section-label {
  font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: .08em;
  text-transform: uppercase; margin: 28px 0 12px 2px;
}

.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.stat.alert { background: var(--bad-bg); border-color: #fbcfd6; }
.stat.alert .value, .stat.alert .label { color: var(--bad-fg); }
.link-btn { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; color: var(--ink); }
.link-btn:hover .name, .link-btn:focus-visible .name { color: var(--indigo); text-decoration: underline; }
.modal.wide { max-width: 720px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 18px; border: 1px solid var(--line); }
.stat .value { font-size: 30px; font-weight: 800; line-height: 1.1; }
.stat .label { color: var(--muted); font-weight: 600; font-size: 13.5px; margin-top: 4px; }
.stat.hero { background: var(--brand); color: #fff; border: 0; }
.stat.hero .label { color: var(--on-dark-muted); }

.waiting { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.waiting a {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.waiting a:hover { border-color: var(--indigo); color: var(--ink); }
.waiting .num {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: var(--violet-soft); color: var(--violet); font-weight: 800; font-size: 18px; flex-shrink: 0;
}
.waiting .num.zero { background: var(--neutral-bg); color: var(--muted); }
.waiting strong { display: block; }
.waiting span { color: var(--muted); font-size: 13px; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1.5px solid transparent;
  background: var(--indigo); color: #fff; font-weight: 700; cursor: pointer; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--indigo-hover); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--card); color: var(--indigo); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--indigo); background: var(--card); color: var(--indigo); }
.btn.danger { background: var(--card); color: var(--bad-fg); border-color: #fbcfd6; }
.btn.danger:hover { background: var(--bad-bg); color: var(--bad-fg); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn svg { width: 18px; height: 18px; }

.chip {
  display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 800; white-space: nowrap;
}
.chip.ok { background: var(--ok-bg); color: var(--ok-fg); }
.chip.wait { background: var(--wait-bg); color: var(--wait-fg); }
.chip.bad { background: var(--bad-bg); color: var(--bad-fg); }
.chip.review { background: var(--review-bg); color: var(--review-fg); }
.chip.neutral { background: var(--neutral-bg); color: var(--neutral-fg); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button {
  min-height: 40px; padding: 0 16px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--card); font-weight: 700; cursor: pointer;
}
.tabs button.active { background: var(--indigo); border-color: var(--indigo); color: #fff; }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  font-weight: 800; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .name { font-weight: 700; }
td .code { color: var(--muted); font-size: 13px; }
td.actions-cell { text-align: right; white-space: nowrap; }
td.actions-cell .btn + .btn { margin-left: 6px; }
tr.inactive td { color: var(--muted); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

.banner {
  display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 14px;
  background: var(--wait-bg); color: var(--wait-fg); font-weight: 600; margin-bottom: 20px;
}
.banner.info { background: var(--violet-soft); color: var(--review-fg); }

img.selfie, .selfie.none {
  width: 56px; height: 56px; border-radius: 14px; object-fit: cover; display: block; background: var(--neutral-bg);
}
img.selfie { cursor: zoom-in; }
.selfie.none { display: grid; place-items: center; font-size: 10.5px; font-weight: 700; color: var(--muted); text-align: center; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 700; font-size: 14px; }
.field .help { color: var(--muted); font-size: 12.5px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card);
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-soft); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-error {
  background: var(--bad-bg); color: var(--bad-fg); font-weight: 700; padding: 10px 14px;
  border-radius: 12px; margin-bottom: 14px; font-size: 14px;
}
.dev-code { background: var(--wait-bg); color: var(--wait-fg); font-weight: 700; padding: 10px 14px; border-radius: 12px; margin-bottom: 14px; }
.inline-input { width: 90px; min-height: 38px; padding: 6px 10px; border-radius: 10px; border: 1.5px solid var(--line); text-align: right; }
.inline-input:focus { outline: none; border-color: var(--indigo); }

.daypicker { display: flex; gap: 8px; flex-wrap: wrap; }
.daypicker label {
  display: inline-flex; align-items: center; justify-content: center; min-width: 58px; min-height: 44px;
  border: 1.5px solid var(--line); border-radius: 12px; font-weight: 700; cursor: pointer; padding: 0 12px;
  background: var(--card);
}
.daypicker input { position: absolute; opacity: 0; pointer-events: none; }
.daypicker input:checked + span { color: #fff; }
.daypicker label:has(input:checked) { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.daypicker label:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--indigo-soft); }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.two-col .card + .card { margin-top: 0; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(30, 27, 75, .45); display: grid; place-items: center;
  padding: 20px; z-index: 50;
}
.modal {
  background: var(--card); border-radius: 22px; width: 100%; max-width: 520px; max-height: calc(100vh - 40px);
  overflow-y: auto; padding: 24px; box-shadow: 0 24px 60px rgba(30, 27, 75, .3);
}
.modal h2 { margin: 0 0 18px; font-size: 21px; font-weight: 800; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(30,27,75,.3); max-width: 360px;
}
.toast.bad { background: var(--bad-fg); }

/* ---------- Narrow screens ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 32px 20px; gap: 32px; }
  .login-brand h1 { font-size: 30px; }
  .shell { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; padding: 14px 16px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .brand { padding: 0 8px 0 0; }
  .nav { display: flex; gap: 4px; overflow-x: auto; width: 100%; order: 3; padding-top: 8px; }
  .nav a { white-space: nowrap; }
  .sidebar .me { margin: 0 0 0 auto; padding: 4px 4px 4px 12px; }
  main { padding: 20px 16px 40px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .waiting, .two-col { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 24px; }
}
.muted { color: var(--muted); font-size: 12px; font-weight: 600; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 10px 12px; border: 1px solid var(--line, #e4e2f3); border-radius: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; cursor: pointer; }
.field[hidden] { display: none; }

/* ---------- Notifications bell ---------- */
.sidebar .me .bell { position: relative; }
.bell-badge {
  position: absolute; top: 2px; right: 0; min-width: 18px; padding: 0 5px; text-align: center;
  background: #fff; color: var(--indigo); font-size: 11px; font-weight: 800; line-height: 18px; border-radius: 9px;
}
.bell-badge[hidden] { display: none; }
.inbox-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; margin-bottom: 14px; }
.inbox-item {
  text-align: left; display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--line, #e4e2f3); border-radius: 12px; background: #fff; font: inherit; color: inherit;
}
.inbox-item.unread { border-color: var(--indigo); background: #f4f3ff; }
.inbox-item span { color: var(--muted); font-size: 14px; }
.inbox-item small { color: var(--muted); font-size: 12px; }
/* The phone app cannot open a print window; downloads work through the app instead. */
.in-app #pr { display: none; }
