/* Work-site — оформление в стиле московского метрополитена.
   Фирменный красный — «М», у каждого раздела свой цвет линии. */

:root {
  --metro-red: #D52B1E;
  /* цвета линий */
  --l1: #E42313; --l2: #4BAF4F; --l3: #0072BA; --l4: #1EBCEF; --l5: #915133;
  --l6: #F07E24; --l7: #943E90; --l8: #FFCD1C; --l9: #ADACAC; --l10: #BED12C;

  --bg: #F2F3F5; --surface: #FFFFFF; --surface-2: #F7F8FA; --fg: #1B1C1F; --muted: #6A6F78;
  --line: #E1E3E8; --line-strong: #CDD1D8;
  --accent: var(--l3); --accent-hover: #005A93; --accent-soft: #E3F0F9;
  --bad: #D52B1E; --bad-soft: #FCE8E6; --warn: #C25E00; --warn-soft: #FFF1E0;
  --ok: #2E8B3A; --ok-soft: #E6F4E7; --idle: #6A6F78; --idle-soft: #EDEEF1;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --surface: #1A1D22; --surface-2: #20242A; --fg: #ECEEF2; --muted: #9AA1AC;
    --line: #2C3138; --line-strong: #3A4049;
    --accent: #3D9BE0; --accent-hover: #63B1EA; --accent-soft: #15324A;
    --bad: #FF6B5E; --bad-soft: #3A1C1A; --warn: #FFA24C; --warn-soft: #3A2814;
    --ok: #6CCB76; --ok-soft: #1A3320; --idle: #9AA1AC; --idle-soft: #262A31;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.5 "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 8px 0 12px; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 24px 0 10px; }
h3 { font-size: 1.05rem; margin: 18px 0 8px; }
small, .hint { color: var(--muted); }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
main { padding: 16px; max-width: 1240px; margin: 0 auto; }

/* --- шапка --- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); }
.brand:hover { text-decoration: none; }
.logo {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px;
  background: var(--metro-red); color: #fff; font: 700 23px/1 Arial, sans-serif;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 1.05rem; }
.brand-text small { font-size: .78rem; }
.account { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.account form { margin: 0; }
.account .tool { color: var(--muted); font-size: .92rem; }
.account .tool:hover { color: var(--accent); }

/* --- меню-«линии» --- */
nav.lines {
  display: flex; gap: 4px; overflow-x: auto; padding: 0 12px; background: var(--surface);
  border-bottom: 1px solid var(--line); scrollbar-width: thin;
}
nav.lines a.line {
  display: flex; align-items: center; gap: 7px; padding: 11px 10px 9px; white-space: nowrap;
  color: var(--fg); border-bottom: 3px solid transparent; font-size: .95rem;
}
nav.lines a.line:hover { text-decoration: none; background: var(--surface-2); }
nav.lines a.line.active { border-bottom-color: var(--c); font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; display: inline-block; }
.line-home { --c: var(--metro-red); }
.line-siz { --c: var(--l6); }
.line-instr { --c: var(--l2); }
.line-exams { --c: var(--l7); }
.line-norms { --c: var(--l5); }
.line-tp { --c: var(--l4); }
.line-cards { --c: var(--l8); }
.line-apparatura { --c: var(--l3); }
.line-schedule { --c: var(--l9); }

.line-title { display: flex; align-items: center; gap: 10px; }
.line-title .dot { width: 16px; height: 16px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent); }
.line-badge { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; white-space: nowrap; }
.line-badge::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }

/* --- кнопки и поля --- */
input, select, button, textarea { font: inherit; color: inherit; }
input, select, textarea {
  padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
  min-height: 36px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
button, .button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 7px 16px; border-radius: 999px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background .15s;
}
button:hover, .button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn.ghost, button.ghost { background: transparent; color: var(--fg); border-color: var(--line-strong); }
.btn.ghost:hover, button.ghost:hover { background: var(--surface-2); }
.btn.small, button.small { min-height: 30px; padding: 4px 12px; font-size: .88rem; }
.btn.danger, button.danger { color: var(--bad); }
.search {
  width: min(460px, 100%); padding-left: 34px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236A6F78' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E") no-repeat 11px center;
}

form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
form.done { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
form.stack { display: grid; gap: 8px; max-width: 560px; }
form.stack label { display: grid; grid-template-columns: 210px 1fr; align-items: center; gap: 8px; }
form.stack button { justify-self: start; }
@media (max-width: 600px) { form.stack label { grid-template-columns: 1fr; } }
td.inline-forms form { display: inline; margin-right: 6px; }

/* --- карточки и таблицы --- */
.table-card, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow-x: auto;
}
.panel { padding: 4px 16px 14px; margin-top: 20px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th {
  position: sticky; top: 0; background: var(--surface-2); z-index: 1;
  font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600;
}
tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
tr.group th {
  padding: 14px 10px 8px; font-size: 1rem; background: var(--surface); color: var(--fg);
  border-left: 4px solid var(--c, var(--accent)); text-transform: none; letter-spacing: 0;
}
tr.rejected td { color: var(--muted); }
tr[data-status="overdue"] td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
tr[data-status="due_soon"] td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
tr.just-saved td { animation: saved 1.6s ease-out; }
@keyframes saved { from { background: var(--ok-soft); } to { background: transparent; } }
.cell-done, .cell-due { white-space: nowrap; }
.cell-due .hint { display: block; font-size: .82rem; margin-top: 2px; }
.cell-card { text-align: right; }
.icon-link { font-size: .85rem; color: var(--muted); }
.icon-link:hover { color: var(--accent); }

/* дата прямо в таблице (как в Excel) */
input.inline-date {
  min-height: 32px; padding: 4px 8px; border-color: transparent; background: var(--surface-2); cursor: pointer;
  font-variant-numeric: tabular-nums; width: 9.6em;
}
input.inline-date:hover { border-color: var(--line-strong); }
input.inline-date:focus { background: var(--surface); }
input.inline-date.saving { opacity: .5; }
input.inline-date.due.st-overdue { color: var(--bad); font-weight: 600; background: var(--bad-soft); }
input.inline-date.due.st-due_soon { color: var(--warn); font-weight: 600; background: var(--warn-soft); }

/* --- статусы --- */
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-weight: 600; font-size: .9rem;
  font-variant-numeric: tabular-nums; background: var(--ok-soft); color: var(--ok);
}
.chip.st-overdue { background: var(--bad-soft); color: var(--bad); }
.chip.st-due_soon { background: var(--warn-soft); color: var(--warn); }
.chip.st-not_entered { background: var(--idle-soft); color: var(--idle); }
.chip.st-rejected { background: var(--idle-soft); color: var(--idle); text-decoration: line-through; }
.st-overdue { color: var(--bad); font-weight: 600; }
.st-due_soon { color: var(--warn); font-weight: 600; }
.st-not_entered { color: var(--idle); }
.st-rejected { color: var(--muted); text-decoration: line-through; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--idle-soft); color: var(--muted);
  font-size: .8rem; vertical-align: middle;
}
.error { color: var(--bad); }

