:root {
  --grad-l: #1C453F;
  --grad-r: #208D59;
  --grad: linear-gradient(90deg, #1C453F 0%, #1F6B52 48%, #208D59 100%);
  --g-deep: #0E2F2B;
  --g-mid: #155C48;
  --g-bright: #208D59;
  --bg: #F2F5F3;
  --surface: #fff;
  --border: #E2E8E4;
  --border-light: #EEF2EF;
  --text: #1A2B26;
  --text2: #5A6B64;
  --text3: #8A9A93;
  --ok: #1E8A59;
  --ok-bg: #E8F6EE;
  --wait: #B45309;
  --wait-bg: #FEF3C7;
  --doing: #1D4ED8;
  --doing-bg: #EFF6FF;
  --danger: #C0392B;
  --font: "PingFang TC", "PingFang HK", "Helvetica Neue", "Microsoft JhengHei", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 0;
}
.page-title { text-align: center; margin-bottom: 22px; }
.page-title h1 { font-size: 22px; font-weight: 800; color: var(--g-deep); }
.page-title p { margin-top: 6px; font-size: 13px; color: var(--text2); }
.page-title a { color: var(--g-mid); font-weight: 700; text-decoration: none; }
.page-title a:hover { text-decoration: underline; }

.admin-frame {
  width: 100%;
  min-height: 100vh;
  height: 100%;
  margin: 0;
  background: var(--surface);
  border-radius: 0;
  overflow: hidden;
  display: flex;
  box-shadow: none;
  border: none;
}

.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--grad);
  color: #fff;
  display: flex; flex-direction: column;
}
.sb-logo {
  padding: 22px 18px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  font-size: 14px; font-weight: 800;
}
.sb-logo .mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.28);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
}
.sb-menu { padding: 14px 10px; flex: 1; }
.sb-item {
  padding: 11px 14px; margin-bottom: 4px; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,.62); cursor: pointer;
  transition: .15s;
}
.sb-item:hover { color: #fff; background: rgba(255,255,255,.08); }
.sb-item.on { color: #fff; background: rgba(255,255,255,.16); }
.sb-item .ico {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
}
.sb-item .ico svg {
  width: 18px; height: 18px; stroke: currentColor; fill: none;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.sb-foot {
  padding: 14px 16px; font-size: 11px; color: rgba(255,255,255,.45);
  border-top: 1px solid rgba(255,255,255,.1);
}

.admin-body { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.admin-top {
  height: 56px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
}
.admin-top .bc { font-size: 13px; color: var(--text2); }
.admin-top .bc b { color: var(--text); font-weight: 700; }
.admin-top .user { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; }
.user-av {
  width: 32px; height: 32px; border-radius: 50%;
  background: #E8F6EE; color: var(--g-mid);
  border: 1px solid #CDE8D8;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
}
.admin-content { flex: 1; min-height: 0; padding: 18px 22px; overflow-y: auto; }
.a-page { display: none; }
.a-page.on { display: block; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px;
}
.kpi .kl { font-size: 12px; color: var(--text2); font-weight: 600; margin-bottom: 6px; }
.kpi .kv { font-size: 26px; font-weight: 800; letter-spacing: -.02em; color: var(--g-deep); }
.kpi .ks { font-size: 11px; margin-top: 6px; color: var(--ok); font-weight: 600; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 14px; overflow: hidden;
}
.panel-hd {
  padding: 13px 16px; border-bottom: 1px solid var(--border-light);
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  font-size: 14px; font-weight: 700; background: #F7FAF8;
}
.panel-hd-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto;
}
.list-search {
  width: min(260px, 100%);
  height: 32px; padding: 0 12px 0 32px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238A9A93' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3-3'/%3E%3C/svg%3E") no-repeat 10px 50%;
  font-size: 12px; font-weight: 500; font-family: inherit; color: var(--text);
  outline: none;
}
.list-search:focus { border-color: var(--g-mid); box-shadow: 0 0 0 3px rgba(32,141,89,.12); }
.list-search::placeholder { color: var(--text3); font-weight: 500; }
.tbl tr.list-empty-row td { text-align: center; color: var(--text3); padding: 28px 12px; font-weight: 500; }
.tbl tr.list-empty-row:hover td { background: transparent; }
.panel-bd { padding: 16px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  background: #F7FAF8; padding: 10px 12px; text-align: left;
  font-size: 11px; font-weight: 700; color: var(--text2);
  border-bottom: 1px solid var(--border); letter-spacing: .02em;
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #F9FCFB; }

.btn-a {
  padding: 6px 12px; border-radius: 7px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 12px; font-weight: 600;
  margin-right: 4px; font-family: inherit; color: var(--text);
}
.btn-a:hover { background: #F3F7F5; }
.btn-a.primary {
  background: var(--grad); color: #fff; border: none;
}
.btn-a.ok { background: var(--g-bright); color: #fff; border-color: var(--g-bright); }
.btn-a.danger { color: var(--danger); border-color: #F5C6C2; background: #fff; }

.tag {
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  display: inline-block;
}
.tag.wait { background: var(--wait-bg); color: var(--wait); }
.tag.dispatched { background: #DBEAFE; color: #1D4ED8; }
.tag.doing { background: var(--doing-bg); color: var(--doing); }
.tag.done { background: var(--ok-bg); color: var(--ok); }
.tag.billed { background: #E0E7FF; color: #3730A3; }
.tag.cancelled { background: #FEE2E2; color: #B91C1C; }
.tag.mute { background: #F0F0F0; color: #666; }
.tag.night, .tag.morning { background: #E8F6EE; color: var(--g-mid); }

.dispatch-hint {
  font-size: 11px; color: var(--text2); margin: -4px 0 10px; line-height: 1.45;
}
.dispatch-select { position: relative; }
.dispatch-trigger {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 13px; font-family: inherit; text-align: left;
}
.dispatch-trigger:hover { border-color: var(--g-mid); }
.dispatch-trigger .trig-main { flex: 1; min-width: 0; }
.dispatch-trigger .trig-main .nm { font-weight: 700; color: var(--text); line-height: 1.3; }
.dispatch-trigger .trig-main .meta { font-size: 11px; color: var(--text2); margin-top: 2px; }
.dispatch-trigger .chev {
  color: var(--text3); font-size: 12px; flex-shrink: 0;
}
.dispatch-status-bar {
  font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 6px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.dispatch-status-bar .leg { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.dispatch-dd {
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  max-height: 220px; overflow-y: auto; margin-top: 6px;
  box-shadow: 0 8px 20px rgba(0,0,0,.08);
}
.dispatch-dd .dd-hd {
  padding: 8px 10px; font-size: 11px; font-weight: 700; color: var(--text2);
  background: #F7FAF8; border-bottom: 1px solid var(--border-light);
  position: sticky; top: 0;
}
.dispatch-dd .dd-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 10px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border-light);
}
.dispatch-dd .dd-item:last-child { border-bottom: none; }
.dispatch-dd .dd-item:hover { background: #F4F9F6; }
.dispatch-dd .dd-item.on { background: #EFF6FF; }
.dispatch-dd .dd-item .nm { font-weight: 700; color: var(--text); }
.dispatch-dd .dd-item .meta { font-size: 11px; color: var(--text2); margin-top: 2px; }
.dispatch-dd .dd-sep {
  padding: 6px 10px; font-size: 10px; font-weight: 800; color: var(--text3);
  background: #F3F5F4; letter-spacing: .04em;
}
.st-dot {
  width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0;
}
.st-dot.idle { background: #22C55E; }
.st-dot.busy { background: #F59E0B; }
.st-dot.leave { background: #A855F7; }
.st-dot.inline { margin-top: 0; display: inline-block; vertical-align: middle; }
.dispatch-dd .dd-item.disabled { opacity: .55; cursor: not-allowed; background: #FAFAFA; }
.dispatch-dd .dd-item.disabled:hover { background: #FAFAFA; }
.worker-tags {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0;
  min-height: 28px;
}
.worker-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: #E8F6EE; color: var(--g-mid); border: 1px solid #CDE8D8;
}
.worker-tag button {
  border: none; background: transparent; cursor: pointer;
  color: var(--text2); font-size: 14px; line-height: 1; padding: 0 2px;
}

.badge {
  padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700;
  margin-left: 4px; display: inline-block;
}
.badge.foreman { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.badge.driver { background: #E8F6EE; color: var(--g-mid); border: 1px solid #CDE8D8; }
.badge.worker { background: #F4F4F5; color: #666; border: 1px solid #E4E4E7; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-item label { display: block; font-size: 12px; font-weight: 700; color: var(--text2); margin-bottom: 6px; }
.form-item input, .form-item select, .form-item textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; font-family: inherit; outline: none;
  background: #fff;
}
.form-item input:focus, .form-item select:focus, .form-item textarea:focus {
  border-color: var(--g-mid); box-shadow: 0 0 0 3px rgba(32,141,89,.12);
}
.form-item.full { grid-column: 1 / -1; }

.sub-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.sub-tab {
  padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--text2);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.sub-tab.on { color: var(--g-mid); border-bottom-color: var(--g-mid); }

.dispatch-steps { display: flex; gap: 10px; margin-bottom: 14px; }
.d-step {
  flex: 1; background: #fff; border: 1.5px solid var(--border);
  border-radius: 10px; padding: 12px; text-align: center; font-size: 12px; font-weight: 700; color: var(--text2);
}
.d-step.on { border-color: var(--g-mid); background: #F0F8F4; color: var(--g-mid); }
.d-step .dn {
  width: 26px; height: 26px; border-radius: 50%; margin: 0 auto 6px;
  background: #E8E8E8; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #888;
}
.d-step.on .dn { background: var(--g-mid); color: #fff; }

.schedule-toolbar {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.sch-month { font-size: 16px; font-weight: 800; }
.sch-view-toggle {
  display: flex; gap: 4px; background: #F0F3F1; padding: 3px; border-radius: 8px; border: 1px solid var(--border);
}
.sch-view-toggle button {
  border: none; background: transparent; padding: 6px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 700; cursor: pointer; color: var(--text2); font-family: inherit;
}
.sch-view-toggle button.on { background: #fff; color: var(--g-mid); box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.sch-select-bar {
  display: flex; gap: 14px; align-items: center; font-size: 12px; font-weight: 600;
  color: var(--text2); margin-bottom: 10px; padding: 8px 10px;
  background: #F7FAF8; border-radius: 8px;
}
.sch-select-bar .cnt { color: var(--g-mid); font-weight: 800; }

.schedule-panel { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.schedule-date-head {
  padding: 10px 14px; background: #F0F8F4; font-size: 13px; font-weight: 800;
  border-bottom: 1px solid var(--border); color: var(--g-deep);
}
.sch-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.sch-row:last-child { border-bottom: none; }
.sch-row.selectable { cursor: pointer; }
.sch-row.selectable:hover { background: #F7FBF9; }
.sch-row.selected { background: #F0F8F4; border-left: 3px solid var(--g-mid); padding-left: 11px; }
.sch-row.disabled { opacity: .72; }
.sch-time {
  width: 52px; flex-shrink: 0; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--g-deep);
}
.sch-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.sch-body { flex: 1; min-width: 0; line-height: 1.45; }
.sch-body .meta { font-size: 12px; color: var(--text2); margin-top: 2px; }
.sch-legend {
  display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 0 0;
  font-size: 11px; color: var(--text2);
}
.sch-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }

.info-row {
  display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.info-row .k { width: 72px; color: var(--text2); font-weight: 600; flex-shrink: 0; }
.info-row .v { flex: 1; font-weight: 600; }
.timeline { padding-left: 14px; border-left: 2px solid var(--border); margin: 8px 0; }
.tl-item { position: relative; padding: 0 0 12px 12px; font-size: 13px; }
.tl-item::before {
  content: ''; position: absolute; left: -18px; top: 5px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--g-mid);
}
.tl-time { font-size: 11px; font-weight: 700; color: var(--text3); margin-bottom: 2px; }

.photo-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-thumbs .ph {
  width: 76px; height: 76px; border-radius: 8px; background: #E8ECE9;
  border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text2); text-align: center; line-height: 1.3; position: relative;
}
.job-place-photos {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px;
}
.job-place-slot {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff;
}
.job-place-slot .slot-hd {
  padding: 6px 8px; font-size: 11px; font-weight: 800; color: var(--g-deep);
  background: #F3F7F5; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
}
.job-place-slot .slot-hd input {
  flex: 1; min-width: 0; border: none; background: transparent; font-size: 11px; font-weight: 800;
  color: var(--g-deep); padding: 0; outline: none; width: auto;
}
.job-place-slot .slot-body {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: #F3F7F5; cursor: pointer;
  font-size: 12px; font-weight: 700; color: var(--text2);
  background-size: cover; background-position: center;
}
.job-place-slot .slot-body.filled { color: transparent; }
.job-time-range {
  display: flex; align-items: center; gap: 8px;
}
.job-time-range input[type="time"] { flex: 1; }
.job-time-range .sep { font-size: 12px; font-weight: 700; color: var(--text2); flex-shrink: 0; }
.job-shield-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; background: #F8FAF9;
}
.job-shield-toggle {
  display: flex; align-items: flex-start; gap: 10px;
  cursor: pointer; margin: 0; font-weight: 400;
}
.job-shield-toggle input[type="checkbox"] {
  width: 16px; height: 16px; margin: 2px 0 0; flex-shrink: 0;
  accent-color: var(--g-mid);
}
.job-shield-title {
  display: block; font-size: 13px; font-weight: 700; color: var(--text);
  line-height: 1.35;
}
.job-shield-desc {
  display: block; margin-top: 3px; font-size: 11px;
  color: #888; line-height: 1.45; font-weight: 500;
}
.job-shield-fields {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-light);
}
.job-shield-fields label {
  display: block; font-size: 12px; font-weight: 700;
  color: var(--text2); margin-bottom: 6px;
}
.job-shield-fields input[type="datetime-local"] {
  width: 100%; max-width: 280px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; background: #fff;
}
.job-dispatch-hint {
  margin-top: 14px; padding: 10px 12px; border-radius: 8px;
  background: #EAF5EF; color: #4A6B5C; font-size: 12px;
  font-weight: 600; line-height: 1.45;
}
.job-detail-tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border-light); margin: -4px 0 14px;
}
.job-detail-tabs .tab {
  padding: 8px 12px; font-size: 12px; font-weight: 700; color: var(--text2);
  border-bottom: 2px solid transparent; cursor: default;
}
.job-detail-tabs .tab.on { color: var(--g-mid); border-bottom-color: var(--g-mid); }
.job-detail-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px;
}
.job-detail-hd .ttl { font-size: 14px; font-weight: 800; color: var(--g-deep); }
.job-detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.job-info-card, .job-tl-card {
  border: 1px solid var(--border-light); border-radius: 10px; padding: 12px 14px; background: #FBFCFB;
}
.job-info-card .sec, .job-tl-card .sec {
  font-size: 12px; font-weight: 800; color: var(--g-deep); margin-bottom: 8px;
}
.crew-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.invoice-bar {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
}
.invoice-bar label { font-size: 13px; font-weight: 800; color: #C0392B; }
.invoice-bar input {
  width: 160px; padding: 8px 10px; border: 1px solid #F5C6C2; border-radius: 8px;
  font-size: 13px; font-family: inherit;
}
.modal.xlarge { width: min(860px, 100%); }
.modal.xlarge .modal-bd { max-height: 78vh; }
@media (max-width: 720px) {
  .job-detail-grid { grid-template-columns: 1fr; }
}

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(8px);
  background: var(--grad); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 700; opacity: 0; pointer-events: none; transition: .22s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Modal */
.modal-mask {
  position: fixed; inset: 0; background: rgba(14,47,43,.45);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal-mask.on { display: flex; }
.modal {
  width: min(440px, 100%); background: #fff; border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.18); overflow: hidden;
  animation: modalIn .18s ease;
}
.modal.wide { width: min(680px, 100%); }
@keyframes modalIn { from { opacity:0; transform: translateY(8px) scale(.98); } to { opacity:1; transform:none; } }
.modal-hd {
  padding: 14px 18px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; font-weight: 800; color: var(--g-deep);
}
.modal-hd .x {
  width: 28px; height: 28px; border: none; border-radius: 8px; background: #F3F5F4;
  cursor: pointer; font-size: 16px; color: #666; line-height: 1;
}
.modal-hd .x:hover { background: #E8ECE9; }
.modal-bd { padding: 16px 18px; max-height: 60vh; overflow-y: auto; }
.modal.wide .modal-bd { max-height: 74vh; }
.modal-ft {
  padding: 12px 18px 16px; display: flex; gap: 10px;
  align-items: center; flex-wrap: wrap;
  border-top: 1px solid var(--border-light); background: #F9FBFA;
}
.modal-ft-actions {
  display: flex; gap: 8px; flex-shrink: 0; margin-left: auto;
}
.dispatch-field-hd {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 6px;
}
.dispatch-field-hd > label:first-child {
  font-size: 12px; font-weight: 700; color: var(--text2); margin: 0;
}
.dispatch-shuttle-inline {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; color: var(--g-mid);
  cursor: pointer; user-select: none; flex-shrink: 0;
}
.dispatch-shuttle-inline input[type="checkbox"] {
  width: 14px; height: 14px; accent-color: var(--g-mid); cursor: pointer;
}
.dispatch-shield-ft {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  flex: 1; min-width: 0;
}
.dispatch-shield-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--text2);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.dispatch-shield-toggle input[type="checkbox"] {
  width: 14px; height: 14px; accent-color: var(--g-mid); cursor: pointer;
}
.dispatch-shield-time {
  display: none; align-items: center; gap: 8px; flex-wrap: wrap;
}
.dispatch-shield-time.on { display: flex; }
.dispatch-shield-time > label {
  font-size: 12px; font-weight: 600; color: var(--text2);
  white-space: nowrap; margin: 0;
}
.dispatch-shield-time input[type="datetime-local"] {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; font-family: inherit; background: #fff; min-width: 0;
  max-width: 210px;
}
.modal .form-item { margin-bottom: 12px; }
.modal .form-item:last-child { margin-bottom: 0; }
.modal-view-row {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border-light); font-size: 13px;
}
.modal-view-row:last-child { border-bottom: none; }
.modal-view-row .k { width: 118px; color: var(--text2); font-weight: 600; flex-shrink: 0; }
.modal-view-row .v { flex: 1; font-weight: 700; }
.modal-sec {
  font-size: 12px; font-weight: 800; color: var(--g-deep);
  margin: 14px 0 4px; padding-top: 4px;
}
.modal-sec:first-child { margin-top: 0; }
/* 導出師傅 PDF 彈窗 */
.doc-export {
  display: flex; flex-direction: column; gap: 14px;
}
.doc-export-summary {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(135deg, #EAF6EF 0%, #F4FAF6 100%);
  border: 1px solid #D5EADF;
}
.doc-export-summary .count {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px;
  background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800;
}
.doc-export-summary .txt { min-width: 0; flex: 1; }
.doc-export-summary .txt b {
  display: block; font-size: 13px; font-weight: 800; color: var(--g-deep); margin-bottom: 4px;
}
.doc-export-summary .names {
  font-size: 12px; color: var(--text2); line-height: 1.45; font-weight: 600;
}
.doc-export-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 8px;
}
.doc-export-hd .ttl {
  font-size: 12px; font-weight: 800; color: var(--g-deep); letter-spacing: .02em;
}
.doc-export-hd .acts { display: flex; gap: 4px; }
.doc-export-hd .acts button {
  border: none; background: transparent; cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 700; color: var(--g-mid); padding: 4px 8px; border-radius: 6px;
}
.doc-export-hd .acts button:hover { background: #EAF5EF; }
.doc-export-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.doc-export-grid .item {
  display: flex; align-items: center; gap: 8px;
  margin: 0; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: #fff; cursor: pointer;
  font-size: 13px; font-weight: 700; color: var(--text);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.doc-export-grid .item:hover {
  border-color: #B8D4C4; background: #F7FBF8;
}
.doc-export-grid .item:has(input:checked) {
  border-color: #9CCBB3; background: #EAF6EF;
  box-shadow: inset 0 0 0 1px rgba(32,141,89,.12);
}
.doc-export-grid .item input {
  width: 15px; height: 15px; accent-color: var(--g-bright); flex-shrink: 0; cursor: pointer;
}
.doc-export-extra {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 0; padding: 12px 14px;
  border-radius: 10px; border: 1px dashed #C5D9CD;
  background: #F9FBFA; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--text2); line-height: 1.45;
}
.doc-export-extra:has(input:checked) {
  border-style: solid; border-color: #B8D4C4; background: #F3F9F5; color: var(--text);
}
.doc-export-extra input {
  width: 15px; height: 15px; margin-top: 1px; accent-color: var(--g-bright); flex-shrink: 0; cursor: pointer;
}
.doc-export-extra em {
  display: block; font-style: normal; font-size: 11px; font-weight: 600;
  color: var(--text3); margin-top: 2px;
}
@media (max-width: 480px) {
  .doc-export-grid { grid-template-columns: 1fr; }
}
.hours-filter {
  display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-end;
  padding: 14px 16px; border-bottom: 1px solid var(--border-light);
  background: #F9FBFA;
}
.hours-filter .fi { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.hours-filter .fi > span {
  font-size: 11px; font-weight: 800; color: var(--text3); letter-spacing: .02em;
}
.hours-filter .fi input[type="date"],
.hours-filter .fi .ms-trigger {
  height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; font-size: 12px; font-weight: 600; font-family: inherit; color: var(--text);
}
.hours-filter .fi input[type="date"] { min-width: 140px; }
.hours-filter .ms-wrap { position: relative; min-width: 180px; }
.hours-filter .ms-trigger {
  width: 100%; text-align: left; cursor: pointer; position: relative; padding-right: 28px;
}
.hours-filter .ms-trigger::after {
  content: ''; position: absolute; right: 10px; top: 50%;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid var(--text3); margin-top: -2px;
}
.hours-filter .ms-menu {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(28,69,63,.14); z-index: 40; max-height: 220px; overflow: auto;
  padding: 6px 0;
}
.hours-filter .ms-menu.on { display: block; }
.hours-filter .ms-menu label {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.hours-filter .ms-menu label:hover { background: #F3F7F5; }
.hours-filter .export-link {
  margin-left: auto; border: none; background: transparent; cursor: pointer;
  color: var(--g-mid); font-size: 13px; font-weight: 700; font-family: inherit;
  padding: 8px 0;
}
.hours-filter .export-link:hover { text-decoration: underline; }
.tbl .link-edit {
  border: none; background: transparent; color: var(--g-mid);
  font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit; padding: 0;
}
.tbl .link-edit:hover { text-decoration: underline; }
.punch-box {
  margin: 10px 0 4px; padding: 12px 14px;
  background: #FFFBEB; border: 1.5px solid #F59E0B; border-radius: 10px;
}
.punch-box .ph {
  font-size: 12px; font-weight: 800; color: #B45309; margin-bottom: 8px;
}
.punch-box .modal-view-row { border-bottom-color: #FDE68A; }
.punch-box .modal-view-row:last-child { border-bottom: none; }
.punch-box .k { color: #92400E; width: 140px; }
.punch-box .v { color: var(--g-deep); }
.quote-content-box {
  font-size: 13px; line-height: 1.65; color: var(--text); font-weight: 600;
  white-space: pre-line; padding: 10px 0 4px;
}
.quote-photo-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 8px;
}
.quote-photo-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in;
  background: #E8EEEA;
}
.quote-photo-lightbox {
  position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.78);
  display: none; align-items: center; justify-content: center; padding: 24px;
  cursor: zoom-out;
}
.quote-photo-lightbox.on { display: flex; }
.quote-photo-lightbox img {
  max-width: min(920px, 96vw); max-height: 88vh;
  border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.modal-danger-tip {
  font-size: 13px; line-height: 1.55; color: var(--text2);
  padding: 12px; background: #FFF5F5; border-radius: 8px; border: 1px solid #F5C6C2;
}

/* Google Calendar–style schedule */
.cal-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: visible;
  min-height: calc(100vh - 92px);
}
.cal-side {
  border-right: 1px solid var(--border);
  padding: 16px 14px;
  background: #FAFCFA;
}
.cal-create {
  width: 100%; height: 44px; border: none; border-radius: 999px;
  background: #fff; color: var(--g-deep); font-size: 14px; font-weight: 700;
  font-family: inherit; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 4px 12px rgba(28,69,63,.08);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 18px;
}
.cal-create:hover { box-shadow: 0 2px 8px rgba(28,69,63,.16); }
.cal-create span { font-size: 22px; line-height: 1; color: var(--g-mid); font-weight: 400; }
.cal-mini {
  font-size: 12px; margin-bottom: 18px;
}
.cal-mini .mh {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 800; margin-bottom: 8px; color: var(--g-deep);
}
.cal-mini .mh button {
  border: none; background: transparent; cursor: pointer; color: var(--text2);
  width: 24px; height: 24px; border-radius: 50%; font-size: 14px;
}
.cal-mini .mh button:hover { background: #E8ECE9; }
.cal-mini .grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center;
}
.cal-mini .dow { color: var(--text3); font-size: 10px; font-weight: 700; padding: 4px 0; }
.cal-mini .d {
  height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; cursor: pointer; color: var(--text);
}
.cal-mini .d:hover { background: #E8F6EE; }
.cal-mini .d.on { background: var(--g-mid); color: #fff; }
.cal-mini .d.mute { color: #CCC; }
.cal-filters { font-size: 13px; }
.cal-filters .ft {
  font-size: 11px; font-weight: 800; color: var(--text3); margin-bottom: 8px; letter-spacing: .04em;
}
.cal-filters label {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px; cursor: pointer; font-weight: 600;
}
.cal-filters i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.cal-type-filter { margin-top: 16px; position: relative; z-index: 5; }
.cal-type-filter .ft {
  font-size: 11px; font-weight: 800; color: var(--text3); margin-bottom: 8px; letter-spacing: .04em;
}
.cal-type-dd { position: relative; }
.cal-type-trigger {
  width: 100%; height: 36px; padding: 0 34px 0 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; text-align: left; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; color: var(--text);
  position: relative;
}
.cal-type-trigger:hover { border-color: #B8D4C4; }
.cal-type-trigger::after {
  content: ''; position: absolute; right: 12px; top: 50%;
  width: 0; height: 0; margin-top: -2px;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 6px solid var(--text3);
}
.cal-type-menu {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(28,69,63,.14); overflow: hidden; z-index: 30;
}
.cal-type-menu.on { display: block; }
.cal-type-menu button {
  display: block; width: 100%; text-align: left; padding: 10px 12px;
  border: none; background: #fff; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; color: var(--text);
}
.cal-type-menu button:hover:not(.on) { background: #F3F7F5; }
.cal-type-menu button.on { background: #3B82F6; color: #fff; }

.cal-main { display: block; min-width: 0; background: #fff; }
.cal-top {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: #fff;
}
.cal-top .today-btn {
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit;
  color: var(--text);
}
.cal-top .nav-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none; background: transparent;
  cursor: pointer; font-size: 16px; color: var(--text2);
}
.cal-top .nav-btn:hover { background: #F0F3F1; }
.cal-top .title { font-size: 18px; font-weight: 800; color: var(--g-deep); margin-right: auto; }
.cal-top .search-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 16px; color: var(--g-mid);
  display: flex; align-items: center; justify-content: center; font-family: inherit;
}
.cal-top .search-btn:hover { background: #EAF5EF; border-color: #B8D4C4; }
.cal-top .search-btn.active { background: #EAF5EF; border-color: var(--g-mid); color: var(--g-deep); }
.cal-top .export-btn {
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: #fff;
  color: var(--g-mid); font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
}
.cal-top .export-btn:hover { background: #EAF5EF; border-color: #B8D4C4; }
.cal-search-chip {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 4px; padding: 5px 10px; border-radius: 999px;
  background: #EAF5EF; color: var(--g-mid); font-size: 12px; font-weight: 700;
}
.cal-search-chip button {
  border: none; background: transparent; color: var(--g-mid);
  font-size: 14px; font-weight: 800; cursor: pointer; font-family: inherit; line-height: 1;
}
.job-search-mask {
  display: none; position: fixed; inset: 0; z-index: 1200;
  background: rgba(15,25,22,.45); align-items: flex-start; justify-content: center;
  padding-top: 120px;
}
.job-search-mask.on { display: flex; }
.job-search-panel {
  width: min(520px, 92vw); background: #fff; border-radius: 14px;
  padding: 16px; box-shadow: 0 16px 40px rgba(0,0,0,.22);
}
.job-search-panel .row { display: flex; gap: 8px; align-items: center; }
.job-search-panel input {
  flex: 1; border: 1.5px solid #D0D8D4; border-radius: 10px;
  padding: 11px 14px; font-size: 14px; font-family: inherit; outline: none;
}
.job-search-panel input:focus { border-color: var(--g-mid); }
.job-search-panel .go {
  border: none; border-radius: 10px; background: var(--grad-btn, linear-gradient(90deg,#1D4842,#208D59));
  color: #fff; padding: 11px 18px; font-size: 13px; font-weight: 800; cursor: pointer; font-family: inherit;
}
.job-search-panel .hint { margin-top: 10px; font-size: 12px; color: #888; line-height: 1.5; }
.cal-body {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  padding: 8px 0 24px;
  min-height: 420px;
  background: #fff;
  color: var(--text);
  overflow: visible;
}
.staff-stat-bar {
  margin: 4px 16px 12px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #F7FAF8 0%, #fff 100%);
  border: 1px solid var(--border-light);
  border-radius: 10px;
}
.staff-stat-hd {
  font-size: 12px; color: var(--text3); margin-bottom: 8px; font-weight: 700;
}
.staff-stat-row {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; line-height: 1.5;
}
.staff-stat-row + .staff-stat-row { margin-top: 8px; }
.staff-stat-row .lab {
  flex-shrink: 0; font-weight: 800; color: var(--text2); min-width: 92px; padding-top: 2px;
}
.staff-stat-row .chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.staff-chip {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 700;
  background: #fff; border: 1px solid var(--border); color: var(--text);
}
.staff-chip.leave { background: #FFF7ED; border-color: #FED7AA; color: #C2410C; }
.staff-chip.idle { background: #E8F6EE; border-color: #B7E0C8; color: #155C48; }
.staff-chip.more {
  cursor: pointer; background: #EEF2F0; border-color: #D5DED8; color: var(--g-mid);
}
.staff-chip.more:hover { background: #E2EBE6; }
.staff-chip.mute { color: var(--text3); font-weight: 600; border-style: dashed; }
.cal-day {
  display: grid; grid-template-columns: 72px 1fr;
  border-bottom: 1px solid var(--border-light);
  min-height: 56px;
}
.cal-day:last-child { border-bottom: none; }
.cal-day-label {
  padding: 14px 8px 14px 16px;
  display: flex; flex-direction: column; align-items: flex-start;
  box-sizing: border-box;
}
.cal-day-label .md {
  font-size: 11px; font-weight: 800; color: var(--text3); letter-spacing: .02em;
  line-height: 1.2;
}
.cal-day-label .dd {
  width: 36px; height: 36px; margin-top: 2px;
  font-size: 20px; font-weight: 800; color: var(--g-deep);
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; box-sizing: border-box;
}
.cal-day-label .wd {
  font-size: 11px; color: var(--text3); font-weight: 600;
  margin-top: 2px; line-height: 1.2;
}
.cal-day-label.today .dd {
  border-radius: 50%; background: var(--g-mid); color: #fff; font-size: 18px;
}
.cal-mini .d.has { position: relative; }
.cal-mini .d.has::after {
  content: ''; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--g-bright);
}
.cal-mini .d.on.has::after { background: #fff; }
.cal-day-label.selected .dd {
  border-radius: 50%;
  background: #E8F6EE; color: var(--g-mid);
  font-size: 18px;
  box-shadow: inset 0 0 0 2px var(--g-mid);
}
.cal-events { padding: 6px 12px 10px 0; }
.cal-ev {
  display: grid; grid-template-columns: 12px 64px 1fr auto;
  gap: 10px; align-items: start;
  padding: 10px 10px; border-radius: 8px; cursor: pointer;
  transition: background .12s;
}
.cal-ev:hover { background: #F4F9F6; }
.cal-ev .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; }
.cal-ev .tm { font-size: 13px; font-weight: 700; color: var(--text2); font-variant-numeric: tabular-nums; padding-top: 2px; }
.cal-ev .bd { min-width: 0; }
.cal-ev .bd .t { font-size: 14px; font-weight: 800; color: var(--text); line-height: 1.35; }
.cal-ev .bd .s { font-size: 12px; color: var(--text2); margin-top: 3px; line-height: 1.45; }
.cal-ev .acts { display: flex; gap: 4px; flex-shrink: 0; padding-top: 2px; }

@media (max-width: 980px) {
  .cal-layout { grid-template-columns: 1fr; }
  .cal-side { border-right: none; border-bottom: 1px solid var(--border); }
}

@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .admin-frame { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .sidebar { width: 100%; }
  .sb-menu { display: flex; flex-wrap: wrap; gap: 4px; }
  .sb-item { flex: 1 1 140px; }
}
