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

* { 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; }
.report-table { min-width: 1500px; }
.report-table td:nth-child(7), .report-table td:nth-child(8) { 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(5, minmax(130px, 1fr)) auto; 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%; }
}
