:root {
  --bg: #f6f4ee; --surface: #fff; --surface-2: #faf8f2; --line: #e7e2d3; --line-strong: #d3cbb4;
  --text: #14120b; --muted: #6f6a5a; --brand: #8a6508; --gold: #d4a72c; --brand-ink: #14120b; --brand-soft: #f8f0d6;
  --nav: #0a0a0a; --nav-text: #d6d0bd; --danger: #b91c1c; --danger-soft: #fdecec;
  --warn: #92400e; --warn-soft: #fef3c7; --ok: #166534; --ok-soft: #e3f6e8; --off: #be123c; --off-soft: #ffeef1;
  --me: #1d4ed8; --me-soft: #e8efff; --radius: 10px; --shadow: 0 1px 2px rgba(20,18,11,.07), 0 1px 1px rgba(20,18,11,.04);
  --sidebar: 232px; --tabbar: 60px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0a0a0a; --surface: #141414; --surface-2: #1b1b1b; --line: #2a2a2a; --line-strong: #3d3d3d;
    --text: #f5f1e6; --muted: #a8a08c; --brand: #e6b93c; --gold: #e6b93c; --brand-ink: #0a0a0a; --brand-soft: #2a2208;
    --nav: #000; --nav-text: #d6d0bd; --danger: #f87171; --danger-soft: #3a1717; --warn: #fb923c; --warn-soft: #3a210e;
    --ok: #4ade80; --ok-soft: #12301c; --off: #fb7185; --off-soft: #3a1620; --me: #93b4ff; --me-soft: #172447; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); } .small { font-size: 13px; } .grow { flex: 1; } .row { display: flex; align-items: center; gap: 8px; } .wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

/* shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--nav); color: var(--nav-text); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; letter-spacing: .01em; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand small { display: block; font-weight: 500; color: #94a3b8; font-size: 12px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--nav-text); text-decoration: none; font-weight: 500; border: 0; background: none; width: 100%; text-align: left; position: relative; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(230,185,60,.16); color: #e6b93c; }
.badge { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; }
.nav-item .badge { margin-left: auto; }
.sidebar .spacer { flex: 1; }
.who { padding: 10px 12px; font-size: 13px; color: #94a3b8; border-top: 1px solid rgba(255,255,255,.08); margin-top: 6px; }
.who b { display: block; color: #fff; font-weight: 600; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.topbar h1 { font-size: 19px; }
.content { padding: 20px clamp(16px, 2vw, 40px) 40px; width: 100%; }
.topbar { padding-left: clamp(16px, 2vw, 40px); padding-right: clamp(16px, 2vw, 40px); }
.list.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); }
@media (min-width: 861px) { .list.cols > * { border-right: 1px solid var(--line); } }
.set-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.set-cols > div + div { border-left: 1px solid var(--line); }
@media (max-width: 860px) { .set-cols > div + div { border-left: 0; border-top: 1px solid var(--line); } }
.mobile-only { display: none; }
body.has-preview { --bar-h: 44px; }
.preview-bar { position: sticky; top: 0; z-index: 45; height: var(--bar-h, 44px); display: flex; align-items: center; gap: 10px; padding: 0 clamp(16px, 2vw, 40px); background: var(--gold); color: #0a0a0a; font-weight: 600; font-size: 14px; white-space: nowrap; }
.preview-bar .grow { overflow: hidden; text-overflow: ellipsis; }
.preview-bar .btn { background: #0a0a0a; color: #f5f1e6; border-color: #0a0a0a; }
body.has-preview .topbar { top: var(--bar-h); }
body.has-preview .roster { top: calc(var(--bar-h) + 76px); }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); } .btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.whatsapp { background: #128c7e; border-color: #128c7e; color: #fff; } .btn.whatsapp:hover { background: #0f7a6d; }
.btn.icon-only { width: 38px; padding: 0; } .btn.sm.icon-only { width: 32px; }
.iconbtn { position: relative; width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; }
.iconbtn .badge { position: absolute; top: -6px; right: -6px; }
.field { display: grid; gap: 5px; margin-bottom: 14px; } .field > label { font-weight: 600; font-size: 13px; }
.input, select.input, textarea.input { width: 100%; height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); }
textarea.input { height: auto; padding: 10px 12px; min-height: 80px; resize: vertical; }
input[type=date].input { display: block; min-width: 0; max-width: 100%; text-align: left; -webkit-appearance: none; appearance: none; }
input[type=date].input::-webkit-date-and-time-value { text-align: left; min-height: 1.4em; }
select.input { -webkit-appearance: none; appearance: none; padding-right: 36px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center; }
.input:focus, .btn:focus-visible, .nav-item:focus-visible, .chip:focus-visible, .shift:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.hint { font-size: 12.5px; color: var(--muted); }
.toggle { display: flex; align-items: center; gap: 10px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--brand); }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented button { border: 0; background: none; padding: 0 14px; height: 36px; font-weight: 600; color: var(--muted); }
.segmented button.on { background: var(--brand-soft); color: var(--brand); }

/* cards + lists */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; font-weight: 700; }
.card-b { padding: 16px; }
.list > * { padding: 14px 16px; border-bottom: 1px solid var(--line); } .list > *:last-child { border-bottom: 0; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; } .pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; } .pill.brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.banner { padding: 10px 14px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-weight: 600; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; }
.banner.info { background: var(--brand-soft); color: var(--brand); }

