/* Судебник – фирменный стиль «Бородин и Партнеры»
   Шрифты: KuzanyanC – название месяца и экран входа (шрифт логотипа),
           Arno Pro Bold – заголовки дней, Golos Text – всё рабочее.
   Цвета из фирменного руководства: бордовый (CMYK 0/100/90/60), тёмно-серый (K90), белый. */

@font-face { font-family: "Golos"; src: url(/static/fonts/golos-cyr-400.woff2) format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0400-045F, U+2116; }
@font-face { font-family: "Golos"; src: url(/static/fonts/golos-lat-400.woff2) format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Golos"; src: url(/static/fonts/golos-cyr-500.woff2) format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0400-045F, U+2116; }
@font-face { font-family: "Golos"; src: url(/static/fonts/golos-lat-500.woff2) format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Golos"; src: url(/static/fonts/golos-cyr-600.woff2) format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0400-045F, U+2116; }
@font-face { font-family: "Golos"; src: url(/static/fonts/golos-lat-600.woff2) format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: "Arno"; src: url(/static/fonts/arno-bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Kuzanyan"; src: url(/static/fonts/kuzanyan.woff2) format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --ground: #ffffff;
  --raised: #f7f6f5;
  --active: #efedeb;
  --border: #e6e3e1;
  --rule: #f0eeec;
  --control: #cfcbc8;
  --text: #262626;
  --ink-brand: #424242;          /* серый логотипа */
  --muted: #5e5e5e;
  --faint: #6b6b6b;
  --brand: #871813;              /* бордовый логотипа */
  --brand-hover: #6f130f;
  --brand-tint: #f8eeec;
  --trip: #1a7f43;               /* мониторинг – зелёным, как в бумажном судебнике */
  --negative: #b3261e;
  --radius: 6px;
  --gap: 16px;
  --font: "Golos", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-day: "Arno", Georgia, "Times New Roman", serif;
  --font-brand: "Kuzanyan", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--text); font: 400 14px/20px var(--font); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.num, time { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- кнопки и поля ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid var(--control); background: #fff; cursor: pointer; white-space: nowrap;
  font-weight: 500; text-decoration: none; color: var(--text); transition: background .15s, border-color .15s, transform .08s; }
.btn:hover { background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--active); }
.btn.danger { color: var(--negative); border-color: #e3c4c1; }
.btn.danger:hover { background: #fbf0ef; }
.btn.icon { width: 36px; padding: 0; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn[disabled] { opacity: .6; cursor: default; }

.field { display: grid; gap: 6px; }
.field > span { font-weight: 500; }
.field small { color: var(--muted); font-size: 12px; line-height: 16px; }
.input { height: 40px; padding: 0 12px; border: 1px solid var(--control); border-radius: var(--radius); background: #fff; width: 100%; min-width: 0; }
textarea.input { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 20px; }
.input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.datebox { position: relative; display: block; }
.datebox .input { padding-right: 44px; }
.dnative { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.dpick { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 40px; height: 36px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; border-radius: 4px; }
.dpick:hover { background: var(--active); color: var(--text); }
.dpick svg { width: 18px; height: 18px; }
.row2 { align-items: start; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--active); border-radius: var(--radius); padding: 3px; gap: 3px; }
.seg label { display: grid; place-items: center; height: 34px; border-radius: 4px; cursor: pointer; font-weight: 500; color: var(--muted); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: var(--text); }
.seg label:has(input:checked) { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--brand); }

.err { color: var(--negative); font-weight: 500; min-height: 20px; }

/* ---------- вход ---------- */
.login { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px; }
.login form { width: 100%; max-width: 360px; display: grid; gap: 16px; }
.login img { width: 260px; height: auto; max-width: 80%; margin: 0 0 24px; }
.login h1 { font: 400 32px/36px var(--font-brand); color: var(--ink-brand); margin: 0; letter-spacing: .01em; }
.login p.lead { margin: -8px 0 8px; color: var(--muted); }
.login .btn { height: 44px; }

/* ---------- шапка ---------- */
.bar { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--border); }
.bar-in { display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 24px; }
.bar .logo { height: 34px; width: auto; display: block; }
.bar .mark { height: 34px; width: auto; display: none; }
.monthnav { display: flex; align-items: center; gap: 4px; margin-left: 24px; }
.monthnav h1 { font: 400 28px/32px var(--font-brand); color: var(--ink-brand); margin: 0 6px; min-width: 210px; text-align: center; letter-spacing: .01em; }
.bar .spacer { flex: 1; }
.search { position: relative; width: 240px; }
.search svg { position: absolute; left: 11px; top: 11px; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search input { padding-left: 34px; height: 36px; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 44px; min-width: 240px; background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; display: grid; z-index: 30; }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 4px; border: 0; background: none;
  text-align: left; cursor: pointer; color: var(--text); text-decoration: none; font-weight: 500; }
.menu a:hover, .menu button:hover { background: var(--raised); }
.menu .who { padding: 8px 12px 10px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--rule); margin-bottom: 4px; }
.menu .who b { display: block; color: var(--text); font-size: 14px; font-weight: 600; }
.menu .only-phone { display: none; }

.subbar { display: flex; align-items: baseline; gap: 12px; padding: 10px 24px; color: var(--muted); font-size: 13px; line-height: 18px; }
.subbar .hdr { flex: 1; }
.subbar a { white-space: nowrap; }
.stamp { color: var(--faint); white-space: nowrap; font-size: 12px; }

/* ---------- сетка месяца (компьютер) ---------- */
.month { padding: 0 24px 48px; }
.weekdays, .week { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) repeat(2, minmax(0, .55fr)); }
.weekdays { position: sticky; top: 64px; z-index: 10; background: #fff; border-bottom: 1px solid var(--border); }
.weekdays div { padding: 8px 12px; font-weight: 500; color: var(--muted); font-size: 13px; }
.week { border-bottom: 1px solid var(--border); }
.day { position: relative; padding: 10px 12px 14px; min-height: 150px; border-right: 1px solid var(--rule); min-width: 0; }
.day:last-child { border-right: 0; }
.day.wkend { background: #fbfaf9; }
.day.wkend .dnum { color: var(--muted); }
.day.out { background: var(--raised); }
.day.out .dnum { color: var(--faint); }
.day.today { background: var(--brand-tint); box-shadow: inset 0 3px 0 var(--brand); }
.day.today .dnum { color: var(--brand); }
.dhead { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.dnum { font: 700 22px/26px var(--font-day); color: var(--ink-brand); font-variant-numeric: lining-nums; }
.dlabel { color: var(--brand); font-size: 12px; font-weight: 600; }
.addday { margin-left: auto; opacity: 0; width: 28px; height: 28px; border-radius: 4px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; transition: opacity .15s, background .15s; }
.addday svg { width: 16px; height: 16px; }
.day:hover .addday, .addday:focus-visible { opacity: 1; }
.addday:hover { background: var(--active); color: var(--text); }
.status { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 2px; }
.status li { font-weight: 600; font-size: 13px; line-height: 18px; color: var(--ink-brand); }
.status li.abs { color: var(--muted); font-weight: 500; }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.ev { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 3px 6px; margin: 0 -6px; width: calc(100% + 12px);
  border-radius: 4px; cursor: pointer; font-size: 13px; line-height: 18px; color: var(--text); overflow-wrap: anywhere; }
.ev:hover { background: var(--active); }
.ev time { font-weight: 600; margin-right: 4px; }
.ev .who { color: var(--muted); }
.ev.st { font-weight: 600; color: var(--ink-brand); font-size: inherit; }
.ev.hit, .status li.hit { background: #fff3c4; }
.events + .empty, .empty { color: var(--faint); font-size: 13px; }

/* ---------- страницы ---------- */
.page { max-width: 880px; margin: 0 auto; padding: 24px 24px 64px; }
.page h2 { font: 400 28px/32px var(--font-brand); color: var(--ink-brand); margin: 0 0 4px; }
.page .lead { color: var(--muted); margin: 0 0 24px; }
.panel { border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 24px; }
.panel h3 { font: 700 18px/24px var(--font-day); margin: 0 0 12px; color: var(--ink-brand); }
.grid-form { display: grid; grid-template-columns: 1.6fr 1.2fr minmax(150px, 1fr) minmax(150px, 1fr) auto; gap: 12px; align-items: end; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.list li:last-child { border-bottom: 0; }
.list .main { flex: 1; min-width: 0; }
.list .sub { color: var(--muted); font-size: 12px; }
.list .tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--active); color: var(--muted); }
.log li { align-items: flex-start; }
.log .when { width: 120px; flex: none; color: var(--muted); font-size: 12px; line-height: 20px; }
.log .act-delete .main { color: var(--muted); }
.back { display: inline-flex; margin-bottom: 16px; }

/* ---------- окно записи ---------- */
dialog { border: 0; padding: 0; border-radius: 10px; width: min(520px, calc(100vw - 32px)); max-height: calc(100svh - 32px);
  box-shadow: 0 24px 60px rgba(0,0,0,.25); color: var(--text); }
dialog::backdrop { background: rgba(20,20,20,.4); }
dialog form { display: grid; gap: 16px; padding: 20px; }
dialog h2 { font: 700 20px/26px var(--font-day); margin: 0; color: var(--ink-brand); }
.sheet-head { display: flex; align-items: center; gap: 8px; }
.sheet-head h2 { flex: 1; }
.sheet-foot { display: flex; gap: 8px; align-items: center; }
.sheet-foot .grow { flex: 1; }
.meta { color: var(--muted); font-size: 12px; line-height: 16px; }

/* ---------- уведомления ---------- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #222; color: #fff; border-radius: 8px; padding: 10px 14px; display: flex; gap: 12px; align-items: center;
  transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px); }
#toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: none; border: 0; color: #f3c9c5; font-weight: 600; cursor: pointer; padding: 4px; }

.fab { display: none; }
.loading { padding: 48px 24px; color: var(--muted); }

/* ---------- планшет ---------- */
@media (max-width: 1180px) {
  .search { width: 180px; }
  .bar .logo { display: none; }
  .bar .mark { display: block; }
  .monthnav { margin-left: 8px; }
}

/* ---------- телефон: список дней вместо сетки ---------- */
@media (max-width: 760px) {
  body { font-size: 15px; line-height: 22px; }
  .bar-in { height: 56px; padding: 0 8px 0 16px; gap: 4px; }
  .bar .mark { height: 30px; }
  .monthnav { margin-left: 4px; gap: 0; }
  .monthnav h1 { font-size: 23px; line-height: 28px; min-width: 0; margin: 0 2px; white-space: nowrap; }
  .bar .desk { display: none; }
  .btn.icon { width: 44px; height: 44px; }
  .menu .only-phone { display: flex; }
  .search.phone { width: auto; margin: 0 16px 8px; }
  .subbar { padding: 8px 16px; flex-wrap: wrap; }
  .weekdays { display: none; }
  .month { padding: 0 0 120px; }
  .week { display: block; border: 0; }
  .day { min-height: 0; border: 0; padding: 0 16px 14px; border-bottom: 1px solid var(--rule); }
  .day.out { display: none; }
  .day.today { box-shadow: none; background: #fff; }
  .dhead { position: sticky; top: 56px; z-index: 5; background: #fff; margin: 0 -16px 6px; padding: 12px 16px 6px; }
  .day.today .dhead { background: var(--brand-tint); box-shadow: inset 3px 0 0 var(--brand); }
  .dnum { font-size: 19px; line-height: 24px; }
  .addday { opacity: 1; width: 44px; height: 32px; margin-right: -10px; }
  .status li { font-size: 14px; line-height: 20px; }
  .ev { font-size: 15px; line-height: 21px; padding: 6px 8px; margin: 0 -8px; width: calc(100% + 16px); display: grid; grid-template-columns: 54px 1fr; column-gap: 8px; }
  .ev time { margin: 0; }
  .ev time .to { display: block; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted); }
  .ev.st { display: block; padding: 2px 8px; }
  .ev.notime { grid-template-columns: 1fr; }
  .ev .who { display: block; font-size: 13px; line-height: 18px; grid-column: 2; }
  .ev.notime .who { grid-column: 1; }
  .fab { display: inline-flex; position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); height: 52px; padding: 0 20px;
    border-radius: 999px; z-index: 15; box-shadow: 0 6px 18px rgba(135,24,19,.35); font-size: 16px; }
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 14px 14px 0 0; max-height: 92svh; }
  dialog form { padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); }
  .input { height: 44px; font-size: 16px; }
  textarea.input { font-size: 16px; }
  .page { padding: 16px 16px 64px; }
  .grid-form { grid-template-columns: 1fr 1fr; }
  .grid-form .wide { grid-column: 1 / -1; }
  .log .when { width: 84px; }
  .list li:not(.act-add):not(.act-edit):not(.act-delete):not(.act-restore) { flex-wrap: wrap; gap: 0 4px; }
  .list li:not([class^="act-"]) .main { flex-basis: 100%; margin-bottom: 2px; }
  .list li .btn.ghost { height: 36px; padding: 0 10px; margin-left: -10px; color: var(--brand); }
  #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- печать: на всякий случай, если распечатают прямо со страницы ---------- */
@media print {
  .bar, .subbar a, .fab, .addday, #toast { display: none !important; }
  .day { min-height: 0; }
}
.hint { font-weight: 400; color: var(--muted); }

/* мониторинг (зелёным) */
.ev.trip, .ev.trip time, .ev.trip .who, .ev.trip time .to { color: var(--trip); }
.legend { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--trip); font-weight: 500; }
.legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--trip); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--trip); flex: none; }
.check small { display: block; color: var(--muted); font-size: 12px; line-height: 16px; }
.check b { font-weight: 600; }
@media (max-width: 760px) {
  .day.wkend { background: #fbfaf9; }
  .day.wkend .dhead { background: #fbfaf9; }
  .check input { width: 22px; height: 22px; }
}

/* заголовок дня: на компьютере просто число, на телефоне – кнопка сворачивания */
.dtoggle { display: contents; }
.dcount { display: none; }
@media (max-width: 760px) {
  .dtoggle { display: flex; align-items: baseline; gap: 8px; flex: 1; min-width: 0; border: 0; background: none; padding: 6px 0; margin: -6px 0; text-align: left; cursor: pointer; flex-wrap: wrap; }
  .dcount { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
  .day.open .dcount { display: none; }
  .mdot { width: 8px; height: 8px; border-radius: 50%; background: var(--trip); display: inline-block; }
  .day:not(.open) .status, .day:not(.open) .events, .day:not(.open) .empty { display: none; }
  .day:not(.open) { padding-bottom: 0; }
  .day:not(.open) .dhead { margin-bottom: 0; padding-bottom: 12px; position: static; }
  .dtoggle::after { content: ""; width: 8px; height: 8px; border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted); transform: rotate(45deg); margin: 0 4px 3px 4px; align-self: center; order: 9; transition: transform .15s; }
  .day.open .dtoggle::after { transform: rotate(-135deg); margin-bottom: -3px; }
  .day.open .dtoggle::after { margin-left: auto; }
}
@media (max-width: 760px) {
  .subbar { gap: 4px 16px; }
  .subbar .hdr { flex-basis: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
  .subbar .hdr.full { display: block; }
}

/* строка «Отпуск (добавить)» над месяцем */
.vac { flex: 1; min-width: 0; }
.vac-title { font-weight: 600; color: var(--text); text-decoration: none; margin-right: 6px; }
.vac-title span { color: var(--brand); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }
.vac-title:hover span { color: var(--brand-hover); }
.vac-list { display: inline; list-style: none; margin: 0; padding: 0; }
.vac-list li { display: inline; }
.vac-list li + li::before { content: ", "; }
.vac-none { color: var(--faint); }
@media (max-width: 760px) {
  .vac { flex-basis: 100%; }
  .vac-title { display: block; margin-bottom: 2px; }
  .vac-list { display: block; }
  .vac-list li { display: block; line-height: 20px; }
  .vac-list li + li::before { content: none; }
}

/* форма «Отпуск или б/с» */
.abs-form { display: grid; grid-template-columns: 1fr 1fr auto; grid-template-areas: "kind person person" "from to actions"; gap: 16px 12px; align-items: end; }
.abs-kind { grid-area: kind; height: 40px; }
.abs-kind label { height: 34px; }
.abs-person { grid-area: person; }
.abs-form > .field:not(.abs-person) { grid-area: from; }
.abs-to { grid-area: to; position: relative; }
.abs-actions { grid-area: actions; display: flex; gap: 8px; }
.abs-actions .btn { height: 40px; }
.hint-below { position: absolute; left: 0; top: 100%; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 16px; white-space: nowrap; }
#absErr { margin-top: 24px; }
@media (max-width: 760px) {
  .abs-form { grid-template-columns: 1fr 1fr; grid-template-areas: "kind kind" "person person" "from to" "actions actions"; align-items: start; }
  .abs-kind { height: auto; }
  .abs-kind label { height: 40px; }
  .hint-below { position: static; display: block; margin-top: 6px; }
  .abs-actions { justify-content: flex-end; }
  .abs-actions .btn { height: 44px; }
  #absErr { margin-top: 8px; }
}
.vac-note { margin: 2px 0 0; color: var(--text); }
.vac-note b { font-weight: 600; }

/* Телефоны (iPhone/Safari не открывает календарь по команде из кода):
   прозрачное системное поле даты лежит прямо поверх значка календаря, и палец нажимает именно его. */
@media (pointer: coarse) {
  .dnative { left: auto; bottom: auto; right: 2px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px;
    opacity: 0.011; pointer-events: auto; z-index: 2; font-size: 16px; -webkit-appearance: none; appearance: none; cursor: pointer; }
  .dnative::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
}
