/* ==========================================================================
   工商信息工作台 · 样式（天美 VI 规范版）
   --------------------------------------------------------------------------
   色彩取自《天美 VI A 基础部分》数字原资产（pymupdf 正规解码实测，非目测）：

     主色   天美蓝  #004EA2  标准色带 #004EA2 平涂 99.8%；横版 LOGO 占比 90.8%
     辅助色 日曜橙  #F39800  标准色带 #F39800 平涂 99.8%；LOGO 旭日占比 6.4%
     标准色带组合     #004EA2 70% + #F39800 30%（蓝橙双色条）
     中性色 深灰 #6E6E6E / 浅灰 #B4B5B5（标准灰阶色带）
     深色阶 #003B7A / #002751（LOGO 内部的深蓝层次）

   【重要】PDF 页面为印刷后扫描位图，主蓝被印/扫偏成 #005BAB、橙偏成 #F7941D，
   全书 71 页无一像素等于 #004EA2。因此一律以嵌入的数字原资产为准，不用扫描色。
   界面中的浅色层不使用杜撰的第二蓝，全部按主色 #004EA2 的平网百分比派生。

   图形语言：深蓝底 + 橙/浅蓝波浪（标准双色条意象）+ 反白 LOGO
   ========================================================================== */

:root {
  /* --- 天美 VI 标准色（实测值） --- */
  --tm-blue: #004ea2;          /* VI 主色 */
  --tm-blue-deep: #003b7a;     /* 主色深一档 */
  --tm-blue-darker: #002751;   /* 主色深二档 */
  --tm-orange: #f39800;        /* VI 辅助色 */
  --tm-orange-deep: #b77200;   /* 辅助色深一档（资产取样） */
  --tm-orange-ink: #8a5600;    /* 辅助色暗阶：小号文字用，保证对比度 ≥4.5:1 */
  --tm-grey: #6e6e6e;          /* VI 中性深灰 */
  --tm-grey-light: #b4b5b5;    /* VI 中性浅灰 */
  --tm-ink: #1a1a1a;
  --tm-text: #333333;

  /* --- 主色平网派生梯队（X% = 主色 X + 白 (100-X)） --- */
  --tm-blue-80: #3371b5;       /* 80% 平网：次深色、图表第二序列 */
  --tm-blue-60: #6695c7;
  --tm-blue-40: #99b8da;
  --tm-blue-20: #ccdcec;
  --tm-blue-12: #e0eaf4;
  --tm-blue-06: #f0f4f9;

  /* --- 由品牌色派生的界面色 --- */
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #e2e9f2;
  --line-soft: #eef2f8;
  --brand: var(--tm-blue);
  --brand-dark: var(--tm-blue-deep);
  --brand-soft: var(--tm-blue-12);
  --brand-softer: var(--tm-blue-06);
  --muted: #8a94a3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 60, 126, .04), 0 6px 20px rgba(0, 60, 126, .06);

  /* --- 语义色（风险状态，保持行业惯例：红=风险） --- */
  --danger: #d64541;
  --ok: #1a9c6b;

  /* --- 风险等级色：与 js/config.js 的 LEVEL_META 一一对应，改色请两处一起改 ---
     刻意不与品牌橙 #F39800 混用：品牌橙只用于品牌装饰与「1 年内待换证」这类
     非风险提示，风险等级保持独立的红/橙/琥珀序列，避免"看到橙色分不清是
     品牌装饰还是真有证照要到期"。 */
  --risk-expired: #dc2626;
  --risk-danger: #ea580c;
  --risk-warning: #b45309;
  --risk-normal: #15803d;
  --risk-unknown: #475569;
  --risk-longterm: #0369a1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--tm-ink);
  font: 14px/1.6 "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

   主框架
   ========================================================== */

.app-shell { display: flex; min-height: 100vh; }

/* 侧边导航：VI 深蓝底 + 反白 LOGO + 底部波浪 */
.sidebar {
  width: 232px; flex: none;
  background: linear-gradient(180deg, var(--tm-blue) 0%, var(--tm-blue-deep) 70%, var(--tm-blue-darker) 100%);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  color: #fff;
  overflow: hidden;
}

.brand { display: flex; align-items: center; padding: 20px 18px 16px; position: relative; z-index: 2; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-text { display: none; }

.nav { padding: 4px 12px; display: flex; flex-direction: column; gap: 3px; position: relative; z-index: 2; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  border: 0; background: transparent; cursor: pointer;
  padding: 10px 13px; border-radius: 8px; color: rgba(255, 255, 255, .82);
  text-align: left; font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav-item.is-active {
  background: #fff; color: var(--brand); font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 24, 54, .22);
}
.nav-ico { width: 16px; text-align: center; opacity: .85; }
.nav-item.is-active .nav-ico { opacity: 1; }
.nav-badge {
  margin-left: auto; background: var(--tm-orange); color: #fff;
  border-radius: 9px; font-size: 11px; padding: 1px 7px; font-weight: 600;
}

/* 侧边栏底部辅助图形（与 VI 辅助图形同构，固定在底边） */
.sidebar-wave { position: absolute; left: 0; right: 0; bottom: 0; height: 88px; z-index: 0; pointer-events: none; }
.sidebar-wave svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sidebar-foot {
  position: relative; z-index: 2;
  margin-top: auto;
  padding: 14px 18px 74px;
}
.sidebar-foot .link-btn { color: rgba(255, 255, 255, .78); }
.sidebar-foot .link-btn:hover { color: #fff; }
/* VI 标语（原登录页封面语，移到侧栏底部常驻） */
.sidebar-slogan {
  margin: 6px 0 0; color: rgba(255, 255, 255, .62);
  font-size: 11.5px; letter-spacing: 3px;
}

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { display: flex; align-items: baseline; gap: 10px; }
.topbar-title h2 { font-size: 16px; color: var(--tm-ink); }
.topbar-title h2::before {
  content: ""; display: inline-block; width: 4px; height: 15px; margin-right: 9px;
  background: linear-gradient(180deg, var(--tm-blue-deep), var(--tm-blue));
  border-radius: 2px; vertical-align: -2px;
}
.topbar-title span { font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.chip { background: var(--brand-soft); color: var(--brand-dark); border-radius: 20px; padding: 4px 12px; font-size: 12px; }
.user-chip { display: flex; align-items: center; gap: 7px; cursor: pointer; padding: 4px 8px; border-radius: 20px; }
.user-chip:hover { background: var(--brand-softer); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}

.page { padding: 20px 22px 44px; display: flex; flex-direction: column; gap: 18px; }

/* ==========================================================
   通用组件
   ========================================================== */

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--tm-text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--brand-softer); border-color: var(--tm-blue-20); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b83a37; border-color: #b83a37; }
.btn-ghost { background: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-xs { padding: 3px 9px; font-size: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

.link-btn {
  border: 0; background: none; color: var(--brand); cursor: pointer;
  padding: 0 6px 0 0; font-size: 12.5px;
}
.link-btn:hover { text-decoration: underline; color: var(--brand-dark); }
.link-btn.danger { color: var(--danger); }
.link-btn.muted { color: var(--muted); font-style: italic; }

/* 负责人：可点击改派，用主色平网做底，和品牌色一致但不抢预警色的注意力 */
.owner-chip {
  display: inline-block; cursor: pointer;
  padding: 2px 8px; border-radius: 999px;
  background: var(--tm-blue-12); color: var(--brand-dark);
  font-size: 12.5px; border: 1px solid transparent;
}
.owner-chip:hover { background: var(--tm-blue-20); border-color: var(--tm-blue-40); }

.icon-btn { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--tm-ink); }

.input, .table-wrap select, .panel-tools select {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  background: #fff; outline: none; font-size: 13px; max-width: 200px;
}
.input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0, 78, 162, .08); }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap;
}
.panel-head h3 { font-size: 14.5px; display: flex; align-items: center; gap: 8px; color: var(--tm-ink); }
.panel-head h3 em { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 500; }

/* 「我的待办」：用品牌主色做顶部条，和普通面板区分开 */
.panel-me { border-color: var(--tm-blue-40); }
.panel-me > .panel-head {
  background: var(--tm-blue-06);
  border-bottom: 1px solid var(--tm-blue-20);
}
.panel-head > span { font-size: 12px; }
.panel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 14px; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 2px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.card::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--card-accent, var(--brand)); opacity: .85;
}
.card-label { font-size: 12.5px; color: var(--tm-grey); }
.card-value { font-size: 26px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.card-hint { font-size: 11.5px; color: var(--tm-grey-light); }

.empty { padding: 34px; text-align: center; color: var(--muted); font-size: 13px; }
.empty-mini { padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px; list-style: none; }

/* ==========================================================
   表格
   ========================================================== */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; color: var(--brand-dark);
  padding: 9px 12px; background: var(--brand-softer); border-bottom: 1px solid var(--line);
  white-space: nowrap; font-size: 12.5px;
}
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; color: var(--tm-text); }
.table tbody tr:hover { background: var(--brand-softer); }
.table .cell-name { cursor: pointer; color: var(--tm-ink); font-weight: 500; }
.table .cell-name:hover { color: var(--brand); }
.table .cell-clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hot { color: var(--danger); font-weight: 600; }

