/* 我的額度 / 成員額度 / 額度與點數 (quotaPage). Load order matters: later files override earlier ones. */
/* ==========================================================================
   Quota redesign (2026-11-16): content column max 880px, own quota as a big number + bar card, department card beside it,
   one-line empty state for 我的申請, department cards + one row per member for managers and admins.
   Bars are <progress> (no inline style under CSP). Levels match the home notice: .is-warn from 85%, .is-full from 100%.
   Every selector is scoped to .qt-* classes.
   ========================================================================== */
:root {
  --qt-shadow: 0 1px 2px rgba(18, 38, 52, .05), 0 10px 32px rgba(18, 38, 52, .07);
  --qt-track: #edf2f5;
  --qt-ok: var(--fg-accent);
  --qt-warn: #ed6b18;
  --qt-warn-soft: #fff1ea;
  --qt-warn-text: #a4500f;
  --qt-full: #b3261e;
  --qt-full-soft: #fdecea;
  --qt-full-text: #a12a22;
}
body.dark {
  --qt-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .28);
  --qt-track: #333c47;
  --qt-warn: #f08c2e;
  --qt-warn-soft: #3a2720;
  --qt-warn-text: #f6b27a;
  --qt-full: #ff8a80;
  --qt-full-soft: #3d2222;
  --qt-full-text: #ffb4ab;
}

.qt-page { max-width:880px; min-width:0; }
.qt-page h1, .qt-page h2, .qt-page h3, .qt-page p { margin:0; }

/* Header: title + period pill + subtitle, admin buttons on the right */
.qt-head { display:flex; align-items:flex-end; justify-content:space-between; gap:16px; flex-wrap:wrap; margin:8px 0 22px; }
.qt-head-text { min-width:0; }
.qt-title { display:flex; align-items:center; flex-wrap:wrap; gap:6px 12px; }
.qt-title h1 { font-size:26px; line-height:1.25; }
.qt-period { padding:3px 10px; border-radius:999px; background:var(--fg-soft); color:var(--fg-accent); font-size:12px; font-weight:700; white-space:nowrap; }
.qt-sub { margin-top:6px !important; color:var(--fg-muted); font-size:13px; }
.qt-actions { display:flex; gap:8px; flex-wrap:wrap; }
.qt-page button { border-radius:9px; font-size:13px; font-weight:600; }

/* Cards */
.qt-card { min-width:0; padding:20px 22px; border:1px solid transparent; border-radius:14px; background:var(--fg-surface); box-shadow:var(--qt-shadow); }
body.dark .qt-card, body.dark .qt-dc { border-color:var(--fg-line); }
.qt-card h2 { color:var(--fg-muted); font-size:14px; font-weight:700; }
.qt-card-head { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:34px; margin-bottom:12px; }
.qt-card-head h2 { flex:none; }
.qt-grid { display:grid; grid-template-columns:minmax(0, 1.35fr) minmax(0, 1fr); gap:16px; }
.qt-dept-name { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--fg-muted); font-size:13px; font-weight:700; }

.qt-big { display:flex; align-items:baseline; flex-wrap:wrap; gap:4px 8px; font-variant-numeric:tabular-nums; }
.qt-big strong { font-size:40px; line-height:1.05; overflow-wrap:anywhere; }
.qt-big span { color:var(--fg-muted); font-size:14px; }
.qt-big-sm strong { font-size:28px; }
.qt-big-empty strong { font-size:22px; color:var(--fg-muted); }

/* Bars */
.qt-bar { display:block; width:100%; height:10px; margin:14px 0 8px; border:0; border-radius:999px; overflow:hidden; background:var(--qt-track); color:var(--qt-ok); appearance:none; -webkit-appearance:none; }
.qt-bar::-webkit-progress-bar { background:var(--qt-track); border-radius:999px; }
.qt-bar::-webkit-progress-value { background:var(--qt-ok); border-radius:999px; }
.qt-bar::-moz-progress-bar { background:var(--qt-ok); border-radius:999px; }
.qt-bar.is-warn::-webkit-progress-value { background:var(--qt-warn); }
.qt-bar.is-warn::-moz-progress-bar { background:var(--qt-warn); }
.qt-bar.is-full::-webkit-progress-value { background:var(--qt-full); }
.qt-bar.is-full::-moz-progress-bar { background:var(--qt-full); }
.qt-bar-sm { height:6px; margin:8px 0 6px; }

.qt-meta { display:flex; justify-content:space-between; flex-wrap:wrap; gap:4px 12px; color:var(--fg-muted); font-size:12.5px; font-variant-numeric:tabular-nums; }
.qt-meta b { color:var(--fg-text); font-weight:600; }
.qt-foot { margin-top:16px !important; padding-top:14px; border-top:1px solid var(--fg-line); color:var(--fg-muted); font-size:12.5px; line-height:1.6; }
.qt-foot.is-warn { color:var(--qt-warn-text); }
.qt-foot.is-full { color:var(--qt-full-text); }

/* 我的申請 */
.qt-requests { margin-top:18px; padding:16px 22px; }
.qt-requests h2 { margin-bottom:10px; }
.qt-empty { display:flex; align-items:center; gap:12px; color:var(--fg-muted); font-size:13.5px; line-height:1.6; }
.qt-empty-icon { flex:none; display:grid; place-items:center; width:34px; height:34px; border-radius:10px; background:var(--fg-soft); color:var(--fg-accent); font-weight:800; }
.qt-req-list { margin:0; padding:0; list-style:none; }
.qt-req { display:grid; grid-template-columns:auto minmax(0, 1fr) auto auto; align-items:center; gap:4px 14px; padding:9px 0; border-top:1px solid var(--fg-line); font-size:13.5px; }
.qt-req:first-child { border-top:0; }
.qt-req-kind { padding:2px 8px; border-radius:999px; background:var(--fg-soft); color:var(--fg-accent); font-size:12px; font-weight:700; white-space:nowrap; }
.qt-req-summary { min-width:0; overflow-wrap:anywhere; }
.qt-req-status { color:var(--qt-warn-text); font-size:12.5px; font-weight:600; white-space:nowrap; }
.qt-req-time { color:var(--fg-muted); font-size:12.5px; font-variant-numeric:tabular-nums; white-space:nowrap; }

