/* Светлая тема в мягких «водных» тонах. Тёмной темы нет намеренно. */
:root {
  --bg: #f2f8fb;
  --surface: #ffffff;
  --surface-2: #eaf4f8;
  --text: #22384a;
  --muted: #6b8294;
  --border: #d6e6ee;
  --accent: #2b93c4;
  --accent-ink: #ffffff;
  --accent-soft: #dff1f9;
  --ok: #2f9d6b;
  --ok-soft: #e1f4ea;
  --warn: #b27a1e;
  --warn-soft: #fcf2df;
  --danger: #d0584c;
  --danger-soft: #fcebe8;
  --t1: #2b93c4; --t2: #8069c9; --t3: #22a197;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(34, 80, 110, .05), 0 4px 14px rgba(34, 80, 110, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: linear-gradient(180deg, #e6f3f9 0, var(--bg) 320px) no-repeat, var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* шапка */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 56px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); box-shadow: 0 1px 6px rgba(34, 80, 110, .05); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); letter-spacing: .02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; }
#nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
#nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 500; }
#nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
#nav a.active { background: var(--accent-soft); color: var(--accent); }
.me { display: flex; align-items: center; gap: 10px; white-space: nowrap; color: var(--muted); font-size: 14px; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 48px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { flex: 1; min-width: 200px; }
.back { display: inline-block; margin-bottom: 8px; font-size: 14px; }

/* карточки */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.kpi .card { margin: 0; }
.kpi .value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .danger { color: var(--danger); }
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; overflow-wrap: anywhere; }

/* кнопки и формы */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.secondary { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); font-weight: 500; }
.btn.danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 38px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 70px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; cursor: pointer; }
label.check input { width: 18px; height: 18px; min-height: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 340px; }
.toolbar select, .toolbar input[type=month] { width: auto; }

/* таблицы */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
tfoot td { font-weight: 700; }

/* метки */
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.tag.t1 { background: color-mix(in srgb, var(--t1) 15%, transparent); color: var(--t1); }
.tag.t2 { background: color-mix(in srgb, var(--t2) 15%, transparent); color: var(--t2); }
.tag.t3 { background: color-mix(in srgb, var(--t3) 15%, transparent); color: var(--t3); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }

/* вкладки */
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tabs a { padding: 6px 14px; border-radius: 7px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* задачи */
.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 8px; }
.task.overdue { border-left: 4px solid var(--danger); }
.task.done { opacity: .75; border-left: 4px solid var(--ok); }
.task .body { flex: 1; min-width: 0; }
.task .title { font-weight: 600; }
.task .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.task .tags { margin-top: 6px; }
.day-group { margin-bottom: 18px; }
.day-group h3 { position: sticky; top: 56px; background: var(--surface); padding: 6px 0; z-index: 1; }
.empty { padding: 24px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }

/* прогресс */
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; min-width: 80px; }
.progress > div { height: 100%; background: var(--ok); border-radius: 99px; }
.progress.big { height: 14px; }

/* график обслуживания */
.sched { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.sched .item { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.sched .item .date { font-size: 20px; font-weight: 700; margin: 4px 0; font-variant-numeric: tabular-nums; }
.sched .item.overdue { border-color: var(--danger); background: var(--danger-soft); }

/* вход */
.login { max-width: 360px; margin: 10vh auto 0; }
.login .brand { justify-content: center; font-size: 22px; margin-bottom: 20px; }
.login .brand img { width: 40px; height: 40px; }
.error { color: var(--danger); background: var(--danger-soft); padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.error:empty { display: none; }

/* модальное окно */
dialog { border: none; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(34, 70, 95, .35); }
dialog form { padding: 20px; }
dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; position: sticky; bottom: -20px; background: var(--surface); padding: 12px 0 0; }
dialog h2 { margin-bottom: 16px; }
.hint { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .2s; background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-weight: 500; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 6px 12px; }
  .brand span { display: none; }
  #nav { order: 3; flex-basis: 100%; }
  .me { margin-left: auto; }
  .day-group h3 { top: 96px; }
  main { padding-top: 14px; }
  .hide-sm { display: none; }
  dl.props { grid-template-columns: 1fr; gap: 0; }
  dl.props dd { margin-bottom: 8px; }
}

@media print {
  .topbar, .toolbar, .actions, .btn, #toast { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: none; box-shadow: none; padding: 0; }
  main { max-width: none; padding: 0; }
}
