/* ============================================================
 * style.css — 深色金融终端风格
 * ============================================================ */
:root {
  --bg: #0a0e15;
  --bg-glow1: rgba(232, 180, 84, .05);
  --bg-glow2: rgba(91, 155, 255, .05);
  --panel: #111a28;
  --panel-2: #0e1622;
  --border: #1d2a3d;
  --border-2: #26364f;
  --text: #dfe8f5;
  --text-dim: #9fb0c8;
  --muted: #7d8aa0;
  --gold: #e8b454;
  --gold-dim: #b98f3e;
  --green: #24d18f;
  --blue: #5b9bff;
  --red: #ff6b6b;
  --mono: "Cascadia Mono", Consolas, "SF Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1100px 520px at 85% -8%, var(--bg-glow1), transparent 60%),
    radial-gradient(900px 480px at -5% 110%, var(--bg-glow2), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px;
  background: rgba(10, 14, 21, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand .logo { color: var(--gold); font-size: 15px; }
.brand h1 { font-size: 17px; letter-spacing: .5px; white-space: nowrap; }
.brand-sub {
  font-size: 10px; letter-spacing: 2.5px; color: var(--gold-dim);
  font-family: var(--mono); white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.today-wrap {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.today-wrap input[type="date"] { width: 138px; }

/* ---------------- 按钮 / 输入 ---------------- */
.btn {
  appearance: none; border: 1px solid var(--border-2); border-radius: 6px;
  background: #142032; color: var(--text);
  font-size: 12.5px; padding: 6px 12px; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); background: #182740; }
.btn-gold { border-color: rgba(232, 180, 84, .55); color: var(--gold); background: rgba(232, 180, 84, .08); }
.btn-gold:hover { background: rgba(232, 180, 84, .16); border-color: var(--gold); }
.btn-blue { border-color: rgba(91, 155, 255, .55); color: var(--blue); background: rgba(91, 155, 255, .08); }
.btn-blue:hover { background: rgba(91, 155, 255, .16); border-color: var(--blue); }
.btn-danger { border-color: rgba(255, 107, 107, .5); color: var(--red); background: rgba(255, 107, 107, .06); }
.btn-danger:hover { background: rgba(255, 107, 107, .14); }

.mini {
  appearance: none; border: 1px solid var(--border-2); border-radius: 5px;
  background: #16233a; color: var(--text-dim);
  font-size: 11px; padding: 3px 8px; cursor: pointer; white-space: nowrap;
}
.mini:hover { border-color: var(--blue); color: var(--blue); }

input[type="date"], input[type="number"], select {
  appearance: none; width: 100%;
  background: #0c1522; color: var(--text);
  border: 1px solid var(--border-2); border-radius: 6px;
  padding: 6px 8px; font-size: 13px;
  font-family: inherit;
  outline: none;
}
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.7); cursor: pointer; }
input:focus { border-color: var(--gold-dim); box-shadow: 0 0 0 2px rgba(232, 180, 84, .12); }
input:disabled { opacity: .45; }

/* ---------------- 布局 ---------------- */
.layout {
  display: grid;
  grid-template-columns: 372px minmax(0, 1fr);
  gap: 16px;
  max-width: 1560px;
  margin: 0 auto;
  padding: 16px 20px 8px;
  align-items: start;
}
.side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.content { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.card h2 {
  font-size: 13.5px; letter-spacing: .4px;
  padding-bottom: 9px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.h2-sub { font-size: 11px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.h2-sub b { color: var(--text-dim); font-weight: 600; font-family: var(--mono); font-size: 11px; }

/* ---------------- 表单字段 ---------------- */
.field { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; margin-bottom: 10px; align-items: center; }
.field label { grid-column: 1 / -1; font-size: 12px; color: var(--text-dim); }
.field input, .field select { grid-column: 1; }
.hint { font-size: 11px; color: var(--muted); line-height: 1.5; }
.hint-strong { color: var(--gold); margin-top: 4px; }
.field .hint { grid-column: 1 / -1; }

.switch { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--text-dim); cursor: pointer; }
.switch input { margin-top: 2px; accent-color: var(--gold); }
.switch span { line-height: 1.5; }
.lpr-note { margin-top: 10px; font-size: 11px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 8px; }

/* ---------------- 事件时间线 ---------------- */
.ev-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.ev-actions .btn { flex: 1; }
.event-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow: auto; }
.ev-empty { color: var(--muted); font-size: 12px; padding: 10px 2px; }
.ev-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
}
.ev-item:last-child { border-bottom: none; }
.ev-badge {
  flex: 0 0 auto; width: 34px; text-align: center;
  font-size: 10px; font-family: var(--mono); font-weight: 700;
  border-radius: 4px; padding: 3px 0;
}
.ev-badge-lpr { color: var(--blue); background: rgba(91, 155, 255, .12); border: 1px solid rgba(91, 155, 255, .35); }
.ev-badge-prepay { color: var(--green); background: rgba(36, 209, 143, .1); border: 1px solid rgba(36, 209, 143, .3); }
.ev-main { flex: 1; min-width: 0; }
.ev-main b { font-family: var(--mono); font-weight: 600; color: var(--text); }
.ev-main small { display: block; color: var(--muted); font-size: 11px; }
.ev-warn { color: #ffb020; font-size: 11px; cursor: help; margin: 0 2px; }
.ev-ops { display: flex; gap: 4px; }
.ev-ops button {
  appearance: none; border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 12px;
  width: 24px; height: 24px; border-radius: 5px; line-height: 1;
}
.ev-ops button:hover { color: var(--gold); border-color: var(--border-2); background: #16233a; }

/* ---------------- 统计卡片 ---------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.stat {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 0;
}
.stat-title { font-size: 11.5px; color: var(--muted); letter-spacing: .3px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stat-value { font-size: 19px; font-weight: 600; font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.stat-gold { border-color: rgba(232, 180, 84, .45); background: linear-gradient(180deg, rgba(232, 180, 84, .1), rgba(232, 180, 84, .02)); }
.stat-gold .stat-value { color: var(--gold); }
.stat-big .stat-value { font-size: 23px; }
.stat-green .stat-value { color: var(--green); }
.stat-wide { grid-column: span 2; }
.tag {
  font-size: 10.5px; font-family: var(--mono);
  color: var(--gold); border: 1px solid rgba(232, 180, 84, .4);
  border-radius: 4px; padding: 1px 6px;
}
.since-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: 10px; margin-top: 4px; }
.since-grid > div { display: flex; flex-direction: column; gap: 2px; }
.since-num { font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.since-lbl { font-size: 11px; color: var(--muted); }

/* ---------------- 图表 ---------------- */
.chart { width: 100%; height: 340px; }

/* ---------------- 表格 ---------------- */
.tbl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tbl-head-2 { margin-top: 16px; border-top: 1px dashed var(--border); padding-top: 12px; }
.tbl-head .hint { margin: 0; }
.tbl-scroll { max-height: 430px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: #101a2a;
  color: var(--muted); font-weight: 500; text-align: left;
  padding: 8px 12px; border-bottom: 1px solid var(--border-2);
  font-size: 11.5px; letter-spacing: .3px; white-space: nowrap;
}
th.num, td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.th-idx { width: 52px; }
.th-op { width: 44px; }
tbody td { padding: 6px 12px; border-bottom: 1px solid rgba(29, 42, 61, .6); white-space: nowrap; }
tbody tr:hover { background: rgba(91, 155, 255, .05); }
.td-idx { color: var(--muted); font-family: var(--mono); }
.td-date { font-family: var(--mono); color: var(--text-dim); }
.td-total { color: var(--text); }
.td-remain { color: var(--text-dim); }
.td-op { text-align: center; }
.tbl-empty { text-align: center; color: var(--muted); padding: 18px 0; }

.row-current { background: rgba(232, 180, 84, .09); }
.row-current td { border-bottom-color: rgba(232, 180, 84, .35); }
.row-current .td-idx { color: var(--gold); }
.row-current:hover { background: rgba(232, 180, 84, .14); }
.row-final .td-remain { color: var(--green); }

.row-event td { background: rgba(91, 155, 255, .05); padding: 6px 12px; }
.ev-line { font-size: 11.5px; }
.ev-line-lpr { color: var(--blue); }
.ev-line-prepay { color: var(--green); }
.ev-date { float: right; color: var(--muted); font-family: var(--mono); font-size: 11px; }

.adj-dot { color: var(--gold); font-size: 10px; cursor: help; }
.adj-btn { padding: 2px 6px; font-size: 11px; }
.adj-btn:hover { color: var(--gold); border-color: var(--gold-dim); }

/* ---------------- 对话框 ---------------- */
dialog {
  border: 1px solid var(--border-2); border-radius: 12px;
  background: linear-gradient(180deg, #121c2c, #0e1622);
  color: var(--text); padding: 0; width: min(480px, calc(100vw - 32px));
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
}
dialog::backdrop { background: rgba(4, 7, 12, .68); backdrop-filter: blur(2px); }
.dlg-body { padding: 18px 20px; }
.dlg-body h3 { font-size: 15px; margin-bottom: 14px; }
fieldset { border: none; margin: 0; padding: 0; }
fieldset[hidden] { display: none !important; }
.seg { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; font-size: 12.5px; color: var(--text-dim); }
.seg-col { flex-direction: column; gap: 8px; }
.seg label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.seg input { accent-color: var(--gold); }
.chk { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; margin-bottom: 10px; }
.chk input { accent-color: var(--gold); }
.mini-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.dlg-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; align-items: center; }
.dlg-spacer { flex: 1; }

/* ---------------- 页脚 ---------------- */
.footer {
  max-width: 1560px; margin: 8px auto 0; padding: 14px 20px 22px;
  color: var(--muted); font-size: 11.5px; line-height: 1.7;
}
.footer b { color: var(--text-dim); }

/* ---------------- 滚动条 ---------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #22304a; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2e415f; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart { height: 300px; }
}
@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .brand-sub { display: none; }
  .stats { grid-template-columns: 1fr; }
  .stat-wide { grid-column: span 1; }
  .stat-big .stat-value { font-size: 20px; }
  .layout { padding: 12px 12px 6px; }
}
