* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 7px 12px;
  cursor: pointer;
  transition: transform 100ms ease-out, background-color 120ms;
  touch-action: manipulation;
  white-space: nowrap;
}
button:hover { background: var(--surface-2); }
button:active { transform: scale(0.97); }
button.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
button.danger { color: var(--danger); }
button.ghost { border-color: transparent; background: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, td:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input, select, textarea {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 8px 10px;
  min-height: 38px;
}
label { display: block; font-size: 13px; color: var(--text-2); margin: 10px 0 4px; }
.hint { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.err { font-size: 13px; color: var(--danger); margin-top: 4px; min-height: 1em; }
.muted { color: var(--text-2); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 10px; }
.icon { width: 18px; height: 18px; vertical-align: -3px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.brand { font-weight: 600; letter-spacing: -0.01em; margin-right: 6px; }
.monthnav { display: flex; align-items: center; gap: 2px; }
.monthnav .title { min-width: 150px; text-align: center; font-weight: 600; font-size: 16px; }
.monthnav button { padding: 6px 10px; }
.chip { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.chip.final { background: var(--green-bg); color: var(--green-text); border-color: transparent; }
.toolbar a { color: inherit; text-decoration: none; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.navlinks { display: flex; gap: 2px; margin-left: auto; }
.navlinks a { text-decoration: none; color: var(--text-2); padding: 6px 10px; border-radius: var(--radius); font-size: 14px; }
.navlinks a.active, .navlinks a:hover { background: var(--surface-2); color: var(--text); }
.busy { font-size: 13px; color: var(--text-2); display: none; align-items: center; gap: 6px; }
.busy.on { display: inline-flex; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.content { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; padding: 14px 16px; min-height: 0; }
.content.full { grid-template-columns: minmax(0, 1fr); }
.mainpane { min-width: 0; }
.side { min-width: 0; }
.side .card { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; }
.page { max-width: 860px; }

/* ---------- grid ---------- */
.gridwrap { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); max-height: calc(100vh - 120px); }
table.g { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
table.g th, table.g td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: center; padding: 0; }
table.g thead th { position: sticky; top: 0; background: var(--surface); z-index: 3; font-weight: 600; font-size: 12px; padding: 4px 0; }
table.g thead th .wd { display: block; color: var(--text-3); font-weight: 500; }
table.g th.off, table.g td.off { background-image: linear-gradient(var(--weekend), var(--weekend)); }
table.g thead th.off { color: var(--weekend-text); }
/* Официални празници: розово (Apple systemPink) — над жълтото на почивните дни */
table.g th.hol, table.g td.hol { background-image: linear-gradient(var(--holiday), var(--holiday)); }
table.g thead th.hol { color: var(--holiday-text); box-shadow: inset 0 -2.5px 0 var(--holiday-head); }
table.g th.hol-h { color: var(--holiday-text); }
.holpill { display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--holiday); color: var(--holiday-text); font-weight: 600; }
.daycard.hol { border-left: 4px solid var(--holiday-head); background: linear-gradient(var(--holiday), var(--holiday)), var(--surface); }
.summary .hol-sum { background: var(--holiday); border-color: transparent; }
.summary .hol-sum b, .summary .hol-sum span { color: var(--holiday-text); }
.legend .lh { display: inline-block; width: 14px; height: 14px; border-radius: 4px; background: var(--holiday); box-shadow: inset 0 -2px 0 var(--holiday-head); vertical-align: -2px; }
table.g .name { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; padding: 0 10px; white-space: nowrap; font-size: 14px; min-width: 190px; max-width: 210px; overflow: hidden; text-overflow: ellipsis; }
table.g thead .name { z-index: 4; }
table.g tr.fc-green .name { box-shadow: inset 4px 0 0 var(--green); }
table.g tr.fc-yellow .name { box-shadow: inset 4px 0 0 var(--yellow); }
table.g tr.fc-orange .name { box-shadow: inset 4px 0 0 var(--orange); }
table.g tr.fc-red .name { box-shadow: inset 4px 0 0 var(--red); }
table.g tr.fc-green td.c { background-color: color-mix(in srgb, var(--green-bg) 45%, transparent); }
table.g tr.fc-yellow td.c { background-color: color-mix(in srgb, var(--yellow-bg) 55%, transparent); }
table.g tr.fc-orange td.c { background-color: color-mix(in srgb, var(--orange-bg) 60%, transparent); }
table.g tr.fc-red td.c { background-color: color-mix(in srgb, var(--red-bg) 65%, transparent); }
/* Маркиран ред (клик върху името): плътна зелена лента през целия месец */
table.g td.name[role="button"] { cursor: pointer; transition: background-color 160ms ease-out, color 160ms ease-out; }
table.g td.name[role="button"]:hover { color: var(--green-text); }
table.g td.name[role="button"]:active { background-color: color-mix(in srgb, var(--green) 18%, var(--surface)); transition-duration: 0ms; }
table.g tr.hl td.c, table.g tr.hl td.name, table.g tr.hl td.t { background-color: color-mix(in srgb, var(--green) 20%, var(--surface)); transition: background-color 200ms ease-out; }
table.g tr.hl td.c, table.g tr.hl td.t { box-shadow: inset 0 1.5px 0 var(--green), inset 0 -1.5px 0 var(--green); }
table.g tr.hl td.name { color: var(--green-text); font-weight: 600; box-shadow: inset 4px 0 0 var(--green), inset 0 1.5px 0 var(--green), inset 0 -1.5px 0 var(--green); }
table.g tr.hl td.t, table.g tr.hl td.t b { color: var(--green-text); }
@media (prefers-reduced-motion: reduce) { table.g td.name[role="button"], table.g tr.hl td { transition: none; } }
@media (prefers-contrast: more) { table.g tr.hl td { background-color: var(--green-bg); } }
@media print { table.g tr.hl td { background-color: transparent !important; box-shadow: none !important; } }
table.g td.c { width: 34px; min-width: 34px; height: 34px; font-size: 14px; font-weight: 600; cursor: pointer; position: relative; user-select: none; }
table.g td.c:hover { outline: 2px solid var(--border-strong); outline-offset: -2px; }
table.g td.c.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
td.k-Д, .dnd-ghost.k-Д { color: var(--code-d); }
td.k-Н, .dnd-ghost.k-Н { color: var(--code-n); }
td.k-Х { color: var(--code-x); font-weight: 500 !important; }
td.k-О, td.k-Б, td.k-НП { color: var(--code-abs); }
td.c.locked::after { content: ""; position: absolute; inset: 2px; border: 1.5px solid var(--accent); border-radius: 5px; pointer-events: none; }
td.c.bad { color: var(--danger) !important; text-decoration: underline wavy; }
td.c.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: inset 0 0 0 40px var(--accent-bg); } 100% { box-shadow: inset 0 0 0 40px transparent; } }
table.g td.t { font-size: 12.5px; padding: 0 8px; color: var(--text-2); white-space: nowrap; }
table.g td.t b { color: var(--text); font-weight: 600; }
table.g th.t { padding: 4px 8px; font-size: 12px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin: 10px 2px 0; }
.legend .lk { display: inline-block; width: 16px; height: 16px; border: 1.5px solid var(--accent); border-radius: 4px; vertical-align: -3px; }
.violations { margin-top: 10px; }
.violations li { color: var(--danger); font-size: 13.5px; }

/* ---------- fairness ---------- */
.fr { display: grid; grid-template-columns: 92px 1fr 58px; gap: 8px; align-items: center; padding: 7px 4px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.fr:hover { background: var(--surface-2); }
.fr .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fr .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bar { position: relative; height: 10px; background: var(--surface-2); border-radius: 5px; border: 1px solid var(--border); }
.bar::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--border-strong); }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.c-green { background: var(--green); } .c-yellow { background: var(--yellow); } .c-orange { background: var(--orange); } .c-red { background: var(--red); } .c-none { background: var(--text-3); }
.t-none { color: var(--text-3); } .t-green { color: var(--green-text); } .t-yellow { color: var(--yellow-text); } .t-orange { color: var(--orange-text); } .t-red { color: var(--red-text); }
.frdet { font-size: 12.5px; color: var(--text-2); padding: 2px 6px 8px 8px; display: grid; grid-template-columns: repeat(4, auto); gap: 2px 10px; }
.frdet b { color: var(--text); font-weight: 600; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; font-size: 13px; border-radius: 7px; }
.seg button.on { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.sug { border: 1px solid var(--border); border-radius: 12px; padding: 10px; margin-top: 8px; font-size: 13.5px; }
.sug .eff { color: var(--green-text); font-size: 12.5px; }
.axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-3); padding: 0 50px 0 100px; }

