/* 君曜後台・共用樣式 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700&family=Noto+Serif+TC:wght@600;700&display=swap');

:root {
  --navy: #12294A; --navy-dark: #0B1B33; --gold: #C2A46A; --gold-dark: #8A6A2F;
  --ink: #1E2430; --muted: #5a6072; --line: #ECE6DA; --line-strong: #D9D2C3;
  --bg: #F5F3EE; --card: #ffffff;
  --ok-bg: #EEF3EC; --ok: #3E6638; --warn-bg: #FBF1DE; --warn: #8A5A12;
  --err-bg: #FBE9E7; --err: #B4372E; --info-bg: #E8EEF6; --info: #2F5D8A; --off-bg: #F1F1F3;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Noto Sans TC', system-ui, sans-serif; color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.6; }
a { color: var(--navy); }
h1, h2, h3 { font-family: 'Noto Serif TC', serif; color: var(--navy); margin: 0; }
h1 { font-size: 26px; } h2 { font-size: 18px; } h3 { font-size: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* 版面 */
.layout { display: flex; min-height: 100vh; }
.side { width: 232px; flex: none; background: var(--navy-dark); color: #C9D0DE; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 18px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 12px; }
.side .brand img { width: 36px; height: auto; }
.side .brand b { font-family: 'Noto Serif TC', serif; color: #fff; font-size: 16px; display: block; line-height: 1.3; }
.side .brand small { color: #8E99B0; font-size: 12px; }
.side .group { font-size: 12px; color: #8E99B0; margin: 14px 8px 4px; letter-spacing: .08em; }
.side a.item, .side span.item { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: #C9D0DE; font-size: 14px; }
.side a.item:hover { background: rgba(255,255,255,.06); }
.side a.item.on { background: var(--navy); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.side span.item { color: #5f6b82; cursor: default; }
.side span.item em { font-style: normal; font-size: 11px; border: 1px solid #3a4560; border-radius: 99px; padding: 0 7px; }
.side .me { margin-top: 18px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.side .me b { color: #fff; display: block; }
.side .me button { margin-top: 8px; background: none; border: 1px solid #3a4560; color: #C9D0DE; border-radius: 8px; padding: 4px 10px; cursor: pointer; }

.main { flex: 1; min-width: 0; }
.test-bar { background: var(--warn-bg); color: var(--warn); font-size: 13px; text-align: center; padding: 4px 12px; border-bottom: 1px solid #EBD3A6; }
.subnav { display: flex; gap: 4px; padding: 0 32px; background: #fff; border-bottom: 1px solid #E6DFD0; overflow-x: auto; overflow-y: hidden; white-space: nowrap; }
.subnav a { padding: 12px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-size: 14px; }
.subnav a.on { color: var(--navy); font-weight: 700; border-bottom-color: var(--gold); }
.page { padding: 28px 32px 60px; max-width: 1180px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 元件 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; margin-bottom: 18px; }
.card > h2 { margin-bottom: 12px; }
.note { background: #FBF6EA; border: 1px solid #EFE3C8; border-radius: 12px; padding: 12px 16px; color: var(--gold-dark); font-size: 14px; margin-bottom: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--navy); background: var(--navy); color: #fff; border-radius: 10px; padding: 8px 16px; cursor: pointer; text-decoration: none; font-size: 14px; white-space: nowrap; }
.btn.ghost { background: #fff; color: var(--navy); border-color: var(--line-strong); }
.btn.danger { background: #fff; color: var(--err); border-color: #EBC1BC; }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.tag { display: inline-block; border-radius: 99px; padding: 1px 10px; font-size: 12px; white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); } .tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.err { background: var(--err-bg); color: var(--err); } .tag.info { background: var(--info-bg); color: var(--info); }
.tag.off { background: var(--off-bg); color: var(--muted); } .tag.gold { background: #FBF1DE; color: var(--gold-dark); }

table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; color: var(--muted); font-weight: 500; font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 10px; border-bottom: 1px solid #F2EEE6; vertical-align: top; overflow-wrap: anywhere; }
table.list td.nw, table.list td .tag, table.list td b { white-space: nowrap; overflow-wrap: normal; }
.card { min-width: 0; overflow-x: auto; }
table.list tr.click { cursor: pointer; } table.list tr.click:hover td, table.list tr.sel td { background: #FBF6EA; }
.table-wrap { overflow-x: auto; }

/* 表單：一律兩欄或整列，避免落單 */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 12px; background: #fff; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid #E6D3A8; border-color: var(--gold); }
.field input[type=checkbox] { width: auto; accent-color: var(--navy); margin: 0; }
.field label.check { color: var(--ink); font-size: 14px; margin: 0; }
.field input[readonly] { background: #F7F5F0; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.toast { position: fixed; right: 24px; bottom: 24px; background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 99; }
.toast.err { background: var(--err); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

dialog { border: none; border-radius: 16px; padding: 0; width: min(560px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(11,27,51,.45); }
dialog .dlg-head { padding: 18px 22px 0; } dialog .dlg-body { padding: 16px 22px; } dialog .dlg-foot { padding: 0 22px 18px; display: flex; justify-content: flex-end; gap: 8px; }

/* 手機 */
.mobile-top { display: none; }
@media (max-width: 860px) {
  .side { display: none; position: fixed; z-index: 50; height: 100vh; }
  .side.open { display: block; }
  .mobile-top { display: flex; justify-content: space-between; align-items: center; background: var(--navy-dark); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 40; }
  .mobile-top button { background: none; border: 1px solid #3a4560; color: #fff; border-radius: 8px; padding: 4px 12px; }
  .mobile-top img { height: 26px; opacity: .55; }
  .page { padding: 18px 16px 60px; }
  .subnav { padding: 0 8px; }
  .form, .split { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  /* 手機上表格改成一列一張小卡，不用左右滑 */
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr { display: block; }
  table.list tr { padding: 10px 0; border-bottom: 1px solid #F2EEE6; }
  table.list td { display: inline-block; border: none; padding: 2px 10px 2px 0; max-width: 100%; }
  .tabs { flex-wrap: nowrap !important; overflow-x: auto; }
  .tabs button { white-space: nowrap; }
}
@media print { .side, .subnav, .test-bar, .mobile-top, .no-print { display: none !important; } body { background: #fff; } .page { padding: 0; } }
