:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  color: #1f2937;
  background: #f3f5f7;
  font-synthesis: none;
}

/* EASY additions. Base palette, spacing, cards and login switch match overtime v1.1.3. */
[hidden] { display: none !important; }
body { font-size: 16px; line-height: 1.5; }
input, select, textarea { font-size: 16px; min-width: 0; }
main.container > *, .charts-grid > *, .stats-filter > *, .form-grid > * { min-width: 0; }
a { color: #1f5f8b; }
button, summary { touch-action: manipulation; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #94b8d2; outline-offset: 3px; }
.login-heading { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 10px; }
.login-heading h1 { flex: 1 0 210px; }
.login-heading button { flex-shrink: 0; }
.login-card .install-hint { font-size: .88rem; margin: 22px 0 0; }
.link-button { text-decoration: none; display: inline-flex; align-items: center; }
.page-tabs { display: flex; gap: 6px; background: #e8edf1; border-radius: 12px; padding: 5px; }
.page-tab { flex: 1; border: 0; border-radius: 9px; padding: 12px 10px; color: #51616e; background: transparent; font-weight: 700; }
.page-tab.active { background: #fff; color: #1f5f8b; box-shadow: 0 2px 6px #1f293710; }
.kind-picker { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-top: 18px; }
.kind-button { display: flex; align-items: center; gap: 12px; text-align: left; border: 1px solid #dce4eb; border-radius: 12px; background: #fff; padding: 18px 14px; color: #23445a; font-weight: 700; min-height: 72px; }
.kind-button:hover, .kind-button.selected { border-color: #1f5f8b; background: #edf4f9; }
.kind-letter { display: grid; place-items: center; flex: 0 0 34px; height: 34px; border-radius: 9px; color: #1f5f8b; background: #e8eef3; font-size: 1.1rem; }
.editor-card { margin-top: 20px; scroll-margin-top: 90px; }
.choice-fieldset { border: 0; margin: 12px 0 18px; padding: 0; min-width: 0; }
.choice-fieldset legend { font-size: .95rem; font-weight: 700; padding: 0; margin-bottom: 10px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(145px,1fr)); gap: 9px; }
.choice { position: relative; display: block; min-width: 0; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.choice-face { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 9px; min-height: 54px; height: 100%; padding: 12px 10px; border: 1px solid #dce4eb; border-radius: 10px; background: #fff; text-align: center; font-weight: 650; }
.choice-face span { margin: 0; font-weight: inherit; }
.choice input:checked + .choice-face { border: 2px solid #1f5f8b; padding: 11px 9px; background: #edf4f9; color: #174e74; }
.choice input:focus-visible + .choice-face { outline: 3px solid #94b8d2; outline-offset: 2px; }
.swatch-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; }
.color-swatch { display: block; width: 100%; height: 36px; border-radius: 7px; border: 1px solid #00000012; }
.card-choice-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin-bottom: 12px; max-width: 660px; }
.official-choice img { width: 100%; height: auto; max-height: 140px; object-fit: contain; border-radius: 6px; }
.official-choice .choice-face { gap: 4px; }
details > summary { cursor: pointer; color: #315872; font-weight: 700; margin: 12px 0; }
.check-inline { display: inline-flex; gap: 9px; align-items: center; }
.check-inline input { width: 20px; height: 20px; flex: 0 0 20px; }
.check-inline span { margin: 0; }
.permission-fieldset { margin: 18px 0; padding: 14px; border: 1px solid #dce4eb; border-radius: 12px; }
.permission-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.permission-grid .check-row { font-size: .9rem; padding: 10px; }
.permission-grid .check-row input { width: 20px; }
.record-list { display: grid; gap: 12px; margin-top: 18px; }
.record-card { border: 1px solid #dfe5ea; border-radius: 12px; padding: 16px; background: #fff; min-width: 0; overflow-wrap: anywhere; }
.record-card .muted { font-size: .88rem; }
.record-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.record-heading time { font-size: .92rem; color: #51616e; }
.record-summary { font-weight: 650; margin: 12px 0 6px; }
.record-note { white-space: pre-wrap; margin: 8px 0; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; font-size: .9rem; }
.summary-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin: 18px 0; }
.summary-grid .muted { font-size: .88rem; }
.summary-grid .mini-quota-total { font-size: 1.3rem; }
.section-note { margin-top: 18px; }
.stats-filter { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; align-items: end; gap: 12px; }
.charts-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; margin-top: 20px; }
.chart-card { overflow: hidden; }
.chart-scroll { overflow-x: auto; max-width: 100%; padding-bottom: 6px; }
.chart-scroll svg { display: block; max-width: none; }
.timeline-scroll { max-height: 570px; overflow: auto; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; font-size: .88rem; }
.chart-legend span { display: inline-flex; gap: 6px; align-items: center; }
.chart-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.chart-legend label { cursor: pointer; }
.date-link { border: 0; background: transparent; padding: 6px 0; color: #1f5f8b; text-decoration: underline; font: inherit; }
.daily-table { min-width: 860px; }
.source-panel { font-size: .9rem; }
.source-panel p { overflow-wrap: anywhere; }
dialog { border: 1px solid #dce4eb; border-radius: 16px; padding: 22px; width: min(720px,calc(100% - 24px)); max-height: 85vh; color: #1f2937; }
dialog::backdrop { background: #0f172a66; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: -22px; padding: 12px 0; background: #fff; }
.detail-list { display: grid; grid-template-columns: minmax(100px,1fr) 2fr; gap: 10px 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-list dt { color: #64748b; }
.detail-list dd { margin: 0; }
.notice { margin: 10px 0; }
@media (max-width:980px) { .kind-picker { grid-template-columns: repeat(3,minmax(0,1fr)); } .charts-grid { grid-template-columns: 1fr; } }
@media (max-width:680px) {
 .kind-picker { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
 .kind-button { padding: 14px 10px; gap: 9px; min-height: 68px; font-size: .95rem; }
 .topbar { flex-wrap: wrap; gap: 8px; }
 .topbar-actions { width: 100%; justify-content: flex-start; }
 .topbar-user { font-size: .88rem; }
 .swatch-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
 .choice-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
 .choice-face { font-size: .9rem; }
 .summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
 .stats-filter { grid-template-columns: repeat(2,minmax(0,1fr)); }
 .stats-filter button { grid-column: 1 / -1; }
 .permission-grid { grid-template-columns: 1fr; }
 .pagination { gap: 10px; flex-wrap: wrap; }
 .detail-list { grid-template-columns: 1fr; gap: 4px; }
 .detail-list dd { margin-bottom: 9px; }
 .editor-card { scroll-margin-top: 125px; }
}

* { box-sizing: border-box; }
body { margin: 0; background: #f3f5f7; color: #1f2937; }
button, input, textarea, select, output { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
h1, h2, h3 { margin-top: 0; }
h1 { font-size: 1.55rem; margin-bottom: 8px; }
h2 { font-size: 1.22rem; margin-bottom: 7px; }
h3 { font-size: 1rem; }
.muted { color: #6b7280; margin-top: 0; line-height: 1.55; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: #fff; border-radius: 18px; padding: 30px; box-shadow: 0 16px 50px rgba(15, 23, 42, .10); }
.login-role-switch { position: relative; display: grid; grid-template-columns: 1fr 1fr; margin-top: 22px; padding: 4px; border-radius: 12px; background: #edf1f4; overflow: hidden; }
.login-role-slider { position: absolute; top: 4px; left: 4px; width: calc(50% - 4px); height: calc(100% - 8px); border-radius: 9px; background: #fff; box-shadow: 0 1px 5px rgba(15, 23, 42, .14); transition: transform .22s ease; }
.login-role-switch.admin-selected .login-role-slider { transform: translateX(100%); }
.login-role-option { position: relative; z-index: 1; border: 0; background: transparent; color: #6b7280; padding: 10px 12px; border-radius: 9px; font-weight: 700; }
.login-role-option.active { color: #1f5f8b; }

.stack { display: grid; gap: 16px; margin-top: 24px; }
label span { display: block; font-size: .9rem; margin-bottom: 7px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #d1d5db; border-radius: 10px; padding: 10px 11px; background: #fff; color: #111827; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31, 95, 139, .18); border-color: #1f5f8b; }

.primary, .secondary, .danger-outline { border: 0; border-radius: 10px; padding: 10px 15px; font-weight: 750; }
.primary { background: #1f5f8b; color: #fff; }
.primary:hover:not(:disabled) { background: #174e74; }
.secondary { background: #e8eef3; color: #23445a; }
.danger-outline { background: #fff; color: #a83232; border: 1px solid #e3b4b4; }
.small { padding: 7px 10px; font-size: .88rem; }

.topbar { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 22px; background: #fff; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 5; }
.topbar-user { color: #6b7280; font-size: .92rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.container { width: min(1240px, calc(100% - 32px)); margin: 28px auto 56px; display: grid; gap: 20px; }
.admin-grid { grid-template-columns: 1fr 1fr; }
.full-width { grid-column: 1 / -1; }
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 16px; padding: 22px; box-shadow: 0 4px 18px rgba(15, 23, 42, .035); min-width: 0; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.button-row { display: flex; flex-wrap: wrap; gap: 9px; margin: 12px 0 0; }

.badge { display: inline-block; padding: 6px 10px; border-radius: 999px; font-size: .82rem; font-weight: 800; white-space: nowrap; }
.badge.open, .status-approved { background: #e4f5ea; color: #1c6b38; }
.badge.closed, .status-withdrawn, .status-cancelled { background: #eceff2; color: #59636e; }
.badge.neutral { background: #e8eef3; color: #315872; }
.status-pending_manager, .status-pending_director { background: #fff5dc; color: #8b5a00; }
.status-rejected { background: #fff0f0; color: #9d2b2b; }
.count-pill { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 7px; border-radius: 999px; background: #1f5f8b; color: #fff; font-size: .88rem; }

.message { margin-top: 14px; padding: 10px 12px; border-radius: 9px; background: #eef3f7; color: #3d5565; line-height: 1.5; }
.message.success { background: #e9f6ed; color: #24653a; }
.message.error { background: #fff0f0; color: #9d2b2b; }
.notice { padding: 13px 15px; border-radius: 11px; line-height: 1.55; }
.notice.danger { background: #fff0f0; color: #932c2c; border: 1px solid #f0caca; }

.compact-field { min-width: 170px; }
.quota-layout { display: flex; align-items: center; gap: 28px; margin: 12px 0; }
.quota-total { min-width: 150px; font-size: 2.35rem; line-height: 1; font-weight: 850; color: #1f5f8b; }
.quota-total.over-limit { color: #c03535; }
.quota-breakdown { display: flex; flex-wrap: wrap; gap: 10px; }
.quota-breakdown span { padding: 8px 11px; border-radius: 9px; background: #f4f7f9; color: #51616e; }

.check-list { display: grid; gap: 9px; margin: 16px 0; }
.check-row { display: flex; align-items: center; gap: 11px; padding: 12px; border: 1px solid #dfe5ea; border-radius: 10px; }
.check-row input { width: 19px; height: 19px; flex: 0 0 auto; }
.check-row span { margin: 0; font-weight: 550; }
.check-row.forbidden { background: #fff8f8; color: #9d2b2b; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.form-grid .full-row { grid-column: 1 / -1; }
.readonly-value { display: flex; align-items: center; min-height: 42px; padding: 10px 11px; border-radius: 10px; background: #f5f7f9; color: #334155; font-weight: 700; }
.compact-form { margin-top: 12px; }

.table-wrapper { width: 100%; overflow-x: auto; border: 1px solid #e3e7eb; border-radius: 11px; }
.data-table { width: 100%; min-width: 880px; border-collapse: collapse; font-size: .9rem; }
.data-table th { background: #f5f7f9; color: #475569; font-size: .82rem; text-align: left; white-space: nowrap; }
.data-table th, .data-table td { padding: 11px 10px; border-bottom: 1px solid #e8ebee; vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td { line-height: 1.45; }
.data-table details summary { color: #1f5f8b; cursor: pointer; font-weight: 700; }
.record-details { min-width: 220px; max-width: 360px; margin-top: 8px; padding: 10px; border-radius: 8px; background: #f7f9fb; display: grid; gap: 7px; white-space: normal; }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 100px; }
.approval-table .table-actions { min-width: 132px; }
.report-table { min-width: 1640px; }
.report-table td:nth-child(8), .report-table td:nth-child(9) { min-width: 180px; white-space: normal; }

.quota-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.mini-quota-card { border: 1px solid #dfe5ea; border-radius: 11px; padding: 14px; background: #fff; }
.mini-quota-card.over-limit { border-color: #e5a9a9; background: #fff5f5; }
.mini-quota-card.over-limit .mini-quota-total { color: #c03535; }
.mini-quota-total { margin: 7px 0; font-size: 1.45rem; font-weight: 850; color: #1f5f8b; }
.mini-quota-card small { color: #64748b; line-height: 1.5; }

.details-heading { cursor: pointer; font-weight: 750; color: #334155; }
.inline-password-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin-top: 16px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 9px; margin-top: 14px; }

.account-form { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 10px; align-items: end; padding: 14px; background: #f7f9fb; border-radius: 11px; }
.account-submit { padding-bottom: 1px; }
.user-editor { display: grid; gap: 13px; margin-top: 18px; }
.user-card { border: 1px solid #dfe5ea; border-radius: 12px; padding: 15px; }
.user-card.inactive { background: #f7f7f7; }
.user-card-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.user-card-heading > div { display: flex; flex-wrap: wrap; gap: 6px; }
.edit-account-form { background: transparent; padding: 0; }

.tag-list { display: grid; gap: 8px; margin-top: 14px; max-height: 300px; overflow: auto; }
.date-tag { display: flex; justify-content: space-between; align-items: center; gap: 9px; padding: 10px 11px; border: 1px solid #e0e5ea; border-radius: 9px; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)) auto; gap: 10px; align-items: end; margin: 15px 0 22px; }
.filter-submit { padding-bottom: 1px; }
.subheading { margin: 24px 0 10px; color: #334155; }
.empty-state { padding: 24px; text-align: center; color: #6b7280; background: #f8fafb; border-radius: 10px; }
.empty-state.compact { padding: 14px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 7px; }

@media (max-width: 980px) {
  .admin-grid, .content-grid { grid-template-columns: 1fr; }
  .full-width { grid-column: auto; }
  .account-form, .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-submit, .filter-submit { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; padding: 10px 14px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .container { width: min(100% - 20px, 1240px); margin-top: 16px; gap: 14px; }
  .card { padding: 16px; border-radius: 13px; }
  .section-heading, .quota-layout { flex-direction: column; align-items: stretch; }
  .form-grid, .account-form, .filter-grid, .inline-password-form, .inline-form { grid-template-columns: 1fr; }
  .form-grid .full-row, .account-submit, .filter-submit { grid-column: auto; }
  .quota-total { font-size: 2rem; }
  .compact-field { width: 100%; }
}

/* Prevent intrinsic date controls and chart contents from widening a narrow PWA. */
.container > section { min-width:0; }
@media(max-width:680px){.stats-filter{grid-template-columns:repeat(2,minmax(0,1fr));}.stats-filter label{min-width:0}.stats-filter input{width:100%;min-width:0}.chart-card{min-width:0}.page-tab{min-width:0}}
