/* Teams Call Report Console — 風格比照 ESI FreeSWITCH Console */
:root {
  --font: "JetBrains Mono", "Cascadia Mono", Consolas, "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", monospace;
  --bg: #edf2f9;
  --bg-2: #e6eef8;
  --side: #e3ebf5;
  --side-line: #cdd9e8;
  --side-active: #d2e0f2;
  --panel: #ffffff;
  --line: #d6e0ec;
  --line-soft: #e7edf5;
  --text: #1c2533;
  --muted: #64748b;
  --accent: #2563a8;
  --accent-soft: #e3edf9;
  --accent-line: #a9c4e6;
  --ok: #2e7d32;
  --ok-soft: #e7f5ea;
  --ok-line: #b9dfc0;
  --warn: #9a6200;
  --warn-soft: #fff6e0;
  --warn-line: #f0d08a;
  --bad: #c62828;
  --bad-soft: #fdecec;
  --bad-line: #f2b8b8;
  --brand-dot: #3aa17e;
  --radius: 6px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 13px/1.55 var(--font);
  color: var(--text);
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%) fixed;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 版面 ---------- */
.layout { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--side);
  border-right: 1px solid var(--side-line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 16px 16px 12px; border-bottom: 1px solid var(--side-line); }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 24px; font-weight: 800; letter-spacing: -1px; color: #11203a; }
.brand-mark i { font-style: normal; color: #c62828; }
.brand-sep { width: 1px; height: 26px; background: var(--side-line); }
.brand-name { font-weight: 700; font-size: 13px; line-height: 1.2; }
.brand-name small { display: block; font-weight: 400; font-size: 8.5px; color: var(--muted); letter-spacing: .2px; }
.brand-product {
  margin-top: 8px; font-size: 10px; letter-spacing: 2.2px; color: #2b7a8c; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.brand-product::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-dot); }

.nav { padding: 6px 0 16px; }
.nav-group { margin-top: 14px; }
.nav-title {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 20px 6px; font-weight: 700; font-size: 12.5px; color: #1f2937;
}
.nav-title::after { content: "▾"; font-size: 9px; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px 9px 24px; color: #2c3a4d; border-left: 3px solid transparent;
}
.nav a:hover { background: #dae5f2; text-decoration: none; }
.nav a.active { background: var(--side-active); border-left-color: var(--accent); color: var(--accent); font-weight: 600; }
.nav .ico { width: 16px; text-align: center; color: #50627a; font-size: 12px; }
.nav a.active .ico { color: var(--accent); }
.nav .count {
  margin-left: auto; min-width: 18px; padding: 0 5px; border-radius: 9px; font-size: 10px; text-align: center;
  background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-line);
}
.side-foot { margin-top: auto; padding: 12px 20px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--side-line); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 52px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 20px; gap: 16px;
}
.topbar h1 { margin: 0; font-size: 14.5px; font-weight: 700; white-space: nowrap; }
.topbar .who { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.topbar .who b { color: var(--text); font-weight: 500; }
.content { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- 面板 ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 11px 16px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; }
.panel-body.flush { padding: 0; }
.hint { color: var(--muted); font-size: 11.5px; }

/* ---------- 標籤 ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 10px; border-radius: 999px;
  font-size: 11px; border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent);
  white-space: nowrap;
}
.pill.ok { border-color: var(--ok-line); background: var(--ok-soft); color: var(--ok); }
.pill.warn { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.pill.bad { border-color: var(--bad-line); background: var(--bad-soft); color: var(--bad); }
.pill.muted { border-color: var(--line); background: #f4f7fb; color: var(--muted); }
.pill.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: #fff; background: var(--ok); white-space: nowrap;
}
.badge.run { background: var(--accent); }
.badge.queue { background: #6b7d95; }
.badge.err { background: var(--bad); }
.badge.cancel { background: #8a8f98; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th {
  text-align: left; font-weight: 700; font-size: 12px; padding: 9px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfcfe;
}
.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; white-space: nowrap; }
.grid tr:last-child td { border-bottom: 0; }
.grid tr:hover td { background: #f6f9fd; }
.grid td.num, .grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid .mono { font-size: 11.5px; color: #3d4b5f; }
.grid .wrap { white-space: normal; min-width: 160px; max-width: 420px; }
.grid .row { flex-wrap: nowrap; gap: 6px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* ---------- 表單 ---------- */
fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.wide { grid-column: 1 / -1; }
.field > label, .field > .label { font-size: 12px; font-weight: 600; color: #334155; }
.field .hint { font-weight: 400; }
input[type=text], input[type=password], input[type=date], select, textarea {
  font: inherit; color: var(--text); background: #fff; border: 1px solid #c8d4e3; border-radius: 4px;
  padding: 6px 9px; width: 100%;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b9d0ee; border-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; padding: 4px 0; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; cursor: pointer; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }

.btn {
  font: inherit; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 4px; border: 1px solid #c3d0e0; background: #fff; color: #23324a;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f2f6fb; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #1f5591; }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.sm { padding: 2px 10px; font-size: 11px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
form.inline { display: inline; }
.w-pw { width: 190px !important; }
.w-auto { width: auto !important; }

/* ---------- 訊息 ---------- */
.flash { border-radius: var(--radius); padding: 9px 14px; border: 1px solid var(--ok-line); background: var(--ok-soft); color: #1d5d22; }
.flash.error { border-color: var(--bad-line); background: var(--bad-soft); color: #8e1c1c; }
.flash.warn { border-color: var(--warn-line); background: var(--warn-soft); color: #6d4700; }
.notice { border: 1px dashed var(--accent-line); background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; }

/* ---------- 查詢進度 ---------- */
.log {
  margin: 0; padding: 12px 14px; background: #0f1b2b; color: #cfe1f7; font: 12px/1.6 var(--font);
  max-height: 260px; overflow: auto; border-radius: 0 0 var(--radius) var(--radius); white-space: pre-wrap;
}
.log .err { color: #ff9b9b; }
.log .done { color: #9be3a6; }
.warnings { margin: 0; padding: 10px 16px 10px 32px; background: var(--warn-soft); border-bottom: 1px solid var(--warn-line); color: #6d4700; }
.report-frame { width: 100%; height: 78vh; border: 0; display: block; border-radius: 0 0 var(--radius) var(--radius); }
[hidden] { display: none !important; }

/* ---------- 登入 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 360px; max-width: 100%; }
.login-card .brand { border-bottom: 1px solid var(--line); }
.login-card .panel-body { display: flex; flex-direction: column; gap: 14px; }

.caps { display: flex; gap: 4px; flex-wrap: wrap; }
.byo-fields { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.consent-steps { display: flex; flex-direction: column; gap: 12px; }
.consent-steps ol { margin: 0; padding-left: 20px; line-height: 1.9; }
.copy-row { flex-wrap: nowrap; }
.copy-row .mono-input { flex: 1; min-width: 0; font-size: 11px; color: #3d4b5f; background: #f6f9fd; }
.consent-card { width: 460px; }
.consent-title { margin: 0; font-size: 17px; }
.consent-title.ok { color: var(--ok); }
.consent-title.fail { color: var(--warn); }
.tenant-pick { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; max-width: 420px; }
.tenant-pick label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; cursor: pointer; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .content { padding: 12px; }
  .topbar { padding: 0 12px; }
  .topbar .who { display: none; }
  .topbar form { margin-left: auto; }
}
