:root {
  color-scheme: light;
  --bg: #f2f5f3;
  --surface: #ffffff;
  --surface-soft: #f7faf8;
  --line: #dbe5e1;
  --line-strong: #b9ccc6;
  --text: #172522;
  --muted: #687772;
  --primary: #176d65;
  --primary-dark: #0e514b;
  --primary-soft: #e5f2ef;
  --warning: #a96017;
  --warning-soft: #fff1dc;
  --success: #277347;
  --success-soft: #e5f3e9;
  --accent: #865829;
  --accent-soft: #f3e8d8;
  --danger: #a64040;
  --danger-soft: #faeaea;
  --shadow: 0 10px 28px rgba(24, 54, 47, 0.08);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.hidden { display: none !important; }
.eyebrow { margin: 0 0 7px; color: var(--primary); font-size: 12px; font-weight: 800; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 520px);
  align-items: center;
  gap: 7vw;
  padding: 7vh 8vw;
  background: #e9f1ee;
}

.login-brand { display: flex; align-items: center; gap: 30px; max-width: 720px; }
.login-brand img { width: clamp(132px, 15vw, 210px); aspect-ratio: 1; object-fit: cover; border: 8px solid #fff; border-radius: 8px; box-shadow: var(--shadow); }
.login-brand h1 { margin: 0; font-size: clamp(42px, 6vw, 78px); line-height: 1.05; }
.login-brand p:last-child { max-width: 520px; margin: 18px 0 0; color: var(--muted); font-size: 18px; line-height: 1.8; }

.login-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 42px; }
.modal-heading h2 { margin: 0; font-size: 28px; }

.field { display: grid; gap: 8px; margin-bottom: 20px; }
.field span { color: #35453f; font-size: 14px; font-weight: 700; }
.field input, .field select, .field textarea, select {
  width: 100%; min-width: 0; height: 46px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: #fff; color: var(--text); padding: 0 13px; outline: none;
}
.field input:focus, .field textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23, 109, 101, 0.12); }
.field.compact { margin-top: 15px; }
.field-help { margin: -10px 0 18px; color: var(--muted); font-size: 12px; }
.form-error { min-height: 20px; margin: -4px 0 14px; color: var(--danger); font-size: 13px; line-height: 1.5; }

