:root {
  --bg: #09090b;
  --panel: #131215;
  --panel-2: #1b171a;
  --text: #f4f1ed;
  --muted: #8f8985;
  --orange: #ff6b1a;
  --orange-soft: #ff9a62;
  --line: rgba(255, 107, 26, .25);
  --line-strong: rgba(255, 107, 26, .55);
  --danger: #ff8177;
  --ok: #65d8a2;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background:
    radial-gradient(circle at 50% -22%, rgba(121, 45, 13, .3), transparent 40%),
    linear-gradient(rgba(255, 107, 26, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 107, 26, .025) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 44px 44px, 44px 44px, auto;
  color: var(--text);
  font-family: "IBM Plex Sans", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--orange-soft); text-decoration: none; }
.hidden { display: none !important; }
.muted, .subtle { color: var(--muted); font-size: 11px; line-height: 1.65; }
.error { color: var(--danger); font-size: 12px; line-height: 1.55; min-height: 18px; margin-top: 8px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: min(420px, 100%); padding: 30px; border: 1px solid var(--line-strong); border-radius: 14px;
  background: linear-gradient(180deg, rgba(27, 23, 25, .98), rgba(16, 15, 17, .99));
  box-shadow: 0 24px 90px rgba(0, 0, 0, .55);
}
.login-brand, .brand { font-size: 22px; font-weight: 650; letter-spacing: .04em; }
.login-brand span, .brand span { color: var(--orange); }
.login-brand b { color: var(--orange-soft); margin: 0 4px; font-weight: 400; }
.login-card .subtle { margin: 9px 0 22px; }
.login-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 15px; font-size: 11px; }

