:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #15171c;
  --ink-2: #5b6070;
  --ink-3: #9aa0ae;
  --line: #e6e8ee;
  --accent: #2f6bff;
  --accent-soft: #eaf0ff;
  --side: #121419;
  --side-2: #1d2027;
  --green: #1e9e63;
  --green-soft: #e6f5ec;
  --red: #d9382e;
  --red-soft: #fbeae9;
  --amber: #c9780a;
  --amber-soft: #fdf1de;
  --gray-soft: #eef0f3;
  --radius: 12px;
  --font: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", "Noto Sans SC", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); letter-spacing: 0.02em; }
.muted { color: var(--ink-3); }
.sub { color: var(--ink-2); }
.row { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--side);
}
.login-card {
  width: 380px;
  padding: 44px 40px 34px;
  background: var(--panel);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  text-align: center;
}
.login-card h1 { font-size: 20px; font-weight: 500; margin: 0 0 8px; }
.login-card .lead { margin: 0 0 26px; color: var(--ink-2); font-size: 13px; }
.login-card .btn { margin-top: 22px; width: 100%; justify-content: center; }
.login-input { height: 44px; text-align: center; }
.login-input + .login-input { margin-top: 12px; }
.login-hint { margin: 18px 0 0; font-size: 12px; color: var(--ink-3); line-height: 1.6; }
.icp { margin: 14px 0 0; font-size: 11px; color: var(--ink-3); text-align: center; }
.icp a { color: var(--ink-3); }
.icp a:hover { color: var(--ink-2); }
.sidebar .icp-sm { padding: 10px 8px 0; font-size: 11px; color: #6b7180; }
.sidebar .icp-sm a { color: inherit; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 34px; height: 32px; object-fit: contain; flex: none; display: block; }
.login-logo { width: 104px; height: auto; display: block; margin: 0 auto 20px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent);
  display: grid; place-items: center;
  color: #fff; font-weight: 500; font-size: 13px; letter-spacing: 0.04em;
}
.brand .name { font-size: 15px; font-weight: 500; line-height: 1.3; }
.brand .tag { font-size: 12px; color: var(--ink-3); }

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--side);
  color: #d9dce4;
  padding: 24px 16px 20px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 0 8px 24px; }