/* scheduler */
.sched { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; align-items: start; }
.sched > * { min-width: 0; }
.roster { position: sticky; top: 76px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; }
.roster .card-b { overflow: auto; display: grid; gap: 6px; }
.chip { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); font-weight: 600; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.chip:hover { border-color: var(--gold); }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; flex: none; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; }
.day.today { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.day-h { padding: 10px 10px 8px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.day-h .dow { font-weight: 700; } .day-h .dnum { color: var(--muted); font-size: 13px; }
.day-h .count { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--brand); background: var(--brand-soft); border-radius: 999px; padding: 1px 8px; }
.zone { padding: 8px; display: grid; gap: 6px; align-content: start; transition: background .1s; border-radius: 8px; }
.zone.work { flex: 1; min-height: 120px; }
.zone.offz { background: var(--surface-2); border-top: 1px dashed var(--line-strong); border-radius: 0 0 var(--radius) var(--radius); min-height: 64px; }
.zone-label { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0 2px; }
.zone.over { background: var(--brand-soft); outline: 2px dashed var(--gold); outline-offset: -3px; }
.zone.offz.over { background: var(--off-soft); outline-color: var(--off); }
.shift { display: grid; gap: 1px; padding: 7px 9px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-left: 4px solid var(--gold); text-align: left; width: 100%; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.shift.mine { border-left-color: var(--me); background: var(--me-soft); }
.shift .nm { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shift .tm { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.shift .nt { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shift.admin { cursor: grab; }
.shift.off { border-left-color: var(--off); background: var(--off-soft); }
.shift.off .nm { color: var(--off); }
.shift.pend { border-left-color: var(--warn); background: var(--warn-soft); border-style: dashed; }
.add-day { margin: 0 8px 8px; }
.ghost { position: fixed; z-index: 1000; pointer-events: none; opacity: .92; transform: translate(-50%, -60%) rotate(-2deg); box-shadow: 0 10px 30px rgba(15,23,42,.35); width: 150px; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none !important; }
.weeknav { display: flex; align-items: center; gap: 6px; }
.weeknav .label .sm { display: none; }
@media (max-width: 370px) { .weeknav .label .lg { display: none; } .weeknav .label .sm { display: inline; } }
.weeknav .label { font-weight: 700; min-width: 190px; text-align: center; }
.my-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { padding: 12px 14px; } .stat b { font-size: 22px; display: block; } .stat span { color: var(--muted); font-size: 13px; }

/* requests */
.req { display: grid; gap: 8px; }
.req-top { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.conf { display: grid; gap: 3px; padding: 8px 10px; background: var(--warn-soft); color: var(--warn); border-radius: 8px; font-size: 13px; }
.conf.clear { background: var(--ok-soft); color: var(--ok); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* modal / toast / notifications */
#modal { position: fixed; inset: 0; z-index: 500; display: none; }
#modal.open { display: block; }
.scrim { position: absolute; inset: 0; background: rgba(2,6,23,.55); }
.sheet { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(480px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.sheet.wide { width: min(640px, calc(100vw - 24px)); }
.sheet-h { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; }
.sheet-b { padding: 18px; } .sheet-f { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.picklist { display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.pick { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; }
.pick input { width: 18px; height: 18px; accent-color: var(--brand); }
.pick.dis { opacity: .55; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #0a0a0a; color: #f5f1e6; border: 1px solid #d4a72c; padding: 11px 16px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 900; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); } #toast.err { background: #b91c1c; }
.pop { position: absolute; right: 24px; top: 62px; width: min(380px, calc(100vw - 24px)); z-index: 60; max-height: 70vh; overflow: auto; }
.notif { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.notif.unread { background: var(--brand-soft); } .notif time { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
textarea.wa { min-height: 240px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.linkbox { display: flex; gap: 6px; } .linkbox input { font: 13px ui-monospace, Menlo, Consolas, monospace; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 500px at 50% -10%, rgba(212,167,44,.20), transparent), var(--bg); }
.auth-card { width: min(420px, 100%); padding: 28px; }
.auth-card .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-card .logo img { width: 44px; height: 44px; border-radius: 12px; }
.auth-card h1 { font-size: 21px; margin-bottom: 4px; }
.err { background: var(--danger-soft); color: var(--danger); padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; font-size: 14px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.tb-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.page-head > .grow { min-width: 220px; }
.page-head.inline > .btn.primary { order: 5; }

/* wide screens */
.day { min-height: max(340px, calc(100vh - 400px)); }
.zone.offz { min-height: 150px; }
.shift .nm { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.roster .card-b .hint { flex: 1 1 100%; margin-top: 2px; }
@media (min-width: 1700px) { body { font-size: 16px; } .sched { grid-template-columns: 270px 1fr; } .week { gap: 14px; } .shift .nm { font-size: 15px; } .shift .tm { font-size: 13px; } }
/* mid-width desktops: roster becomes a strip above the week so all 7 days get the full width */
@media (min-width: 861px) and (max-width: 1499px) {
  .sched { grid-template-columns: minmax(0, 1fr); }
  .roster { position: static; max-height: none; }
  .roster .card-b { display: flex; flex-wrap: wrap; padding: 10px; gap: 8px; }
}

/* mobile */
@media (max-width: 1180px) { .week { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  .sidebar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding: 4px 6px env(safe-area-inset-bottom); flex-direction: row; gap: 0; z-index: 40; border-top: 1px solid rgba(255,255,255,.1); }
  .brand, .who, .sidebar .spacer, .desktop-only, .sidebar [data-act=logout] { display: none !important; }
  .mobile-only { display: inline-flex; }
  .nav-item { flex: 1; flex-direction: column; gap: 2px; justify-content: center; font-size: 11px; padding: 6px 2px; align-items: center; }
  .nav-item .badge { position: absolute; top: 2px; left: 55%; margin: 0; }
  .topbar { padding: 12px 14px; top: 0; } .content { padding: 14px 14px 28px; }
  .sched { grid-template-columns: minmax(0, 1fr); }
  .roster { position: static; max-height: none; }
  .roster .card-b { display: flex; overflow-x: auto; padding: 10px; gap: 8px; scrollbar-width: none; } .roster .chip { flex: none; }
  .week { grid-template-columns: 1fr; gap: 12px; }
  .day { min-height: 0; } .zone.work { min-height: 70px; }
  .toolbar { gap: 10px; }
  .tb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-left: 0; }
  .tb-actions .btn { width: 100%; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-head > .grow { min-width: 0; font-size: 14px; }
  .page-head > .btn { width: 100%; height: 44px; }
  .page-head.inline { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .page-head.inline > .btn.primary { flex: 1 1 100%; width: 100%; height: 44px; margin-left: 0; order: -1; }
  .page-head.inline > .btn { width: auto; height: 38px; margin-left: auto; }
  .zone.work > .zone-label { display: none; }
  .page-head > .segmented { align-self: flex-start; }
  .sheet-f.stack { display: grid; grid-template-columns: 1fr 1fr; }
  .sheet-f.stack > .grow { display: none; }
  .sheet-f.stack > .btn { width: 100%; }
  .sheet-f.stack > .btn.primary { grid-column: 1 / -1; order: 9; height: 44px; }
  .sheet-f > .btn.primary:only-child, form > .sheet-f > .btn.primary:only-child { width: 100%; height: 44px; }
  .zone.offz { min-height: 0; padding: 6px 8px; }
  .zone.offz:not(:has(.shift)) { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
  .zone.work:not(:has(.shift)) { min-height: 0; padding-bottom: 4px; }
  .day-h .count::after { content: " working"; font-weight: 600; }
  .day-h .count { padding: 2px 10px; }
  .tb-status { grid-column: 1 / -1; justify-self: start; order: 0; }
  .tb-wa { grid-column: 1 / -1; order: 1; height: 44px; }
  .tb-actions .btn:not(.tb-wa):not(.tb-clear):not(.tb-req) { order: 2; }
  .tb-req { order: 4; grid-column: 1 / -1; }
  .tb-clear { order: 3; }
  .tb-status.ok ~ .tb-clear { grid-column: 1 / -1; }
  .tb-actions > .btn.primary { grid-column: 1 / -1; height: 44px; }
  .my-summary { grid-template-columns: 1fr 1fr; }
  .my-summary .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .weeknav { flex: 1 1 100%; min-width: 0; gap: 6px; }
  .weeknav .btn:not(.icon-only) { padding: 0 12px; }
  .toolbar > * { min-width: 0; } .weeknav .label { min-width: 0; flex: 1; white-space: nowrap; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
  .pop { right: 8px; left: 8px; width: auto; top: 58px; }
  .sheet { top: auto; bottom: 0; left: 0; transform: none; width: 100%; border-radius: 16px 16px 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); }
  .sheet.wide { width: 100%; }
  #toast { bottom: calc(var(--tabbar) + 16px); }
}
@media print { .sidebar, .topbar .btn, .roster, .add-day, .iconbtn { display: none !important; } .shell { display: block; } .week { grid-template-columns: repeat(7, 1fr); } .zone.offz { min-height: 0; } }
