/* 供应链数据工作台 · 前端样式
   苹果风：浅灰底 / 白卡片 / 大圆角 / 柔和阴影 / 毛玻璃顶栏，品牌红只做点缀
   （图表序列色仍是「平台固定色序」，不随排序漂移，见 app.js） */
:root {
  --page: #f5f5f7;
  --card: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --muted: #86868b;
  --line: #d2d2d7;
  --line-2: #e8e8ed;
  --brand: #dc2626;        /* 品牌红 */
  --brand-dark: #b91c1c;
  --brand-soft: #fef2f2;   /* 红浅底 */
  --good: #16a34a;
  --warn: #d97706;
  --serious: #ea580c;
  --critical: #dc2626;
  /* 平台固定色序（categorical，固定不随排序漂移） */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #6250d6;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
  --shadow-hover: 0 2px 6px rgba(0,0,0,.06), 0 12px 32px rgba(0,0,0,.08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
a { cursor: pointer; }

/* ---------- 顶栏（毛玻璃） ---------- */
.topbar {
  height: 56px; display: flex; align-items: center; gap: 24px;
  background: rgba(255,255,255,.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0,0,0,.06);
  padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; display: flex; align-items: center; gap: 9px; }
.brand-logo { height: 26px; width: auto; border-radius: 6px; display: block; }
.brand-sub { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 2px; }
.nav { display: flex; gap: 2px; flex: 1; }
.nav a {
  padding: 7px 15px; border-radius: 9px; color: var(--ink-2); font-weight: 500; font-size: 14px;
  text-decoration: none; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(0,0,0,.04); color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.who { color: var(--ink-2); font-weight: 600; font-size: 13px; }

/* ---------- 按钮 ---------- */
button { font: inherit; border: none; cursor: pointer; border-radius: 10px; transition: background .15s, transform .05s, box-shadow .15s; }
button:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.primary {
  background: var(--brand); color: #fff; padding: 9px 18px; font-weight: 600;
  box-shadow: 0 1px 3px rgba(220,38,38,.25);
}
.primary:hover { background: var(--brand-dark); }
.ghost { background: transparent; color: var(--ink-2); padding: 7px 13px; border: 1px solid var(--line); }
.ghost:hover { background: #f5f5f7; color: var(--ink); }
.small { padding: 4px 10px; font-size: 13px; }
.approve { background: var(--brand-soft); color: var(--brand-dark); padding: 4px 12px; font-size: 13px; font-weight: 600; }
.approve:hover { background: #fde3e3; }

/* ---------- 登录 ---------- */
.login-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(165deg, #fbfbfd 0%, #f5f5f7 55%, #fdf2f2 100%);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.login-card {
  background: var(--card); width: 372px; padding: 44px 38px 34px; border-radius: 20px;
  box-shadow: 0 12px 48px rgba(0,0,0,.10); text-align: center;
}
.login-logo {
  position: relative; width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 18px;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 22px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  box-shadow: 0 4px 14px rgba(220,38,38,.30);
}
.login-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.login-card h1 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 4px; }
.login-card .muted { font-size: 12.5px; }
.login-card label { display: block; text-align: left; font-size: 13px; color: var(--ink-2); margin-top: 15px; font-weight: 500; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 11px; font: inherit; background: #fafafa; transition: border-color .15s, box-shadow .15s, background .15s;
}
.login-card input:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(220,38,38,.12); }
.login-card .primary { width: 100%; margin-top: 22px; padding: 11px; }
.login-err { color: var(--critical); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

/* ---------- 布局 ---------- */
.view { max-width: 1280px; margin: 0 auto; padding: 26px 22px 72px; }
.view > h2 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 4px; }
.view > .sub { color: var(--muted); margin: 0 0 20px; font-size: 13px; }

/* KPI 卡片 */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(184px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .k-value { font-size: 27px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .k-foot { font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.kpi.good .k-value { color: var(--good); }
.kpi.bad .k-value { color: var(--critical); }

/* 卡片 */
.card { background: var(--card); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card h3 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 .card { margin-bottom: 0; }
.chart { width: 100%; height: 320px; }
.chart-sm { height: 260px; }

/* 告警横幅 */
.alertbar { border-radius: var(--radius); padding: 13px 18px; margin-bottom: 20px; font-weight: 500; font-size: 13.5px; }
.alertbar.critical { background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #f6caca; }
.alertbar.warning { background: #fdf6e8; color: #8a5a00; border: 1px solid #f2e2b6; }
.alertbar.ok { background: #eaf7ee; color: #176a2f; border: 1px solid #c9e8d0; }

/* 表格 */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 8px 11px; border-bottom: 1px solid var(--line-2); text-align: right; white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 600; text-align: right; background: #fafafa; }
.tbl th.l, .tbl td.l { text-align: left; }
.tbl tbody tr:hover { background: #fafafa; }
.tbl .num { font-variant-numeric: tabular-nums; }
.diff0 { color: var(--good); }
.diffbad { color: var(--critical); font-weight: 700; }
.diffwarn { color: #b26a00; }

/* 状态徽章 */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #eaf7ee; color: #176a2f; }
.badge.warn { background: #fdf6e8; color: #8a5a00; }
.badge.critical { background: var(--brand-soft); color: var(--brand-dark); }
.badge.muted { background: #f0f0f2; color: var(--ink-2); }

/* 二级导航（业务管理） */
.subnav { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.subnav a { padding: 6px 15px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); font-size: 13px; transition: background .15s, color .15s; }
.subnav a:hover { background: #f5f5f7; }
.subnav a.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* 行内工具条 */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type=text] { padding: 7px 11px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fafafa; }
.toolbar input[type=text]:focus { outline: none; border-color: var(--brand); background: #fff; }

/* 表浏览器 */
.tbl-wrap { max-height: 480px; overflow: auto; border: 1px solid var(--line-2); border-radius: 11px; }
.tbl-wrap table.tbl th { position: sticky; top: 0; z-index: 1; }

/* 数据库概览 */
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.table-card { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); cursor: pointer; transition: box-shadow .15s, transform .1s; }
.table-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.table-card .t-name { font-weight: 600; font-size: 13px; }
.table-card .t-rows { font-size: 21px; font-weight: 700; margin-top: 5px; font-variant-numeric: tabular-nums; }

/* 日志 */
.logbox { background: #1d1d1f; color: #d7dbe0; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; padding: 14px; border-radius: 11px; white-space: pre-wrap; max-height: 420px; overflow: auto; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1d1d1f; color: #fff; padding: 11px 22px; border-radius: 12px; z-index: 200; box-shadow: 0 8px 32px rgba(0,0,0,.22); font-size: 13px; }
.toast.err { background: var(--critical); }

/* 拖拽上传 */
.dropzone {
  border: 2px dashed var(--line); border-radius: 12px; padding: 34px 20px;
  text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.dropzone .dz-hint { font-size: 14px; }
select { font: inherit; padding: 7px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink-2); }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .nav a { padding: 7px 10px; }
  .brand-sub { display: none; }
}