/* --- главная --- */
.home-section {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin: 12px 0; padding: 0 0 4px;
}
.home-section > summary {
  cursor: pointer; padding: 12px 16px; font-size: 1.02rem; list-style: none; display: flex; align-items: center; gap: 8px;
}
.home-section > summary::-webkit-details-marker { display: none; }
.home-section > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.home-section[open] > summary::before { transform: rotate(90deg); }
.home-section > .table-card { border: 0; box-shadow: none; border-radius: 0 0 var(--radius) var(--radius); }
.home-section.upcoming { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.notice {
  margin: 12px 0; padding: 12px 16px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
}
.notice.st-due_soon, .notice.st-not_entered { font-weight: 400; color: var(--fg); border-left-color: var(--warn); }
.hint-bar { background: var(--accent-soft); color: var(--fg); padding: 9px 14px; border-radius: 10px; font-size: .92rem; }

/* --- карточка, факты, архив --- */
.facts {
  display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow);
}
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
ol.history { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 18px 10px 38px; }
ol.history li { padding: 4px 0; }
ol.history form.del { display: inline; margin-left: 8px; }
.back { color: var(--muted); }

/* --- вкладки (аппаратура, графики) --- */
nav.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
nav.tabs a {
  padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-strong);
  color: var(--fg); font-size: .93rem;
}
nav.tabs a:hover { text-decoration: none; border-color: var(--accent); }
nav.tabs a.current { background: var(--accent); border-color: var(--accent); color: #fff; }
nav.tabs a.current small { color: rgba(255, 255, 255, .8); }
a.current { font-weight: 700; }

/* --- график работы --- */
.scroll { overflow-x: auto; }
table.grid { background: var(--surface); }
table.grid th, table.grid td { padding: 5px 5px; text-align: center; white-space: nowrap; font-size: .82rem; border: 1px solid var(--line); }
table.grid tbody th { text-align: left; position: sticky; left: 0; background: var(--surface); }
table.grid td.off { color: var(--muted); }
table.grid td.vac { color: var(--muted); background: var(--idle-soft); }
ul.shifts { columns: 3 220px; }

/* --- выгрузки --- */
table.export th, table.export td { font-size: .85rem; white-space: nowrap; }
tr.off-plan td { background: var(--warn-soft); }

/* --- всплывающее сообщение «Записано · Отменить» --- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 140%); opacity: 0;
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
  padding: 11px 16px; border-radius: 12px; background: #1B1C1F; color: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
  transition: transform .2s, opacity .2s; z-index: 50; font-size: .95rem;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--metro-red); }
.toast-undo { background: transparent; border: 1px solid rgba(255, 255, 255, .5); color: #fff; min-height: 30px; padding: 3px 12px; }
.toast-undo:hover { background: rgba(255, 255, 255, .12); }

/* телефон: строки таблиц — карточки, даты рядом под названием */
@media (max-width: 700px) {
  table.data thead { display: none; }
  table.data, table.data tbody { display: block; }
  table.data tr { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 12px; padding: 10px 12px;
                  border-bottom: 1px solid var(--line); }
  table.data td, table.data tr.group th { display: block; border: 0; padding: 0; box-shadow: none !important; }
  table.data td { flex: 1 1 100%; }
  table.data td.cell-done, table.data td.cell-due { flex: 1 1 40%; }
  table.data td.cell-done::before { content: "Выполнено"; }
  table.data td.cell-due::before { content: "Срок"; }
  table.data td.cell-done::before, table.data td.cell-due::before {
    display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 2px;
  }
  table.data td.cell-card { flex: 0 0 auto; margin-left: auto; }
  table.data tr.group { padding: 12px 12px 6px; }
  table.data tr.group th { padding-left: 8px; border-left: 4px solid var(--c, var(--accent)) !important; }
  table.data tr[data-status="overdue"] { box-shadow: inset 3px 0 0 var(--bad); }
  table.data tr[data-status="due_soon"] { box-shadow: inset 3px 0 0 var(--warn); }
  table.data tbody tr:hover td { background: transparent; }
  input.inline-date { width: 100%; }
  table.data td.cell-place.empty { display: none; }
  table.data td.cell-place { color: var(--muted); font-size: .9rem; }
}

@media (max-width: 700px) {
  main { padding: 12px; }
  h1 { font-size: 1.35rem; }
  .brand-text small { display: none; }
  .account { margin-left: 0; width: 100%; }
  th, td { padding: 8px 8px; }
}
