/* Culorile din logo-ul Bestmun: albastru #0e76bc, turcoaz #138da4 și #087881 (nuanțele pentru
   text sunt puțin mai închise, ca să se citească bine). Roșul rămâne doar pentru avertizări. */
:root {
  color-scheme: light dark;
  --bg: #f3f8fb;
  --gradient: linear-gradient(160deg, #bfdef4 0%, #e8f4fb 48%, #bfe8e2 100%);
  --muted-on-bg: #3d5967;
  --surface: transparent;
  --text: #12303f;
  --muted: #4d6977;
  --line: #3f7ea6;
  --shade: rgb(18 48 63 / .09);
  --on-danger: #ffffff;
  --accent: #126090;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --warn-bg: #fdecea;
  --info-bg: #dfeefa;
  --ok-bg: #d5f0ec;
  --mid-bg: #c4e2f4;
  --arrived-bg: #087881;
  --on-arrived: #ffffff;
  --highlight: #0f7c92;
  --on-highlight: #ffffff;
  --tasks: #0e72b6;
  --on-tasks: #ffffff;
  --tasks-soft: transparent;
  --partners: #164a74;
  --on-partners: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c161b;
    --gradient: linear-gradient(160deg, #0b2b43 0%, #0c161b 48%, #073333 100%);
    --muted-on-bg: #a9c3d0;
    --surface: transparent;
    --text: #e6f1f6;
    --muted: #9db8c6;
    --line: #4d85a1;
    --shade: rgb(255 255 255 / .07);
    --on-danger: #14242d;
    --accent: #62b6ea;
    --on-accent: #04202f;
    --danger: #ff8a80;
    --warn-bg: #4a211e;
    --info-bg: #143a56;
    --ok-bg: #0f403e;
    --mid-bg: #1d4f72;
    --arrived-bg: #7fd8d0;
    --on-arrived: #042523;
    --highlight: #52c2d6;
    --on-highlight: #04232a;
    --tasks: #6fbef0;
    --on-tasks: #04202f;
    --tasks-soft: transparent;
    --partners: #b5d6f7;
    --on-partners: #04202f;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-wrap: anywhere;
}

/* Fundal în degradé albastru → turcoaz, fix în spatele paginii (merge și pe iPhone). */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: var(--gradient); }
/* Chenare mai groase, ca zonele să fie clar delimitate pe același fundal. */
.card, .appointment, .comment, .week-scroll, input, textarea, select, button, .chip, .subnav a { border-width: 1.5px; }
option { background: var(--bg); color: var(--text); }
/* Textul așezat direct pe fundal are nevoie de nuanțe ceva mai puternice. */
#view, .auth, .page { --muted: var(--muted-on-bg); }

a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
small, .meta { color: var(--muted); }
section { margin-top: 24px; }

button, .fab {
  font: inherit;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--accent); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

input, textarea, select {
  font: inherit;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}
textarea { resize: vertical; }
.person-data { display: flex; flex-direction: column; gap: 4px; padding-top: 12px; border-top: 1px solid var(--line); }

.done-at { font-weight: 700; font-size: .92rem; }
.card-comments { display: flex; flex-direction: column; gap: 6px; align-self: stretch; }
.card-comment { display: flex; flex-direction: column; padding: 6px 10px; border-left: 3px solid var(--accent); border-radius: 6px; background: var(--shade); }
/* Un comentariu lung se oprește după trei rânduri. */
.card-comment > span { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
/* „Toate”: o secțiune pentru fiecare zi; task-urile terminate apar tăiate și șterse. */
details.day-group { margin: 0 0 12px; color: var(--text); }
.day-group summary {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-height: 44px; padding: 10px 12px;
  border: 1.5px solid var(--accent); border-radius: 10px; cursor: pointer;
}
.day-group summary::before { content: "▸"; font-weight: 700; }
.day-group[open] summary { margin-bottom: 8px; }
.day-group[open] summary::before { content: "▾"; }
.day-group summary::-webkit-details-marker { display: none; }
/* O linie subțire doar peste titlu, ca task-ul vechi să se citească în continuare. */
.day-group.struck .card.finished { opacity: .85; }
.day-group.struck .card.finished > strong {
  text-decoration: line-through 1.5px var(--danger);
}
.attachments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.attachments li { display: flex; align-items: center; gap: 8px; }
.attachments span { flex: 1; min-width: 0; }
.attachments button { flex: 0 0 auto; width: 36px; min-height: 36px; padding: 0; color: var(--danger); }

/* „Finalizate”: căutare după firmă și perioadă. */
.filters { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.filter-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.filter-summary:empty { display: none; }

/* Task nou: butoanele pentru dată și ora aleasă din listă. */
.due-date { display: flex; flex-direction: column; gap: 6px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button { flex: 1 0 auto; min-height: 36px; padding: 4px 12px; font-size: .88rem; }
.presets button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.reminder, .remind-choice { display: flex; flex-direction: column; gap: 6px; }
.week-days { padding: 8px; border: 1.5px dashed var(--line); border-radius: 10px; }
.presets button[aria-expanded="true"] { border: 2px solid var(--accent); font-weight: 700; }
.time-list { display: flex; flex-direction: column; gap: 6px; }
.time-row { display: flex; gap: 6px; }
.time-row input { flex: 1; min-width: 0; }
button.time-open { flex: 0 0 46px; padding: 0; font-size: 1.1rem; }
.time-list .suggestions button { align-items: center; }

/* Data (zz.ll.aaaa) cu butonul de calendar alături. */
.date-input { display: flex; gap: 6px; align-items: stretch; }
.date-input > input { flex: 1; min-width: 0; }
/* Pe ecran îngust data trece pe rândul ei, ca să se vadă întreagă. */
.row > :has(> .date-input) { flex-basis: 190px; }
.date-pick {
  position: relative; flex: 0 0 46px; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--line); border-radius: 10px;
}
.date-pick input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; opacity: 0; cursor: pointer; }
.date-pick:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }

form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span, .field > label, legend { font-weight: 600; font-size: .92rem; }
.suggestions {
  display: flex; flex-direction: column; max-height: 220px; overflow-y: auto;
  border: 1px solid var(--accent); border-radius: 10px; background: var(--surface);
}
.suggestions button { flex: 0 0 auto; min-height: 40px; border: 0; border-radius: 0; text-align: left; }
.suggestions button:hover, .suggestions button[aria-selected="true"] { background: var(--info-bg); }
.filter { margin-bottom: 10px; }
.suggestions button { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.known-patient {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 12px;
  border: 2px solid var(--highlight); border-radius: 10px; background: var(--surface);
}
.phone-check { margin: -6px 0 0; padding: 8px 10px; border-radius: 8px; background: var(--info-bg); font-size: .9rem; }
.phone-check.ok { background: var(--ok-bg); font-weight: 700; }
.phone-check.warn { background: var(--warn-bg); font-weight: 700; }
.known-patient ul { margin: 2px 0; padding-left: 18px; font-size: .88rem; }
.patient-history h3 { margin: 14px 0 6px; font-size: 1rem; }
.patient-history ol { margin: 0; padding-left: 22px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
button.history-button { min-height: 36px; padding: 4px 10px; border-color: var(--highlight); font-size: .85rem; font-weight: 700; }
fieldset { border: 0; margin: 0; padding: 0; }
fieldset.group { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.details { display: flex; flex-direction: column; gap: 6px; width: 100%; margin: 4px 0; }
.details > div { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.details dt { flex: 0 0 150px; color: var(--muted); font-size: .9rem; }
.details dd { flex: 1 1 180px; margin: 0; font-weight: 600; }
legend { margin-bottom: 6px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 20px; cursor: pointer;
}
.chip:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.error { color: var(--danger); margin: 0; }
.error:empty { display: none; }

.auth {
  max-width: 400px; margin: 0 auto; padding: 40px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.auth img { align-self: center; }
/* Logo-ul are text albastru închis: pe temă întunecată stă pe un fond alb. */
.logo { display: block; }
@media (prefers-color-scheme: dark) { .logo { padding: 3px 6px; border-radius: 10px; background: #fff; box-sizing: content-box; } }
.auth h1 { text-align: center; }

.top {
  display: flex; align-items: center; gap: 4px;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, calc((100% - 760px) / 2)) 8px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; margin-right: auto; }
.icon {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; text-decoration: none; font-size: 1.15rem;
}
#badge {
  position: absolute; top: 2px; right: 0; min-width: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: var(--on-danger);
  font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center;
}
#badge:empty { display: none; }

nav {
  position: sticky; top: 0; z-index: 2;
  display: flex; overflow-x: auto;
  padding: 0 max(8px, calc((100% - 776px) / 2));
  background: var(--gradient) fixed, var(--bg); border-bottom: 1px solid var(--line);
}
/* Tab-urile de sus: cel activ este plin, mai mare și cu umbră; celelalte au doar contur.
   Fiecare are culoarea lui: Task-uri albastru, Programări turcoaz, Clinici partenere bleumarin. */
nav a {
  --tab: var(--accent); --on-tab: var(--on-accent);
  flex: 1 0 auto; align-self: center; margin: 9px 5px; padding: 8px 12px;
  border: 2px solid var(--tab); border-radius: 22px;
  color: var(--tab); text-align: center; text-decoration: none; font-weight: 600; font-size: .95rem;
}
nav a[data-tab="taskuri"] { --tab: var(--tasks); --on-tab: var(--on-tasks); }
nav a[data-tab="programari"] { --tab: var(--highlight); --on-tab: var(--on-highlight); }
nav a[data-tab="parteneri"] { --tab: var(--partners); --on-tab: var(--on-partners); }
nav a.active {
  margin-block: 6px; padding-block: 11px;
  background: var(--tab); color: var(--on-tab); font-weight: 800; font-size: 1.02rem;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--tab), 0 6px 14px rgb(0 0 0 / .28);
}

.subnav { display: flex; gap: 6px; max-width: 760px; margin: 0 auto; padding: 12px 16px 0; }
.subnav a {
  flex: 1; min-width: 0; min-height: 40px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 10px; background: var(--tasks-soft);
  color: var(--text); text-decoration: none; font-size: .92rem; white-space: nowrap;
}
.subnav a.active {
  background: var(--tasks); border-color: var(--tasks); color: var(--on-tasks); font-weight: 800;
  box-shadow: 0 4px 10px rgb(0 0 0 / .28);
}

/* Pe telefon: cele cinci butoane din „Task-uri interne” rămân pe un rând sau trec pe două. */
@media (max-width: 560px) {
  .subnav { flex-wrap: wrap; gap: 4px; padding-inline: 10px; }
  .subnav a { flex: 1 0 auto; padding: 0 5px; font-size: .84rem; }
}

/* Pe telefon tab-urile pot trece pe două rânduri, ca toate să se vadă. */
@media (max-width: 560px) {
  nav { flex-wrap: wrap; padding-block: 1px; }
  nav a { margin: 8px 4px; padding: 7px 9px; font-size: .9rem; }
  nav a.active { margin-block: 6px; padding-block: 9px; font-size: .95rem; }
}

#view { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(100px + env(safe-area-inset-bottom)); }

/* Pe calculator: logo, tab-uri, clopoțel și cont pe același rând, lipit sus. Pe telefon învelișul
   nu se vede și așezarea rămâne cea de dinainte. */
.bar { display: contents; }
@media screen and (min-width: 701px) {
  .bar {
    position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 4px;
    padding: 0 max(12px, calc((100% - 760px) / 2 + 16px));
    background: var(--gradient) fixed, var(--bg); border-bottom: 1px solid var(--line);
  }
  .bar .top { display: contents; }
  .bar .brand { order: 1; margin-right: 8px; }
  .bar nav { order: 2; position: static; flex: 1; min-width: 0; overflow: visible; padding: 0; border: 0; background: none; }
  .bar nav a { flex: 1 1 auto; margin: 9px 4px; padding: 6px 8px; font-size: .9rem; }
  .bar nav a.active { margin-block: 7px; padding-block: 8px; font-size: .95rem; }
  .bar .icon { order: 3; flex: 0 0 auto; width: 40px; }
  #view { padding-top: 10px; }
  .subnav { padding-top: 8px; }
}

.fab {
  position: fixed; z-index: 3;
  right: max(16px, calc((100% - 760px) / 2 + 16px));
  bottom: calc(16px + env(safe-area-inset-bottom));
  border-radius: 28px; padding: 12px 22px; box-shadow: 0 4px 14px rgb(0 0 0 / .28);
}

.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  padding: 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); text-decoration: none;
}
.card.urgent { border-left: 5px solid var(--danger); }
.card.unread { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card.off { opacity: .65; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { padding: 2px 9px; border-radius: 10px; border: 1px solid var(--line); font-size: .8rem; }
.badge.urgent, .badge.late { background: var(--warn-bg); border-color: transparent; font-weight: 600; }
.badge.partner { background: var(--info-bg); border-color: transparent; font-weight: 600; }
.badge.new { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.status-new { background: var(--info-bg); }
.status-progress { background: var(--mid-bg); }
.status-done { background: var(--ok-bg); }

.segmented { display: flex; align-self: stretch; gap: 6px; margin-bottom: 14px; }
.segmented button { flex: 1; padding-inline: 6px; }
.segmented button.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), 0 4px 10px rgb(0 0 0 / .22); font-weight: 800; }
.segmented button.selected:not([class*="status-"]) { background: var(--accent); color: var(--on-accent); }
article .segmented { margin: 8px 0 0; }
article h1 { margin: 0; }
article p { margin: 0; }
.description { white-space: pre-wrap; margin-top: 6px !important; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.heading h1 { margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }

.files { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 10px; }
.files li { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.files img { max-width: 100%; max-height: 220px; border-radius: 10px; border: 1px solid var(--line); }

.comment { margin: 0 24px 10px 0; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.comment.mine { margin: 0 0 10px 24px; background: var(--info-bg); }
.comment p { margin: 3px 0 0; white-space: pre-wrap; }
.reply button { align-self: flex-end; }

/* Pe calculator: titlul și butoanele în stânga, calendarul unei singure luni în dreapta. */
.schedule-top { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.schedule-tools { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.schedule-tools > * { margin: 0; }
.schedule-tools .view-switch { margin: 0; }
.calendar-box { flex: 0 0 250px; }
.month { margin: 0; overflow: hidden; border: 2px solid var(--accent); border-radius: 10px; background: var(--surface); }
.month-head { display: flex; align-items: center; background: var(--accent); color: var(--on-accent); }
.month-head h3 { flex: 1; margin: 0; font-size: .84rem; text-align: center; }
.month-head h3::first-letter { text-transform: uppercase; }
button.month-arrow { flex: 0 0 38px; min-height: 28px; padding: 0; border: 0; border-radius: 0; background: none; color: inherit; font-size: 1.35rem; font-weight: 700; line-height: 1; }
button.month-arrow:hover { background: rgb(255 255 255 / .22); }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; padding: 3px; }
.weekday { text-align: center; font-size: .62rem; font-weight: 800; color: var(--text); }
button.calendar-today { width: 100%; min-height: 26px; margin-top: 4px; padding: 0; font-size: .76rem; }
/* Fiecare zi lucrătoare are chenarul ei; zilele fără program sunt doar umbrite. */
button.day {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  min-height: 26px; padding: 0; gap: 0; border: 1.5px solid color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: 5px; font-size: .72rem; font-weight: 700; line-height: 1.15;
}
button.day.closed { border-color: transparent; background: var(--shade); color: var(--muted); font-weight: 400; }
button.day.today { border: 2.5px solid var(--highlight); font-weight: 900; }
button.day.selected { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 900; }
.counts { display: flex; gap: 1px; }
.count { display: inline-block; min-width: 12px; padding: 0 1px; border-radius: 4px; text-align: center; font-size: .56rem; font-weight: 800; line-height: 11px; white-space: nowrap; overflow-wrap: normal; }
.count.free { background: var(--ok-bg); color: var(--text); box-shadow: inset 0 0 0 1px var(--arrived-bg); }
.count.free.full { background: var(--warn-bg); color: var(--danger); }
.count.busy { background: var(--tasks); color: var(--on-tasks); }
.count.arrived { background: var(--arrived-bg); color: var(--on-arrived); }
button.day.waiting .count.busy, .count.waiting { background: var(--danger); color: var(--on-danger); }
.legend { display: flex; flex-wrap: wrap; gap: 1px 8px; margin: 4px 0 0; font-size: .66rem; color: var(--muted); }
.day-totals { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 auto 0 0; }
.total { padding: 3px 10px; border-radius: 10px; font-size: .88rem; font-weight: 700; }
.total.free { background: var(--ok-bg); }
.total.busy { background: var(--info-bg); }
.total.arrived { background: var(--arrived-bg); color: var(--on-arrived); }

details { margin-top: 24px; color: var(--muted); }
.history { padding-left: 18px; font-size: .9rem; }

dialog {
  width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
  padding: 18px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--gradient), var(--bg); color: var(--text); overflow-y: auto;
}
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
dialog header h2 { margin: 0; }

/* programări */
.search { margin: 12px 0; gap: 4px; }
.search .row { flex-wrap: nowrap; }
.search .row input { flex: 1; }
.search .row button { flex: 0 0 auto; }
.pending { padding: 12px; border-radius: 12px; background: var(--mid-bg); }
.day-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 20px 0 10px; }
.day-title { margin: 0; }
.holiday-note { margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); font-weight: 700; }
button.day.holiday:not(.selected) { background: var(--warn-bg); color: var(--danger); text-decoration: line-through; }
.day-title::first-letter { text-transform: uppercase; }
.slots { display: flex; flex-direction: column; }
.slot { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.slot-time { flex: 0 0 90px; display: flex; flex-direction: column; padding-top: 2px; }
.slot-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.slot-head strong { white-space: nowrap; }
/* vizualizarea pe săptămână folosește toată lățimea ecranului */
#view:has(.week-box) { max-width: 1280px; }
.view-switch { max-width: 360px; margin: 14px 0 10px; }
.week-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.week-bar h2 { margin: 0; font-size: 1rem; text-align: center; }
.week-bar button { flex: 0 0 auto; min-width: 44px; white-space: nowrap; }
@media (max-width: 560px) { .wide { display: none; } }
.week-scroll { overflow: auto; max-height: 75vh; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table.week { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; min-width: 760px; }
.week th, .week td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 3px; vertical-align: top; }
.week thead th { position: sticky; top: 0; z-index: 1; background: var(--gradient) fixed, var(--bg); }
.week .hour { position: sticky; left: 0; width: 56px; background: var(--gradient) fixed, var(--bg); font-size: .85rem; text-align: center; vertical-align: middle; }
.week thead .hour { z-index: 2; }
.week th.today { background: var(--info-bg); }
.week td.off { background: var(--shade); }
button.week-day { width: 100%; min-height: 32px; padding: 2px; border: 0; background: none; color: var(--accent); font-weight: 700; }
.week-totals { display: flex; justify-content: center; gap: 3px; }
.holiday-tag { display: block; color: var(--danger); font-weight: 700; }
button.patient {
  display: flex; flex-direction: column; width: 100%; min-height: 36px; margin-bottom: 3px; padding: 3px 6px;
  border-radius: 7px; font-size: .82rem; line-height: 1.25; text-align: left;
}
button.patient.status-requested, button.patient.status-noshow { background: var(--warn-bg); }
button.patient.status-scheduled { background: var(--info-bg); }
button.patient.status-arrived { background: var(--ok-bg); }
button.week-add { width: 100%; min-height: 28px; padding: 0; border: 1px dashed transparent; background: none; color: var(--muted); }
button.week-add:hover, button.week-add:focus-visible { border-color: var(--accent); }
button.day.in-week:not(.selected) { background: var(--info-bg); }

button.slot-remove { flex: 0 0 auto; width: 34px; min-height: 34px; padding: 0; color: var(--danger); font-weight: 700; }
.removed h3 { margin: 0 0 8px; font-size: 1rem; }
.slot-items { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.appointment {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.appointment.cancelled .who { opacity: .55; text-decoration: line-through; }
.who { display: flex; flex-direction: column; align-items: flex-start; flex: 1 1 180px; min-width: 0; }
button.name { min-height: 0; padding: 2px 0; border: 0; background: none; font-weight: 700; text-align: left; }
select.status { width: auto; }
select.status-requested, select.status-noshow { background: var(--warn-bg); }
select.status-scheduled { background: var(--info-bg); }
select.status-arrived { background: var(--ok-bg); }
button.add { align-self: flex-start; min-height: 36px; padding: 4px 12px; border-style: dashed; color: var(--muted); }
.settings { align-items: stretch; }
/* alegerea destinatarilor la un task: câte un buton pe rând */
.target-choice { display: flex; flex-direction: column; gap: 6px; }
.target-choice .chip { justify-content: center; min-height: 46px; font-weight: 700; }
.target-choice .chip:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.target-choice .chip:has(input:checked) span::before { content: "✓ "; }
.recipients small { display: block; margin-top: 8px; }
/* butonul plin arată alegerea; bifa nativă rămâne doar pentru tastatură și cititoare de ecran */
.target-choice .chip { position: relative; }
.target-choice input { position: absolute; opacity: 0; }
.target-choice .chip:has(input:focus-visible) { outline: 3px solid var(--highlight); outline-offset: 2px; }
.status-choice .chip { flex: 1 1 150px; justify-content: center; min-height: 46px; font-weight: 700; }
.status-choice .scheduled:has(input:checked) { background: var(--info-bg); }
.status-choice .arrived:has(input:checked) { background: var(--arrived-bg); color: var(--on-arrived); border-color: var(--arrived-bg); }
.status-choice .chip:has(input:disabled) { opacity: .5; cursor: default; }

/* paginile pentru firme și pacienți */
.page { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; }
.page header { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.page header h1 { margin: 0; flex: 1; }
.privacy { white-space: pre-wrap; max-height: 220px; overflow-y: auto; }
.hp { position: absolute; left: -9999px; }

/* ziua afișată: săgeți pentru ziua anterioară și următoare, cu data între ele */
.day-nav { display: flex; align-items: stretch; gap: 8px; }
.day-nav .arrow { flex: 0 0 56px; min-height: 54px; padding: 0; font-size: 1.8rem; line-height: 1; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.day-pick {
  position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); line-height: 1.25;
}
.day-pick.today { border: 2px solid var(--highlight); }
.day-pick strong::first-letter { text-transform: uppercase; }
.day-pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
/* Pe calculator data stă între săgeți, deci titlul zilei nu se mai repetă dedesubt (la tipărire rămâne). */
@media screen {
  .day-nav { margin-top: 16px; }
  .day-nav + .day-heading { margin-top: 10px; }
  .day-nav + .day-heading .day-title { display: none; }
}

/* programările pe telefon: o singură zi, pe toată lățimea */
@media (max-width: 700px) {
  body:has(.day-nav) nav { position: static; }
  #view:has(.day-nav) { padding-inline: 10px; }
  #view:has(.day-nav) .heading { margin-bottom: 8px; }
  .day-nav {
    position: sticky; top: 0; z-index: 4;
    margin: 0 -10px 8px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
    background: var(--gradient) fixed, var(--bg); border-bottom: 1px solid var(--line);
  }
  .to-today { width: 100%; min-height: 36px; margin-bottom: 8px; }
  .main-actions { flex-wrap: nowrap; margin: 0; }
  .main-actions button { flex: 1; }
  .day-heading { margin: 6px 0 8px; }
  .day-heading .day-title { display: none; }
  .day-totals { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin: 0; }
  .day-totals .total { padding: 4px; text-align: center; font-size: .78rem; line-height: 1.2; }
  .day-totals .total:first-child:nth-last-child(2) { grid-column: span 2; }
  .day-heading > button { margin-left: auto; min-height: 34px; padding: 4px 12px; font-size: .85rem; }
  .pending-link { width: 100%; min-height: 36px; margin-top: 8px; background: var(--mid-bg); font-weight: 700; }
  .pending { scroll-margin-top: 80px; }
  .search { margin-top: 20px; }
  .slot { gap: 6px; padding: 5px 0; }
  .slot-time { flex: 0 0 76px; }
  button.slot-remove { width: 28px; min-height: 32px; }
  .appointment { padding: 6px 8px; gap: 4px; }
  .who { flex-basis: 100%; }
  .row-actions { width: 100%; flex-wrap: nowrap; }
  .row-actions select.status { flex: 1; min-width: 0; min-height: 38px; padding-block: 5px; }
  button.add { align-self: stretch; }
}

@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #333; --line: #999; --info-bg: #fff; --ok-bg: #fff; --warn-bg: #fff; --mid-bg: #fff; }
  .bar, .top, nav, .fab, .no-print, #toast, body::before { display: none !important; }
  #view { max-width: none; padding: 0; }
  .slot { break-inside: avoid; padding: 3px 0; }
  #view:has(.week-box) { max-width: none; }
  .week-scroll { overflow: visible; max-height: none; border: 0; }
  table.week { min-width: 0; font-size: .7rem; }
  .week thead th, .week .hour { position: static; }
  .week tr { break-inside: avoid; }
  button.patient { border: 0; padding: 0; min-height: 0; }
  .slot.free { opacity: .6; }
  .appointment { border: 0; padding: 2px 0; }
  .appointment.cancelled { display: none; }
  button.name { color: #000; }
  select.status { appearance: none; border: 0; min-height: 0; padding: 0; }
  a { color: #000; text-decoration: none; }
}

#toast {
  position: fixed; left: 16px; right: 16px; bottom: 84px; z-index: 10;
  max-width: 480px; margin: 0 auto; padding: 12px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }
