/* 網頁資料夾一鍵備份工具 v1.1 — 樣式表
 * 配色：冷灰紙底＋鋼藍主色，呼應機房設備的沉穩感；唯一的視覺重點是上方的容量量表。 */

:root {
  --paper: #EDF0F2;
  --surface: #FFFFFF;
  --ink: #1C2630;
  --muted: #5B6775;
  --line: #CBD2D9;
  --steel: #2B5C85;
  --steel-dark: #1F4666;
  --steel-soft: #DCE6EF;
  --ok: #2F7A55;
  --warn: #9A6412;
  --warn-soft: #F6ECD9;
  --err: #A8322A;
  --err-soft: #F5E0DE;
  --info-soft: #E3EAF0;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151B21;
    --surface: #1D252D;
    --ink: #E3E8ED;
    --muted: #9AA6B2;
    --line: #34404B;
    --steel: #6FA3D0;
    --steel-dark: #8DB8DD;
    --steel-soft: #243646;
    --ok: #6CC196;
    --warn: #E0B25E;
    --warn-soft: #3A3122;
    --err: #EE8A80;
    --err-soft: #402624;
    --info-soft: #232F3A;
  }
}

* { box-sizing: border-box; }

/* 確保帶有 hidden 屬性的元素一定隱藏（避免被 .btn 等樣式的 display 設定覆蓋） */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--steel); outline-offset: 2px; }

/* ---------- 頂部列 ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1040px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; min-width: 0; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: .02em; }
.brand-root { color: var(--muted); font-size: 13px; word-break: break-all; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.logout-form { margin: 0; }
/* App 模式（PWA 安裝後）時避開 iPhone 瀏海與圓角區域 */
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top, 0px); }
  .wrap { padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px)); }
}

.wrap { max-width: 1040px; margin: 0 auto; padding: 24px 20px 48px; }

/* ---------- 訊息 ---------- */
.env { display: grid; gap: 8px; margin-bottom: 20px; }
.msg {
  padding: 10px 14px; border-radius: 6px; border-left: 4px solid;
  font-size: 14px;
}
.msg strong { margin-right: 6px; }
.msg-error { background: var(--err-soft); border-color: var(--err); }
.msg-warn { background: var(--warn-soft); border-color: var(--warn); }
.msg-info { background: var(--info-soft); border-color: var(--steel); }