/* Department cards (managers, admins) */
.qt-depts { display:grid; grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); gap:10px; margin-bottom:16px; }
.qt-dc { min-width:0; padding:12px 14px; border:1px solid transparent; border-radius:12px; background:var(--fg-surface); box-shadow:var(--qt-shadow); font-size:12.5px; }
.qt-dc-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:4px; }
.qt-dc h3 { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13.5px; }
.qt-dc-num { display:flex; align-items:baseline; flex-wrap:wrap; gap:2px 6px; font-variant-numeric:tabular-nums; }
.qt-dc-num strong { font-size:18px; overflow-wrap:anywhere; }
.qt-dc-num span, .qt-dc-used { color:var(--fg-muted); }
.qt-dc-used { font-variant-numeric:tabular-nums; }
.qt-dc .qt-link { flex:none; white-space:nowrap; }
/* 全公司 (admins only) is one full-width strip above the department cards. */
.qt-dc.is-company { grid-column:1 / -1; display:grid; grid-template-columns:minmax(0, auto) auto minmax(80px, 1fr) auto; align-items:center; gap:4px 18px; background:var(--fg-soft); box-shadow:none; }
.qt-dc.is-company .qt-dc-head { margin:0; gap:12px; }
.qt-dc.is-company .qt-bar { margin:0; }

/* 成員額度 */
.qt-members { padding:16px 22px 8px; }
.qt-members .qt-card-head { flex-wrap:wrap; }
.qt-chips { display:flex; flex-wrap:wrap; gap:6px; }
.qt-page .qt-chip { min-height:30px; padding:4px 12px; border:1px solid transparent; border-radius:999px; background:var(--fg-soft); color:var(--fg-text); font-size:12.5px; font-weight:600; }
.qt-page .qt-chip:hover { border-color:var(--fg-accent); }
.qt-page .qt-chip[aria-pressed="true"] { background:var(--fg-accent); border-color:var(--fg-accent); color:var(--fg-surface); }
.qt-rows { margin:0; padding:0; list-style:none; }
.qt-row { display:grid; grid-template-columns:minmax(0, 150px) minmax(80px, 1fr) minmax(0, 140px) minmax(0, 120px) 48px; grid-template-areas:"who bar used rem edit"; align-items:center; gap:6px 16px; padding:11px 0; border-top:1px solid var(--fg-line); font-size:13.5px; font-variant-numeric:tabular-nums; }
.qt-row:first-child { border-top:0; }
.qt-who { grid-area:who; min-width:0; }
.qt-who b, .qt-who small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.qt-who small { color:var(--fg-muted); font-size:12px; }
.qt-row-bar { grid-area:bar; margin:0; }
.qt-row-used { grid-area:used; text-align:right; color:var(--fg-muted); white-space:nowrap; }
.qt-row-used b { color:var(--fg-text); font-weight:600; }
.qt-row-rem { grid-area:rem; display:flex; align-items:center; justify-content:flex-end; gap:6px; white-space:nowrap; }
.qt-row-edit { grid-area:edit; text-align:right; }
.qt-tag { padding:1px 7px; border-radius:999px; background:var(--qt-warn-soft); color:var(--qt-warn-text); font-size:11px; font-weight:700; }
.qt-tag.is-full { background:var(--qt-full-soft); color:var(--qt-full-text); }
.qt-filter-empty { padding:12px 0; }
.qt-members > .qt-empty { padding-bottom:10px; }

/* 調整 link */
.qt-page .qt-link { min-height:28px; padding:2px 4px; border:0; border-radius:6px; background:transparent; color:var(--fg-accent); font-size:13px; font-weight:600; }
.qt-page .qt-link:hover { background:transparent; text-decoration:underline; text-underline-offset:3px; }
.qt-page .qt-link:disabled { opacity:1; }

/* Keyboard focus */
.qt-page button:focus-visible { outline:2px solid var(--fg-accent); outline-offset:2px; }

/* Narrow widths: one column; member rows become two lines */
@media (max-width: 720px) {
  .qt-grid { grid-template-columns:1fr; }
  .qt-head { align-items:flex-start; }
  .qt-big strong { font-size:34px; }
  .qt-big-sm strong { font-size:26px; }
  .qt-card { padding:16px 16px; }
  .qt-depts { grid-template-columns:repeat(auto-fill, minmax(140px, 1fr)); }
  .qt-dc.is-company { grid-template-columns:1fr; }
  .qt-dc.is-company .qt-bar { margin:8px 0 6px; }
  .qt-row { grid-template-columns:minmax(0, 1fr) auto auto; grid-template-areas:"who rem edit" "bar bar bar" "used used used"; gap:6px 12px; }
  .qt-row-used { text-align:left; font-size:12.5px; }
  .qt-req { grid-template-columns:auto auto minmax(0, 1fr); grid-template-areas:"kind summary summary" ". status time"; }
  .qt-req-kind { grid-area:kind; }
  .qt-req-summary { grid-area:summary; }
  .qt-req-status { grid-area:status; }
  .qt-req-time { grid-area:time; }
}
