:root {
  --bg: #f3f5f8; --card: #fff; --ink: #1d2733; --muted: #6b7a8c; --line: #e2e7ee;
  --accent: #2563eb; --accent-ink: #fff; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  --urgent: #b91c1c; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif; font-size: 15px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; }
button:hover { border-color: #b9c3d0; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
button.big { padding: 12px 22px; font-size: 17px; }
button.ghost { background: transparent; }
button.warn { color: var(--warn); }
button.danger { color: var(--bad); }
button.small { padding: 4px 9px; font-size: 13px; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; }
textarea { resize: vertical; }
label { display: block; margin: 10px 0 0; font-size: 14px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--ink); }
label.chk { display: inline-flex; align-items: center; gap: 6px; margin: 6px 14px 0 0; color: var(--ink); }
label.chk input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 12px 0 0; padding: 6px 12px 10px; }
legend { color: var(--muted); font-size: 14px; padding: 0 4px; }
.hidden { display: none !important; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 12px; }
.msg { margin-left: 12px; color: var(--muted); }
.msg.ok { color: var(--ok); } .msg.err { color: var(--bad); }
.empty { color: var(--muted); text-align: center; padding: 20px 0; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent);
  color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
.badge:empty { display: none; }

header.top { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: #fff;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
header.top h1 { font-size: 18px; margin: 0; white-space: nowrap; }
header.top nav { display: flex; gap: 4px; flex: 1; }
header.top .tab { border: none; background: transparent; padding: 8px 14px; border-radius: 8px; color: var(--muted); }
header.top .tab.active { background: var(--bg); color: var(--ink); font-weight: 600; }
header.top .logout { color: var(--muted); font-size: 14px; text-decoration: none; }

main { max-width: 1200px; margin: 0 auto; padding: 18px 20px 60px; }
.panel { display: none; } .panel.active { display: block; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h2 { margin: 0 0 8px; font-size: 17px; }
.card h2 .sub { font-weight: normal; color: var(--muted); font-size: 13px; margin-left: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.tools select { width: auto; }
.cols { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.row { display: flex; gap: 14px; }
.row > label { flex: 1; }
.row.inline { align-items: center; margin-top: 14px; }
.row.inline input, .row.inline select { width: auto; }
.row.inline input[name=ip] { width: 220px; }
.actions { display: flex; align-items: center; margin-top: 16px; }
.scope-row { display: flex; flex-wrap: wrap; }
.scope-opt { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.class-grid { display: grid; grid-template-columns: repeat(5, auto); justify-content: start; column-gap: 14px; }
.class-grid label.chk { margin-right: 0; }

/* 進行中的廣播 */
.list { display: flex; flex-direction: column; gap: 10px; }
.bc { border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 8px; padding: 10px 14px; }
.bc.urgent { border-left-color: var(--urgent); background: #fff5f5; }
.bc .bc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.bc .bc-title { font-weight: 600; font-size: 16px; }
.bc .bc-meta { color: var(--muted); font-size: 13px; }
.bc .bc-body { white-space: pre-wrap; margin: 4px 0 6px; }
.bc .acks { font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.bc .acks .pill { padding: 1px 8px; border-radius: 10px; background: #e8f5ec; color: #166534; }
.bc .acks .pill.no { background: #fdecec; color: #991b1b; }
.bc .bc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }

/* 表格 */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 13px; }
.tbl tr.offline td { color: var(--muted); }
.tbl tr.paused td { background: #fff8e6; }
.tbl select, .tbl input { width: auto; padding: 4px 8px; }
.tbl input.note { width: 120px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #c8d0da; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px #dcfce7; }
.dot.paused { background: var(--warn); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; background: var(--bg); }
.tag.urgent { background: #fdecec; color: var(--urgent); }
.tag.cancel { background: #eee; color: #777; text-decoration: line-through; }
.tag.live { background: #e8f5ec; color: #166534; }

/* 課表預覽 */
.sched { border-collapse: collapse; width: 100%; font-size: 13px; }
.sched th, .sched td { border: 1px solid var(--line); padding: 6px 4px; text-align: center; }
.sched th { background: var(--bg); font-weight: 500; }
.sched td .s { font-weight: 600; font-size: 14px; }
.sched td .t { color: var(--muted); }
.sched td.sub { background: #fff8e6; }
.sched td.adj { background: #eef4ff; }
.sched td .x { color: var(--warn); font-size: 11px; }

/* 登入頁 */
body.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 32px 36px; width: 340px; text-align: center; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card .sub { color: var(--muted); margin: 4px 0 18px; }
.login-card input { margin-bottom: 12px; text-align: center; font-size: 17px; }
.login-card button { width: 100%; font-size: 17px; padding: 10px; }
.alert-error { background: #fdecec; color: var(--bad); border-radius: 8px; padding: 8px; margin-bottom: 12px; font-size: 14px; }
