:root {
  --bg: #f4f5f7; --panel: #ffffff; --panel2: #f7f8fa; --field: #ffffff; --hover: #fafbfc;
  --line: #e4e7ec; --line2: #d3d8e0;
  --accent: #34528c; --accent-d: #294271; --accent-text: #34528c; --accent-fg: #ffffff; --accent-soft: #eef2f9;
  --green: #0a7d4f; --gold: #b06f12; --red: #c0334a;
  --tag-on-bg: rgba(10, 125, 79, .10); --tag-on-bd: rgba(10, 125, 79, .22);
  --text: #1a2233; --muted: #667085;
  --toast-bg: #1a2233; --toast-fg: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-card: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}
:root[data-theme="dark"] {
  --bg: #0f131c; --panel: #181d29; --panel2: #1f2532; --field: #10141d; --hover: #1f2634;
  --line: #2a3140; --line2: #3a4255;
  --accent: #3f63b8; --accent-d: #34509a; --accent-text: #8aa9e8; --accent-fg: #ffffff; --accent-soft: #1c2740;
  --green: #3ddc97; --gold: #e0a93c; --red: #ff6b81;
  --tag-on-bg: rgba(61, 220, 151, .12); --tag-on-bd: rgba(61, 220, 151, .28);
  --text: #e6eaf2; --muted: #8b93a7;
  --toast-bg: #2b3346; --toast-fg: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; min-height: 100vh;
}
.boot { text-align: center; padding-top: 40vh; color: var(--muted); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font: inherit; cursor: pointer; border: 1px solid var(--accent); border-radius: 7px; padding: 8px 14px; font-weight: 600;
  background: var(--accent); color: var(--accent-fg); transition: background .14s, border-color .14s, color .14s;
}
button:hover { background: var(--accent-d); border-color: var(--accent-d); }
button.ghost { background: var(--field); border: 1px solid var(--line2); color: var(--text); }
button.ghost:hover { background: var(--panel2); border-color: var(--muted); }
button.danger { background: var(--red); border-color: var(--red); color: #fff; }
button.danger:hover { filter: brightness(.92); }
button.sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select {
  font: inherit; padding: 8px 11px; border-radius: 7px; border: 1px solid var(--line2);
  background: var(--field); color: var(--text); width: 100%; transition: border-color .14s, box-shadow .14s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); }
label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; display: block; margin: 12px 0 5px; font-weight: 600; }

