/* AWS OPC 运营后台 —— 设计令牌与基础布局
   数据标记色用校验过的可视化色板；品牌蓝只做界面点缀，不进图表 */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --series: #2a78d6;
  --series-soft: rgba(42, 120, 214, 0.10);
  --good: #0ca30c;
  --good-text: #006300;
  --critical: #d03b3b;
  --warning: #fab219;
  --brand: #00b0ff;
  --side-bg: #16171b;
  --side-ink: #b9bcc5;
  --side-active: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink2: #c3c2b7;
    --grid: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --series: #3987e5;
    --series-soft: rgba(57, 135, 229, 0.14);
    --good-text: #0ca30c;
    --side-bg: #131312;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.6 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--page);
  color: var(--ink);
}
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---- 布局：左侧导航 + 内容区 ---- */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side {
  background: var(--side-bg);
  color: var(--side-ink);
  padding: 20px 12px;
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh;
}
.side .logo {
  color: #fff; font-weight: 700; font-size: 15px; letter-spacing: 0.02em;
  padding: 4px 10px 18px;
}
.side .logo small { display: block; font-weight: 400; font-size: 11px; color: var(--side-ink); margin-top: 2px; }
.side a {
  color: inherit; text-decoration: none;
  padding: 8px 10px; border-radius: 8px; border-left: 2px solid transparent;
  font-size: 13.5px;
}
.side a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.side a.active { background: rgba(255, 255, 255, 0.09); color: var(--side-active); border-left-color: var(--brand); font-weight: 600; }
.side .foot { margin-top: auto; padding: 10px; font-size: 12px; color: #7d818c; display: flex; align-items: center; gap: 8px; }
.side .foot img { width: 22px; height: 22px; border-radius: 50%; }
.side .foot button { margin-left: auto; background: none; border: none; color: #7d818c; cursor: pointer; font-size: 12px; padding: 2px 4px; }
.side .foot button:hover { color: #fff; }

.main { padding: 28px 32px 48px; max-width: 1100px; width: 100%; margin: 0 auto; }
.main h1 { font-size: 19px; margin: 0 0 4px; }
.main .sub { color: var(--muted); font-size: 12.5px; margin: 0 0 20px; }

/* ---- 卡片与栅格 ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h2 { font-size: 13.5px; margin: 0 0 12px; color: var(--ink2); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .label { font-size: 12px; color: var(--muted); }
.tile .value { font-size: 26px; font-weight: 650; margin-top: 2px; }
.tile .aux { font-size: 11.5px; color: var(--ink2); margin-top: 2px; }

/* ---- 图表 ---- */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-wrap .bar { fill: var(--series); }
.chart-wrap .bar.dim { fill: var(--series); opacity: 0.55; }
.chart-wrap .gridline { stroke: var(--grid); stroke-width: 1; }
.chart-wrap .baseline { stroke: var(--grid); stroke-width: 1; }
.chart-wrap text { font: 10.5px system-ui, sans-serif; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart-wrap text.val { fill: var(--ink2); font-weight: 600; }
.tooltip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--ink); color: var(--page);
  font-size: 12px; line-height: 1.5; padding: 6px 9px; border-radius: 7px;
  transform: translate(-50%, calc(-100% - 10px));
  white-space: nowrap; display: none;
}

/* Top 项目横条 */
.toplist { display: grid; gap: 8px; }
.toplist .row { display: grid; grid-template-columns: minmax(90px, 200px) 1fr 48px; gap: 10px; align-items: center; font-size: 13px; }
.toplist .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toplist .track { height: 14px; display: flex; align-items: center; }
.toplist .fill { height: 14px; background: var(--series); border-radius: 0 4px 4px 0; min-width: 2px; }
.toplist .num { text-align: right; color: var(--ink2); font-variant-numeric: tabular-nums; }

/* ---- 表格 ---- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
td { padding: 7px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--series-soft); }
td.wrap { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink2); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge.good::before { background: var(--good); }
.badge.warn::before { background: var(--warning); }
.badge.bad::before { background: var(--critical); }

/* ---- 控件 ---- */
input, select, textarea, button {
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
textarea { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.55; resize: vertical; }
button { cursor: pointer; }
button.primary { background: var(--ink); color: var(--page); border-color: transparent; font-weight: 600; }
button.primary:hover { opacity: 0.85; }
button.danger { color: var(--critical); border-color: var(--critical); background: transparent; }
button.danger:hover { background: var(--critical); color: #fff; }
button.ghost { background: transparent; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters label { font-size: 12px; color: var(--muted); }
.filters input, .filters select { padding: 5px 8px; font-size: 13px; }
.actionbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 0; }
.hint { font-size: 12px; color: var(--muted); }
.err { color: var(--critical); font-size: 12.5px; white-space: pre-wrap; }

/* ---- 表单（配置中心与编辑抽屉共用，由 app.js 的 field() 生成） ---- */
.form { display: grid; gap: 14px; }
.fld { display: grid; gap: 5px; }
.fld > label { font-size: 12.5px; color: var(--ink2); font-weight: 600; }
.fld > .hint { margin-top: -1px; }
.fld input[type="text"], .fld input[type="number"], .fld input[type="datetime-local"], .fld select, .fld textarea {
  width: 100%; max-width: 520px;
}
.fld textarea { font-family: inherit; font-size: 13px; }
.fld input[type="number"] { max-width: 160px; }
/* 开关反过来：控件在前、文字在后，一眼能扫出哪些是开着的 */
.fld-bool > label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.fld-bool input { width: 15px; height: 15px; accent-color: var(--ink); padding: 0; }

/* 键值行编辑器（links 这类「名称 → URL」字典字段） */
.kv { display: grid; gap: 6px; justify-items: start; max-width: 520px; }
.kv-rows { display: grid; gap: 6px; width: 100%; }
.kv-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 6px; }
.kv-row input { width: 100%; }
.kv-del { padding: 4px 10px; line-height: 1; color: var(--muted); }
.kv-del:hover { color: var(--critical); border-color: var(--critical); }
.kv-add { font-size: 12.5px; padding: 4px 10px; }

/* 配置中心的兜底入口：schema 出问题时才需要它，默认收起 */
.raw { margin-top: 14px; border-top: 1px solid var(--grid); padding-top: 10px; }
.raw summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.raw textarea { margin-top: 8px; }

/* ---- 编辑抽屉 ---- */
.drawer-wrap { position: fixed; inset: 0; z-index: 30; }
.drawer-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.32); }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw); background: var(--page);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.12);
}
.drawer header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.drawer header h2 { font-size: 15px; margin: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: grid; gap: 14px; }
.drawer footer { padding: 12px 20px 16px; border-top: 1px solid var(--border); }
.drawer footer .actionbar { margin-top: 8px; justify-content: flex-end; }

