/* שיבוץ טיפולים: base styles. RTL Hebrew, desktop only (minimum width 1280px).
   No inline styles anywhere: positions and per-definition colors are set through the CSSOM (custom properties). */

:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --ink: #1f2933;
  --muted: #6b7785;
  --line: #dde2e8;
  --line-strong: #cfd5dc;
  --accent: #2f5d9b;
  --accent-ink: #ffffff;
  --accent-soft: #eaf1fa;
  --accent-line: #cfdcee;
  --danger: #c62828;
  --danger-soft: #fdeaea;
  --danger-line: #f3b9bd;
  --ok: #1d7a3a;
  --ok-soft: #e3f5e8;
  --ok-line: #b9e2c4;
  --warn: #5c4a00;
  --warn-soft: #fff6cc;
  --warn-line: #efd96a;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 2px 8px rgba(16, 24, 40, 0.07);
  --font: 'Segoe UI', system-ui, 'Arial Hebrew', Arial, 'Noto Sans Hebrew', sans-serif;
  --header-h: 56px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 1280px;
  min-height: 100vh;
  background: var(--bg);
}

h1,
h2,
h3 {
  margin: 0 0 0.5em;
  line-height: 1.25;
}

h1 {
  font-size: 1.6rem;
}

h2 {
  font-size: 1.25rem;
}

p {
  margin: 0 0 0.75em;
}

.noscript {
  padding: 24px;
  text-align: center;
}

.muted {
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- controls ---------- */

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 1px rgba(16, 24, 40, 0.05);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--accent-soft);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover:not(:disabled) {
  background: #264e84;
}

.btn-quiet {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.btn:focus-visible,
.nav-tab:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #9db9de;
  outline-offset: 1px;
}

.btn-small {
  min-height: 30px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #a82020;
}

.btn-danger-quiet {
  border-color: var(--danger-line);
  background: var(--panel);
  color: var(--danger);
}

.btn-danger-quiet:hover:not(:disabled) {
  background: var(--danger-soft);
}

input[type='text'],
input[type='password'],
input[type='date'],
select {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
}

input[type='text']:disabled,
select:disabled {
  background: var(--panel-2);
  color: var(--muted);
}

label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}

/* ---------- header ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 30px;
  height: var(--header-h);
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.brand::before {
  content: '';
  width: 30px;
  height: 30px;
  background: url('/favicon.svg') center / contain no-repeat;
}

.nav {
  display: flex;
  align-self: stretch;
  gap: 4px;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  padding: 3px 18px 0;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #4a5560;
  font-size: 1rem;
  cursor: pointer;
}

.nav-tab:hover {
  color: var(--ink);
}

.nav-tab[aria-current='page'] {
  border-bottom-color: var(--accent);
  background: linear-gradient(#fff, var(--accent-soft));
  color: var(--accent);
  font-weight: 700;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-inline-start: auto;
}

.week-picker {
  min-width: 190px;
  min-height: 36px;
  font-size: 0.95rem;
}

/* ---------- save badge ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 84px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--ok-line);
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 0.9rem;
  font-weight: 600;
}

.badge::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
}

.badge[data-state='saving'] {
  border-color: var(--warn-line);
  background: var(--warn-soft);
  color: var(--warn);
}

.badge[data-state='saving']::before {
  background: #e0a100;
}

.badge[data-state='error'] {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

.badge[data-state='error']::before {
  background: var(--danger);
}

/* ---------- main area ---------- */

