/* Starix Orbit 網頁共用樣式:行動優先,窄螢幕時表格改成卡片。 */
:root {
  --bg: #f3efeb;
  --card: #ffffff;
  --line: #e6e0db;
  --border: #d3ccc6;
  --text: #2b2320;
  --soft: #6f6560;
  --accent: #a63d24;
  --accent-hover: #8f331d;
  --bar: #1b100c;
  --good: #1e7d46;
  --good-bg: #e4f3ea;
  --off: #8a7f79;
  --off-bg: #eeeae6;
  --warn-bg: #fdf1dc;
  --warn: #8a5a00;
  /* 圖表:直連、中繼(已用色盲模擬驗證過可分辨) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e1e0d9;
  --axis: #898781;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Microsoft JhengHei UI", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
}
[hidden] { display: none !important; }
a { color: var(--accent); }

.topbar {
  background: var(--bar);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 3px solid var(--accent);
}
.topbar .brand { font-size: 18px; font-weight: 700; margin-right: auto; }
.topbar .who { font-size: 14px; color: #f3e9e3; word-break: break-all; }
.topbar button, .topbar a.btn { background: #2e1d16; color: #fff; border-color: #4a3229; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 460px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs button:disabled { opacity: 0.5; cursor: default; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 10px; font-size: 18px; }
.card h3 { margin: 14px 0 6px; font-size: 16px; }
.hint { color: var(--soft); font-size: 14px; margin: 4px 0 10px; }

label { display: block; font-weight: 600; margin: 12px 0 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="search"], select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button, a.btn {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); }
button.danger { color: #a3261a; border-color: #e3b9b3; }
button.small { min-height: 36px; padding: 4px 12px; font-size: 14px; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 0; min-height: 36px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 160px; }
.row > .fit { flex: 0 0 auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.msg { padding: 10px 14px; border-radius: 10px; margin: 10px 0; font-size: 15px; }
.msg.err { background: #fbe9e6; color: #8f1f14; }
.msg.ok { background: var(--good-bg); color: #14532d; }
.msg.warn { background: var(--warn-bg); color: var(--warn); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge.on { background: var(--good-bg); color: var(--good); }
.badge.off { background: var(--off-bg); color: var(--off); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.mono { font-family: Consolas, "SF Mono", monospace; letter-spacing: 0.5px; }

/* 表格:桌機是表格,手機每一列變成一張卡片,欄名顯示在左邊 */
table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th { text-align: left; font-size: 13px; color: var(--soft); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; word-break: break-word; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #faf7f4; }
.empty { color: var(--soft); padding: 18px 4px; }
@media (max-width: 760px) {
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; background: #fff; }
  table.data td { border: 0; padding: 4px 0; display: flex; gap: 12px; justify-content: space-between; text-align: right; }
  table.data td::before { content: attr(data-label); color: var(--soft); font-size: 13px; flex: 0 0 auto; text-align: left; }
  table.data td.num { text-align: right; }
  table.data td.full { display: block; text-align: left; }
  table.data td.full::before { display: block; margin-bottom: 2px; }
}

/* 數字卡 */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.tile .label { font-size: 14px; color: var(--soft); }
.tile .value { font-size: 28px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 13px; color: var(--soft); }

/* 圖表 */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--soft); margin: 4px 0 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip {
  position: absolute;
  pointer-events: none;
  background: #1b100c;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  z-index: 5;
}

/* 載入中:置中的小視窗(只擋操作,不是可以點掉的對話框) */
#loading { position: fixed; inset: 0; background: rgba(27, 16, 12, 0.28); display: flex; align-items: center; justify-content: center; z-index: 50; }
#loading div { background: #fff; border-radius: 14px; padding: 18px 26px; font-weight: 600; display: flex; gap: 12px; align-items: center; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18); }
#loading span { width: 20px; height: 20px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.qr { display: inline-block; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.qr svg, .qr img { display: block; width: 190px; height: 190px; }
.codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 6px; font-size: 16px; }
.codes span { background: var(--bg); border-radius: 8px; padding: 6px 10px; text-align: center; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--soft); font-size: 14px; margin: 16px 0 8px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.row-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