.table tr.risk-expired td:first-child { box-shadow: inset 3px 0 0 var(--risk-expired); }
.table tr.risk-danger td:first-child { box-shadow: inset 3px 0 0 var(--risk-danger); }
.table tr.risk-warning td:first-child { box-shadow: inset 3px 0 0 var(--risk-warning); }
.table tr.risk-unknown td:first-child { box-shadow: inset 3px 0 0 var(--risk-unknown); }

/* ==========================================================
   徽标
   ========================================================== */

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.days { display: block; font-size: 11px; color: var(--muted); font-style: normal; margin-top: 2px; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; white-space: nowrap; }
.tag-blue { background: #e5eef9; color: var(--brand-dark); }
.tag-green { background: #e2f5ec; color: #157a53; }
.tag-amber { background: #fef3e0; color: var(--tm-orange-ink); }
.tag-grey { background: #eef1f5; color: #55606e; }

/* ==========================================================
   弹窗
   ========================================================== */

.modal-mask {
  position: fixed; inset: 0; background: rgba(0, 32, 68, .45);
  display: grid; place-items: center; z-index: 100; padding: 24px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 520px; max-width: 100%; max-height: 88vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 24, 54, .28);
  animation: pop .18s ease;
}
.modal-lg { width: 900px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(90deg, var(--brand-softer), #fff 70%);
}
.modal-head h3 { font-size: 15px; padding-right: 12px; color: var(--tm-ink); }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 10px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--tm-text); }
.req { color: var(--danger); font-style: normal; }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=date], .field input[type=number], .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none; background: #fbfdff;
  font-size: 13px; width: 100%; min-width: 0;
}
.field textarea { resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0, 78, 162, .1);
}
.field-hint { margin: 0; font-size: 11.5px; color: var(--muted); }