.sidebar .brand .name { color: #fff; }
.sidebar .brand .tag { color: #7f8595; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: #b8bdca; font-size: 14px;
}
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.active { background: var(--side-2); color: #fff; }
.nav a.active .dot { background: var(--accent); }
.nav .dot { width: 6px; height: 6px; border-radius: 50%; background: #4a4f5c; }
.sidebar .foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid #242830; font-size: 12px; color: #7f8595; display: flex; align-items: center; justify-content: space-between; }
.sidebar .foot button { background: none; border: 0; color: #b8bdca; cursor: pointer; font-size: 12px; padding: 4px; }
.sidebar .foot button:hover { color: #fff; }

.main { padding: 32px 40px 64px; max-width: 1480px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; font-weight: 500; margin: 0; letter-spacing: 0.01em; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 卡片与统计 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; min-width: 0; }
.card.pad { padding: 20px 22px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15px; font-weight: 500; margin: 0; }
.card-head .sub { font-size: 13px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat { padding: 20px 22px; }
.stat .label { color: var(--ink-2); font-size: 13px; }
.stat .value { font-size: 30px; font-weight: 500; line-height: 1.2; margin-top: 6px; letter-spacing: -0.01em; }
.stat .hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.stat.alert .value { color: var(--red); }
.two-col { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.two-col .card + .card { margin-top: 0; }
.two-col + .card, .card + .two-col { margin-top: 16px; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-weight: 500; color: var(--ink-2);
  font-size: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: #fafbfc; white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbfc; }

/* ---------- 工作台看板 ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden; transition: box-shadow 0.2s ease;
}
.kpi:hover { box-shadow: 0 6px 20px rgba(18, 20, 25, 0.06); }
.kpi::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: 0.85; }
.kpi.alert::after { background: var(--red); }
.kpi-k { font-size: 12px; color: var(--ink-3); letter-spacing: 0.02em; }
.kpi-v { font-size: 26px; font-weight: 600; line-height: 1.25; margin-top: 6px; letter-spacing: -0.01em; }
.kpi-v span { font-size: 12px; font-weight: 400; color: var(--ink-3); margin-left: 6px; letter-spacing: 0; }
.kpi-h { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

.board-wrap { padding: 16px 20px 18px; }
.board-wrap .card-head { padding: 0 0 14px; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 14px; }
.room-card {
  display: block; text-align: left; width: 100%; cursor: pointer;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 12px; padding: 14px 16px 12px; font: inherit;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.room-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(18, 20, 25, 0.09); border-color: #d9e2f2; }
.room-card.warn { border-left-color: var(--amber); }
.room-card.danger { border-left-color: var(--red); background: linear-gradient(180deg, #fffdfd 0%, #fffafa 100%); }
.rc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.rc-room { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
.rc-room span { font-size: 12px; font-weight: 400; color: var(--ink-3); margin-left: 3px; }
.rc-due { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: #f2f4f8; color: var(--ink-2); white-space: nowrap; }
.rc-due.soon { background: #eef4ff; color: #2c5cc5; }
.rc-due.warn { background: #fff5e6; color: #a86508; }
.rc-due.danger { background: #fdeceb; color: #c23a2f; }
.rc-dates { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.rc-dates i { color: var(--ink-3); font-style: normal; }
.rc-dates em { margin-left: auto; font-style: normal; color: var(--ink-3); font-size: 11px; }
.rc-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.rc-cat { font-size: 11px; color: var(--ink-2); background: #f4f6fa; border-radius: 6px; padding: 2px 7px; }
.rc-cat b { font-weight: 600; margin-left: 4px; color: var(--ink); }
.rc-cats .muted { color: var(--ink-3); }
.rc-codes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; max-height: 54px; overflow: hidden; }
.rc-dev {
  font-size: 11px; color: var(--ink-2); background: #f7f8fb; border: 1px solid #eef0f5;
  border-radius: 4px; padding: 1px 6px; max-width: 140px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rc-dev.more { color: var(--ink-3); }
.rc-dev.muted { color: var(--ink-3); }
.rc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--ink-3); }
.rc-link { color: var(--accent); opacity: 0; transition: opacity 0.16s ease; }
.room-card:hover .rc-link { opacity: 1; }
.board-empty { grid-column: 1 / -1; text-align: center; padding: 46px 20px; }
.be-title { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.be-sub { font-size: 13px; color: var(--ink-3); margin-bottom: 16px; line-height: 1.7; }

/* ---------- 历史订单 ---------- */
.hist-head { flex-wrap: wrap; gap: 12px; }
.hist-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hist-tools .input { width: auto; }
.hist-tools #hist-q { width: 230px; }
.hist-tools select.input { width: 130px; }
.hist-assets { max-width: 520px; }
.hist-assets .rc-dev { max-width: 170px; }
.rc-dev.off { color: var(--ink-3); text-decoration: line-through; background: #f3f4f7; }
.hist-more { text-align: center; padding: 14px 0 2px; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.table tr.dirty td { background: var(--amber-soft); }
.table tr.dirty .input { border-color: #e9c48b; background: #fffdf7; }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .code { font-family: var(--mono); font-size: 13px; }
.table .act { display: flex; gap: 6px; justify-content: flex-end; }
.table td.empty-cell { text-align: center; color: var(--ink-3); padding: 48px 16px; }

/* ---------- 标签与按钮 ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; line-height: 1.6; white-space: nowrap; }
.s-green { background: var(--green-soft); color: var(--green); }
.s-blue { background: var(--accent-soft); color: var(--accent); }
.s-red { background: var(--red-soft); color: var(--red); }
.s-amber { background: var(--amber-soft); color: var(--amber); }
.s-gray { background: var(--gray-soft); color: var(--ink-2); }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font-size: 14px; font-family: var(--font);
  cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: #cfd4de; background: #fafbfc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2559d9; border-color: #2559d9; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: #f0c4c0; }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 筛选与表单 ---------- */
.filters { display: flex; gap: 10px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.input, select.input {
  height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); font-size: 14px; font-family: var(--font); outline: none; min-width: 150px;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.w { min-width: 240px; }
.input.sm { height: 32px; font-size: 13px; min-width: 130px; padding: 0 10px; }
textarea.input { height: auto; padding: 10px 12px; line-height: 1.7; resize: vertical; font-family: var(--mono); font-size: 13px; }
input[type="file"].input { padding: 6px 10px; height: 38px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--ink-2); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 4px 10px; border-radius: 6px; background: var(--gray-soft); font-size: 12px; color: var(--ink-2); }

/* ---------- 弹层 ---------- */
.modal-layer { position: fixed; inset: 0; z-index: 60; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(18, 20, 25, 0.45);
  display: grid; grid-template-columns: minmax(0, 1fr); place-items: center;
  z-index: 50; padding: 24px;
}
.modal { width: 640px; max-width: 100%; max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: var(--panel); border-radius: 14px; }
.modal.wide { width: 820px; }
.manage-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 14px; }
.manage-row .field { flex: 1 1 220px; min-width: 0; margin: 0; }
.manage-row .field .input { width: 100%; }
.manage-row .btn { flex: none; }
.manage-row > .input { flex: 0 0 170px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 500; }
.modal-head .x { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 0 4px; }
.modal-head .x:hover { color: var(--ink); }
.modal form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.modal-body { flex: 1 1 auto; min-height: 0; padding: 22px 24px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 16px; margin-bottom: 18px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; }
.list .item.warn { border-color: #f3c7c3; background: var(--red-soft); }
.list .item.extra { border-color: #f6dcae; background: var(--amber-soft); }
.section-title { font-size: 13px; color: var(--ink-2); margin: 18px 0 10px; font-weight: 500; }

#toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast-msg { background: var(--side); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); animation: rise 0.2s ease-out; }
.toast-msg.err { background: var(--red); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .stat-grid, .two-col, .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 20px; }
}