/* ---- 表格导入 ---- */
.imp-head { margin: 0 0 10px; }
.filebtn {
  display: inline-block; cursor: pointer; font-size: 13px;
  background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}
.filebtn:hover { border-color: var(--ink2); }
.mapgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 6px; }
.mapgrid label { display: grid; gap: 4px; font-size: 12px; color: var(--ink2); align-content: start; }
.mapgrid label > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mapgrid select { font-size: 12.5px; padding: 5px 8px; }
.mapgrid .req { color: var(--critical); }
.scrollx { overflow-x: auto; }
h3 { font-size: 12.5px; color: var(--ink2); margin: 16px 0 8px; font-weight: 600; }

/* 页内分段（预约管理的专家/场次/记录/白名单）。下边框承载选中态，
   不用背景块——右侧内容区已经全是卡片，再加填充色会糊成一片 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 4px 0 16px; }
.tabs button {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 8px 14px; font-size: 13px; color: var(--ink2);
  margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--page); font-size: 13px;
  padding: 9px 16px; border-radius: 9px; z-index: 20;
  opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* 无权限页 */
.denied { display: grid; place-items: center; min-height: 100vh; text-align: center; }
.denied .box { max-width: 340px; }
.denied h1 { font-size: 18px; }
.denied p { color: var(--ink2); font-size: 13.5px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side .logo { padding-bottom: 4px; }
  .side .foot { margin-top: 0; margin-left: auto; }
  .main { padding: 20px 16px 40px; }
}