.screen {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

.card {
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.stat {
  min-width: 140px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.stat strong {
  display: block;
  font-size: 1.4rem;
}

.empty {
  max-width: 520px;
  margin: 72px auto;
  text-align: center;
}

.empty .btn {
  margin-top: 8px;
}

.notice {
  margin: 12px 24px 0;
  padding: 10px 16px;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 600;
}

.notice[hidden] {
  display: none;
}

.error-text {
  margin: 8px 0 0;
  color: var(--danger);
  font-weight: 600;
}

.error-text:empty {
  display: none;
}

/* ---------- login ---------- */

#overlay:empty,
#modal-root:empty,
#warn-root:empty {
  display: none;
}

.login-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  width: 400px;
  max-width: calc(100vw - 32px);
}

.login-card h1 {
  color: var(--accent);
}

.login-card .field {
  margin: 16px 0 12px;
}

.login-card input {
  width: 100%;
}

.login-card .btn {
  width: 100%;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- dialogs ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 30, 45, 0.45);
}

.modal {
  width: 420px;
  max-width: calc(100vw - 32px);
  padding: 22px 24px;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal h2 {
  margin-bottom: 8px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.modal .field {
  margin: 12px 0;
}

.modal input {
  width: 100%;
}

/* the "still here?" dialog sits above every other dialog */
.warn-backdrop {
  z-index: 80;
}

/* ---------- page layout shared by the template screens ---------- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}

.page-head h1 {
  margin-bottom: 2px;
  font-size: 1.5rem;
}

.page-help {
  max-width: 78ch;
  margin: 0;
}

.page-actions {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}

.section {
  margin-bottom: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
}

.add-inline,
.add-stack {
  display: flex;
  gap: 8px;
}

.add-name {
  width: 240px;
}

.add-stack .add-name {
  flex: 1;
  width: auto;
  min-width: 0;
}

.field {
  min-width: 0;
}

.field.grow {
  flex: 1;
}

.field > label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.field > input[type='text'],
.field > select {
  width: 100%;
}

.small {
  font-size: 0.88rem;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-weight: 500;
  cursor: pointer;
}

input[type='checkbox'] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent);
}

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-btn:focus-visible,
.drag-handle:focus-visible,
.patient-item:focus-visible {
  outline: 3px solid #9db9de;
  outline-offset: 1px;
}

.field-error {
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 600;
}

.field-error:empty {
  display: none;
}

input.invalid,
select.invalid {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.mini-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.time-text {
  width: 76px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.time-text-wide {
  width: 100%;
  max-width: 340px;
  text-align: start;
}

.confirm h2 {
  margin-bottom: 6px;
}

/* ---------- tables ---------- */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong);
  background: #f3f5f8;
  color: #3a4651;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: start;
  white-space: nowrap;
}

.table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table .center {
  text-align: center;
}

.defs-table thead th {
  position: sticky;
  top: var(--header-h);
  z-index: 2;
}

.def-name {
  width: 100%;
  max-width: 460px;
}

.def-kind {
  min-width: 150px;
}

.color-input {
  width: 44px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
}

/* ---------- team meeting ---------- */

.meeting-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meeting-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.meeting-day {
  min-width: 110px;
}

.meeting-type {
  min-width: 180px;
}

/* ---------- staff ---------- */

.staff-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.staff-item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.staff-item.open {
  border-color: var(--accent-line);
  box-shadow: var(--shadow);
}

.staff-item.inactive .staff-main {
  opacity: 0.62;
}

.staff-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
}

.drag-handle {
  width: 28px;
  height: 34px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  letter-spacing: -3px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.drag-handle:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.staff-item.dragging {
  z-index: 5;
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.28);
  cursor: grabbing;
}

.staff-item.dragging .drag-handle {
  cursor: grabbing;
}

.staff-item.drop-before::before,
.staff-item.drop-after::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  z-index: 6;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.staff-item.drop-before::before {
  top: -6px;
}

.staff-item.drop-after::after {
  bottom: -6px;
}