label { display: block; color: #aaa49f; font-size: 11px; margin: 0 0 7px; }
input, textarea, select {
  width: 100%; color: var(--text); background: #100f11; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 11px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: rgba(255, 107, 26, .72); }
.login-card input { margin-bottom: 13px; }

.btn {
  border: 1px solid rgba(255, 107, 26, .62); background: transparent; color: var(--orange-soft);
  border-radius: 7px; padding: 8px 14px; transition: .15s;
}
.btn:hover { background: rgba(255, 107, 26, .1); color: #fff; }
.btn:disabled { opacity: .48; cursor: wait; }
.btn.primary { background: rgba(255, 107, 26, .13); color: #ffd5bd; }
.btn.danger { border-color: rgba(255, 129, 119, .45); color: var(--danger); }
.btn.full { width: 100%; margin-top: 4px; }

.app { min-height: 100vh; padding: 12px 18px 18px; }
.top { height: 50px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255, 255, 255, .06); margin-bottom: 12px; }
.top-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.snapshot-badge { color: var(--orange-soft); border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; font-size: 10px; }
.snapshot-badge.ready { color: var(--ok); border-color: rgba(101, 216, 162, .3); }

.layout { display: grid; grid-template-columns: minmax(240px, .82fr) minmax(390px, 1.4fr) minmax(260px, .9fr); gap: 12px; align-items: start; }
.column { display: grid; gap: 12px; min-width: 0; }
.panel {
  background: linear-gradient(180deg, rgba(24, 21, 25, .97), rgba(17, 16, 18, .99));
  border: 1px solid var(--line); border-radius: 12px; padding: 17px; box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
}
.panel-head { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; letter-spacing: .07em; margin-bottom: 14px; }
.panel-head:before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 14px rgba(255, 107, 26, .7); flex: none; }
.panel-head:after { content: ""; height: 1px; flex: 1; background: linear-gradient(90deg, rgba(255, 107, 26, .68), transparent); }
.panel-head .badge { order: 5; }
.badge {
  display: inline-block; flex: none; border: 1px solid rgba(255, 107, 26, .28); border-radius: 999px;
  padding: 2px 7px; color: var(--orange-soft); background: rgba(255, 107, 26, .05);
  font-size: 8px; font-weight: 400; letter-spacing: .04em; white-space: nowrap;
}
.kicker, .subhead { color: var(--orange-soft); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.subhead { margin: 18px 0 8px; }
.metric-row { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; }
.metric { font-size: 42px; line-height: 1; color: #fff; font-variant-numeric: tabular-nums; }
.point-rules { display: grid; gap: 5px; color: var(--muted); font-size: 10px; text-align: right; }
.point-rules span { border-bottom: 1px solid rgba(255, 107, 26, .2); padding-bottom: 4px; }
.ledger { max-height: 238px; overflow: auto; scrollbar-width: thin; scrollbar-color: #57331f transparent; }
.ledger-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, .055); font-size: 10px; }
.ledger-row .delta { color: var(--ok); font-variant-numeric: tabular-nums; }
.ledger-row .delta.negative { color: var(--danger); }
.ledger-row .reason { color: #d8d3ce; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-row time { color: var(--muted); }

.status-chip { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; color: var(--orange-soft); font-size: 10px; margin-bottom: 10px; }
.status-chip.active { color: var(--ok); border-color: rgba(101, 216, 162, .35); }
.notice { border-left: 2px solid var(--orange); background: rgba(255, 107, 26, .055); color: #cfc6c0; padding: 9px 10px; font-size: 10px; line-height: 1.65; margin: 12px 0; }

.run-grid { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
.run-asof { font-size: 28px; margin: 5px 0 4px; font-variant-numeric: tabular-nums; }
.run-panel .btn { padding: 12px 15px; }
.report-list { display: grid; gap: 8px; }
.report-row { border: 1px solid rgba(255, 107, 26, .18); background: rgba(31, 26, 29, .65); border-radius: 9px; padding: 11px 12px; }
.report-row button { width: 100%; text-align: left; background: none; border: 0; color: inherit; padding: 0; }
.report-row .report-title { font-size: 12px; color: #eee8e3; line-height: 1.5; margin-bottom: 5px; }
.report-row .report-meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 9px; }
.empty { border: 1px dashed rgba(255, 107, 26, .25); border-radius: 9px; padding: 14px; color: var(--muted); font-size: 11px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .wide { grid-column: 1 / -1; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: grid; grid-template-columns: 1fr auto auto; gap: 7px; }
.inline-form input { min-width: 0; }

.report-headline { font-size: 22px; line-height: 1.35; margin: 4px 0 10px; }
.report-summary { color: #d8d3ce; font-size: 12px; line-height: 1.75; white-space: pre-wrap; }
.report-meta-line { color: var(--muted); font-size: 9px; margin: 8px 0 16px; letter-spacing: .03em; }
.report-section { margin-top: 18px; border-top: 1px solid rgba(255, 255, 255, .06); padding-top: 14px; }
.report-section h3 { margin: 0 0 10px; color: var(--orange-soft); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.report-item { border-left: 2px solid rgba(255, 107, 26, .38); background: rgba(255, 255, 255, .022); padding: 9px 11px; margin: 8px 0; }
.report-item p { margin: 0; color: #ded8d3; font-size: 11px; line-height: 1.7; }
.report-item ul, .report-section ul { margin: 7px 0 0; padding-left: 18px; color: #d8d3ce; font-size: 11px; line-height: 1.7; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.tag { color: var(--orange-soft); border: 1px solid rgba(255, 107, 26, .27); background: rgba(255, 107, 26, .05); border-radius: 999px; padding: 2px 7px; font-size: 8px; }
.tag.risk { color: #ffb38d; }
.tag.unknown { color: var(--muted); border-color: rgba(255, 255, 255, .12); }
.evidence-list { font-size: 9px; color: var(--muted); line-height: 1.6; }
.evidence-list code { color: var(--orange-soft); }

.admin-section { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 17px; background: rgba(17, 16, 18, .96); }
.admin-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.admin-tools select { width: 150px; }
.admin-list { display: grid; gap: 8px; }
.admin-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; border: 1px solid rgba(255, 107, 26, .17); border-radius: 9px; padding: 10px 12px; }
.admin-row .who { font-size: 11px; color: #e2dcd7; }
.admin-row .detail { font-size: 9px; color: var(--muted); margin-top: 4px; }

.toast { position: fixed; right: 18px; bottom: 18px; max-width: min(420px, calc(100vw - 36px)); padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: 9px; background: rgba(20, 17, 19, .98); color: #eee8e3; font-size: 11px; line-height: 1.55; box-shadow: 0 18px 60px rgba(0, 0, 0, .5); z-index: 20; }

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr 1fr; }
  .column.wide { grid-column: 1 / -1; grid-row: 1; }
}
@media (max-width: 720px) {
  .app { padding: 10px; }
  .top { height: auto; min-height: 58px; align-items: flex-start; gap: 10px; padding: 8px 0; }
  .top-actions { max-width: 65%; }
  .layout { grid-template-columns: 1fr; }
  .column.wide { grid-column: auto; grid-row: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .run-grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .admin-row { grid-template-columns: 1fr; }
}
