:root {
  --navy: #17365d;
  --blue: #245783;
  --teal: #147782;
  --ink: #233449;
  --muted: #718096;
  --line: #dce4ed;
  --surface: #ffffff;
  --bg: #f4f7fb;
  --pale: #eaf1f8;
  --green: #e4f2e8;
  --green-ink: #27633c;
  --orange: #fff0e4;
  --orange-ink: #a95118;
  --gray: #eef1f4;
  --gray-ink: #687482;
  --red: #fde9e8;
  --red-ink: #a33b36;
  --purple: #f0eafb;
  --purple-ink: #6542a2;
  --shadow: 0 10px 30px rgba(28, 55, 90, .07);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 14px;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.loading-screen { min-height: 100vh; display:grid; place-content:center; justify-items:center; color:var(--muted); }
.loader { width:30px;height:30px;border:3px solid #dbe5ef;border-top-color:var(--teal);border-radius:50%;animation:spin .8s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }
.shell { min-height:100vh; }
.topbar {
  background: linear-gradient(115deg, #17365d, #20577b);
  color:#fff; padding:17px max(22px, calc((100vw - 1440px)/2));
  display:flex; align-items:center; justify-content:space-between; gap:20px;
  box-shadow:0 4px 16px rgba(15,42,72,.16);
}
.brand { display:flex; align-items:center; gap:12px; min-width:0; }
.brand-mark { width:38px;height:38px;border-radius:12px;background:rgba(255,255,255,.15);display:grid;place-items:center;font-weight:800;font-size:18px; }
.brand-title { font-weight:750;font-size:17px;letter-spacing:.3px; }
.brand-sub { color:rgba(255,255,255,.7);font-size:11px;margin-top:3px; }
.user-tools { display:flex;align-items:center;gap:12px; }
.user-label { color:rgba(255,255,255,.9);font-size:13px; }
.btn { border:1px solid var(--line);border-radius:9px;padding:9px 13px;background:#fff;color:var(--ink);font-weight:600;transition:.15s; }
.btn:hover { transform:translateY(-1px);box-shadow:0 4px 12px rgba(30,60,90,.1); }
.btn.primary { background:var(--teal);border-color:var(--teal);color:#fff; }
.btn.dark { background:rgba(255,255,255,.12);border-color:rgba(255,255,255,.24);color:#fff; }
.btn.small { padding:7px 10px;font-size:12px; }
.main { max-width:1440px;margin:0 auto;padding:24px 22px 42px; }
.nav { display:flex;gap:7px;border-bottom:1px solid var(--line);margin-bottom:20px;overflow:auto; }
.nav button { border:0;background:transparent;color:var(--muted);padding:12px 16px 13px;font-weight:650;white-space:nowrap;border-bottom:3px solid transparent; }
.nav button.active { color:var(--navy);border-bottom-color:var(--teal); }
.page-head { display:flex;align-items:flex-end;justify-content:space-between;gap:16px;margin:6px 0 18px; }
.page-head h1 { margin:0;font-size:24px;color:var(--navy);letter-spacing:.2px; }
.page-head p { margin:7px 0 0;color:var(--muted);font-size:13px; }
.month-actions { display:flex;align-items:center;gap:8px; }
.head-actions { display:flex;align-items:center;gap:10px;flex-wrap:wrap; }
.login-brand .brand-title { color:var(--navy); }
.login-brand .brand-sub { color:var(--muted); }
.month-title { font-size:18px;font-weight:750;color:var(--navy);min-width:112px;text-align:center; }
.card { background:var(--surface);border:1px solid var(--line);border-radius:15px;box-shadow:var(--shadow); }
.legend { display:flex;flex-wrap:wrap;gap:8px;padding:13px 15px;border-bottom:1px solid var(--line); }
.legend-item { display:inline-flex;align-items:center;gap:6px;color:var(--muted);font-size:12px; }
.dot { width:9px;height:9px;border-radius:3px;display:inline-block; }
.dot.white { background:#71b985; }.dot.evening { background:#f0a36c; }.dot.rest { background:#aab4bf; }.dot.leave { background:#df7771; }.dot.comp { background:#a78ad7; }
.calendar-scroll { overflow-x:auto;padding:0 12px 14px; }
.calendar { min-width:1050px;display:grid;grid-template-columns:repeat(7,minmax(140px,1fr));gap:8px;padding-top:12px; }
.weekday-label { text-align:center;color:#718096;font-weight:700;font-size:12px;padding:8px 0; }
.day-cell { min-height:174px;border:1px solid var(--line);border-radius:11px;background:#fff;overflow:hidden; }
.day-cell.outside { background:#f7f9fb;border-style:dashed;opacity:.55; }
.day-cell.past { background:#fafbfd; }
.day-cell.today { border:2px solid #23838b;box-shadow:0 0 0 3px rgba(35,131,139,.08); }
.day-head { display:flex;justify-content:space-between;align-items:center;padding:9px 10px;background:#f1f5f9;border-bottom:1px solid var(--line); }
.day-cell.today .day-head { background:#e4f2f2; }
.day-num { font-weight:800;color:var(--navy);font-size:14px; }
.day-state { font-size:10px;color:#8995a2; }
.staff-shifts { padding:7px 8px;display:grid;gap:6px; }
.shift-row { display:grid;grid-template-columns:48px minmax(0,1fr);align-items:center;gap:5px; }
.staff-name { font-size:11px;color:#5d6b7b;overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }
.shift-select { width:100%;min-width:0;border:1px solid transparent;border-radius:7px;padding:6px 5px;font-size:11px;font-weight:700;outline:none;background:#f5f7fa;color:#667382; }
.shift-select:enabled { cursor:pointer;border-color:#e6ebf1; }
.shift-select:disabled { cursor:not-allowed;opacity:.82; }
.shift-select.white { background:var(--green);color:var(--green-ink); }
.shift-select.evening { background:var(--orange);color:var(--orange-ink); }
.shift-select.rest { background:var(--gray);color:var(--gray-ink); }
.shift-select.leave { background:var(--red);color:var(--red-ink); }
.shift-select.comp { background:var(--purple);color:var(--purple-ink); }
.lock-note { color:#9aa4af;font-size:10px; }
.section-title { font-size:16px;color:var(--navy);font-weight:750;margin:0 0 13px; }
.summary-wrap { margin-top:20px;padding:18px; }
.table-wrap { overflow-x:auto; }
table { width:100%;border-collapse:collapse;min-width:650px; }
th,td { padding:12px 13px;border-bottom:1px solid var(--line);text-align:center;white-space:nowrap; }
th { background:#f1f5f9;color:#53657a;font-size:12px;font-weight:750; }
td { color:#33465c;font-size:13px; }
td.name { text-align:left;font-weight:700;color:var(--navy); }
td.emphasis { color:var(--teal);font-weight:800;font-size:15px; }
.summary-note { color:var(--muted);font-size:12px;margin-top:12px; }
.panel { padding:20px; }
.form-grid { display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;align-items:end; }
.field { display:grid;gap:6px; }
.field label { color:#637286;font-size:12px;font-weight:650; }
.field input,.field select { width:100%;padding:10px 11px;border:1px solid #d8e1eb;border-radius:9px;background:#fff;outline:none; }
.field input:focus,.field select:focus { border-color:#4c9ba1;box-shadow:0 0 0 3px rgba(20,119,130,.1); }
.form-actions { display:flex;gap:8px;align-items:end; }
.status { display:inline-flex;padding:4px 8px;border-radius:20px;font-size:11px;font-weight:700; }
.status.active { background:#e4f3e9;color:#267343; }.status.inactive { background:#edf0f3;color:#788391; }
.action-row { display:flex;flex-wrap:wrap;gap:7px;justify-content:center; }
.audit-reason { white-space:normal;min-width:140px;text-align:left; }
.notice { border:1px solid #dce8ef;background:#f3f8fb;color:#526b7c;border-radius:10px;padding:11px 13px;font-size:12px;line-height:1.65;margin-bottom:15px; }
.login-wrap { min-height:100vh;display:grid;place-items:center;padding:24px;background:radial-gradient(circle at 20% 10%,#e1edf6,transparent 36%),linear-gradient(135deg,#f5f8fb,#eaf0f6); }
.login-card { width:min(420px,100%);padding:30px;border:1px solid #e1e8ef;border-radius:18px;background:#fff;box-shadow:0 18px 55px rgba(23,54,93,.12); }
.login-brand { display:flex;align-items:center;gap:12px;margin-bottom:24px; }
.login-brand .brand-mark { background:var(--navy);color:#fff; }
.login-card h1 { margin:0 0 7px;color:var(--navy);font-size:22px; }
.login-card p { margin:0 0 23px;color:var(--muted);font-size:13px; }
.login-form { display:grid;gap:14px; }
.login-error { color:#b54742;font-size:12px;min-height:17px; }
.toast { position:fixed;left:50%;bottom:24px;transform:translate(-50%,20px);opacity:0;pointer-events:none;background:#233449;color:#fff;padding:11px 16px;border-radius:9px;box-shadow:0 8px 28px rgba(0,0,0,.18);transition:.2s;z-index:20;max-width:calc(100vw - 30px); }
.toast.show { opacity:1;transform:translate(-50%,0); }
.empty { padding:34px;text-align:center;color:var(--muted); }
@media (max-width:760px) {
  .topbar { padding:13px 15px;align-items:flex-start; }
  .brand-title { font-size:15px; }.brand-sub { display:none; }
  .user-tools { gap:7px;flex-direction:column;align-items:flex-end; }
  .user-label { font-size:11px; }
  .main { padding:16px 12px 30px; }
  .page-head { align-items:flex-start;flex-direction:column; }
  .page-head h1 { font-size:21px; }
  .month-actions { width:100%;justify-content:space-between; }
  .head-actions { width:100%;align-items:stretch;flex-direction:column; }
  .head-actions .month-actions { width:100%; }
  .calendar { min-width:980px; }
  .form-grid { grid-template-columns:1fr; }
  .form-actions { align-items:stretch; }
  .panel { padding:15px; }
  .summary-wrap { padding:13px; }
}


/* Calendar and permission polish */
.main { max-width:1480px; padding-top:26px; }
.nav { gap:10px; margin-bottom:22px; }
.nav button { padding-left:17px; padding-right:17px; }
.page-head { margin:8px 0 20px; }
.page-head p { line-height:1.65; }
.card { border-color:#e1e8f0; box-shadow:0 8px 26px rgba(28,55,90,.055); }
.calendar { gap:9px; padding-top:14px; }
.day-cell { min-height:180px; border-radius:12px; transition:border-color .16s, box-shadow .16s; }
.day-cell.weekday { background:#f8fbff; border-color:#e1eaf4; }
.day-cell.weekend { background:#f5f6fb; border-color:#e1e4ef; }
.day-cell.holiday { background:#fff8f0; border-color:#f0dfca; }
.day-cell.makeup-workday { background:#f1faf6; border-color:#d8ece2; }
.day-cell.weekday .day-head { background:#eef4fa; }
.day-cell.weekend .day-head { background:#eceff6; }
.day-cell.holiday .day-head { background:#fff0df; }
.day-cell.makeup-workday .day-head { background:#e5f4ec; }
.day-cell.past { filter:saturate(.88); }
.day-cell.today { border:2px solid #23838b; box-shadow:0 0 0 3px rgba(35,131,139,.09),0 5px 16px rgba(35,131,139,.06); }
.day-cell.today .day-head { background:#e4f2f2; }
.day-head { min-height:39px; padding:7px 9px; }
.day-meta { display:flex; flex-direction:column; align-items:flex-end; gap:3px; min-width:0; }
.day-state { line-height:1.2; }
.day-holiday-tag { display:inline-block; max-width:86px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; border-radius:5px; padding:2px 5px; font-size:9px; line-height:1.25; font-weight:750; }
.day-holiday-tag.weekend { background:#e7eaf2; color:#65738a; }
.day-holiday-tag.holiday { background:#ffe9d2; color:#9b5a21; }
.day-holiday-tag.makeup-workday { background:#dff1e8; color:#287653; }
.staff-shifts { padding:8px 8px 9px; gap:7px; }
.shift-row { grid-template-columns:58px minmax(0,1fr); gap:6px; }
.staff-name { display:block; min-width:0; padding:4px 5px; border-radius:6px; font-size:11px; line-height:1.35; }
.staff-name.self { color:#087b82; background:#e1f3f2; font-weight:800; box-shadow:inset 2px 0 0 #28a0a1; }
.shift-select { padding:7px 7px; border-radius:8px; font-size:11px; }
.date-swatch { width:10px; height:10px; display:inline-block; border-radius:3px; border:1px solid transparent; }
.date-swatch.weekday { background:#eef4fa; border-color:#dbe6f1; }
.date-swatch.weekend { background:#eceff6; border-color:#dfe3ed; }
.date-swatch.holiday { background:#fff0df; border-color:#f0dfca; }
.date-swatch.makeup-workday { background:#e5f4ec; border-color:#d5eadd; }
.calendar-head-actions { justify-content:flex-end; flex-wrap:wrap; }
.calendar-head-actions .month-actions { gap:7px; }
.calendar-head-actions .btn.primary { box-shadow:0 3px 9px rgba(20,119,130,.12); }
.user-name { display:inline-block; padding:4px 8px; border-radius:7px; color:#d9f6f1; background:rgba(160,232,220,.13); font-weight:800; }
.user-role { color:rgba(255,255,255,.76); }
.summary-wrap { margin-top:22px; padding:20px; }
.summary-wrap .section-title { margin-bottom:15px; }
th { background:#eef3f8; }
tbody tr:hover td { background:#f8fbfd; }
.total-row td { background:#f5f8fb; font-weight:750; }
.self-summary-row td { background:#f1faf9; }
.self-summary-row td.name { color:#087b82; }
.btn { border-color:#dce5ee; box-shadow:0 1px 2px rgba(20,40,70,.025); }
.btn:focus-visible, .nav button:focus-visible, .shift-select:focus-visible { outline:3px solid rgba(35,131,139,.22); outline-offset:2px; }
.btn:disabled { opacity:.62; cursor:wait; transform:none; box-shadow:none; }
@media (max-width:760px) {
  .calendar-head-actions { width:100%; }
  .calendar-head-actions .month-actions { width:100%; }
  .calendar-head-actions #syncHolidays { width:100%; }
  .day-cell { min-height:172px; }
  .summary-wrap { padding:14px; }
}

.holiday-sync-status { margin-left:auto; color:#718096; font-size:11px; }

.calendar-head-actions #syncHolidays { min-width:184px; white-space:nowrap; }
.holiday-sync-status { font-variant-numeric:tabular-nums; line-height:1.5; }


/* Mobile calendar: show usable full-width day cards instead of a fixed 980px scroll strip. */
.day-head { gap: 5px; }
.day-meta { flex: 1; min-width: 0; }
.day-state { white-space: nowrap; font-weight: 650; font-size: 10px; color: #75869b; }
.shift-select { text-overflow: clip; }
@media (max-width: 760px) {
  .calendar-scroll { overflow-x: visible; padding: 0 10px 12px; }
  .calendar {
    min-width: 0;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 10px;
    align-items: stretch;
  }
  .calendar > .weekday-label, .day-cell.outside { display: none; }
  .day-cell {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border-radius: 12px;
  }
  .day-head { padding: 8px 7px; min-height: 51px; align-items: flex-start; }
  .day-num { font-size: 14px; flex-shrink: 0; margin-top: 3px; }
  .day-meta { align-items: flex-end; gap: 4px; }
  .day-state { font-size: 10px; letter-spacing: -.25px; }
  .day-holiday-tag { max-width: 82px; font-size: 9px; }
  .staff-shifts { padding: 7px 6px 9px; gap: 6px; }
  .shift-row { grid-template-columns: minmax(0,1fr) minmax(65px, 76px); gap: 3px; }
  .staff-name { font-size: 11px; padding: 4px 2px; }
  .shift-select {
    font-size: 16px;  /* iOS Safari: avoid unexpected focus zoom */
    line-height: 1.2;
    height: 44px;
    padding: 7px 3px;
    width: 100%;
    min-width: 0;
    border-radius: 8px;
  }
  .legend { column-gap: 10px; row-gap: 9px; padding: 13px 12px; }
  .legend-item { font-size: 11px; }
  .holiday-sync-status { margin-left: 0; flex-basis: 100%; font-size: 11px; }
  .day-cell.past .shift-select:disabled { opacity: .72; }
  .month-actions .month-title { min-width: 0; font-size: 17px; }
}
@media (max-width: 359px) {
  .calendar { grid-template-columns: 1fr; }
  .day-head { min-height: 44px; }
  .shift-row { grid-template-columns: 1fr 100px; }
  .staff-name { font-size: 12px; }
  .month-actions { gap: 4px; }
  .month-actions .btn { padding: 7px 6px; font-size: 11px; }
}

@media (max-width:760px) {
  .field input, .field select { font-size:16px; min-height:44px; }
  .toast { bottom:max(20px, env(safe-area-inset-bottom)); }
  .month-actions .btn { min-height:40px; }
}


/* iPhone portrait fix: all workdays stay visible, one full-width card per date.
   The header uses .weekday-label, never the .weekday day-type class. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (max-width: 599px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .calendar-scroll { padding: 0 10px 14px; overflow-x: visible; }
  .calendar {
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
    width: 100%;
    gap: 9px;
  }
  .calendar > .weekday-label, .calendar > .day-cell.outside { display: none; }
  .calendar > .day-cell.weekday { display: block; }
  .day-cell { border-radius: 12px; min-height: 0; }
  .day-head {
    min-height: 48px;
    padding: 9px 12px;
    align-items: center;
  }
  .day-num { font-size: 17px; line-height: 1.3; }
  .day-meta { align-items: flex-end; gap: 3px; }
  .day-state {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.35;
  }
  .day-holiday-tag {
    font-size: 11px;
    max-width: 170px;
    line-height: 1.35;
    padding: 2px 6px;
  }
  .staff-shifts { padding: 7px 11px 10px; gap: 4px; }
  .shift-row {
    grid-template-columns: minmax(0, 1fr) minmax(118px, 39%);
    gap: 10px;
    min-height: 42px;
  }
  .staff-name {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    padding: 5px 7px;
    min-width: 0;
  }
  .staff-name.self { font-weight: 750; }
  .shift-select {
    height: 42px;
    min-height: 42px;
    font-size: 16px;
    line-height: 1.3;
    font-weight: 650;
    padding: 6px 8px;
    border: 1px solid #e1e6ed;
    border-radius: 9px;
    background-color: #f8fafc;
  }
  .day-cell.past .shift-select:disabled { opacity: .8; }
  .legend { padding: 12px; gap: 10px 12px; }
  .legend-item { font-size: 12px; line-height: 1.45; }
  .date-swatch, .dot { flex-shrink: 0; }
  .holiday-sync-status { font-size: 12px; line-height: 1.55; }
  .page-head { gap: 12px; margin-bottom: 16px; }
  .page-head h1 { font-size: 21px; }
  .page-head p { font-size: 13px; }
  .month-title { font-size: 17px; }
  .month-actions { gap: 5px; }
  .month-actions .btn { font-size: 12px; padding: 7px 8px; }
  .summary-wrap .section-title { font-size: 15px; }
}
@media (min-width: 600px) and (max-width: 760px) {
  .calendar > .weekday-label, .calendar > .day-cell.outside { display: none; }
  .calendar > .day-cell.weekday { display: block; }
  .staff-name { font-size: 13px; }
  .day-state { font-size: 11px; }
}


/* Quick month/year navigation and bulk scheduling */
.month-actions { flex-wrap:wrap; }
.month-picker-label { display:inline-flex; }
.month-picker {
  min-height:34px; padding:6px 9px; border:1px solid #dce5ee; border-radius:8px;
  background:#fff; color:var(--navy); font-size:13px; font-weight:750; cursor:pointer;
}
.month-picker:focus-visible { outline:3px solid rgba(35,131,139,.22); outline-offset:2px; }
.year-picker { min-width:94px; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.bulk-panel { margin:0 0 18px; padding:20px; }
.bulk-panel-head { display:flex; justify-content:space-between; align-items:flex-start; gap:14px; }
.bulk-panel-head .section-title { margin-bottom:5px; }
.bulk-panel-head p,.bulk-hint { margin:0; color:var(--muted); font-size:12px; line-height:1.65; }
.bulk-block { padding:15px 0; border-top:1px solid var(--line); }
.bulk-label { margin-bottom:10px; color:var(--navy); font-size:13px; font-weight:800; }
.bulk-staff-list { display:flex; flex-wrap:wrap; gap:9px; }
.bulk-staff { display:inline-flex; align-items:center; gap:7px; padding:8px 11px; border:1px solid #dce5ee; border-radius:9px; background:#f8fafc; color:#34465a; font-size:13px; cursor:pointer; }
.bulk-staff input,.bulk-radio-row input { accent-color:var(--teal); }
.bulk-date-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.bulk-week-grid { display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:9px; }
.bulk-week-grid .field span { color:#637286; font-size:12px; font-weight:700; }
.bulk-week-grid select,.bulk-date-grid input,.bulk-reason { width:100%; min-width:0; padding:9px 10px; border:1px solid #d8e1eb; border-radius:8px; background:#fff; color:#33465c; }
.bulk-radio-row { display:flex; flex-wrap:wrap; gap:18px; color:#42546a; font-size:13px; }
.bulk-radio-row label { display:inline-flex; align-items:center; gap:7px; }
.bulk-reason { max-width:520px; }
.bulk-preview { margin-top:8px; padding:13px 14px; border:1px solid #dce8ef; border-radius:10px; background:#f5f9fb; color:#526b7c; font-size:13px; line-height:1.7; }
.bulk-preview-stats { display:flex; flex-wrap:wrap; gap:8px 18px; margin-top:7px; }
.bulk-preview-stats span { white-space:nowrap; }
.bulk-preview-stats b { color:var(--navy); }
.bulk-actions { display:flex; flex-wrap:wrap; gap:9px; margin-top:14px; }
@media (max-width:900px) { .bulk-week-grid { grid-template-columns:repeat(4,minmax(0,1fr)); } }
@media (max-width:600px) {
  .bulk-panel { padding:14px; }
  .bulk-date-grid { grid-template-columns:1fr; }
  .bulk-week-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .month-actions { justify-content:flex-start; }
  .month-picker { min-height:40px; font-size:14px; }
  .bulk-actions > button { flex:1; }
}

/* Brand icon shared with the browser favicon */
.brand-mark { overflow:hidden; padding:0; background:transparent; flex:0 0 38px; }
.brand-icon { display:block; width:38px; height:38px; border-radius:12px; object-fit:contain; }
.login-brand .brand-mark { background:transparent; }
.login-brand .brand-icon { width:38px; height:38px; }

/* Self-service password management */
.password-panel{max-width:540px;}
.password-account{font-size:13px;color:var(--muted);margin:0 0 18px;overflow-wrap:anywhere;}
.password-form{display:grid;gap:15px;}
.password-hint{font-size:12px;line-height:1.65;color:var(--muted);margin:0;}
.password-actions{display:flex;gap:10px;flex-wrap:wrap;}
@media(max-width:600px){.password-actions>button{flex:1;min-height:44px;}.password-form input{font-size:16px;min-height:44px;}}
