/* Админка учёта рабочего времени.
   Состояние ячейки передаётся не только цветом: у каждого есть знак и подпись —
   табель печатают в чёрно-белом виде, и цветовосприятие у людей разное. */

:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #d9e0ea;
  --text: #1c2430;
  --muted: #6b7a8d;
  --accent: #1f4e79;
  --accent-soft: #e8eff7;
  --ok: #1f7a3d;
  --ok-soft: #e4f3e8;
  --warn: #9a6b00;
  --warn-soft: #fdf3dd;
  --bad: #a32b1c;
  --bad-soft: #fbe6e3;
  --off: #eceff4;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 22px 0 8px; font-weight: 600; }
.muted { color: var(--muted); }
button { font: inherit; cursor: pointer; }

/* ------------------------------------------------------------- вход */
.login { min-height: 100%; display: grid; place-items: center; }
.login-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 28px 26px; width: 330px; box-shadow: 0 6px 24px rgba(20,40,70,.08);
}
.login-box label { display: block; margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.login-box input {
  width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--text);
}
.login-box button { width: 100%; margin-top: 18px; }

/* ----------------------------------------------------------- шапка */
.top {
  display: flex; align-items: center; gap: 18px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 0 18px; height: 52px; position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 600; color: var(--accent); white-space: nowrap; }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.tabs button {
  background: none; border: none; padding: 8px 12px; border-radius: 7px;
  color: var(--muted); white-space: nowrap;
}
.tabs button:hover { background: var(--bg); }
.tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.badge {
  display: inline-block; min-width: 18px; padding: 1px 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; text-align: center;
}

main { padding: 18px; }
.view { max-width: 1500px; }

/* --------------------------------------------------------- кнопки */
button.primary { background: var(--accent); color: #fff; border: none; border-radius: 7px; padding: 8px 15px; }
button.primary:hover { background: #1a4268; }
button.link { background: none; border: none; color: var(--accent); padding: 4px; text-decoration: underline; }
.toolbar button:not(.primary):not(.link) {
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 7px 12px;
}
button.danger { background: var(--bad-soft); border: 1px solid #e8b6ae; color: var(--bad);
                border-radius: 7px; padding: 6px 11px; }

/* -------------------------------------------------------- карточки */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
}
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 27px; font-weight: 600; margin-top: 4px; }
.card .value small { font-size: 14px; font-weight: 400; color: var(--muted); }
.card.alarm { border-color: #e8b6ae; background: var(--bad-soft); }

/* --------------------------------------------------------- таблицы */
table.list { width: 100%; border-collapse: collapse; background: var(--panel);
             border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.list th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fafbfd;
}
table.list td { padding: 9px 12px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list tr.clickable:hover { background: var(--accent-soft); cursor: pointer; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px;
}
.toolbar input, .toolbar select {
  padding: 7px 10px; font: inherit; border: 1px solid var(--line);
  border-radius: 7px; background: var(--panel); color: var(--text);
}
.toolbar label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.check { user-select: none; }
.legend { margin-left: auto; color: var(--muted); font-size: 12px; display: flex; gap: 12px; align-items: center; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px;
            border: 1px solid var(--line); margin-right: 4px; vertical-align: -2px; }
.c-ok { background: var(--ok-soft); }
.c-warn { background: var(--warn-soft); }
.c-off { background: var(--off); }
.c-open { background: var(--accent-soft); }

/* ----------------------------------------------------- сетка табеля */
.grid-wrap { overflow: auto; max-height: calc(100vh - 190px);
             border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.grid th, table.grid td { border-bottom: 1px solid #eef1f6; border-right: 1px solid #eef1f6; }
table.grid thead th {
  position: sticky; top: 0; background: #fafbfd; z-index: 2; padding: 6px 4px;
  font-weight: 600; color: var(--muted); min-width: 34px; text-align: center;
}
table.grid thead th.weekend { background: #f0f2f6; }
table.grid td.name, table.grid th.name {
  position: sticky; left: 0; background: var(--panel); z-index: 1;
  min-width: 190px; padding: 6px 10px; text-align: left;
}
table.grid thead th.name { z-index: 3; background: #fafbfd; }
table.grid td.cell { text-align: center; padding: 4px 2px; cursor: pointer; height: 30px; }
table.grid td.cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
td.cell .mark { font-size: 10px; display: block; line-height: 1; }
td.s-ok { background: var(--ok-soft); }
td.s-warn { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
td.s-off { background: var(--off); color: var(--muted); }
td.s-open { background: var(--accent-soft); }
td.total { font-weight: 600; text-align: right; padding-right: 10px; background: #fafbfd; }

/* ---------------------------------------------------------- панель */
.panel {
  position: fixed; right: 0; top: 0; bottom: 0; width: 460px; max-width: 94vw;
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -8px 0 28px rgba(20,40,70,.12); display: flex; flex-direction: column; z-index: 20;
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start;
              padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-body { overflow: auto; padding: 14px 16px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-bottom: 14px; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; font-variant-numeric: tabular-nums; }
.kv .v.big { font-size: 18px; font-weight: 600; }
.block { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.block h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase;
            letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0;
       border-bottom: 1px solid #f0f3f7; }
.row:last-child { border-bottom: none; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--off); color: var(--muted); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }

/* ----------------------------------------------------------- прочее */
.modal { position: fixed; inset: 0; background: rgba(20,32,48,.45);
         display: grid; place-items: center; z-index: 30; }
.modal-box { background: var(--panel); border-radius: 12px; padding: 22px 24px;
             width: 420px; max-width: 92vw; }
.modal-box textarea { width: 100%; min-height: 74px; font: inherit; padding: 8px;
                      border: 1px solid var(--line); border-radius: 7px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.pin { font-size: 38px; font-weight: 700; letter-spacing: 8px; text-align: center;
       padding: 16px; background: var(--accent-soft); border-radius: 10px; margin: 12px 0; }
.error { color: var(--bad); margin-top: 10px; min-height: 18px; font-size: 13px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
         background: #1c2430; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 40; }
.empty { padding: 26px; text-align: center; color: var(--muted); }
