:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --line: #e6e3dc;
  --line-strong: #d4d0c6;
  --text: #1d1c1a;
  --muted: #6f6b63;
  --accent: #1f5f5b;
  --accent-ink: #ffffff;
  --accent-soft: #e3efed;
  --danger: #b4372f;
  --danger-soft: #fbe9e7;
  --warn: #9a6200;
  --warn-soft: #fdf1dc;
  --ok: #2d7a46;
  --ok-soft: #e4f3e8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(30, 28, 24, .06), 0 4px 16px rgba(30, 28, 24, .05);
  --font: "Rubik", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer;
  font-weight: 500; text-decoration: none; color: var(--text); white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: #bdb8ad; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #184e4b; }
.btn.danger { color: var(--danger); border-color: #e7c2bd; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.04); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn.wa { color: #136b3a; border-color: #bfe0cb; }
.btn.wa:hover { background: #eaf6ee; }
.icon-btn { width: 40px; padding: 0; }
.btn svg { width: 17px; height: 17px; flex: none; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 500; color: #3d3a35; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); font-size: 15px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 1px;
}
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
input[type=color] { padding: 2px; width: 48px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.daypicks { display: flex; flex-wrap: wrap; gap: 6px; }
.daypicks label { display: flex; align-items: center; gap: 5px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 999px; font-weight: 400; cursor: pointer; }
.daypicks label:has(input:checked) { background: var(--danger-soft); border-color: #e7c2bd; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.on { border-color: var(--text); box-shadow: inset 0 0 0 2px #fff; }

/* ---------- auth ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); display: grid; gap: 16px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-brand small { display: block; color: var(--muted); }
.steps { margin: 0; padding-inline-start: 20px; display: grid; gap: 6px; }

/* ---------- shell ---------- */
.shell { max-width: 1240px; margin: 0 auto; padding: 0 16px 96px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; flex: none;
}
.brand strong { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; color: var(--muted); font-size: 12.5px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab {
  border: 0; background: none; padding: 12px 14px; cursor: pointer; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; gap: 7px; align-items: center; white-space: nowrap;
}
.tab svg { width: 18px; height: 18px; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.badge { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11.5px; padding: 1px 7px; font-weight: 600; }
.mobile-nav { display: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.stack { display: grid; gap: 14px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ---------- schedule toolbar ---------- */
.week-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; margin-bottom: 12px; }
.week-nav { display: flex; align-items: center; gap: 6px; }
.week-title { font-size: 18px; font-weight: 600; min-width: 170px; text-align: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 500; }
.pill.draft { background: #efece5; color: #5d584e; }
.pill.published { background: var(--ok-soft); color: var(--ok); }
.pill.changed { background: var(--warn-soft); color: var(--warn); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }

/* warnings */
.checks { margin-bottom: 14px; }
.checks summary { cursor: pointer; padding: 12px 16px; display: flex; align-items: center; gap: 10px; list-style: none; font-weight: 500; }
.checks summary::-webkit-details-marker { display: none; }
.checks ul { margin: 0; padding: 0 16px 12px; list-style: none; display: grid; gap: 6px; }
.checks li { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 7px; }
.dot.error { background: var(--danger); } .dot.warn { background: #d18b00; } .dot.info { background: #a29d92; }
.checks.okay summary { color: var(--ok); }
.checks.bad { border-color: #ecc9c4; }
.checks.bad summary { color: var(--danger); }

/* grid */
.grid-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 760px; }
.grid th, .grid td { border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line); vertical-align: top; }
.grid th:first-child, .grid td:first-child { border-inline-start: 0; }
.grid thead th { padding: 10px 8px; font-weight: 600; text-align: center; background: var(--surface-2); font-size: 14px; }
.grid thead th small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.grid thead th:first-child { border-start-start-radius: var(--radius); }
.grid thead th:last-child { border-start-end-radius: var(--radius); }
.grid .who { padding: 10px 12px; min-width: 150px; position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 1; }
.who-in { display: flex; align-items: center; gap: 9px; }
.who strong { display: block; font-weight: 500; }
.who small { color: var(--muted); font-size: 12.5px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 13px; flex: none; }
.cell { padding: 6px; min-width: 104px; height: 64px; cursor: pointer; position: relative; }
.cell:hover { background: var(--surface-2); }
.cell .add-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #b3ada1; opacity: 0; font-size: 20px; }
.cell:hover .add-hint { opacity: 1; }
.cell.closed { background: repeating-linear-gradient(-45deg, #f7f6f2, #f7f6f2 6px, #f1efe9 6px, #f1efe9 12px); cursor: default; }
.chip {
  display: block; width: 100%; text-align: start; border: 0; cursor: pointer; border-radius: 8px;
  padding: 5px 8px; margin-bottom: 4px; font-size: 13px; font-weight: 500; position: relative; z-index: 1;
  background: color-mix(in srgb, var(--c, #1f5f5b) 13%, #fff); color: #1d1c1a;
  border-inline-start: 3px solid var(--c, #1f5f5b);
}
.chip small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; }
.chip.mine { outline: 2px solid var(--accent); }
.tag { display: inline-block; font-size: 11.5px; border-radius: 6px; padding: 2px 6px; margin-bottom: 4px; position: relative; z-index: 1; }
.tag.off { background: #efece5; color: #5d584e; }
.tag.pending { border: 1px dashed #c9a35a; color: var(--warn); }
.tag.want { border: 1px dashed var(--accent); color: var(--accent); background: var(--accent-soft); cursor: pointer; font: inherit; font-size: 11.5px; }
.tag.want:hover { background: color-mix(in srgb, var(--accent) 18%, #fff); }
.hours { text-align: center; padding: 10px 8px; font-size: 13.5px; white-space: nowrap; }
.hours .over { color: var(--danger); }
.hours small { display: block; color: var(--muted); }
tr.coverage td { background: var(--surface-2); text-align: center; font-size: 12.5px; padding: 8px 4px; }
.cov-ok { color: var(--ok); } .cov-bad { color: var(--danger); font-weight: 500; }

/* mobile day list */
.days { display: none; gap: 12px; }
.day-card { padding: 14px; }
.day-card header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.day-card .chip { padding: 9px 10px; font-size: 14px; }
.day-card .chip span { font-weight: 400; }
.day-card .none { color: var(--muted); font-size: 14px; padding: 4px 0 8px; }

/* lists */
.list { display: grid; gap: 10px; }
.item { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 14px 16px; flex-wrap: wrap; }
.item-main { display: flex; gap: 12px; align-items: flex-start; min-width: 0; flex: 1 1 260px; }
.item-main p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.item-main .note { margin-top: 6px; color: var(--text); background: var(--surface-2); border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.status { font-size: 12.5px; border-radius: 999px; padding: 3px 10px; font-weight: 500; }
.status.pending { background: var(--warn-soft); color: var(--warn); }
.status.approved { background: var(--ok-soft); color: var(--ok); }
.status.rejected { background: var(--danger-soft); color: var(--danger); }
.status.cancelled { background: #efece5; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.segmented { display: inline-flex; background: #ebe8e1; border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; color: var(--muted); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.inactive { opacity: .6; }

/* settings */
.day-set { border-top: 1px solid var(--line); padding: 14px 0; display: grid; gap: 10px; }
.day-set:first-child { border-top: 0; }
.day-set-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.day-set-head strong { width: 56px; }
.day-set-head input[type=time] { width: 136px; }
.tpl { display: grid; grid-template-columns: 1.2fr 1fr 1fr 80px 40px; gap: 8px; align-items: center; }
.tpl-head { font-size: 12px; color: var(--muted); }
.tpls { display: grid; gap: 8px; padding-inline-start: 68px; }

/* my shifts (employee) */
.my-shifts { display: grid; gap: 8px; }
.my-shift { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); }
.my-shift strong { font-size: 15px; }
.total { font-size: 14px; color: var(--muted); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(25, 23, 20, .38); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal.wide { max-width: 620px; }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 0; }
.modal .body { padding: 16px 18px; }
.modal footer { display: flex; gap: 8px; justify-content: space-between; padding: 0 18px 18px; flex-wrap: wrap; }
.modal footer .end { display: flex; gap: 8px; margin-inline-start: auto; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.creds { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 14px; direction: rtl; white-space: pre-wrap; }

/* alerts & toasts */
.alert { border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
#toast-root { position: fixed; bottom: 84px; inset-inline: 0; display: grid; justify-items: center; gap: 8px; z-index: 60; pointer-events: none; padding: 0 16px; }
.toast { background: #23211e; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 520px; animation: pop .18s ease-out; }
.toast.error { background: var(--danger); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

#print-area { display: none; }


/* ---------- registration & profiles ---------- */
.reg { width: 100%; max-width: 720px; display: grid; gap: 18px; }
.fs { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; min-width: 0; }
.fs + .fs { border-top: 1px solid var(--line); padding-top: 18px; }
.fs legend { font-size: 16px; font-weight: 600; padding: 0; margin-bottom: 12px; color: var(--text); }
.row3 .span2 { grid-column: span 2; }
.req { font-size: 11.5px; color: var(--danger); background: var(--danger-soft); border-radius: 6px; padding: 1px 6px; font-weight: 500; }
.upl { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: 12px; }
.upl.done { border-style: solid; border-color: #b7d9c2; background: var(--ok-soft); }
.upl.done .upl-name { color: var(--ok); }
.upl-name { word-break: break-all; }
.upl-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.upl-row select { width: auto; flex: 1 1 220px; }
.consent { align-items: flex-start; line-height: 1.5; }
.consent input { margin-top: 2px; flex: none; }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.pending-box { margin-bottom: 24px; padding: 16px; border-radius: var(--radius); background: var(--warn-soft); }
.pending-box h2 { color: var(--warn); }
.kvs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 18px; }
.kv { display: grid; gap: 2px; min-width: 0; }
.kv span { font-size: 12.5px; color: var(--muted); }
.kv strong { font-weight: 500; overflow-wrap: anywhere; }
.docs { display: grid; gap: 8px; }
.doc { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.doc > div:nth-child(2) { flex: 1; }
.doc-ico { width: 38px; height: 38px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.linkbox { margin: 12px 0 10px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
.linkbox code { font-size: 13.5px; white-space: nowrap; }
.form .segmented { justify-self: start; }
@media (max-width: 760px) {
  .row3 .span2 { grid-column: 1 / -1; }
  .fs .row2, .fs .row3 { grid-template-columns: 1fr; }
  .upl { flex-wrap: wrap; }
}

table.diff { border-collapse: collapse; margin-top: 8px; font-size: 13.5px; }
table.diff th, table.diff td { border: 1px solid var(--line); padding: 4px 8px; text-align: start; }
table.diff th { background: var(--surface-2); font-weight: 500; color: var(--muted); }
.my-shift { flex-wrap: wrap; gap: 8px; }
.my-shift .item-actions { flex-wrap: nowrap; }
.my-shift .tr { white-space: nowrap; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .shell { padding: 0 12px 100px; }
  .tabs { display: none; }
  .mobile-nav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; bottom: 0; inset-inline: 0;
    background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 40;
  }
  .mobile-nav button { border: 0; background: none; display: grid; justify-items: center; gap: 2px; font-size: 11.5px; color: var(--muted); padding: 6px 0; position: relative; cursor: pointer; }
  .mobile-nav svg { width: 22px; height: 22px; }
  .mobile-nav .on { color: var(--accent); font-weight: 600; }
  .mobile-nav .badge { position: absolute; top: 0; inset-inline-start: calc(50% + 6px); }
  .grid-wrap { display: none; }
  .days { display: grid; }
  .week-bar { flex-direction: column; align-items: stretch; }
  .week-nav { justify-content: space-between; }
  .week-title { font-size: 16px; min-width: 0; }
  .toolbar .btn { flex: 1 1 auto; }
  .toolbar .sep { display: none; }
  .user-chip .name { display: none; }
  .tpl { grid-template-columns: 1fr 1fr 1fr; }
  .tpl .lbl { grid-column: 1 / -1; }
  .tpl-head { display: none; }
  .tpls { padding-inline-start: 0; }
  .tpl { border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
  .row3 { grid-template-columns: 1fr 1fr; }
  .modal-bg { align-items: end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; }
}

/* ---------- print ---------- */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; font-size: 11px; }
  #app, #modal-root, #toast-root { display: none !important; }
  #print-area { display: block; }
  #print-area h1 { font-size: 18px; margin-bottom: 2px; }
  #print-area p { margin: 0 0 8px; color: #555; }
  #print-area table { width: 100%; border-collapse: collapse; }
  #print-area th, #print-area td { border: 1px solid #999; padding: 4px 5px; text-align: center; vertical-align: top; }
  #print-area th { background: #eee; }
  #print-area td.n { text-align: start; font-weight: 600; white-space: nowrap; }
  #print-area .s { display: block; }
}
