:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1b2435;
  --muted: #6b7686;
  --line: #e3e8f0;
  --brand: #2f6bff;
  --brand-ink: #ffffff;
  --green: #17a673;
  --red: #e0493b;
  --amber: #e2a106;
  --shadow: 0 1px 3px rgba(20, 30, 60, .08), 0 6px 20px rgba(20, 30, 60, .05);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; font-size: 14px; cursor: pointer; }

/* ---- Вход ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--card); padding: 32px; border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 360px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

/* ---- Каркас ---- */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: #0f1b33; color: #c7d2e5; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .logo { color: #fff; font-weight: 700; font-size: 18px; padding: 6px 10px 16px; }
.sidebar .logo small { display: block; font-weight: 400; font-size: 12px; color: #8595b4; }
.nav a { display: block; color: #c7d2e5; padding: 10px 12px; border-radius: 9px; margin-bottom: 2px; font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.main { padding: 22px 26px; max-width: 1200px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.topbar h2 { margin: 0; font-size: 20px; }
.user-chip { color: var(--muted); font-size: 13px; }
.user-chip b { color: var(--ink); }

/* ---- Элементы ---- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat .value.green { color: var(--green); }
.stat .value.red { color: var(--red); }
.stat .value.amber { color: var(--amber); }

label.field { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label.field span { display: block; margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
.inline { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }

.btn { background: var(--brand); color: var(--brand-ink); border: none; padding: 9px 16px; border-radius: 9px; font-weight: 600; }
.btn:hover { filter: brightness(1.05); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.danger { background: var(--red); }
.btn.gray { background: #eef1f7; color: var(--ink); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fafbfe; }
td.num, th.num { text-align: right; white-space: nowrap; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.open { background: #fdecec; color: var(--red); }
.badge.partial { background: #fdf3dc; color: var(--amber); }
.badge.closed { background: #e5f6ee; color: var(--green); }
.badge.late { background: #fdf3dc; color: var(--amber); }
.badge.absent { background: #fdecec; color: var(--red); }
.badge.left_early { background: #eef1f7; color: var(--muted); }
.badge.ontime { background: #e5f6ee; color: var(--green); }

.toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.muted { color: var(--muted); }
.err { color: var(--red); font-size: 13px; margin: 8px 0; min-height: 18px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* ---- Модалка ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,27,51,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; padding: 22px; }
.modal h3 { margin: 0 0 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }

/* мини-график */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 2px; align-items: flex-end; width: 100%; justify-content: center; height: 100%; }
.bars .bar { width: 12px; border-radius: 3px 3px 0 0; }
.bars .bar.inc { background: var(--green); }
.bars .bar.exp { background: var(--red); }
.bars .m { font-size: 10px; color: var(--muted); }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar .logo { width: 100%; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav a { padding: 7px 11px; }
  .main { padding: 16px; }
}
