:root {
  --navy: #0b2a5b;
  --blue: #1565d8;
  --blue-50: #eaf2fe;
  --green: #22b04b;
  --ink: #14213d;
  --muted: #5b6b85;
  --line: #d8e0ec;
  --bg: #f4f7fb;
  --card: #ffffff;
  --danger: #c62828;
  --xl-yellow: #ffff00;
  --xl-pink: #f4b6b0;
  --flag: #ffe94d;
  --radius: 10px;
  --sun: #f7931e;
  --sun-deep: #f26b1d;
  --sun-soft: #fff1e2;
  --sky: #e8f3ff;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg) linear-gradient(180deg, #fff4e8 0px, #fdf6ef 140px, var(--bg) 420px) no-repeat;
  font-size: 14px;
  line-height: 1.45;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; color: var(--navy); }
input, select, textarea, button { font: inherit; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="month"], input:not([type]), select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
label { display: block; font-weight: 600; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; padding: 8px 10px; }
legend { font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 0 4px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

.btn { border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; background: none; color: var(--ink); white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #0f4fae; }
.btn-ghost { background: #fff; border-color: var(--line); }
.btn-ghost:hover { background: var(--blue-50); }
.btn-link { color: var(--blue); padding: 6px 4px; }
.btn-link.danger { color: var(--danger); }
.btn-xl { font-size: 18px; padding: 14px 48px; border-radius: 999px; background: linear-gradient(135deg, #1f78ec, var(--navy)); box-shadow: 0 8px 24px rgba(11,42,91,.28), 0 0 0 4px rgba(247,147,30,.18); }
.btn-xl:hover:not(:disabled) { background: linear-gradient(135deg, #1565d8, #071d42); }
.w-full { width: 100%; margin-top: 8px; }
.row { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.row > input, .row > select { flex: 1 1 120px; width: auto; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0; }
.msg { font-size: 13px; margin: 8px 0 0; min-height: 1em; }
.msg.err { color: var(--danger); }
.msg.ok { color: #1b7f3a; }

/* ---------------- Landing ---------------- */
/* sunset sky fading to calm water, echoing the logo */
.landing {
  min-height: 100vh; display: flex; flex-direction: column; position: relative; overflow: hidden; isolation: isolate;
  background:
    radial-gradient(900px 520px at 50% 8%, rgba(255, 196, 120, .55) 0%, rgba(255, 214, 160, .25) 40%, transparent 70%),
    linear-gradient(180deg, #ffe7cf 0%, #fff3e6 28%, #fffaf4 48%, var(--sky) 78%, #d7ebff 100%);
}
.landing-top { padding: 14px 24px; position: relative; z-index: 1; }
.landing-logo-small { height: 40px; mix-blend-mode: multiply; display: none; }
.hero { flex: 1; width: 100%; max-width: 780px; margin: 0 auto; padding: 8px 16px 140px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.hero-logo { width: 440px; max-width: 86vw; height: auto; mix-blend-mode: multiply; }
.hero h1 { background: linear-gradient(90deg, var(--navy), #1f5fbf); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-points li strong { color: var(--sun-deep); }
.landing-waves { position: absolute; left: 0; right: 0; bottom: 0; height: 170px; z-index: -1; pointer-events: none; }
.landing-waves svg { width: 100%; height: 100%; display: block; }
.hero h1 { font-size: clamp(26px, 4vw, 38px); font-weight: 800; margin-top: 4px; }
.lead { font-size: 16px; color: #33445f; max-width: 640px; }
.hero-points { list-style: none; padding: 0; margin: 8px 0 28px; display: grid; gap: 6px; color: #33445f; }
.signin-wrap { position: relative; display: flex; flex-direction: column; align-items: center; width: 100%; }
.signin-panel { position: static; margin-top: 14px; width: min(380px, 100%); text-align: left; }
.landing-foot { text-align: center; color: rgba(255,255,255,.92); font-size: 12px; padding: 16px; position: relative; z-index: 1; }

.dropdown-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(11,42,91,.14); padding: 14px; }

/* ---------------- App ---------------- */
.topbar { position: relative; z-index: 30; display: flex; align-items: center; gap: 18px; padding: 6px 16px; background: #fff; border-bottom: 3px solid transparent; border-image: linear-gradient(90deg, var(--sun-deep), var(--sun) 30%, #3d8ff0 70%, var(--navy)) 1; }
.topbar-logo { height: 130px; width: auto; mix-blend-mode: multiply; }
.topbar-title { font-size: 20px !important; }
.topbar-title { font-weight: 700; color: var(--navy); font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.save-state { font-size: 12px; color: var(--muted); }
.menu { position: relative; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); width: 300px; z-index: 40; }
.menu-email { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; word-break: break-all; }
.sub-panel { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 6px; }

.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; margin: 0; color: var(--ink); font-size: 13px; }
.switch input { display: none; }
.slider { width: 38px; height: 22px; border-radius: 999px; background: #c5cfdd; position: relative; transition: .2s; flex: none; }
.slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::after { left: 19px; }

.workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px; align-items: start; }
.preview-col { min-width: 0; }
.controls-col { min-width: 0; display: flex; flex-direction: column; gap: 8px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; padding-right: 2px; }
.preview-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.preview-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.pv-sub { color: var(--muted); font-size: 12.5px; }
.draft-badge { background: #fff4e5; color: #9a4b00; border: 1px solid #ffd08a; font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 6px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 10px 0; }
.sw { display: inline-block; width: 12px; height: 12px; border: 1px solid #999; margin-right: 5px; vertical-align: -2px; }
.sw-manual { background: var(--xl-pink); }
.sw-flag { background: var(--flag); }
.preview-scroll { overflow-x: auto; }
.pv-h3 { margin: 16px 0 6px; font-size: 15px; }

/* Excel-like grid */
table.xl { border-collapse: collapse; width: 100%; min-width: 620px; font-size: 12px; margin-bottom: 10px; table-layout: fixed; }
table.xl th, table.xl td { border: 1px solid #222; padding: 2px 4px; height: 20px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
table.xl col.lab { width: 78px; }
table.xl .date-row th { background: var(--sun); color: #1a1200; font-weight: 700; text-align: left; }
table.xl .date-row th.pri { background: var(--blue); color: #fff; }
table.xl .dow-row th { font-weight: 700; text-align: left; background: #fff; }
table.xl th.lab { text-align: left; font-weight: 700; background: #fff; }
table.xl td.slot { cursor: pointer; font-weight: 500; }
table.xl td.slot:hover { outline: 2px solid var(--blue); outline-offset: -2px; }
table.xl td.out { background: #f2f2f2; cursor: default; }
table.xl td.manual { background: var(--xl-pink); }
table.xl td.flag { background: var(--flag); font-weight: 700; box-shadow: inset 0 0 0 2px #e0a800; }
table.xl td.empty-fixed { background: repeating-linear-gradient(45deg, #fff, #fff 4px, #ffe5e5 4px, #ffe5e5 8px); }
table.xl td.offcell { color: #333; }
table.xl td.notes { font-size: 11px; color: #8a1c1c; white-space: normal; }
table.xl .vac { color: #7a4fc2; font-style: italic; }

table.sum { border-collapse: collapse; font-size: 12px; min-width: 360px; }
table.sum th, table.sum td { border: 1px solid #bfc8d6; padding: 3px 8px; text-align: right; }
table.sum th:first-child, table.sum td:first-child { text-align: left; }
table.sum thead th { background: var(--blue-50); }

/* Controls */
.field label { margin-top: 0; }
.team { display: flex; flex-wrap: wrap; gap: 6px; }
.team .tag { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.team .tag b { color: var(--blue); margin-right: 4px; }
.acc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.acc-btn { width: 100%; text-align: left; background: none; border: 0; padding: 11px 14px; font-weight: 700; color: var(--navy); cursor: pointer; display: flex; justify-content: space-between; }
.acc-btn::after { content: "▾"; color: var(--muted); transition: transform .15s; }
.acc.open .acc-btn::after { transform: rotate(180deg); }
.acc.open .acc-btn { border-bottom: 1px solid var(--line); }
.acc-body { padding: 4px 14px 14px; }
.list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.list li { display: flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.list li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.list li select { width: auto; padding: 4px 6px; }
.list li input.ini { width: 52px; text-align: center; font-weight: 700; padding: 4px; }
.list li .swap { border: 1px solid var(--line); background: #fff; color: var(--blue); border-radius: 6px; cursor: pointer; font-size: 14px; line-height: 1; padding: 5px 7px; }
.list li .swap:hover { background: var(--blue-50); border-color: var(--blue); }
.list li input.lbl { width: 110px; padding: 4px 6px; }
.x { border: 0; background: none; color: var(--danger); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin: 6px 0; }
.seg button { border: 0; background: #fff; padding: 7px 16px; cursor: pointer; font-weight: 600; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--blue); color: #fff; }
.seg.small button { padding: 5px 10px; font-size: 12.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; background: #fff; cursor: pointer; user-select: none; }
.chip.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.chip .x { color: inherit; font-size: 13px; padding: 0 0 0 4px; }
.radio, .check { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--ink); font-size: 13px; margin: 4px 0; }
.rules { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.rule-grid { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; margin: 8px 0; }
.rule-grid > label { margin: 0; font-size: 13px; color: var(--ink); font-weight: 500; }
.rule-ctl { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.rule-ctl input[type="number"] { width: 72px; text-align: center; padding: 6px; }
.rule-ctl select { width: auto; padding: 6px 8px; }
.rule-ctl .check { margin: 0; font-size: 12.5px; }
@media (max-width: 520px) { .rule-grid { grid-template-columns: 1fr; } .rule-ctl { justify-content: flex-start; } }
.rules summary { cursor: pointer; font-weight: 600; }

.compliance { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.compliance h3 { font-size: 14px; display: flex; gap: 8px; align-items: center; }
.pill { background: var(--blue-50); color: var(--blue); font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.pill.bad { background: #fdecea; color: var(--danger); }
.comp-emp { margin-top: 8px; }
.comp-emp b { color: var(--navy); }
.comp-emp ul { margin: 2px 0 0; padding-left: 18px; font-size: 12.5px; }
.comp-ok { color: #1b7f3a; font-size: 13px; }

.cell-pop { position: fixed; z-index: 60; width: 220px; padding: 8px; max-height: 320px; overflow: auto; }
.cell-pop .cp-head { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.cell-pop button { display: flex; width: 100%; justify-content: space-between; gap: 6px; text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.cell-pop button:hover { background: var(--blue-50); }
.cell-pop button small { color: var(--muted); }
.cell-pop button.warn small { color: #b26a00; }

.busy { position: fixed; inset: 0; background: rgba(244,247,251,.75); z-index: 80; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; font-weight: 600; color: var(--navy); }
.spinner { width: 36px; height: 36px; border: 4px solid #c9d8f2; border-top-color: var(--blue); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Home (roster sets) ---------------- */
.app.on-home .ws-only { display: none !important; }
.topbar-logo { cursor: pointer; }
.home { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.home-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.home-head h1 { font-size: 24px; }
.home-head .hint { max-width: 620px; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.proj-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.proj-card:hover { border-color: var(--blue); box-shadow: 0 6px 18px rgba(21,101,216,.12); }
.proj-card h3 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-card .meta { color: var(--muted); font-size: 12.5px; }
.proj-card .badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--blue-50); color: var(--blue); }
.badge.shared { background: #e8f7ee; color: #1b7f3a; }
.proj-card .actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.proj-card .actions .btn { padding: 5px 10px; font-size: 12.5px; }
.empty-home { background: #fff; border: 1px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center; color: var(--muted); grid-column: 1 / -1; }

/* ---------------- Workspace bar ---------------- */
.wsbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px 0; flex-wrap: wrap; }
.wsbar-info { flex: 1; min-width: 160px; }
.wsbar-name { font-weight: 800; color: var(--navy); font-size: 16px; }
.wsbar-sub { font-size: 12px; color: var(--muted); }
.wsbar-tools { display: flex; gap: 8px; flex-wrap: wrap; }

/* generic dropdown */
.dd { position: relative; }
.dd-panel { position: absolute; top: calc(100% + 6px); left: 0; width: 320px; z-index: 45; }
.dd-panel.dd-right { left: auto; right: 0; }
.dd-title { font-weight: 700; color: var(--navy); font-size: 13px; margin-bottom: 4px; }
.hist-panel { width: 380px; max-height: 60vh; overflow: auto; }
.hist-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.hist-list li { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; cursor: pointer; }
.hist-list li:hover { background: var(--blue-50); }
.hist-list li.current { border-color: var(--blue); background: var(--blue-50); }
.hist-list .h-month { font-weight: 700; color: var(--navy); min-width: 118px; }
.hist-list .h-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-list .h-meta { font-size: 11px; color: var(--muted); }
.hist-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 8px 0 2px; list-style: none; border: 0 !important; padding: 0 !important; cursor: default !important; background: none !important; }

/* proposal preview */
.proposal-bar { background: #e8f1ff; border: 1px solid #b7d0fb; color: var(--navy); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-top: 10px; }
table.xl td.changed { box-shadow: inset 0 0 0 2px var(--blue); }
.sw-vac { background: #fff; border-color: #7a4fc2; }
.sw-pri { background: var(--blue); border-color: var(--blue); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(11,42,91,.18); z-index: 90; }
.modal { position: absolute; right: 24px; top: 90px; width: min(440px, calc(100vw - 32px)); background: #fff; border-radius: 12px; border: 1px solid var(--line); box-shadow: 0 20px 50px rgba(11,42,91,.25); padding: 18px; max-height: calc(100vh - 120px); overflow: auto; }
.modal h3 { font-size: 17px; margin-bottom: 8px; }
.modal-body { font-size: 13.5px; color: #33445f; }
.modal-body ul { padding-left: 18px; margin: 6px 0; }
.modal-body .warn { background: #fff4e5; border: 1px solid #ffd08a; color: #7a3d00; border-radius: 8px; padding: 8px 10px; margin-top: 10px; font-size: 13px; }
.modal-body .stat { display: flex; gap: 14px; flex-wrap: wrap; margin: 8px 0; }
.modal-body .stat div { background: var(--bg); border-radius: 8px; padding: 6px 10px; }
.modal-body .stat b { display: block; font-size: 18px; color: var(--navy); }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a61f1f; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 95; font-size: 13.5px; box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: calc(100vw - 32px); }

@media (max-width: 980px) {
  .modal { left: 16px; right: 16px; top: auto; bottom: 16px; width: auto; }
  .dd-panel, .hist-panel { width: min(340px, calc(100vw - 32px)); }
  .workspace { grid-template-columns: 1fr; }
  .controls-col { position: static; max-height: none; }
  .topbar { flex-wrap: wrap; }
  .topbar-logo { height: 90px; }
  .switch-label { display: none; }
}
