:root {
  --navy: #1d2b45;
  --navy-2: #24365a;
  --accent: #2f80c3;
  --green: #27ae60;
  --bg: #f4f6f9;
  --line: #e1e6ee;
  --line-2: #ccd4e0;
  --text: #2b3648;
  --muted: #7b8698;
  --open-bg: #f0f4fa;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 13px/1.4 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text); background: var(--bg);
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}

/* ---------- top bar ---------- */
.topbar {
  background: var(--navy); color: #fff; display: flex; align-items: center;
  gap: 24px; padding: 0 16px; height: 48px; flex: 0 0 auto;
}
.brand { font-size: 16px; font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.brand-logo {
  background: var(--accent); width: 26px; height: 26px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800;
}
.brand-sub { font-weight: 400; opacity: .75; }
.topnav { display: flex; gap: 4px; height: 100%; }
.topnav-btn {
  background: none; border: none; color: #c6cfdd; font-size: 13px; padding: 0 14px;
  cursor: pointer; border-bottom: 3px solid transparent; height: 100%;
}
.topnav-btn.active { color: #fff; border-bottom-color: var(--accent); font-weight: 600; }
.topbar-right { margin-left: auto; }
.save-status { font-size: 11px; color: #9fb0c8; }
.save-status.dirty { color: #ffd479; }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: #fff; border-bottom: 1px solid var(--line-2); flex: 0 0 auto; flex-wrap: wrap;
}
.tb-group { display: flex; align-items: center; gap: 6px; }
.tb-group.grow { flex: 1; min-width: 120px; }
.range-label { font-size: 15px; font-weight: 600; margin-left: 8px; white-space: nowrap; }
.btn {
  background: #fff; border: 1px solid var(--line-2); color: var(--text);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.btn:hover { background: #f0f3f8; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #219653; }
.btn.danger { background: #fff; border-color: #e74c3c; color: #e74c3c; }
.btn.danger:hover { background: #fdecea; }
.btn.seg { border-radius: 0; margin-left: -1px; }
.view-switch .seg:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.view-switch .seg:last-child { border-radius: 0 6px 6px 0; }
.btn.seg.active { background: var(--navy); color: #fff; border-color: var(--navy); z-index: 1; }
.sched-tabs .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
#btnRolling.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* 2-week compact grid */
table.sched.compact th.emp-col, table.sched.compact td.emp-cell { width: 150px; min-width: 150px; max-width: 150px; }
table.sched.compact .shift-block { font-size: 9.5px; padding: 3px 4px; }
table.sched.compact .shift-block .sched-tag { display: none; }
table.sched.compact .day-num { font-size: 13px; }
table.sched.compact .day-totals { font-size: 9px; }
table.sched.compact thead th { padding: 4px 4px; }
#searchBox {
  width: 100%; max-width: 220px; padding: 6px 10px; border: 1px solid var(--line-2);
  border-radius: 6px; font-size: 13px;
}

/* ---------- template tray ---------- */
.template-tray {
  display: flex; gap: 8px; padding: 6px 12px; background: #fff;
  border-bottom: 1px solid var(--line-2); flex: 0 0 auto; align-items: center; overflow-x: auto;
}
.tray-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.tmpl-pill {
  border-radius: 14px; padding: 4px 12px; font-size: 12px; color: #fff; cursor: grab;
  user-select: none; white-space: nowrap; border: 2px solid transparent;
}
.tmpl-pill.armed { outline: 2px solid var(--navy); outline-offset: 2px; }

/* ---------- main ---------- */
main { flex: 1; overflow: auto; position: relative; }

/* ---------- week grid ---------- */
table.sched { border-collapse: separate; border-spacing: 0; width: 100%; background: #fff; table-layout: fixed; }
table.sched th, table.sched td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
table.sched thead th {
  position: sticky; top: 0; z-index: 5; background: #fff; padding: 6px 8px;
  font-size: 12px; text-align: left; border-bottom: 2px solid var(--line-2);
}
th.day-col.today { background: #eaf3fc; }
.day-name { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 10px; }
.day-num { font-size: 16px; font-weight: 700; }
.day-totals { font-size: 10px; color: var(--muted); }
th.emp-col, td.emp-cell {
  width: 200px; min-width: 200px; max-width: 200px;
  position: sticky; left: 0; z-index: 4; background: #fff;
  border-right: 2px solid var(--line-2);
}
thead th.emp-col { z-index: 6; }
td.emp-cell { padding: 6px 10px; }
.emp-name { font-weight: 600; font-size: 12.5px; }
.emp-meta { font-size: 10.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.chip { background: #eef1f6; border-radius: 8px; padding: 0 6px; font-size: 9.5px; text-transform: uppercase; letter-spacing: .3px; }
.chip.hny5 { background: #e3f0e6; color: #1e7c3d; }
.chip.hny8 { background: #e6ecf7; color: #2f5aa8; }
.emp-hours { margin-left: auto; font-weight: 600; color: var(--text); }
tr.group-row td {
  background: #eef1f6; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; padding: 3px 10px; color: #59657c;
  position: sticky; left: 0;
}
tr.open-row td.emp-cell { background: var(--open-bg); }
tr.open-row .emp-name { color: var(--accent); }
td.shift-cell { vertical-align: top; padding: 3px; height: 52px; position: relative; }
td.shift-cell.today { background: #f6fafe; }
td.shift-cell.dragover { background: #dcecfb; box-shadow: inset 0 0 0 2px var(--accent); }
td.shift-cell .add-hint {
  display: none; position: absolute; inset: 3px; border: 1px dashed var(--line-2);
  border-radius: 6px; color: var(--muted); text-align: center; cursor: pointer;
  align-items: center; justify-content: center; font-size: 16px; background: #fafbfd;
}
td.shift-cell:hover .add-hint { display: flex; }
td.shift-cell.has-shifts:hover .add-hint { display: none; }

.shift-block {
  border-radius: 6px; color: #fff; padding: 4px 7px; margin-bottom: 3px; cursor: grab;
  font-size: 11px; line-height: 1.25; position: relative; overflow: hidden;
  box-shadow: 0 1px 2px rgba(20,30,50,.18);
}
.shift-block:active { cursor: grabbing; }
.shift-block .t { font-weight: 700; white-space: nowrap; padding-right: 24px; }
.shift-block .l { opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shift-block.dragging { opacity: .4; }
.shift-block .sched-tag {
  position: absolute; top: 3px; right: 5px; font-size: 8.5px; font-weight: 700; opacity: .8;
}

/* ---------- day view ---------- */
.dayview { background: #fff; }
.dayview table.sched td.time-cell { padding: 0; position: relative; height: 40px; }
.time-axis { display: flex; }
.time-axis .hr { flex: 1; font-size: 9.5px; color: var(--muted); border-left: 1px solid var(--line); padding: 2px 3px; }
.day-lane { position: relative; height: 38px; }
.day-lane .grid-line { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); }
.day-bar {
  position: absolute; top: 5px; height: 28px; border-radius: 5px; color: #fff;
  font-size: 10.5px; padding: 2px 6px; overflow: hidden; white-space: nowrap; cursor: pointer;
  box-shadow: 0 1px 2px rgba(20,30,50,.2);
}

/* ---------- month view ---------- */
.monthview { padding: 10px; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month-dow { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; text-align: center; padding: 4px; }
.month-cell {
  background: #fff; border: 1px solid var(--line); border-radius: 8px; min-height: 96px;
  padding: 6px 8px; cursor: pointer; transition: box-shadow .1s;
}
.month-cell:hover { box-shadow: 0 2px 8px rgba(20,30,50,.12); }
.month-cell.other { opacity: .45; }
.month-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.month-cell .d { font-weight: 700; font-size: 13px; }
.month-cell .stat { font-size: 11px; margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.month-cell .none { color: var(--muted); font-size: 11px; margin-top: 6px; }

/* ---------- staff view ---------- */
.staffview { padding: 14px; max-width: 900px; }
.staffview table { border-collapse: collapse; width: 100%; background: #fff; border: 1px solid var(--line); }
.staffview th, .staffview td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; font-size: 12.5px; }
.staffview th { background: #eef1f6; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.staffview tr.inactive { opacity: .45; }
.staffview .btn { padding: 3px 9px; font-size: 11.5px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,25,45,.45); display: flex;
  align-items: center; justify-content: center; z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal { background: #fff; border-radius: 10px; width: 440px; max-width: 94vw; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(10,20,40,.35); }
.modal-head { display: flex; align-items: center; padding: 14px 16px 8px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .x { margin-left: auto; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 8px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-body label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.modal-body input, .modal-body select {
  padding: 7px 9px; border: 1px solid var(--line-2); border-radius: 6px; font-size: 13px; color: var(--text);
}
.modal-body input[type="color"] { padding: 2px; height: 34px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.grow { flex: 1; }
.tmpl-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.tmpl-chips .tmpl-pill { cursor: pointer; }
.repeat-days { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.repeat-days .dow {
  display: inline-flex; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line-2);
  align-items: center; justify-content: center; cursor: pointer; font-size: 10.5px; margin-right: 3px;
  user-select: none;
}
.repeat-days .dow.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

/* templates modal list */
.tmpl-row { display: grid; grid-template-columns: 1fr 90px 90px 110px 46px 30px; gap: 6px; align-items: center; margin-bottom: 6px; }
.tmpl-row input { padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 6px; font-size: 12.5px; width: 100%; }
.tmpl-row input[type="color"] { height: 32px; padding: 2px; }
.tmpl-row .del { background: none; border: none; color: #e74c3c; font-size: 16px; cursor: pointer; }

.empty-note { padding: 40px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- login ---------- */
.login-screen {
  position: fixed; inset: 0; background: var(--navy); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.login-screen[hidden] { display: none; }
.login-card {
  background: #fff; border-radius: 14px; padding: 32px 30px; width: 340px; max-width: 92vw;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.brand.big { color: var(--navy); font-size: 20px; justify-content: center; }
.brand.big .brand-sub { opacity: .6; }
.login-hint { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
#loginUser, #loginPass { padding: 11px 12px; border: 1px solid var(--line-2); border-radius: 8px; font-size: 15px; }
#loginPass[hidden] { display: none; }
.btn.wide { width: 100%; padding: 11px; font-size: 15px; }
.login-error { color: #e74c3c; font-size: 12.5px; text-align: center; min-height: 16px; }
.user-badge { font-size: 12px; color: #c6cfdd; margin-right: 10px; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.ghost { background: transparent; color: #c6cfdd; border-color: #46536e; }
.btn.ghost:hover { background: var(--navy-2); }

/* ---------- unavailability on the grid ---------- */
td.shift-cell.unavail {
  background: repeating-linear-gradient(135deg, #fdf0f0, #fdf0f0 6px, #f9e2e2 6px, #f9e2e2 12px);
}
td.shift-cell.unavail::after {
  content: "✕ " attr(data-unavail); position: absolute; bottom: 2px; right: 4px;
  font-size: 8.5px; color: #b3524a; font-weight: 700; pointer-events: none;
  max-width: 95%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.day-unavail { color: #c0392b; font-weight: 700; }

/* ---------- employee portal ---------- */
.portal { max-width: 560px; margin: 0 auto; padding: 16px 14px 90px; }
.portal h2 { margin: 6px 0 2px; font-size: 19px; }
.portal .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.portal-week-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 0 6px; }
.pday {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  margin-bottom: 8px; display: flex; flex-direction: column; gap: 8px;
}
.pday.today { border-color: var(--accent); }
.pday-top { display: flex; align-items: center; gap: 10px; }
.pday-date { font-weight: 700; font-size: 14px; width: 84px; flex: 0 0 auto; }
.pday-shift { font-size: 12px; border-radius: 6px; color: #fff; padding: 3px 8px; }
.pday-noshift { font-size: 12px; color: var(--muted); }
.pday-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.avail-btn {
  border: 1.5px solid var(--line-2); background: #fff; border-radius: 18px; padding: 7px 16px;
  font-size: 13px; cursor: pointer; font-weight: 600; color: var(--muted);
}
.avail-btn.on-avail { background: #e6f6ec; border-color: var(--green); color: #1e7c3d; }
.avail-btn.on-unavail { background: #fdecea; border-color: #e74c3c; color: #c0392b; }
.pday-note { flex: 1; min-width: 130px; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 8px; font-size: 12.5px; }
.portal-savebar {
  position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line-2);
  padding: 10px 14px; display: flex; justify-content: center; gap: 10px; align-items: center;
  box-shadow: 0 -4px 16px rgba(20,30,50,.08);
}
.portal-savebar .btn { min-width: 200px; padding: 11px; font-size: 15px; }
.portal-saved { color: var(--green); font-weight: 600; font-size: 13px; }

/* ---------- staff extras ---------- */
.badge { border-radius: 9px; padding: 1px 8px; font-size: 10.5px; font-weight: 700; }
.badge.active { background: #e6f6ec; color: #1e7c3d; }
.badge.hiddenb { background: #fdf3e3; color: #ad6b0c; }
.badge.inactive { background: #f0f1f4; color: #7b8698; }
.sched-checks label { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 4px; margin-right: 14px; font-weight: 400 !important; }
.form-note { font-size: 11.5px; color: var(--muted); margin: 0; }
.modal.wide { width: 640px; }
.avail-day-block { margin-bottom: 12px; }
.avail-day-block h4 { margin: 0 0 4px; font-size: 13px; }
.avail-day-block .who { font-size: 12.5px; padding: 2px 0; }
.avail-day-block .who .note { color: var(--muted); }
.no-response { background: #f7f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--muted); max-height: 140px; overflow-y: auto; }