.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 21px; border-radius: 20px; background: #d5dfea; position: relative; transition: background .18s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .18s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(17px); }
.switch em { font-style: normal; font-size: 13px; color: var(--tm-text); }

.confirm-text { white-space: pre-line; line-height: 1.8; margin: 0; color: var(--tm-text); }

/* ==========================================================
   详情
   ========================================================== */

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-h {
  font-size: 13px; color: var(--brand-dark); margin: 16px 0 8px;
  display: flex; align-items: center; gap: 10px; font-weight: 600;
}
.detail-h::before { content: ""; width: 3px; height: 12px; background: var(--brand); border-radius: 2px; }
.detail-h:first-child { margin-top: 0; }
.detail-h em { font-style: normal; color: var(--muted); font-weight: 500; }
.detail-h button { margin-left: auto; }
.detail-p { margin: 0; line-height: 1.8; color: var(--tm-text); white-space: pre-wrap; }
.scroll-pane {
  max-height: 210px; overflow: auto; background: var(--brand-softer);
  border: 1px solid var(--line-soft); border-radius: 8px; padding: 10px 12px; font-size: 12.5px;
}

.kv { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.kv th { width: 132px; text-align: left; font-weight: 500; color: var(--muted); padding: 6px 8px; vertical-align: top; border-bottom: 1px dashed var(--line-soft); }
.kv td { padding: 6px 8px; border-bottom: 1px dashed var(--line-soft); color: var(--tm-text); word-break: break-all; }

/* ==========================================================
   留痕
   ========================================================== */

.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li {
  display: flex; gap: 10px; align-items: baseline; padding: 8px 16px;
  border-bottom: 1px solid var(--line-soft); font-size: 12.5px; flex-wrap: wrap;
}
.log-list.lg li { font-size: 13px; padding: 10px 16px; }
.log-time { color: var(--muted); width: 118px; flex: none; font-variant-numeric: tabular-nums; }
.log-tag { background: var(--brand-soft); color: var(--brand-dark); border-radius: 5px; padding: 1px 6px; font-size: 11px; }
.log-target { color: var(--brand); cursor: pointer; font-weight: 500; }
.log-act { font-weight: 600; color: var(--tm-ink); }
.log-op { color: var(--tm-orange); }
.log-detail { color: var(--tm-grey); flex: 1; min-width: 200px; word-break: break-all; }

/* ==========================================================
   图表
   ========================================================== */

.bars { padding: 8px 16px 16px; display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-label { width: 96px; flex: none; color: var(--tm-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; background: var(--brand-softer); border-radius: 5px; height: 16px; overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 5px; transition: width .4s ease; }
.bar-value { width: 34px; text-align: right; font-variant-numeric: tabular-nums; color: var(--tm-text); }

.donut-row { display: flex; align-items: center; gap: 22px; padding: 14px 16px 18px; flex-wrap: wrap; }
.donut { width: 140px; height: 140px; flex: none; }
.donut-wrap { position: relative; width: 140px; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center strong { display: block; font-size: 22px; color: var(--tm-ink); }
.donut-center span { font-size: 11px; color: var(--muted); }

.legend { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; }
.legend-item { display: flex; align-items: center; gap: 7px; color: var(--tm-text); }
.legend-item i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-item b { margin-left: auto; color: var(--tm-ink); }

.cols { display: flex; gap: 8px; padding: 16px; align-items: flex-end; min-height: 150px; }
.col-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.col-value { font-size: 11.5px; color: var(--tm-text); font-variant-numeric: tabular-nums; }
.col-bar { width: 100%; height: 110px; background: var(--brand-softer); border-radius: 5px; display: flex; align-items: flex-end; overflow: hidden; }
.col-bar i { width: 100%; border-radius: 5px; transition: height .4s ease; }
.col-label { font-size: 11px; color: var(--muted); }

/* ==========================================================
   导入导出页
   ========================================================== */

.stack { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 11px; align-items: flex-start; }
.stack > p { margin: 0; line-height: 1.8; }
.stack .btn { align-self: flex-start; }
.row-gap { display: flex; gap: 10px; flex-wrap: wrap; }
.sep { border: 0; border-top: 1px solid var(--line-soft); width: 100%; margin: 4px 0; }
.switch-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--tm-text); }
code { background: var(--brand-soft); color: var(--brand-dark); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
pre {
  background: #f8fafd; border: 1px solid var(--line-soft); border-radius: 8px;
  padding: 12px 14px; font-size: 12px; line-height: 1.8; overflow: auto; width: 100%; margin: 0;
  font-family: Consolas, Monaco, monospace; color: var(--tm-text);
}
.help ol, .help ul { margin: 0; padding-left: 20px; line-height: 1.9; font-size: 13px; color: var(--tm-text); }
.help h4 { font-size: 13.5px; margin-top: 4px; color: var(--tm-ink); }

/* ==========================================================
   Toast
   ========================================================== */

.toast-root { position: fixed; z-index: 200; top: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--tm-blue-deep); color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 24, 54, .24); opacity: 0; transform: translateY(-8px);
  transition: opacity .25s, transform .25s; max-width: 80vw; white-space: pre-wrap;
}
.toast.is-in { opacity: 1; transform: none; }
.toast-success { background: var(--ok); }
.toast-error { background: var(--danger); }
.toast-warn { background: var(--tm-orange-deep); }

/* 滚动条（浅蓝调） */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--tm-blue-20); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--tm-grey-light); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