/* ---------- lists / pages ---------- */
.list { display: flex; flex-direction: column; gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.li { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.li:last-child { border-bottom: 0; }
.li .grow { min-width: 0; }
.li .sub { font-size: 13px; color: var(--text-2); }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; }
.wdpick { display: flex; gap: 4px; }
.wdpick button { flex: 1; padding: 8px 0; }
.wdpick button.on { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin: 10px 0 0; cursor: pointer; }
.switch input { width: 20px; height: 20px; min-height: 0; }
table.simple { border-collapse: collapse; width: 100%; font-size: 14px; }
table.simple td, table.simple th { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; }
table.simple input { width: 90px; }

/* ---------- popover / sheet / toast ---------- */
.popover { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 10px; width: 260px; transform-origin: top left; animation: pop 140ms ease-out; }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }
.codes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.codes button { height: 44px; font-size: 17px; font-weight: 600; padding: 0; }
.codes button.cur { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.pophead { font-size: 13px; color: var(--text-2); margin: 0 2px 8px; }
.pophead b { color: var(--text); }
.effect { font-size: 12.5px; margin-top: 8px; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 70; opacity: 0; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 71; background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow); padding: 8px 0 0; max-height: 88vh; max-height: 92dvh; display: flex; flex-direction: column; overflow: hidden; touch-action: none; will-change: transform; }
.sheet .scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet.has-foot .scroll { padding-bottom: 12px; }
.sheet-foot { flex: none; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent); -webkit-backdrop-filter: blur(16px) saturate(170%); backdrop-filter: blur(16px) saturate(170%); }
.sheet-foot .err:empty { display: none; }
.sheet-foot .err { margin: 0 0 8px; }
.foot-btns { display: flex; gap: 10px; justify-content: flex-end; }
.sheet .foot-btns button { flex: 1; min-height: 48px; font-size: 16px; border-radius: 12px; }
.sheet .foot-btns button.primary { flex: 2; }
.dialog .sheet-foot { position: sticky; bottom: -18px; margin: 14px -18px -18px; padding: 12px 18px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.linkbtn { display: block; border: 0; background: transparent; padding: 10px 0 4px; color: var(--accent); font-size: 14px; text-align: left; min-height: 44px; }
@media (prefers-reduced-transparency: reduce) { .sheet-foot { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; } }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 0 auto 12px; }
.sheet .scroll { touch-action: pan-y; }
.sheet .scroll .reqcal { touch-action: pan-y; }
.sheet h2 { margin-bottom: 2px; }
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 520px); }
.toast { background: var(--text); color: var(--bg); border-radius: 12px; padding: 10px 12px 10px 14px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); font-size: 14px; animation: pop 160ms ease-out; width: 100%; }
.toast button { background: transparent; color: var(--bg); border-color: rgba(255,255,255,.35); padding: 5px 10px; }
.toast.err { background: var(--red-bg); color: var(--red-text); }
.toast.err button { color: var(--red-text); border-color: var(--red); }
.dialog-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 18px; width: min(520px, 100%); max-height: 90vh; overflow: auto; }