.button { min-height: 40px; border: 1px solid transparent; border-radius: 6px; padding: 0 17px; font-weight: 750; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { border-color: var(--line-strong); background: #fff; color: var(--primary); }
.button-secondary:hover { border-color: var(--primary); background: var(--primary-soft); }
.button-quiet { background: transparent; color: var(--muted); }
.button-quiet:hover { background: var(--surface-soft); color: var(--text); }
.button-block { width: 100%; min-height: 48px; }
.danger-text { color: var(--danger); }


.app-shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; height: 72px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); padding: 0 28px; }
.brand-lockup { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-lockup img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }
.brand-lockup div { display: grid; }
.brand-lockup strong { font-size: 16px; }
.brand-lockup span { color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.account-meta { display: grid; text-align: right; margin-right: 10px; }
.account-meta strong { font-size: 14px; }
.account-meta span { color: var(--muted); font-size: 12px; }

.workspace { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.sidebar { position: sticky; top: 72px; align-self: start; height: calc(100vh - 72px); display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line); background: #f9fbfa; padding: 26px 18px; }
.sidebar nav { display: grid; gap: 8px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); padding: 0 14px; text-align: left; font-weight: 750; }
.nav-item span { color: #95a39e; font-size: 11px; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item.active span { color: #bfe3dd; }

.content { width: 100%; max-width: 1460px; margin: 0 auto; padding: 38px clamp(24px, 4vw, 64px) 70px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading h2 { margin: 0; font-size: 32px; }
.page-heading p:last-child { margin: 9px 0 0; color: var(--muted); }
.date-control { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.date-control input { width: 168px; height: 42px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; padding: 0 12px; color: var(--text); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 30px; }
.stat-card { min-height: 114px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-top: 4px solid var(--primary); border-radius: 8px; background: var(--surface); padding: 18px; box-shadow: 0 4px 14px rgba(24,54,47,.04); }
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { font-size: 34px; line-height: 1; }
.stat-card.warning { border-top-color: var(--warning); }
.stat-card.success { border-top-color: var(--success); }
.stat-card.accent { border-top-color: var(--accent); }

.section-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 0 14px; }
.section-toolbar h3 { margin: 0; font-size: 20px; }
.section-toolbar p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.task-list { display: grid; gap: 12px; }
.time-group { min-width: 0; margin-bottom: 12px; }
.time-group-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 12px 0; }
.time-group-heading h3 { margin: 0; color: var(--primary); font-size: 20px; font-variant-numeric: tabular-nums; }
.time-group-counts { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--muted); }
.time-group-counts strong { color: var(--text); font-variant-numeric: tabular-nums; }
.time-group-counts .count-completed strong { color: var(--success); }
.time-group-counts .count-pending strong { color: var(--warning); }
.time-group-orders { display: grid; gap: 10px; }
.statistics-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.statistics-filters .field { margin: 0; min-width: 0; }
.statistics-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.statistics-period { color: var(--muted); font-size: 13px; line-height: 1.6; }
.statistics-table-wrap { width: 100%; overflow-x: auto; }
.statistics-table { border-collapse: collapse; width: 100%; min-width: 550px; background: var(--surface); font-size: 14px; }
.statistics-table th, .statistics-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.statistics-table th:first-child, .statistics-table td:first-child, .statistics-table th[scope="row"] { text-align: left; }
.statistics-table thead { background: var(--surface-soft); color: var(--muted); }
.statistics-table th[scope="row"] { overflow-wrap: anywhere; max-width: 220px; }
.statistics-table small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; }
.statistics-detail-heading { margin-top: 30px; }
.task-card { display: grid; grid-template-columns: 84px minmax(0, 1fr) minmax(0, 1.6fr) 140px; align-items: center; gap: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 18px 20px; box-shadow: 0 3px 12px rgba(24,54,47,.035); }
.task-card.completed { background: #f8faf9; opacity: .78; }
.task-time { color: var(--primary); font-size: 24px; font-weight: 850; }
.task-order { display: grid; gap: 6px; min-width: 0; }
.task-order span { color: var(--muted); font-size: 12px; }
.credentials { display: grid; gap: 8px; min-width: 0; }
.credential-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) 40px; align-items: center; gap: 8px; }
.credential-row > span:first-child { color: var(--muted); font-size: 12px; }
.credential-value { min-width: 0; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.5; }
.mini-button { min-width: 42px; min-height: 30px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); color: var(--primary); font-size: 12px; font-weight: 700; }
.copy-credential { display: inline-grid; place-items: center; width: 40px; height: 40px; min-width: 0; padding: 0; }
.copy-credential svg { pointer-events: none; }
.copy-credential:disabled { opacity: .4; cursor: not-allowed; }
.totp-row { min-height: 40px; }
.totp-value { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; min-width: 0; }
.totp-code { font-size: 12px; color: var(--muted); }
.totp-code.ready { color: var(--primary-dark); font-size: 20px; font-weight: 750; font-variant-numeric: tabular-nums; }
.totp-countdown { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.totp-search { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; }
.totp-search input { flex: 1; min-width: 0; max-width: 460px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.totp-list { border-top: 1px solid var(--line); }
.totp-key-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.totp-key-row > div:first-child { display: grid; gap: 6px; min-width: 0; }
.totp-key-row strong { overflow-wrap: anywhere; font-size: 14px; }
.totp-key-row span { color: var(--muted); font-size: 12px; }
.totp-key-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.totp-pagination { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 12px; padding: 20px 0; font-size: 13px; }
.totp-policy { font-size: 12px; line-height: 1.6; color: var(--muted); }
.totp-heading-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.manual-order-toolbar { display: flex; justify-content: flex-end; margin: 0 0 14px; }
.manual-order-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.manual-order-grid .field { min-width: 0; }
.manual-order-grid input, .manual-order-grid select { min-width: 0; width: 100%; }
.manual-order-entry { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 20px; }
.manual-order-entry .field { margin-bottom: 10px; }
.manual-order-entry textarea { min-height: 118px; height: 118px; resize: vertical; line-height: 1.5; width: 100%; padding: 10px 13px; }
.order-source { font-size: 12px; color: var(--muted); font-weight: 400; }
#manualOrderDialog { max-height: 90vh; overflow-y: auto; }
.totp-import-summary { min-height: 48px; line-height: 1.6; font-size: 14px; font-variant-numeric: tabular-nums; }
.totp-import-progress { width: 100%; height: 8px; accent-color: var(--primary); }
.totp-import-issues { max-height: 180px; overflow: auto; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
#totpImportFile { min-width: 0; max-width: 100%; padding: 10px; font-size: 13px; }
.task-state { display: grid; justify-items: end; gap: 9px; }
.status-pill { display: inline-flex; min-height: 28px; align-items: center; border-radius: 999px; padding: 0 10px; background: var(--warning-soft); color: var(--warning); font-size: 12px; font-weight: 800; }
.status-pill.completed { background: var(--success-soft); color: var(--success); }
.assignee-line { color: var(--muted); font-size: 12px; }

.empty-state { border: 1px dashed var(--line-strong); border-radius: 8px; background: rgba(255,255,255,.65); padding: 54px 24px; text-align: center; }
.empty-state strong { display: block; font-size: 18px; }
.empty-state p { margin: 8px 0 0; color: var(--muted); }
.loading-row { padding: 48px; color: var(--muted); text-align: center; }

.assignment-bar { position: sticky; top: 86px; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.97); padding: 14px 16px; box-shadow: var(--shadow); }
.check-all { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.assignment-actions { display: flex; align-items: center; gap: 12px; }
.assignment-actions span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.assignment-actions select { width: 190px; }
.filter-row { display: flex; gap: 8px; margin: 18px 0 12px; }
.filter-chip { min-height: 34px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--muted); padding: 0 14px; font-size: 13px; }
.filter-chip.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 750; }
.assignment-list { display: grid; gap: 9px; }
.assignment-row { display: grid; grid-template-columns: 28px 90px minmax(190px, 1fr) minmax(150px, .7fr) 160px; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 14px 16px; }
.assignment-row .main { min-width: 0; }
.assignment-row .main strong, .assignment-row .main span { display: block; overflow-wrap: anywhere; }
.assignment-row .main span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.assignment-row .assigned { color: var(--primary); font-size: 13px; font-weight: 750; }
.assignment-row.completed { opacity: .58; }

.staff-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.staff-card { display: grid; gap: 18px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 20px; }
.staff-card-head { display: flex; justify-content: space-between; gap: 16px; }
.staff-card-head strong { display: block; font-size: 17px; }
.staff-card-head span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.staff-status { color: var(--success); font-size: 12px; font-weight: 800; }
.staff-status.disabled { color: var(--danger); }
.staff-actions { display: flex; gap: 8px; }
.staff-actions .button { flex: 1; }
.manual-time-picker { border: 1px solid var(--line); border-radius: 4px; background: var(--surface-soft); font-weight: 400; min-width: 0; }
.manual-time-picker summary { min-height: 46px; padding: 12px; cursor: pointer; overflow-wrap: anywhere; }
.manual-time-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 8px; max-height: 250px; overflow-y: auto; border-top: 1px solid var(--line); }
.manual-time-options label { display: flex; gap: 6px; align-items: center; min-height: 40px; padding: 4px; font-size: 14px; cursor: pointer; }
.manual-time-options input { width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0; flex: 0 0 16px; accent-color: var(--accent); }
.manual-order-count { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.staff-actions { flex-wrap: wrap; }
.staff-actions .button { min-width: 72px; }
.staff-card-head > div { min-width: 0; overflow-wrap: anywhere; }
.staff-notify { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.notification-heading { margin-top: 32px; }
.notification-list { display: grid; }
.notification-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.notification-row > div { flex: 1; min-width: 180px; overflow-wrap: anywhere; }
.notification-row p { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

.notice { margin-bottom: 20px; border: 1px solid var(--line); border-radius: 6px; padding: 13px 15px; font-size: 13px; }
.notice-error { border-color: #e7bcbc; background: var(--danger-soft); color: var(--danger); }

.modal { width: min(92vw, 500px); border: 1px solid var(--line); border-radius: 8px; padding: 0; box-shadow: 0 24px 70px rgba(15,42,36,.22); }
.modal::backdrop { background: rgba(13, 30, 27, .52); }
.modal form { padding: 28px; }
.modal-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.modal-close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--surface-soft); color: var(--muted); font-size: 24px; line-height: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 80; transform: translate(-50%, 18px); min-width: 180px; max-width: min(90vw, 460px); border-radius: 6px; background: #172522; color: #fff; padding: 12px 18px; text-align: center; opacity: 0; pointer-events: none; transition: .18s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 1180px) {
  .task-card { grid-template-columns: 74px minmax(0, 1fr) minmax(0, 1.6fr); }
  .task-state { grid-column: 2 / -1; grid-auto-flow: column; justify-content: end; align-items: center; }
}

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .staff-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .assignment-row { grid-template-columns: 28px 72px minmax(160px, 1fr) 140px; }
  .assignment-row .status-pill { display: none; }
}

@media (max-width: 760px) {
  .login-shell { grid-template-columns: 1fr; align-content: center; gap: 28px; padding: 36px 18px; }
  .login-brand { gap: 18px; }
  .login-brand img { width: 96px; border-width: 5px; }
  .login-brand h1 { font-size: 38px; }
  .login-brand p:last-child { display: none; }
  .login-panel { padding: 26px 22px; }
  .topbar { height: 64px; padding: 0 14px; }
  .brand-lockup img { width: 38px; height: 38px; }
  .brand-lockup strong { font-size: 14px; }
  .topbar-actions .button { padding: 0 8px; font-size: 12px; }
  .account-meta { display: none; }
  .workspace { display: block; }
  .sidebar { position: sticky; top: 64px; bottom: auto; left: auto; right: auto; z-index: 18; width: 100%; height: 62px; display: block; border-top: 0; border-bottom: 1px solid var(--line); border-right: 0; padding: 7px 10px; }
  .sidebar nav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
  .nav-item { justify-content: center; min-height: 46px; padding: 0 4px; font-size: 12px; }
  .statistics-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .statistics-filters .field:nth-child(3) { grid-column: 1 / -1; }
  .statistics-table { font-size: 12px; }
  .statistics-table th, .statistics-table td { padding: 10px; }
  .nav-item span { display: none; }
  .totp-key-row { align-items: stretch; flex-direction: column; gap: 12px; }
  .totp-key-actions { justify-content: flex-end; }
  .totp-search .button { padding: 0 10px; }
  .content { padding: 26px 14px 48px; }
  .page-heading { align-items: start; flex-direction: column; margin-bottom: 20px; }
  .page-heading h2 { font-size: 26px; }
  .date-control, .date-control input { width: 100%; }
  .stats-grid { gap: 8px; margin-bottom: 24px; }
  .stat-card { min-height: 94px; padding: 14px; }
  .stat-card strong { font-size: 28px; }
  .task-card { grid-template-columns: 70px minmax(0, 1fr); gap: 14px; padding: 16px; }
  .credentials { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 13px; }
  .task-state { grid-column: 1 / -1; justify-content: space-between; }
  .task-state .button { min-width: 112px; }
  .assignment-bar { top: 72px; align-items: stretch; flex-direction: column; }
  .assignment-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .assignment-actions span { grid-column: 1 / -1; }
  .assignment-actions select { width: 100%; }
  .assignment-row { grid-template-columns: 28px 64px minmax(0, 1fr); gap: 10px; }
  .assignment-row .assigned { grid-column: 2 / -1; }
  .staff-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .login-brand img { width: 78px; }
  .login-brand h1 { font-size: 32px; }
  .brand-lockup span { display: none; }
  .section-toolbar { align-items: start; }
  .assignment-actions { grid-template-columns: 1fr; }
  .assignment-actions span { grid-column: auto; }
}