.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; align-self: start; height: 100vh;
  background: var(--panel); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column;
}
.logo { font-weight: 800; font-size: 18px; letter-spacing: .02em; color: var(--accent-text); }
.logo small { display: block; color: var(--muted); font-size: 9.5px; letter-spacing: .16em; font-weight: 600; margin-top: 3px; }
.logorow { display: flex; align-items: center; gap: 9px; }
.logo-mark { width: 28px; height: 28px; flex: none; display: block; }
.logo-mark.big { width: 64px; height: 64px; margin: 0 auto 10px; display: block; }
.nav { margin-top: 24px; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 7px;
  color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; position: relative;
  transition: background .14s, color .14s;
}
.nav a:hover { background: var(--panel2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); }
.nav a.active::before { content: ''; position: absolute; left: -1px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.theme-toggle { margin-top: auto; width: 100%; justify-content: center; }
.who { margin-top: 14px; padding-top: 14px; font-size: 12px; color: var(--muted); line-height: 1.7; border-top: 1px solid var(--line); }
.who #out { display: inline-block; margin-left: 2px; padding: 2px 9px; border-radius: 6px; border: 1px solid transparent; color: var(--accent-text); cursor: pointer; transition: background .14s, border-color .14s, color .14s; }
.who #out:hover { background: var(--panel2); border-color: var(--line2); color: var(--text); text-decoration: none; }
.main { padding: 26px 30px; max-width: 1140px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.head h1 { font-size: 22px; letter-spacing: -.01em; font-weight: 700; }
.head .spacer { flex: 1; }
.pill { font-size: 11px; padding: 3px 10px; border-radius: 6px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; box-shadow: var(--shadow-card); }
.card .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.card .v { font-size: 26px; font-weight: 700; margin-top: 7px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.card.green .v { color: var(--green); } .card.gold .v { color: var(--gold); } .card.cyan .v { color: var(--accent-text); }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-card); }
th, td { text-align: left; padding: 11px 15px; font-size: 13px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; background: var(--panel2); font-weight: 600; }
tbody tr { transition: background .1s; }
tbody tr:hover > td { background: var(--hover); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", monospace; font-size: 12px; color: var(--text); }
.tag { font-size: 10px; padding: 2px 8px; border-radius: 5px; font-weight: 600; letter-spacing: .02em; border: 1px solid transparent; }
.tag.on { background: var(--tag-on-bg); color: var(--green); border-color: var(--tag-on-bd); }
.tag.off { background: var(--panel2); color: var(--muted); border-color: var(--line); }
.good { color: var(--green); } .bad { color: var(--red); } .warn { color: var(--gold); }

.caret {
  width: 26px; height: 26px; padding: 0; border-radius: 6px; background: var(--field); border: 1px solid var(--line2);
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.caret:hover { color: var(--text); border-color: var(--muted); background: var(--panel2); }
.caret .chev { font-size: 9px; line-height: 1; transform: rotate(-90deg); transition: transform .18s ease; }
.caret.open { color: var(--accent-text); border-color: var(--accent); background: var(--accent-soft); }
.caret.open .chev { transform: rotate(0); }
tr.expanded > td { background: var(--accent-soft); }
.prow-detail > td { background: var(--panel2); padding: 6px 16px 12px; }
.phist { display: grid; gap: 10px; }
.phist .panelbox { background: var(--panel); margin: 0; }
.phist h3 { font-size: 13px; letter-spacing: .01em; }
table.sub { font-size: 12px; box-shadow: none; }
table.sub th { background: var(--panel2); }
table.sub td, table.sub th { padding: 8px 12px; }

.sortable th[data-sort] { cursor: pointer; user-select: none; transition: color .12s, background .12s; }
.sortable th[data-sort]:hover { color: var(--text); background: var(--hover); }
.sortable th .ind { color: var(--accent-text); }

.panelbox { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow-card); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > * { flex: 1; }
.login-wrap { max-width: 384px; margin: 14vh auto; }
.login-wrap .logo { font-size: 26px; }
.toast { position: fixed; right: 22px; bottom: 22px; background: var(--toast-bg); color: var(--toast-fg); border: 1px solid var(--toast-bg); padding: 11px 16px; border-radius: 8px; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; z-index: 50; box-shadow: 0 8px 24px rgba(16, 24, 40, .2); font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--red); border-color: var(--red); color: #fff; }
h2 { font-size: 15px; margin-bottom: 13px; font-weight: 700; }
h3 { font-size: 13px; font-weight: 700; }
.muted { color: var(--muted); font-size: 13px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 12, 22, .55); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 100; animation: fade .14s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: min(420px, 92vw); background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; box-shadow: 0 16px 48px rgba(8, 12, 22, .4); overflow: hidden; animation: pop .15s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; flex: 1; }
.modal-x { padding: 4px 9px; }
.modal-body { padding: 18px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.chip2 { background: var(--panel2); border: 1px solid var(--line2); color: var(--text); font-weight: 600; }
.chip2:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

.drawer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(222px, 1fr)); gap: 14px; }
.drawer-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 15px 16px; }
.drawer-name { font-weight: 700; font-size: 15px; margin-bottom: 11px; }
.drawer-bal { display: flex; align-items: baseline; justify-content: space-between; margin-top: 5px; }
.drawer-bal .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.drawer-bal .v { font-weight: 700; font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .cards { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .main { padding: 18px; }
}