/* ---------- mobile ---------- */
.tabbar { display: none; }
.mobile-only { display: none; }
.daycards { display: flex; flex-direction: column; gap: 10px; }
.daycard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; }
.daycard.off { border-left: 4px solid var(--weekend-head); }
.daycard.today { border-color: var(--accent); }
.daycard .dh { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; }
.daycard .dh span { color: var(--text-2); font-weight: 500; font-size: 13px; }
.duty { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 15px; }
.duty .k { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); flex: none; }
.duty .k.Д { color: var(--code-d); } .duty .k.Н { color: var(--code-n); }
.duty .who { flex: 1; }
.duty .dot { width: 8px; height: 8px; border-radius: 50%; }
.daycard .others { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.pills { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.pills button { border-radius: 999px; padding: 6px 12px; }
.pills button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.dlist .li { padding: 9px 14px; }
.dlist .k { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.summary div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; }
.summary b { display: block; font-size: 18px; }
.summary span { font-size: 12px; color: var(--text-2); }

@media (max-width: 767px) {
  body { font-size: 16px; }
  .desktop-only { display: none !important; }
  .mobile-only { display: block; }
  .topbar { padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); gap: 6px; }
  .brand { display: none; }
  .monthnav { flex: 1; justify-content: center; }
  .monthnav .title { min-width: 0; flex: 1; font-size: 17px; }
  .content { grid-template-columns: minmax(0, 1fr); padding: 10px 10px calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); }
  .side { display: none; }
  .gridwrap { max-height: calc(100vh - 190px); border-radius: 12px; }
  table.g .name { min-width: 84px; max-width: 84px; font-size: 13px; padding: 0 6px; }
  table.g td.c { width: 36px; min-width: 36px; height: 38px; }
  table.g td.t, table.g th.t { display: none; }
  .gridwrap { scroll-snap-type: x proximity; }
  table.g td.c.wk { scroll-snap-align: start; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 72%, transparent);
    -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--border);
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--text-3); font-size: 11px; }
  .tabbar a.active { color: var(--accent); }
  .tabbar svg { width: 24px; height: 24px; }
  .page { max-width: none; }
  .popover { display: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .tabbar { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
.print-head { display: none; }
.dialog input:not([type=checkbox]), .dialog select, .sheet input:not([type=checkbox]), .sheet select { width: 100%; max-width: 100%; }
.dialog .row input, .dialog .row select { width: auto; flex: 1; min-width: 0; }
.dialog { overflow-x: hidden; }

/* Справедливост: категория под стойността; статистика за празниците */
.fr .val { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.fr .val small { font-size: 10.5px; font-weight: 500; color: var(--text-3); letter-spacing: 0.01em; }
.holstats { margin-top: 18px; }
.holstats h2 { margin-bottom: 8px; }
.holstats .hr { display: grid; grid-template-columns: 78px 1fr auto; gap: 8px; align-items: center; padding: 4px 0; font-size: 13px; }
.holstats .hbar { height: 8px; border-radius: 999px; background: var(--holiday); overflow: hidden; }
.holstats .hbar i { display: block; height: 100%; border-radius: 999px; background: var(--holiday-head); transition: width 320ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.holstats .hv { color: var(--holiday-text); font-variant-numeric: tabular-nums; font-size: 12.5px; min-width: 56px; text-align: right; }
@media (prefers-reduced-motion: reduce) { .holstats .hbar i { transition: none; } }

/* ---------- Размяна с влачене ---------- */
table.g td.c { -webkit-touch-callout: none; touch-action: pan-x pan-y; }
table.g td.c.dnd-press { transform: scale(0.9); transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1); }
table.g td.c.dnd-src { color: transparent; background-image: repeating-linear-gradient(135deg, var(--border-strong) 0 2px, transparent 2px 6px); }
table.g.dnd-on td.c:not(.dnd-ok):not(.dnd-src) { opacity: 0.38; transition: opacity 160ms ease-out; }
table.g td.c.dnd-ok { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); }
table.g td.c.dnd-hover { box-shadow: inset 0 0 0 2.5px var(--accent); background-color: var(--accent-bg) !important; }
table.g td.c.dnd-hide { color: transparent; }
body.dnd-dragging, body.dnd-dragging * { cursor: grabbing !important; user-select: none; }
.dnd-ghost {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; border-radius: 9px; transform-origin: center; will-change: transform;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(170%); backdrop-filter: blur(12px) saturate(170%);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.18), inset 0 0 0 1.5px var(--accent);
}
.dnd-overlay { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 55; pointer-events: none; overflow: visible; color: var(--accent); transition: opacity 380ms ease-out; }
.dnd-overlay.fade { opacity: 0; }
.dnd-arrow { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 2 6; }
.dnd-overlay.swap .dnd-arrow { stroke-dasharray: none; }
.dnd-overlay.swap .dnd-arrow.back { color: var(--green); stroke: var(--green); }
/* разменените клетки светят ~5 s: две меки пулсации и затихване */
table.g td.c.swapped { animation: swapglow 5s ease-out forwards; }
@keyframes swapglow {
  0%, 24%, 48% { box-shadow: inset 0 0 0 2.5px var(--green), 0 0 0 0 transparent; background-color: color-mix(in srgb, var(--green) 28%, var(--surface)); }
  12%, 36% { box-shadow: inset 0 0 0 2.5px var(--green), 0 0 14px 2px color-mix(in srgb, var(--green) 55%, transparent); background-color: color-mix(in srgb, var(--green) 38%, var(--surface)); }
  80% { box-shadow: inset 0 0 0 2px var(--green); background-color: color-mix(in srgb, var(--green) 18%, var(--surface)); }
  100% { box-shadow: inset 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
  table.g td.c.dnd-press { transform: none; }
  table.g td.c.swapped { animation: none; box-shadow: inset 0 0 0 2.5px var(--green); }
}
@media (prefers-reduced-transparency: reduce) { .dnd-ghost { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; } }

.checkline { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.checkline input { width: auto; margin: 0; }
.axis span { white-space: nowrap; }

/* ---------- Заявка по дни ---------- */
.reqform { min-width: min(520px, 100%); }
.palette { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin: 12px 0 10px; }
.palette .pal { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 2px 6px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); transition: transform 120ms ease-out, background-color 160ms ease-out, border-color 160ms ease-out; }
.palette .pal b { font-size: 17px; line-height: 1.1; }
.palette .pal span { font-size: 11px; color: var(--text-2); }
.palette .pal:active { transform: scale(0.94); transition-duration: 0ms; }
.palette .pal.on { border-color: var(--accent); background: var(--accent-bg); box-shadow: 0 0 0 1px var(--accent); }
.pal.k-Д b, .reqcal .k-Д, .reqsum .k-Д, .reqcode.k-Д { color: var(--code-d); }
.pal.k-Н b, .reqcal .k-Н, .reqsum .k-Н, .reqcode.k-Н { color: var(--code-n); }
.pal.k-Х b, .reqcal .k-Х, .reqsum .k-Х { color: var(--code-x); }
.pal.k-О b, .pal.k-Б b, .reqcal .k-О, .reqcal .k-Б, .reqsum .k-О, .reqsum .k-Б { color: var(--code-abs); }
.reqcal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.reqcal .wd { text-align: center; font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 2px 0 4px; }
.reqcal .wd.we { color: var(--weekend-text); }
.reqcal .day { position: relative; aspect-ratio: 1 / 0.92; min-height: 44px; padding: 0; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center; transition: transform 140ms cubic-bezier(0.2, 0.8, 0.2, 1), background-color 160ms ease-out, border-color 160ms ease-out; }
.reqcal .day.off { background: linear-gradient(var(--weekend), var(--weekend)), var(--surface); }
.reqcal .day.hol { background: linear-gradient(var(--holiday), var(--holiday)), var(--surface); border-color: color-mix(in srgb, var(--holiday-head) 45%, transparent); }
.reqcal .day .n { position: absolute; top: 3px; left: 6px; font-size: 11.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.reqcal .day .cur { position: absolute; bottom: 2px; right: 5px; font-size: 10px; color: var(--text-3); white-space: nowrap; }
.reqcal .day.has-req .cur { color: var(--accent); }
.reqcal .day .pick { font-size: 19px; font-weight: 700; transform: scale(0.4); opacity: 0; transition: transform 220ms cubic-bezier(0.34, 1.4, 0.64, 1), opacity 120ms ease-out; }
.reqcal .day.picked { border-color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); background-color: var(--accent-bg); }
.reqcal .day.picked .pick { transform: scale(1); opacity: 1; }
.reqcal .day.picked .cur { opacity: 0.5; }
.reqcal .day:active { transform: scale(0.94); }
.reqsum { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 13.5px; min-height: 20px; }
.reqcode { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); font-weight: 700; margin-right: 10px; flex: none; }
@media (prefers-reduced-motion: reduce) { .reqcal .day, .reqcal .day .pick, .palette .pal { transition: none; } }

/* ---------- Заявки в графика ---------- */
table.g td.c.rq::before { content: ""; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); pointer-events: none; }
table.g td.c.rq.wish::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--accent); }
.rqsum { margin-top: 12px; }
.rqrow { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--border); }
.rqrow:first-of-type { border-top: 0; }
.rqrow .nm { border: 0; background: transparent; padding: 4px 2px; text-align: left; font-weight: 600; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rqrow .nm:hover { color: var(--accent); }
.rqrow .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rqchip { display: inline-flex; align-items: center; gap: 2px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-variant-numeric: tabular-nums;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.rqchip b { font-weight: 700; }
.rqchip.k-Д b { color: var(--code-d); } .rqchip.k-Н b { color: var(--code-n); } .rqchip.k-Х b { color: var(--code-x); }
.rqchip.k-О b, .rqchip.k-Б b, .rqchip.k-НП b { color: var(--code-abs); }
.rqchip.wish { background: transparent; border-style: dashed; }
@media (max-width: 760px) { .rqrow { grid-template-columns: 84px 1fr; } }

@media (max-width: 760px) {
  .reqform { min-width: 0; }
  .reqcal { gap: 3px; }
  .reqcal .day { aspect-ratio: auto; height: 44px; min-height: 0; border-radius: 9px; }
  .reqcal .day .pick { font-size: 18px; }
  .reqcal .day .cur { font-size: 9.5px; right: 3px; }
  .reqcal .day .n { left: 4px; top: 2px; font-size: 11px; }
  .palette { gap: 5px; margin: 10px 0 8px; }
  .palette .pal { padding: 6px 0 5px; min-height: 48px; border-radius: 11px; }
  .palette .pal span { font-size: 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .reqsum { font-size: 14px; }
}

/* На телефон съобщенията идват отгоре (като известие в iOS), за да не закриват бутоните долу */
@media (max-width: 760px) {
  .toasts { top: calc(8px + env(safe-area-inset-top)); bottom: auto; }
}

.seg-wide { display: flex; width: 100%; margin-top: 10px; }
.seg-wide button { flex: 1; min-height: 36px; font-size: 14px; }
.sheet-foot .reqsum, .dialog .sheet-foot .reqsum { margin: 0 0 8px; font-size: 13.5px; }
button:disabled { opacity: 0.45; cursor: default; }
@media (max-width: 760px) and (max-height: 700px) { .reqcal .day { height: 40px; } }

.reqli { align-items: flex-start; }
.reqli .rq-name { font-weight: 600; }
.rq-actions { display: flex; flex-direction: column; gap: 6px; flex: none; }
.rq-actions button { min-height: 36px; min-width: 92px; }
button.danger { color: var(--danger); }
button.danger-fill, button.primary.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.rqtag { flex: none; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-bg); color: var(--accent); }
.rqtag.wish { background: transparent; box-shadow: inset 0 0 0 1px var(--accent); }
.reqli .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.rq-type { margin-left: 8px; font-size: 11.5px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--accent-bg); color: var(--accent); vertical-align: 1px; }
.rq-type.wish { background: transparent; box-shadow: inset 0 0 0 1px var(--accent); }

/* формите: полетата заемат цялата ширина на колоната */
.formgrid input:not([type=checkbox]), .formgrid select, .card > div > input:not([type=checkbox]) { width: 100%; max-width: 100%; }
@media (max-width: 760px) {
  /* Лекари: името на цял ред, действията отдолу вдясно — без пренасяне на 3 реда */
  .doclist .li { flex-wrap: wrap; row-gap: 6px; }
  .doclist .li > .grow { flex: 1 1 100%; }
  .doclist .li > button:first-of-type { margin-left: auto; }
  .doclist .li > button { min-height: 40px; min-width: 44px; }
}
