/* ============================================================
   app.css — 区域 Dealer Status Update 面板
   JLR 调性：近黑 chrome + 浅灰底 / 白卡细描边 / 青蓝强调
   字体：微软雅黑（Windows）/ 思源黑体（macOS）
   ============================================================ */
:root {
  /* 中性色（冷灰、低饱和） */
  --bg: #F1F2F3;
  --card: #FFFFFF;
  --border: #E2E4E5;
  --line: #EDEEEF;
  --text: #14181A;
  --muted: #5A6469;
  --faint: #8C9498;

  /* 强调色：青蓝 */
  --accent: #0F6FA8;
  --accent-deep: #0B4F79;
  --accent-bg: #E9F2F9;

  --teal: #0F6E56;
  --teal-bg: #E4F3EE;
  --amber: #8A5209;
  --amber-bg: #FBF0DC;
  --red: #A32D2D;
  --red-bg: #FBEBEB;
  --green: #3B6D11;
  --green-bg: #EBF3E0;

  /* 近黑 chrome（侧栏 / 主按钮） */
  --ink: #0E1113;
  --ink-2: #191D20;
  --ink-line: rgba(255, 255, 255, .10);
  --ink-text: rgba(255, 255, 255, .84);
  --ink-faint: rgba(255, 255, 255, .42);

  --radius: 6px;
  --radius-sm: 4px;
  --shadow: none;
  --sidebar-w: 216px;

  /* 字体：思源黑体优先（macOS 已装），Windows 落到微软雅黑，再兜底苹方 */
  --font: "Source Han Sans CN", "Source Han Sans SC", "Noto Sans CJK SC", "Noto Sans SC",
          "Microsoft YaHei", "微软雅黑", "PingFang SC", "Hiragino Sans GB",
          -apple-system, "Helvetica Neue", sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg); color: var(--text); font-size: 13px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea { font-family: inherit; font-size: 13px; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

/* 侧栏：近黑 chrome（JLR 调性） */
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--ink); border-right: none;
  height: 100vh; position: sticky; top: 0; overflow: hidden;
  transition: width .26s cubic-bezier(.4, 0, .2, 1);
}
.sidebar-inner {
  width: calc(var(--sidebar-w) - 28px); height: 100%; padding: 20px 14px 22px;
  display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;
}
.layout.nav-collapsed .sidebar { width: 0; }

