:root {
  --bg: #f4f5f7; --card: #fff; --text: #1f2328; --muted: #65707c; --line: #e3e6ea;
  --accent: #1f6feb; --accent-soft: #e6f0fd; --side: #1e2532; --side-text: #c9d1dc;
  --green: #1a7f37; --green-soft: #e3f4e6; --amber: #9a6700; --amber-soft: #fdf1d6;
  --red: #c4262e; --red-soft: #fde8e8; --coral: #b4471c; --coral-soft: #fbe9e1;
  --violet: #6639ba; --violet-soft: #efe9fb; --gray-soft: #eef0f2;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }

.test-banner { background: #d4570f; color: #fff; text-align: center; padding: 6px 16px; font-weight: 700; letter-spacing: .04em; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 230px; flex-shrink: 0; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 16px 12px; }
.sidebar .brand { color: #fff; font-weight: 700; font-size: 1.15rem; padding: 4px 10px 18px; display: flex; align-items: center; gap: 8px; text-decoration: none; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar .section { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #7f8a99; padding: 14px 10px 6px; }
.sidebar nav a { color: var(--side-text); text-decoration: none; padding: 9px 10px; border-radius: 8px; display: flex; align-items: center; gap: 10px; font-size: .95rem; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar nav a i { font-size: 1.15rem; }
.sidebar .user { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: .88rem; }
.sidebar .user button { background: none; border: 0; color: var(--side-text); cursor: pointer; font: inherit; padding: 6px 0 0; display: flex; align-items: center; gap: 6px; }
.sidebar .user button:hover { color: #fff; }

.content { flex: 1; min-width: 0; }
.topbar { display: none; }
main { max-width: 1200px; margin: 0 auto; padding: 24px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 20px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
.tile .icon { font-size: 1.4rem; }
.tile .num { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.tile .label { font-size: .9rem; font-weight: 500; }
.tile .hint { font-size: .8rem; opacity: .8; }
.tile.green { background: var(--green-soft); color: var(--green); }
.tile.amber { background: var(--amber-soft); color: var(--amber); }
.tile.red { background: var(--red-soft); color: var(--red); }
.tile.violet { background: var(--violet-soft); color: var(--violet); }
.tile.blue { background: var(--accent-soft); color: var(--accent); }
.tile.gray { background: var(--card); border: 1px solid var(--line); }
a.tile:hover { outline: 2px solid currentColor; }
.tile.selected { outline: 2px solid currentColor; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; overflow-x: auto; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; margin-right: auto; }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; height: 100%; }
.chart .stack { flex: 1; width: 100%; max-width: 34px; display: flex; flex-direction: column-reverse; border-radius: 5px; overflow: hidden; background: var(--gray-soft); }
.chart .seg.present { background: #4cae6a; } .chart .seg.half { background: #e8a26b; } .chart .seg.absent { background: #e06469; }
.chart .day { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .present::before { background: #4cae6a; } .legend .half::before { background: #e8a26b; } .legend .absent::before { background: #e06469; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: #fafbfc; }
td.why { white-space: normal; min-width: 260px; color: var(--muted); font-size: .85rem; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.present { background: var(--green-soft); color: var(--green); }
.badge.half_day { background: var(--coral-soft); color: var(--coral); }
.badge.absent { background: var(--red-soft); color: var(--red); }
.badge.late { background: var(--amber-soft); color: var(--amber); }
.badge.missing { background: var(--violet-soft); color: var(--violet); }
.badge.off_day, .badge.holiday, .badge.pending, .badge.not_employed, .badge.neutral { background: var(--gray-soft); color: var(--muted); }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warning { background: var(--amber-soft); color: var(--amber); }
.badge.failed { background: var(--red-soft); color: var(--red); }
.badge.running { background: var(--gray-soft); color: var(--muted); }

.bar { height: 8px; border-radius: 4px; background: var(--gray-soft); overflow: hidden; min-width: 80px; }
.bar > div { height: 100%; background: #4cae6a; }

.muted { color: var(--muted); }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--accent-soft); }
.msg.error { background: var(--red-soft); } .msg.success { background: var(--green-soft); } .msg.warning { background: var(--amber-soft); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
input[type=text], input[type=password], input[type=date], input[type=time], select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--line); }
.pager { margin-top: 12px; display: flex; gap: 12px; align-items: center; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login-card input { width: 100%; }

@media (max-width: 860px) {
  .layout { display: block; }
  .topbar { display: flex; align-items: center; gap: 10px; background: var(--side); color: #fff; padding: 10px 14px; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; padding: 0; }
  .sidebar { display: none; width: auto; }
  .sidebar.open { display: flex; }
  .sidebar .brand { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  main { padding: 16px; }
}
