:root {
  --bg: #0a1530;
  --bg-2: #0e1c3f;
  --surface: #12244d;
  --surface-2: #172d5c;
  --line: #22396b;
  --line-2: #2c4783;
  --text: #e8eefa;
  --muted: #93a6cb;
  --faint: #6f84ad;
  --blue: #4d8dff;
  --blue-d: #2f6fe4;
  --cyan: #3cd2e4;
  --ok: #45d19a;
  --warn: #f4c15d;
  --danger: #ff6b7a;
  --r-lg: 14px;
  --r: 10px;
  --r-sm: 7px;
  color-scheme: dark;
  font-family: "Manrope", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 500px at 10% -10%, #13306a 0%, transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.num { font-variant-numeric: tabular-nums; }
a { color: var(--cyan); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--blue-d), var(--cyan));
  font-weight: 800; font-size: 15px; letter-spacing: -.5px; color: #061026;
}
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -.3px; }
.brand-sub { color: var(--muted); font-size: 13px; font-weight: 600; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card-pad { padding: 14px 16px; }
.card h2 { font-size: 16px; margin: 0 0 10px; letter-spacing: -.2px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }

/* Controls */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.input, .select {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 9px 11px; min-height: 40px; width: 100%;
}
.input:focus, .select:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(77,141,255,.25); }
.input.invalid { border-color: var(--danger); }
.input-affix { position: relative; }
.input-affix .input { padding-right: 52px; }
.input-affix span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 13px; font-weight: 700; }
.err { color: var(--danger); font-size: 13px; min-height: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 14px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface-2); font-weight: 700; font-size: 14px;
  white-space: nowrap;
}
.btn:hover { border-color: var(--blue); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); border-color: var(--blue-d); }
.btn-danger { background: transparent; border-color: rgba(255,107,122,.5); color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--line-2); }
.btn-sm { min-height: 30px; padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid var(--line-2); color: var(--muted); }
.pill-ok { color: var(--ok); border-color: rgba(69,209,154,.4); }
.pill-warn { color: var(--warn); border-color: rgba(244,193,93,.45); }
.pill-muted { color: var(--faint); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Dialog */
.dlg-backdrop {
  position: fixed; inset: 0; background: rgba(4,10,26,.72); display: none;
  align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.dlg-backdrop.open { display: flex; }
.dlg {
  width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.45);
  max-height: calc(100vh - 32px); overflow: auto;
}
.dlg h3 { margin: 0 0 8px; font-size: 17px; }
.dlg .dlg-body { color: var(--muted); margin-bottom: 14px; }
.dlg .dlg-body strong { color: var(--text); }
.dlg .dlg-fields { display: grid; gap: 12px; margin-bottom: 14px; }
.dlg .dlg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border: 1px solid var(--line-2); border-left: 3px solid var(--cyan);
  padding: 10px 14px; border-radius: var(--r); font-weight: 600; font-size: 14px; opacity: 0;
  transition: opacity .2s, transform .2s; z-index: 60; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-left-color: var(--danger); }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 0; font-size: 14px; }
.kv dt { padding-right: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }
.kv .total { color: var(--text); font-weight: 800; border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
.kv .total-v { color: var(--cyan); font-weight: 800; border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
[hidden] { display: none !important; }
