:root {
  --bg: #0e1116;
  --panel: #161a22;
  --panel2: #1d222c;
  --line: #272d39;
  --line2: #333b49;
  --text: #e7eaf0;
  --muted: #8a92a3;
  --brand: #e3564d;
  --brand-d: #c0453d;
  --up: #f0544c;      /* 盈 = 红（A 股习惯） */
  --down: #2fbf71;    /* 亏 = 绿 */
  --warn: #e0a33e;
  --info: #4a9eff;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* hidden 属性必须压过任何 display 声明。
   浏览器默认的 [hidden]{display:none} 是元素选择器级别，
   .login-wrap{display:flex} 这类类选择器会把它盖掉 ——
   结果是 JS 里 el.hidden = true 完全无效：登录成功后登录层仍铺满整屏，
   看起来像"点了按钮没反应"。用 !important 一次兜住全部。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- 登录 */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 500px at 50% -10%, #1d2530 0%, var(--bg) 60%);
}
.login-card {
  width: min(92vw, 360px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.login-card h1 {
  font-size: 20px;
  margin: 0 0 4px;
  letter-spacing: .5px;
}
.login-card p { color: var(--muted); font-size: 13px; margin: 0 0 20px; }

/* ---------------------------------------------------------------- 骨架 */

header.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  letter-spacing: .4px;
  font-size: 15px;
}
.brand .dot {
  width: 22px; height: 22px;
  border-radius: 7px;
  background: linear-gradient(140deg, var(--brand), #ff8a7a);
  box-shadow: 0 3px 10px rgba(227, 86, 77, .35);
}
.brand small { color: var(--muted); font-weight: 500; letter-spacing: 0; }
.spacer { flex: 1; }

.pill {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line2);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.pill.ok { color: #7fd6a3; border-color: #2c5a41; background: #14241b; }

nav.tabs {
  display: flex;
  gap: 2px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 47px;
  z-index: 29;
  overflow-x: auto;
}
nav.tabs button {
  background: none;
  border: 0;
  padding: 11px 14px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
nav.tabs button.active { color: var(--text); border-bottom-color: var(--brand); }
nav.tabs button:hover { color: var(--text); }

main { padding: 16px 18px 60px; max-width: 1500px; margin: 0 auto; }

/* ---------------------------------------------------------------- 统计卡 */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.card .k { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.card .v { font-size: 20px; font-weight: 650; letter-spacing: .3px; font-variant-numeric: tabular-nums; }
.card .s { color: var(--muted); font-size: 11px; margin-top: 4px; }
.card.hl { border-color: #3a2a2a; background: linear-gradient(180deg, #1b2029, #171b22); }

/* ---------------------------------------------------------------- 工具条 */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.field { display: flex; align-items: center; gap: 6px; }
.field label { color: var(--muted); font-size: 12px; }

input[type="text"], input[type="password"], input[type="number"],
input[type="date"], select, textarea {
  background: var(--panel2);
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 7px 10px;
  outline: none;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
input[type="date"] { color-scheme: dark; }

.btn {
  background: var(--panel2);
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 7px 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: .15s;
}
.btn:hover { border-color: #4a5364; background: #232936; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-d); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.danger { color: #ff8b84; border-color: #4a2b2b; }

/* ---------------------------------------------------------------- 表格 */

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 300px);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: #1b202a;
  color: var(--muted);
  font-weight: 500;
  text-align: right;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th.l, tbody td.l { text-align: left; }
thead th:hover { color: var(--text); }
tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #1f242e;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
tbody tr:hover { background: #1a1f29; }
tbody tr.review td:first-child { box-shadow: inset 2px 0 0 var(--warn); }
.code { font-weight: 600; letter-spacing: .4px; }

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line2);
  color: var(--muted);
}
.tag.B { color: #8fb4ff; border-color: #2f4270; background: #17203a; }
.tag.S { color: #e0a33e; border-color: #5a4520; background: #2a2214; }
.tag.R { color: #d58bff; border-color: #4a2f66; background: #241a33; }
.tag.ipo { margin-left: 6px; color: #7fd3a0; border-color: #27543c; background: #12281d; }

.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.st i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.st.complete i { background: var(--info); }
.st.open i { background: var(--muted); }
.st.missing i { background: var(--warn); }
.st.missing { color: var(--warn); }

.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--muted); }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- 抽屉 */

.overlay {
  position: fixed; inset: 0;
  background: rgba(5, 7, 10, .6);
  backdrop-filter: blur(2px);
  z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(94vw, 420px);
  background: var(--panel);
  border-left: 1px solid var(--line);
  z-index: 41;
  display: flex;
  flex-direction: column;
  box-shadow: -20px 0 50px rgba(0, 0, 0, .4);
  animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.drawer header h2 { font-size: 15px; margin: 0; }
.drawer .body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.drawer footer {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end;
}
.form-row { margin-bottom: 12px; }
.form-row > label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.form-row input, .form-row textarea { width: 100%; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1;
  background: var(--panel2);
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
}
.seg button.on { border-color: var(--brand); background: #2b1c1c; color: #ffb3ad; font-weight: 600; }

.preview {
  background: var(--panel2);
  border: 1px dashed var(--line2);
  border-radius: 10px;
  padding: 12px;
  margin-top: 4px;
  font-size: 13px;
}
.preview .row { display: flex; justify-content: space-between; padding: 3px 0; }
.preview .row span:first-child { color: var(--muted); }
.preview .big { font-size: 18px; font-weight: 650; }
.hint { color: var(--muted); font-size: 11px; margin-top: 4px; line-height: 1.5; }

/* ---------------------------------------------------------------- 其它页 */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.panel h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.panel h3 small { color: var(--muted); font-weight: 400; margin-left: 6px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; align-items: center; }
.kv label { color: var(--muted); font-size: 12px; }
.kv input { width: 100%; }

.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 74px 1fr 90px; gap: 10px; align-items: center; font-size: 12px; }
.bar-track { height: 18px; background: #1b202a; border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, #4a2a2a, var(--up)); }
.bar-fill.neg { background: linear-gradient(90deg, #1d3a2b, var(--down)); }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; }

.drop {
  border: 1px dashed var(--line2);
  border-radius: 12px;
  padding: 26px;
  text-align: center;
  color: var(--muted);
  transition: .15s;
}
.drop.over { border-color: var(--brand); background: #1c1519; color: var(--text); }

.report { font-size: 13px; }
.report table td, .report table th { text-align: left; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #232a36;
  border: 1px solid var(--line2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: .22s;
  z-index: 90;
  font-size: 13px;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: #6b2f2f; background: #2a1a1a; color: #ffb0a9; }

@media (max-width: 760px) {
  main { padding: 12px 10px 50px; }
  .table-wrap { max-height: none; }
  .hide-sm { display: none; }
  .cards { grid-template-columns: 1fr 1fr; }
  .card .v { font-size: 17px; }
}
