:root {
  --bg: #0f1420; --panel: #171e2e; --panel2: #1e2740; --border: #2a3550;
  --text: #e6ebf5; --muted: #8b98b8; --accent: #3b82f6; --accent2: #60a5fa;
  --green: #34d399; --red: #f87171; --yellow: #fbbf24; --orange: #fb923c;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg);
  color: var(--text); font-size: 14px; }
.hidden { display: none !important; }

.login-screen { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 48px; text-align: center; }
.login-card h1 { margin-bottom: 8px; font-size: 22px; }
.login-card p { color: var(--muted); margin-bottom: 24px; }
.error { color: var(--red); margin-top: 16px; }

#app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 18px 0;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { font-weight: 700; font-size: 17px; padding: 0 20px 18px; }
.nav-item { display: block; padding: 10px 20px; color: var(--muted); text-decoration: none;
  cursor: pointer; border-left: 3px solid transparent; }
.nav-item:hover { color: var(--text); background: var(--panel2); }
.nav-item.active { color: var(--text); border-left-color: var(--accent); background: var(--panel2); }
.nav-footer { margin-top: auto; padding: 16px 20px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted); }
.nav-footer a { color: var(--accent2); }

main { padding: 26px 32px; max-width: 1500px; }
h2 { font-size: 20px; margin-bottom: 18px; }
h3 { font-size: 15px; margin: 18px 0 10px; color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px; margin-bottom: 24px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; cursor: pointer; transition: border-color .15s; }
.card:hover { border-color: var(--accent); }
.card .num { font-size: 26px; font-weight: 700; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card.warn .num { color: var(--yellow); }
.card.bad .num { color: var(--red); }
.card.good .num { color: var(--green); }

table { width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
th { text-align: left; padding: 10px 12px; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--border); }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel2); }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.amount.pos { color: var(--green); } .amount.neg { color: var(--red); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px;
  font-weight: 600; }
.badge.green { background: #0d3d2e; color: var(--green); }
.badge.red { background: #451a1a; color: var(--red); }
.badge.yellow { background: #43350d; color: var(--yellow); }
.badge.blue { background: #172a54; color: var(--accent2); }
.badge.gray { background: var(--panel2); color: var(--muted); }
.badge.orange { background: #43250d; color: var(--orange); }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
input[type=text], input[type=date], input[type=number], select, textarea {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 12px; font-size: 14px; }
input[type=text] { min-width: 240px; }
button { background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px 16px; font-size: 14px; cursor: pointer; font-weight: 600; }
button:hover { background: var(--accent2); }
button.secondary { background: var(--panel2); border: 1px solid var(--border); }
button.danger { background: #7f1d1d; }
button.small { padding: 4px 10px; font-size: 12px; }

#modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex;
  align-items: flex-start; justify-content: center; padding: 40px; z-index: 100; overflow: auto; }
#modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 26px; width: min(880px, 95vw); }
#modal h2 { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 12px 0; }
.form-grid label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.detail-grid { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; margin: 12px 0; }
.detail-grid dt { color: var(--muted); } .detail-grid dd { word-break: break-word; }
.suggestion { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; margin: 8px 0; display: flex; justify-content: space-between; gap: 12px;
  align-items: center; }
.reasons { color: var(--muted); font-size: 12px; }
.problems { background: #43250d; border-radius: 10px; padding: 10px 14px; margin: 10px 0;
  color: var(--orange); }

#toast { position: fixed; bottom: 24px; right: 24px; background: var(--panel);
  border: 1px solid var(--accent); border-radius: 10px; padding: 14px 20px; z-index: 200; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, monospace; font-size: 12px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