/* 折叠 / 展开按钮 */
.brand-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.nav-toggle {
  width: 24px; height: 24px; flex: none; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--ink-line); border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .04); color: var(--ink-faint); transition: .15s;
}
.nav-toggle:hover { color: #fff; background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .26); }
.nav-reopen {
  position: fixed; top: 16px; left: 16px; z-index: 55; display: none; place-items: center;
  width: 30px; height: 30px; cursor: pointer; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  box-shadow: 0 1px 3px rgba(20, 24, 26, .07); transition: .15s;
}
.nav-reopen:hover { color: var(--accent); border-color: #BFD8EA; }
.layout.nav-collapsed .nav-reopen { display: grid; }

.brand { padding: 0 2px 18px; border-bottom: 1px solid var(--ink-line); margin-bottom: 14px; }
.brand .kicker { font-size: 10px; letter-spacing: 2.6px; color: #fff; font-weight: 600; opacity: .92; }
.brand h1 { font-size: 15px; font-weight: 600; margin-top: 8px; line-height: 1.45; color: #fff; letter-spacing: .1px; }
.brand .sub { font-size: 11px; color: var(--ink-faint); margin-top: 3px; letter-spacing: .2px; }

.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--ink-text); cursor: pointer; border: none; background: none; text-align: left; width: 100%;
  transition: background .15s, color .15s; font-size: 13px;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: rgba(255, 255, 255, .11); color: #fff; font-weight: 500; }
.nav-item .ico { width: 16px; height: 16px; flex: none; opacity: .85; }
.nav-item .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-faint); flex: none; transition: .15s; }
.nav-item:hover .dot { background: rgba(255, 255, 255, .6); }
.nav-item.active .dot { background: var(--accent); box-shadow: 0 0 0 3.5px rgba(15, 111, 168, .3); }
.nav-divider { height: 1px; background: var(--ink-line); margin: 12px 2px; }
/* 角色可见性：hidden 属性要能盖住 .nav-item 的 display:flex */
.nav [hidden], .nav-item[hidden] { display: none !important; }
.nav-label { font-size: 10px; color: var(--ink-faint); letter-spacing: 1.6px; padding: 8px 10px 5px; text-transform: uppercase; }
.sidebar .foot { margin-top: 18px; padding: 12px 2px 0; border-top: 1px solid var(--ink-line); font-size: 11px; color: var(--ink-faint); line-height: 1.7; }
.sidebar .foot b { color: var(--ink-text); font-weight: 500; }

.main { flex: 1; min-width: 0; padding: 26px 30px 56px; transition: padding-left .26s cubic-bezier(.4, 0, .2, 1); }
.layout.nav-collapsed .main { padding-left: 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { font-size: 21px; font-weight: 600; letter-spacing: -.2px; }
.page-head .desc { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 通用组件 ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.card.pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 13.5px; font-weight: 600; letter-spacing: -.1px; }
.card-head .hint { font-size: 11px; color: var(--faint); font-weight: 400; letter-spacing: .3px; }
.card-body { padding: 16px 18px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.mt14 { margin-top: 14px; } .mt18 { margin-top: 18px; }

.kpi { padding: 15px 18px 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--border); position: relative; }
.kpi .v { font-size: 27px; font-weight: 600; letter-spacing: -.8px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 11.5px; color: var(--muted); margin-top: 3px; letter-spacing: .2px; }
.kpi .d { font-size: 11px; margin-top: 6px; }
.kpi.accent::before { content: ""; position: absolute; left: -1px; top: -1px; right: -1px; height: 2px; background: var(--accent); border-radius: var(--radius) var(--radius) 0 0; }
.kpi.accent .v { color: var(--accent-deep); }
.kpi.accent .l { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff; cursor: pointer; color: var(--text);
  transition: .15s; white-space: nowrap; font-size: 12.5px;
}
.btn:hover { border-color: #C7CFD4; background: #FAFBFB; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.sm { padding: 3px 9px; font-size: 11.5px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-bg); }
.btn.danger { color: var(--red); }

.tag { display: inline-block; padding: 1.5px 8px; border-radius: 3px; font-size: 11px; font-weight: 500; white-space: nowrap; line-height: 1.7; letter-spacing: .2px; }
.tag.blue { background: var(--accent-bg); color: var(--accent-deep); }
.tag.teal { background: var(--teal-bg); color: var(--teal); }
.tag.amber { background: var(--amber-bg); color: var(--amber); }
.tag.gray { background: #F1F2F3; color: var(--muted); }
.tag.red { background: var(--red-bg); color: var(--red); }
.tag.green { background: var(--green-bg); color: var(--green); }
.tag.line { background: transparent; border: 1px solid var(--border); color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; padding: 9px 12px; font-weight: 600; font-size: 11px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); background: #F6F7F8; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #FAFBFB; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow: auto; max-height: 460px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.empty { padding: 30px; text-align: center; color: var(--faint); font-size: 12.5px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; outline: none; width: 100%;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 111, 168, .1); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .input { width: auto; min-width: 130px; }

/* 弹窗 / 抽屉 */
.overlay { position: fixed; inset: 0; background: rgba(29, 37, 40, .32); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 24px; }
.modal { background: #fff; border-radius: 14px; width: min(640px, 100%); max-height: 88vh; overflow: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, .16); }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; }
.x { border: none; background: none; cursor: pointer; font-size: 18px; color: var(--faint); line-height: 1; padding: 2px 6px; border-radius: 6px; }
.x:hover { background: #F1F3F5; color: var(--text); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* 看板 */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.kcol { background: #F6F7F8; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; min-height: 260px; }
.kcol.drag-over { border-color: var(--accent); background: #F0F6FB; }
.kcol-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kcol-head .name { font-size: 13px; font-weight: 600; }
.kcard { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 8px; cursor: pointer; transition: .15s; }
.kcard:hover { border-color: #BFD8EA; }
.kcard .t { font-size: 12.5px; font-weight: 500; margin-bottom: 5px; }
.kcard .meta { font-size: 11px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kcard .lt { font-size: 10.5px; color: var(--faint); margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }

/* 速览表（Status × 项目类型） */
.subhead { display: flex; align-items: baseline; gap: 10px; font-size: 13px; margin-bottom: 10px; }
.subhead .faint { font-size: 11px; letter-spacing: .3px; }
.mx-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.mx-table { min-width: 880px; }
.mx-table th.mx-corner { background: #F6F7F8; vertical-align: middle; white-space: normal; }
.mx-table th.mx-row { background: #F6F7F8; width: 176px; vertical-align: middle; }
.mx-table tbody th.mx-row { border-bottom: 1px solid var(--line); }
.mx-table td.mx-cell { vertical-align: top; min-width: 190px; background: #FDFDFD; }
.mx-table td.mx-total, .mx-table th.mx-total { background: #FAFBFB; font-weight: 600; }
.mx-chip { border: 1px solid var(--border); border-left: 2px solid var(--border); border-radius: var(--radius-sm); padding: 5px 8px; margin-bottom: 6px; background: #fff; cursor: pointer; transition: .15s; }
.mx-chip:last-child { margin-bottom: 0; }
.mx-chip:hover { border-color: #BFD8EA; border-left-color: var(--accent); background: #F7FBFE; }
.mx-chip .c { font-size: 11.5px; font-weight: 600; }
.mx-chip .t { display: block; font-size: 10.5px; color: var(--faint); }
.mx-empty { color: var(--faint); font-size: 11.5px; }

/* 时间线 */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 14px 4px; }
.tl-item::before { content: ""; position: absolute; left: -19px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid var(--border); }
.tl-item.done::before { background: var(--accent); border-color: var(--accent); }
.tl-item .k { font-size: 12.5px; font-weight: 500; }
.tl-item .v { font-size: 11.5px; color: var(--muted); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab { padding: 9px 14px; border: none; background: none; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 12.5px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { display: none; } .tab-panel.active { display: block; }

.chart { width: 100%; height: 260px; }
.chart.sm { height: 210px; }
.note { background: var(--accent-bg); border-left: 2px solid var(--accent); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 12.5px; color: var(--accent-deep); }
.note.warn { background: var(--amber-bg); border-left-color: var(--amber); color: var(--amber); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12.5px; }
.bar-row .n { width: 46px; color: var(--muted); flex: none; }
.bar-row .track { flex: 1; height: 6px; border-radius: 3px; background: #EAECEE; overflow: hidden; }
.bar-row .fill { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.bar-row .v { width: 42px; text-align: right; font-variant-numeric: tabular-nums; flex: none; }

#map { width: 100%; height: 420px; border-radius: var(--radius); background: #EAECEE; }
.map-fallback { padding: 22px; text-align: center; color: var(--muted); font-size: 12.5px; }

.toast { position: fixed; right: 24px; bottom: 24px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); font-size: 12.5px; z-index: 90; opacity: 0; transform: translateY(8px); transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- 登录与账号 ---------- */
.login-wrap { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px;
  background: var(--ink); }
.login-wrap[hidden] { display: none; }
.login-card { width: 100%; max-width: 372px; background: var(--card); border-radius: var(--radius); padding: 30px 30px 24px;
  border: 1px solid rgba(255, 255, 255, .08); }
.login-brand { margin-bottom: 22px; }
.login-brand .kicker { font-size: 10px; letter-spacing: 2.4px; color: var(--accent); font-weight: 600; }
.login-brand h2 { font-size: 17px; font-weight: 500; margin-top: 6px; letter-spacing: -.2px; }
.login-brand .sub { font-size: 12px; color: var(--faint); margin-top: 5px; }
.login-card .field { display: block; }
.login-card .field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.login-btn { width: 100%; justify-content: center; margin-top: 20px; padding: 9px 13px; }
.login-err { margin-top: 14px; font-size: 12.5px; color: var(--red); background: var(--red-bg); border-left: 2px solid var(--red);
  border-radius: var(--radius-sm); padding: 8px 11px; }
.login-err[hidden] { display: none; }
.login-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--faint); line-height: 1.7; }

.sidebar .foot .who { border: 1px solid var(--ink-line); border-radius: var(--radius-sm); padding: 9px 10px; margin-bottom: 12px; }
.who-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.who-name { font-size: 12px; color: var(--ink-text); font-weight: 500; }
.who-sub { font-size: 10.5px; color: var(--ink-faint) !important; margin-top: 3px; word-break: break-all; line-height: 1.5; }
.who-acts { display: flex; gap: 5px; margin-top: 9px; }
.sidebar .foot .who .btn { flex: 1; justify-content: center; padding: 4px 6px; font-size: 11px;
  background: rgba(255, 255, 255, .07); border-color: var(--ink-line); color: var(--ink-text); }
.sidebar .foot .who .btn:hover { background: rgba(255, 255, 255, .13); color: #fff; }
.sidebar .foot .who .btn.ghost { color: var(--ink-faint); }
.foot-stamp { font-size: 11px; color: var(--ink-faint); line-height: 1.6; }

.readonly-note { margin-bottom: 14px; }

@media (max-width: 1080px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { width: 62px; }
  .sidebar-inner { width: 62px; padding: 14px 8px; }
  .sidebar .brand h1, .sidebar .brand .sub, .nav-item span.txt, .nav-label, .sidebar .foot, .brand .kicker { display: none; }
  .brand { border-bottom: none; margin-bottom: 6px; padding: 0 0 6px; }
  .nav-item { justify-content: center; padding: 10px 0; }
  .nav-toggle { display: none; }
  .main { padding: 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
