/*
 * 後台樣式。要清楚好讀、手機能用，不求華麗：紙色底、墨色字、一個琥珀色當重點（跟生活獵人同一組色）。
 * 表格在窄螢幕改成一列一張卡（data-label 當欄名），不用左右滑。
 */
:root {
  --paper: #faf8f3;
  --paper-deep: #f2eee4;
  --line: #ddd7c9;
  --ink: #191712;
  --ink-soft: #6a6459;
  --accent: #f0a83c;
  --accent-ink: #7d4a0c;
  --good: #2c6a4d;
  --bad: #a03a2c;
  font: 15px/1.6 "Noto Sans TC", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 12px; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 10px 16px; background: var(--paper); border-bottom: 2px solid var(--ink);
}
.brand { font-weight: 700; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs a {
  text-decoration: none; border: 0; background: none; padding: 6px 10px; font: inherit; color: var(--ink-soft);
  border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 64px; }
section + section { margin-top: 32px; }

.btn, .btn-plain, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; min-height: 36px;
  padding: 6px 14px; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.btn-plain { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.btn:disabled, .btn-plain:disabled { opacity: 0.45; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }

form.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-items: end; }
form.grid .wide { grid-column: 1 / -1; }
label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--ink-soft); }
input, select, textarea {
  width: 100%; min-height: 38px; padding: 6px 10px; font: inherit; font-size: 16px; /* 16px 以下 iOS 會自動放大 */
  color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 6px;
}
textarea { min-height: 70px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin: 0 0 20px; background: var(--paper-deep); }
legend { font-weight: 700; padding: 0 6px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
.thumb { width: 128px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; }
.url { word-break: break-all; font-size: 0.85rem; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.8rem; border: 1px solid currentColor; }
.badge.live { color: var(--good); }
.badge.paused { color: var(--bad); }
.badge.checked { color: var(--accent-ink); }
.badge.draft { color: var(--ink-soft); }

.login { max-width: 420px; margin: 40px auto; text-align: center; }
.login img { width: 240px; height: 240px; display: block; margin: 16px auto; border: 1px solid var(--line); border-radius: 8px; }
.login form { text-align: left; margin-top: 24px; display: grid; gap: 12px; }
.divider { margin: 28px 0 0; border-top: 1px solid var(--line); padding-top: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 10;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 6px; background: var(--ink); color: var(--paper);
}
.toast.error { background: var(--bad); }

@media (max-width: 720px) {
  /* 手機上分頁獨立一行，四個都看得到，不用橫向捲 */
  .tabs { order: 3; flex-basis: 100%; }
  .brand { flex: 1; }
  table.cards thead { display: none; }
  table.cards tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.cards td { display: flex; gap: 12px; padding: 4px 0; border: 0; }
  table.cards td::before { content: attr(data-label); flex: 0 0 5.5em; color: var(--ink-soft); font-size: 0.8rem; }
  table.cards td.num { text-align: left; }
  table.cards td[data-label=""]::before { display: none; }
  /* 卡片列是 flex，左邊有欄名，圖用 flex 撐剩下的寬，不然 100% 會超出畫面 */
  .thumb { flex: 1 1 0; width: 0; max-width: 280px; }
}

/* 廣告中心共用版面 */
:root { --paper:#f4f5f0; --paper-deep:#f5f7f3; --ink:#193b32; --ink-soft:#596a61; --line:#d9e1d9; }
[hidden] { display:none !important; }
.topbar { background:#173a31; color:white; border:0; padding:12px max(20px,calc((100% - 1240px)/2)); gap:14px 32px; }
.brand { display:inline-flex; align-items:center; gap:10px; white-space:nowrap; font-size:18px; }
.brand b { display:grid; place-items:center; border-radius:9px; background:#f4bd79; color:#283c2f; width:32px; height:32px; }
.tabs a,.topbar .btn-plain { color:#d4e3da; border:0; border-radius:8px; padding:7px 14px; }
.tabs a[aria-current="page"],.tabs a:hover,.topbar .btn-plain:hover { background:#34584b; color:white; }
main { max-width:1280px; padding:30px 20px 60px; }
main section { background:white; border:1px solid var(--line); border-radius:16px; padding:clamp(15px,2vw,28px); min-width:0; scroll-margin-top:110px; }
main h2 { font-size:clamp(22px,2vw,30px); margin-bottom:18px; }
section + section { margin-top:20px; }
.ad-tools { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:20px; }
.ad-tools input { width:min(100%,320px); }
.ad-tools select { width:auto; }
.ad-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(100%,245px),1fr)); gap:18px; }
.ad-card { display:flex; flex-direction:column; overflow:hidden; border:1px solid var(--line); border-radius:13px; }
.art { position:relative; display:grid; place-items:center; aspect-ratio:16/9; background:#ecf0eb; color:#66756b; font-size:13px; }
.art img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.card-body { display:flex; flex:1; flex-direction:column; padding:16px; align-items:stretch; }
.card-meta { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:10px; color:var(--ink-soft); font-size:13px; }
.card-body h3 { color:#19382f; margin:0; font-size:18px; }
.card-body p { margin:5px 0 0; color:var(--ink-soft); }
.card-body details { margin:12px 0 16px; font-size:13px; color:var(--ink-soft); overflow-wrap:anywhere; }
summary { cursor:pointer; }
.card-body .actions { margin-top:auto; padding-top:12px; border-top:1px solid var(--line); }
.badge { white-space:nowrap; border:0; padding:3px 10px; background:#e9eeea; font-weight:650; }
.badge.live { background:#def1e6; }.badge.paused { color:#57645c; }.badge.checked { background:#fff1d7; }
.btn,.btn-plain,.btn-danger { border-radius:8px; white-space:nowrap; }
.btn-danger { border-color:transparent; }.btn-plain:hover { background:#edf3ed; }
:focus-visible { outline:3px solid #b4711c; outline-offset:2px; }
th { background:#eff3ee; } th,td { vertical-align:middle; } td { overflow-wrap:anywhere; }
fieldset { margin:0; } fieldset + fieldset,table + fieldset { margin-top:18px; }
form.grid { grid-template-columns:repeat(auto-fill,minmax(min(100%,220px),1fr)); }
@media(max-width:720px) {
  .topbar { padding:8px 14px; gap:5px; }
  .tabs a { flex:1; padding:7px 2px; }
  main { padding:16px 10px 36px; }
  table.cards td { flex-wrap:wrap; }
  .ad-grid { gap:12px; }
  .ad-tools input { flex:1 1 140px; width:auto; }
}

/* Life Hunter admin shell */
:root {
  --paper: #f5f7fa;
  --paper-deep: #f8fafc;
  --ink: #0b1120;
  --ink-soft: #526277;
  --line: #dce2ea;
}
.topbar {
  background: var(--ink);
  padding: 16px 20px;
  gap: 18px;
}
.brand img { filter: brightness(0) saturate(100%) invert(76%) sepia(70%) saturate(652%) hue-rotate(337deg); }
.brand small { display: block; color: #cbd5e1; font-size: .78rem; font-weight: 500; }
.tabs a { color: #cbd5e1; text-align: left; }
.tabs a[aria-current="page"] { color: #ffd391; background: #263244; }
.tabs a:hover, .topbar .btn-plain:hover { background: #1e293b; }
main section { border-radius: 12px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h2 { margin: 0; }
.btn { color: #392400; background: var(--accent); border-color: var(--accent); }
.btn:hover { background: #fac36b; }
.btn-plain:hover { background: #f1f5f9; }
.card-body h3 { color: var(--ink); }
th { background: #f1f5f9; }
form.grid { align-items: end; }
.editor {
  width: min(780px, calc(100% - 24px));
  max-height: 88dvh;
  color: var(--ink);
  padding: 0 24px 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.editor::backdrop { background: rgb(11 17 32 / 55%); }
.editor .page-head { position: sticky; top: 0; z-index: 1; background: white; border-bottom: 1px solid var(--line); padding: 16px 0; }
.editor fieldset { min-width: 0; padding: 0; border: 0; background: none; }
.editor legend { position: absolute; clip-path: inset(50%); }
.editor .thumb:not([src]) { display: none; }
.login { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin: 24px 0; }
.metrics div { background: var(--paper-deep); border: 1px solid var(--line); border-radius: 10px; padding: 15px; }
.metrics dt { font-size: .85rem; color: var(--ink-soft); }
.metrics dd { margin: 4px 0 0; font-size: clamp(1.1rem,2vw,1.8rem); font-weight: 700; font-variant-numeric: tabular-nums; }
@media(min-width: 769px) {
  body:has(#tabs:not([hidden])) { padding-left: 220px; }
  .topbar:has(#tabs:not([hidden])) {
    position: fixed; inset: 0 auto 0 0; width: 220px; padding: 24px 14px;
    align-items: stretch; flex-flow: column nowrap;
  }
  .topbar .brand { padding: 0 10px; }
  .tabs { flex-direction: column; gap: 6px; }
  .topbar #logout { text-align: left; justify-content: start; }
}
@media(max-width: 768px) {
  .topbar { padding: 8px 14px; gap: 6px; }
  .tabs { order: 3; flex-basis: 100%; }
  .tabs a { flex: 1; text-align: center; padding: 8px 2px; }
  .brand { flex: 1; } .brand small { display: inline; margin-left: 8px; }
  .metrics { gap: 6px; } .metrics div { padding: 9px; }
  .editor { padding-inline: 14px; }
  .editor .thumb { width: 120px; }
}

.report-ranges { background: var(--paper-deep); border-radius: 12px; padding: 4px; gap: 2px; }
.report-ranges .btn-plain { border: 0; background: transparent; }
.report-ranges [aria-pressed=true] { background: white; box-shadow: 0 1px 4px #29221626; }
.report-filter { margin: 12px 0; }
.report-filter summary, .report-panel summary { cursor: pointer; font-weight: 650; }
.report-filter form { margin-top: 12px; }
.report-summary { background: #243438; border-radius: 16px; padding: clamp(16px,3vw,30px); color: #fff; }
.report-period { color: #d5dedc; font-size: .86rem; font-variant-numeric: tabular-nums; }
.report-summary .metrics { margin: 12px 0 0; gap: 0; }
.report-summary .metrics div { padding: 0 8%; background: transparent; border: 0; border-radius: 0; }
.report-summary .metrics div:first-child { padding-left: 0; }
.report-summary .metrics div + div { border-left: 1px solid #ffffff32; }
.report-summary .metrics dt { color: #e0e6e4; }
.report-summary .metrics dd { font-size: clamp(1.25rem,3vw,2.6rem); line-height: 1.3; overflow-wrap: anywhere; }
.report-summary .metrics div:last-child dd { color: #ffcb83; }
.report-panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: clamp(14px,2.4vw,26px); margin: 16px 0 0; }
.report-plot { position: relative; height: clamp(210px,28vw,300px); }
.report-panel[open] summary { margin-bottom: 12px; }

table.cards th { white-space: nowrap; }
table.cards td[data-label="點擊時間"] { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.cards tbody tr:hover { background: #f8fafc; }
.ad-card, main > div > section { box-shadow: 0 2px 8px rgb(15 23 42 / 4%); }
@media (max-width: 900px) {
  table.cards, table.cards tbody, table.cards tr { display: block; }
  table.cards thead { display: none; }
  table.cards tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.cards td { display: grid; grid-template-columns: 6em minmax(0,1fr); gap: 10px; padding: 4px 0; border: 0; text-align: left; }
  table.cards td::before { content: attr(data-label); color: var(--ink-soft); font-size: .82rem; }
  table.cards td[data-label=""]::before { display: none; }
  table.cards td[data-label=""] { display: block; }
  .page-head { flex-wrap: wrap; }
}