/* ---------- 容量量表（本頁視覺重點） ---------- */
.meter-block { margin: 4px 0 28px; }
.meter-figures {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; flex-wrap: wrap; margin-bottom: 10px;
}
.meter-value {
  font-size: clamp(34px, 6vw, 52px); font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--steel-dark);
}
.meter-value.small { font-size: clamp(20px, 3vw, 26px); color: var(--ink); }
.meter-free { text-align: right; }
.meter-label { color: var(--muted); font-size: 14px; }
.meter {
  height: 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 3px; overflow: hidden;
}
.meter-fill {
  height: 100%; width: 0; background: var(--steel);
  transition: width .5s ease, background-color .3s;
}
.meter-fill.is-warn { background: var(--warn); }
.meter-fill.is-danger { background: var(--err); }
.meter-note { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- 區塊 ---------- */
.block {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 18px 20px; margin-bottom: 20px;
}
.block h2 { font-size: 17px; margin: 0; }
.block-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.block-note { color: var(--muted); font-size: 13px; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 表格 ---------- */
.table-scroll { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; min-width: 560px; }
.grid th, .grid td {
  padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.grid th { font-size: 13px; color: var(--muted); font-weight: 600; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tr.is-checked td { background: var(--steel-soft); }
.col-check { width: 40px; }
.col-check input { width: 18px; height: 18px; accent-color: var(--steel); cursor: pointer; }
.col-name label { display: inline; margin: 0; font-size: inherit; cursor: pointer; font-weight: 600; word-break: break-all; }
.col-num { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.col-date { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.col-act { white-space: nowrap; text-align: right !important; }
.col-act .btn + .btn { margin-left: 4px; }
.empty { text-align: center !important; color: var(--muted); padding: 24px 10px !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error-text { color: var(--err); }
.tag {
  display: inline-block; margin-left: 8px; padding: 0 7px; border-radius: 3px;
  font-size: 12px; background: var(--info-soft); color: var(--muted);
}
.tag-err { background: var(--err-soft); color: var(--err); }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-block; font: inherit; font-size: 14px; line-height: 1.4;
  padding: 7px 14px; border-radius: 5px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--steel); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--steel-dark); }
.btn-ghost { background: transparent; color: var(--steel-dark); border-color: var(--line); }
.btn-ghost:not(:disabled):hover { background: var(--steel-soft); }
.btn-danger { color: var(--err); }
.btn-lg { font-size: 16px; padding: 10px 26px; font-weight: 600; }
.btn-block { display: block; width: 100%; margin-top: 18px; padding: 10px; font-size: 16px; }
.btn-inline { margin-left: 12px; padding: 5px 14px; }

.action-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line);
}
.action-hint { color: var(--muted); font-size: 14px; }

/* ---------- 進度 ---------- */
.progress-block h2 { margin-bottom: 12px; }
.progress-block.is-done h2 { color: var(--ok); }
.progress-block.is-failed h2 { color: var(--err); }
.progress {
  height: 10px; background: var(--paper); border-radius: 3px; overflow: hidden;
  position: relative;
}
.progress-fill { height: 100%; width: 0; background: var(--steel); transition: width .4s ease; }
.is-done .progress-fill { background: var(--ok); }
.progress.is-indeterminate .progress-fill {
  width: 30%; position: absolute; left: -30%;
  animation: slide 1.4s ease-in-out infinite;
}
@keyframes slide { to { left: 100%; } }
.progress-text { margin: 12px 0 0; font-variant-numeric: tabular-nums; }
.progress-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.skipped { margin-top: 12px; font-size: 14px; }
.skipped summary { cursor: pointer; color: var(--warn); }
.skipped ul { margin: 8px 0 0; padding-left: 20px; max-height: 220px; overflow: auto; word-break: break-all; }

@media (prefers-reduced-motion: reduce) {
  .progress.is-indeterminate .progress-fill { animation: none; left: 0; width: 100%; opacity: .5; }
  .meter-fill, .progress-fill { transition: none; }
}

/* ---------- 表單 ---------- */
label { display: block; margin: 14px 0 6px; font-size: 14px; font-weight: 600; }
input[type="password"] {
  width: 100%; max-width: 360px; font: inherit; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 5px;
  background: var(--surface); color: var(--ink);
}
.pw-box summary { cursor: pointer; font-weight: 600; }
.pw-box form .btn { margin-top: 16px; }
.form-msg { margin: 10px 0 0; font-size: 14px; }
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.ios-hint { margin-bottom: 20px; }
.link-btn {
  margin-left: 8px; padding: 0; border: 0; background: none; font: inherit;
  color: var(--steel-dark); text-decoration: underline; cursor: pointer;
}

/* ---------- 離線提示頁 ---------- */
.offline-box { text-align: center; }
.offline-box .btn { margin-top: 8px; }

/* ---------- 登入頁 ---------- */
.auth-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.auth-box {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 28px 28px 18px;
}
.auth-box h1 { margin: 0 0 6px; font-size: 22px; }
.auth-box .lead { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.auth-box .msg { margin-bottom: 10px; }
.auth-box input[type="password"] { max-width: none; }

/* ---------- 其他 ---------- */
.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 24px; }
.toast {
  position: fixed; right: 20px; bottom: 20px; max-width: 360px;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 6px;
  font-size: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}
.toast-error { background: var(--err); color: #fff; }

@media (max-width: 600px) {
  .wrap { padding: 16px 12px 40px; }
  .block { padding: 14px 12px; }
  .meter-free { text-align: left; }
}
