/* 全站樣式，手機優先 */
:root {
  --bg: #F2F4F5;
  --card: #FFFFFF;
  --line: #D9DEE2;
  --line-soft: #E7EBEE;
  --ink: #15202B;
  --ink-2: #55606B;
  --brand: #00ABC5;
  --brand-orange: #F15A29;
  --nav: #0C2A52;
  --nav-grad: linear-gradient(100deg, #071833 0%, #0D2B55 55%, #184A86 100%);
  --nav-hover: rgba(255, 255, 255, .10);
  --nav-text: #D6E4F5;
  --accent: #007C8F;
  --accent-dark: #005E6C;
  --accent-soft: #E0F4F7;
  --warn-bg: #FDF1DC;
  --warn-line: #EBC07A;
  --warn-ink: #6B4508;
  --danger: #B42318;
  --num: 'Barlow Condensed', 'Noto Sans TC', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif; font-size: 15px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 8px; }

.layout { min-height: 100vh; }
.main { padding: 16px 14px calc(28px + var(--safe-bottom)); max-width: 1680px; margin: 0 auto; }
.main.narrow { max-width: 900px; }

/* 頂部導覽列（電腦與手機共用深藍漸層） */
.appbar { background: var(--nav-grad); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 10px rgba(7, 24, 51, .25); }
.appbar .bar { max-width: 1680px; margin: 0 auto; height: 56px; padding: 0 14px; display: flex; align-items: center; gap: 4px; }
.appbar .logo { display: flex; align-items: center; gap: 12px; margin-right: 14px; color: #fff; text-decoration: none; min-width: 0; }
.appbar .logo img { height: 28px; flex: none; }
.appbar .logo span { font-size: 15px; color: var(--nav-text); border-left: 1px solid rgba(255, 255, 255, .25); padding-left: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .5px; }
.appbar .item { position: relative; }
.appbar .item > a, .appbar .item > button { height: 56px; padding: 0 14px; display: flex; align-items: center; gap: 6px; color: var(--nav-text); text-decoration: none; background: none; border: none; cursor: pointer; font-size: 15px; border-bottom: 3px solid transparent; white-space: nowrap; }
.appbar .item > a:hover, .appbar .item > button:hover { background: var(--nav-hover); color: #fff; }
.appbar .item.active > a, .appbar .item.active > button { color: #fff; font-weight: 700; border-bottom-color: var(--brand); }
.appbar .caret { font-size: 10px; opacity: .8; }
.appbar .spacer { flex: 1; }
.appbar .pop { position: absolute; top: 54px; left: 0; min-width: 200px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(7, 24, 51, .22); padding: 6px; display: flex; flex-direction: column; }
.appbar .item.right .pop { left: auto; right: 0; }
.appbar .pop a { padding: 10px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.appbar .pop a:hover { background: var(--accent-soft); }
.appbar .pop a.active { color: var(--accent-dark); font-weight: 700; }
.appbar .icon-btn { height: 40px; min-width: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .08); color: #fff; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; text-decoration: none; cursor: pointer; position: relative; }
.appbar .icon-btn .badge { position: absolute; top: -6px; right: -6px; }
.appbar .desktop { display: none; }
.appbar .mobile { display: flex; align-items: center; gap: 8px; }
.appbar .logo .full { display: none; }

/* 手機選單：點右上角「選單」展開，內容與電腦版完全相同 */
.mpanel { background: var(--card); border-bottom: 1px solid var(--line); box-shadow: 0 12px 24px rgba(7, 24, 51, .15); padding: 8px 14px 14px; display: flex; flex-direction: column; gap: 4px; max-height: calc(100vh - 56px); overflow-y: auto; }
.mpanel .group { font-size: 12px; color: var(--ink-2); padding: 10px 4px 2px; }
.mpanel a { padding: 12px; border-radius: 10px; color: var(--ink); text-decoration: none; display: flex; justify-content: space-between; align-items: center; font-size: 16px; }
.mpanel a.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; }

@media (min-width: 1000px) {
  .appbar .desktop { display: flex; align-items: center; }
  .appbar .mobile, .mpanel { display: none; }
  .appbar .bar { height: 62px; padding: 0 32px; }
  .appbar .item > a, .appbar .item > button { height: 62px; }
  .appbar .pop { top: 60px; }
  .appbar .logo img { height: 32px; }
  .appbar .logo .full { display: block; }
  .appbar .logo .mark { display: none; }
  .main { padding: 28px 32px 48px; }
}
.appbar .logo .mark { height: 30px; width: 30px; border-radius: 7px; background: #fff; }

/* 系統設定：上方分類列與卡片 */
.subnav { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; position: sticky; top: 56px; z-index: 5; background: var(--bg); scrollbar-width: thin; }
.subnav-item { flex: none; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); cursor: pointer; font-size: 14px; }
.subnav-item:hover { border-color: var(--accent); color: var(--accent-dark); }
.subnav-item.active { background: var(--nav); border-color: var(--nav); color: #fff; font-weight: 700; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.set-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; border-top: 3px solid var(--accent); }
.set-card.wide { grid-column: 1 / -1; }
.set-card h3 { margin: 0; font-size: 17px; color: var(--nav); }
.set-card > p { margin: -6px 0 0; color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.set-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.set-actions .btn { height: 38px; padding: 0 20px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .grid3 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .subnav { top: 62px; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.grid6 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 900px) { .grid6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
table.mid td { vertical-align: middle; }
table.mid input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.muted { color: var(--ink-2); font-size: 13px; }
.num { font-family: var(--num); }
.big-time { font-family: var(--num); font-size: 64px; font-weight: 600; line-height: 1; letter-spacing: -1px; }

.btn { height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.outline { border-color: var(--accent); color: var(--accent); }
.btn.danger { color: var(--danger); border-color: #E7B4AE; }
.btn.block { width: 100%; }
.btn.big { height: 56px; font-size: 18px; border-radius: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid #7FC4C9; outline-offset: 1px; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], select, textarea {
  height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--card); width: 100%; font-size: 15px;
}
textarea { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: center; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.banner-warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); border-radius: 14px; padding: 12px 16px; text-decoration: none; display: flex; justify-content: space-between; gap: 10px; }
.banner-error { background: #FDECEA; border: 1px solid #F1B5AE; color: #7A1A12; border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.banner-ok { background: var(--accent-soft); color: var(--accent-dark); border-radius: 12px; padding: 10px 14px; font-size: 14px; }

.chip { display: inline-flex; align-items: center; font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--line-soft); color: #39424B; white-space: nowrap; }
.chip.ok { background: var(--accent-soft); color: var(--accent-dark); }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.bad { background: #FDECEA; color: #7A1A12; }

.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line-soft); }
.list-row:first-child { border-top: none; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--ink-2); font-size: 13px; padding: 12px; white-space: nowrap; }
td { padding: 11px 12px; border-top: 1px solid var(--line-soft); vertical-align: top; }
tr.err td { background: #FDF5F4; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { text-align: center; font-size: 12px; color: var(--ink-2); }
.cal button { height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-family: var(--num); font-size: 17px; }
.cal button.rest { background: transparent; border-color: var(--line-soft); color: #6B737C; }
.cal button.missing { background: #F6DFA8; }
.cal button.fixPending { background: #FBEBC8; }
.cal button.selected { border: 2px solid var(--ink); font-weight: 700; }

.modal-back { position: fixed; inset: 0; background: rgba(21,32,43,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 20px; }
@media (min-width: 700px) { .modal-back { align-items: center; } .modal { border-radius: 18px; } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--safe-bottom)); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 60; font-size: 14px; max-width: 90vw; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; overflow: hidden; padding: 0; }
.login-card .head { background: var(--nav-grad); padding: 22px 24px 18px; display: flex; flex-direction: column; gap: 10px; }
.login-card .head img { height: 34px; align-self: flex-start; }
.login-card .head span { color: #BFE3EA; font-size: 14px; }
.login-card .body { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 12px; }
.money { font-family: var(--num); font-variant-numeric: tabular-nums; }
.items-row { display: grid; grid-template-columns: 150px 150px 120px 1fr; gap: 8px; align-items: end; }
.items-row2 { display: grid; grid-template-columns: 180px 150px 1fr; gap: 8px; align-items: end; }
.items-row2 .field { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 700px) { .items-row, .items-row2 { grid-template-columns: 1fr 1fr; } .items-row2 .field:last-child { grid-column: span 2; } }
.empty { text-align: center; color: var(--ink-2); padding: 28px 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
tr.selected td { background: var(--accent-soft); }
.list-row .money, .list-row b.money { white-space: nowrap; flex: none; }