.staff-num {
  min-width: 24px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.staff-name {
  width: 220px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--c, #d9d9d9);
  box-shadow: inset 0 0 0 1px rgba(16, 24, 40, 0.18);
}

.staff-type {
  width: 190px;
}

.staff-type.warn {
  border-color: var(--warn-line);
  background: var(--warn-soft);
}

.day-chips {
  display: inline-flex;
  gap: 4px;
  margin-inline-start: auto;
}

.day-chip {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f1f3f6;
  color: #9aa5b1;
  font-size: 0.78rem;
}

.day-chip.on {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.staff-detail {
  padding: 8px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 0 0 8px 8px;
}

.days-table th[scope='row'] {
  width: 90px;
  background: transparent;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}

.days-table .windows-cell {
  width: 380px;
}

.days-table td {
  vertical-align: top;
}

/* ---------- editors ---------- */

.windows-editor {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.blocks-editor {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.block-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.block-type {
  min-width: 170px;
}

.avail-editor {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.avail-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 4px 8px;
  padding: 5px 8px;
  border-radius: var(--radius);
}

.avail-row.on {
  background: var(--accent-soft);
}

.avail-day {
  font-weight: 600;
}

.avail-times {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.avail-row:not(.on) .avail-times {
  visibility: hidden;
}

.avail-row .field-error {
  grid-column: 2;
}

.req-editor {
  display: flex;
  flex-direction: column;
}

.req-head,
.req-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) 96px minmax(0, 1.3fr) 30px;
  align-items: center;
  gap: 8px;
}

.req-head {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.req-row {
  margin-bottom: 8px;
}

.req-row select {
  width: 100%;
  min-width: 0;
}

.req-problem {
  grid-column: 1 / -1;
  margin: -2px 0 0;
}

.req-add-row {
  margin-top: 4px;
}

.req-add {
  min-width: 220px;
}

.req-checks {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.95rem;
}

.req-checks p {
  margin: 0 0 4px;
}

.req-checks p:last-child {
  margin-bottom: 0;
}

/* ---------- patients ---------- */

.master-detail {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.master {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 150px);
  padding: 12px;
}

.master .add-stack {
  margin-bottom: 8px;
}

.patient-search {
  width: 100%;
}

.patient-list {
  flex: 1;
  margin: 8px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.patient-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  text-align: start;
  cursor: pointer;
}

.patient-item:hover {
  background: var(--panel-2);
}

.patient-item.selected {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.patient-item.inactive .patient-name {
  color: var(--muted);
  text-decoration: line-through;
}

.patient-meta {
  margin-inline-start: auto;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.dot-warn {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e0a100;
}

.patient-empty {
  padding: 12px 10px;
}

.patient-head {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.patient-head .check {
  min-height: 36px;
}

.patient-detail .columns {
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
}

.patient-detail h3 {
  margin-bottom: 4px;
}

.empty-detail {
  padding: 48px;
  text-align: center;
}

/* ---------- groups ---------- */

.group-list {
  display: flex;
  flex-direction: column;
}

.group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 14px;
}

.group-head .field {
  min-width: 140px;
}

.group-head .field.grow {
  min-width: 220px;
}

.group-times {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}

.pick {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.pick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.pick-count {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
}

.pick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  max-height: 74px;
  margin-bottom: 8px;
  overflow-y: auto;
}

.pick-chip {
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.82rem;
  white-space: nowrap;
}

.pick-chip.muted {
  background: var(--panel);
  color: var(--muted);
}

.pick-search {
  width: 100%;
  margin-bottom: 8px;
}

.pick-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 2px 10px;
  max-height: 210px;
  overflow-y: auto;
}

.pick-row {
  padding: 4px 6px;
  border-radius: 4px;
}

.pick-row:hover {
  background: #fff;
}

.pick-row[hidden],
.pick-empty[hidden] {
  display: none;
}

.defs-table th:nth-child(1),
.defs-table td:nth-child(1) {
  width: 80px;
}

.defs-table th:nth-child(3),
.defs-table td:nth-child(3) {
  width: 200px;
}

.defs-table th:nth-child(n + 4),
.defs-table td:nth-child(n + 4) {
  width: 130px;
}
