:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --text: #172033;
  --muted: #667085;
  --line: #e4e8ef;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --good: #15803d;
  --warn: #b45309;
  --danger: #b42318;
  --shadow: 0 12px 32px rgba(16,24,40,.07);
  --radius: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
}
.auth-side {
  padding: 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #0f172a;
  color: white;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display:grid; place-items:center; background:#fff; color:#0f172a; font-weight:900; }
.auth-copy h1 { font-size: clamp(36px, 5vw, 62px); line-height: 1.02; letter-spacing: -.05em; max-width: 620px; margin: 0 0 22px; }
.auth-copy p { color: #cbd5e1; max-width: 560px; font-size: 18px; line-height:1.6; }
.auth-features { display:grid; gap:12px; margin-top:28px; color:#dbe5f3; }
.auth-feature { display:flex; align-items:center; gap:10px; }
.auth-feature span:first-child { width:26px; height:26px; border-radius:50%; background:#1e293b; display:grid; place-items:center; }
.auth-panel { display:grid; place-items:center; padding:40px; }
.auth-card { width:min(430px,100%); background:var(--surface); border:1px solid var(--line); border-radius:22px; padding:32px; box-shadow:var(--shadow); }
.auth-card h2 { margin:0 0 8px; font-size:28px; letter-spacing:-.03em; }
.auth-card .sub { color:var(--muted); margin-bottom:24px; line-height:1.5; }
.field { margin-bottom:16px; }
.field label { display:block; margin-bottom:7px; font-size:14px; font-weight:700; }
.field input { width:100%; border:1px solid #cfd6e2; border-radius:11px; padding:12px 13px; outline:none; background:white; }
.field input:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(37,99,235,.12); }
.btn { border:0; border-radius:11px; padding:11px 15px; font-weight:750; transition:.16s ease; }
.btn-primary { background:var(--accent); color:white; }
.btn-primary:hover { background:var(--accent-strong); }
.btn-secondary { background:white; color:var(--text); border:1px solid var(--line); }
.btn-secondary:hover { background:var(--surface-2); }
.btn-danger { background:#fff1f2; color:var(--danger); border:1px solid #fecdd3; }
.btn-block { width:100%; }
.auth-switch { text-align:center; margin-top:18px; color:var(--muted); font-size:14px; }
.auth-switch button { border:0; background:none; color:var(--accent); font-weight:750; }
.demo-note { margin-top:16px; padding:12px; background:#eff6ff; border:1px solid #bfdbfe; border-radius:10px; color:#1e40af; font-size:13px; line-height:1.45; }

.portal { min-height:100vh; display:grid; grid-template-columns:250px 1fr; }
.sidebar { background:#101828; color:white; padding:22px 16px; position:sticky; top:0; height:100vh; display:flex; flex-direction:column; }
.sidebar .brand { padding:4px 8px 26px; }
.nav { display:grid; gap:6px; }
.nav button { width:100%; display:flex; align-items:center; gap:10px; border:0; background:transparent; color:#cfd6e2; padding:11px 12px; border-radius:10px; text-align:left; font-weight:650; }
.nav button:hover, .nav button.active { background:#1d2939; color:white; }
.nav .icon { width:20px; text-align:center; }
.sidebar-bottom { margin-top:auto; padding:12px 8px 2px; }
.user-mini { border-top:1px solid #344054; padding-top:16px; display:flex; gap:10px; align-items:center; }
.avatar { width:36px; height:36px; border-radius:50%; background:#344054; display:grid; place-items:center; font-weight:800; }
.user-mini small { color:#98a2b3; display:block; margin-top:2px; }
.main { min-width:0; }
.topbar { min-height:74px; display:flex; align-items:center; justify-content:space-between; padding:0 32px; background:rgba(255,255,255,.93); border-bottom:1px solid var(--line); position:sticky; top:0; z-index:5; backdrop-filter:blur(9px); }
.topbar h1 { margin:0; font-size:22px; letter-spacing:-.025em; }
.content { padding:30px 32px 50px; max-width:1450px; margin:0 auto; }

.grid { display:grid; gap:18px; }
.grid-4 { grid-template-columns:repeat(4,1fr); }
.grid-3 { grid-template-columns:repeat(3,1fr); }
.grid-2 { grid-template-columns:repeat(2,1fr); }
.card { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:20px; box-shadow:0 2px 6px rgba(16,24,40,.02); }
.card h3 { margin:0 0 5px; font-size:15px; }
.kpi-label { color:var(--muted); font-size:13px; font-weight:650; }
.kpi-value { font-size:30px; font-weight:850; letter-spacing:-.035em; margin-top:8px; }
.kpi-foot { margin-top:8px; font-size:12px; color:var(--muted); }
.good { color:var(--good); }
.warn { color:var(--warn); }
.section-head { display:flex; align-items:center; justify-content:space-between; margin:30px 0 13px; }
.section-head h2 { margin:0; font-size:18px; letter-spacing:-.02em; }
.muted { color:var(--muted); }
.row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.space-between { justify-content:space-between; }
.endpoint-box { background:#0b1220; color:#e2e8f0; border-radius:12px; padding:14px; display:flex; align-items:center; justify-content:space-between; gap:12px; overflow:hidden; }
.endpoint-box code { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.copy-btn { border:1px solid #334155; background:#172033; color:#e2e8f0; border-radius:8px; padding:7px 10px; flex:0 0 auto; }
.copy-btn:hover { background:#1e293b; }
.key-box { margin-top:12px; }
.progress { height:9px; background:#e9edf3; border-radius:999px; overflow:hidden; margin-top:12px; }
.progress > div { height:100%; background:var(--accent); border-radius:inherit; }
.tag { display:inline-flex; align-items:center; border-radius:999px; padding:5px 9px; font-size:12px; font-weight:750; background:#eef4ff; color:#3538cd; }
.tag.green { background:#ecfdf3; color:#027a48; }
.tag.gray { background:#f2f4f7; color:#475467; }
.tag.orange { background:#fff7ed; color:#c2410c; }
.model-list { display:grid; gap:9px; margin-top:14px; }
.model-item { border:1px solid var(--line); border-radius:12px; padding:12px 13px; display:flex; align-items:center; justify-content:space-between; gap:12px; }
.model-name { font-weight:750; }
.model-meta { color:var(--muted); font-size:12px; margin-top:3px; }

.table-wrap { overflow:auto; border:1px solid var(--line); border-radius:14px; }
table { width:100%; border-collapse:collapse; background:white; min-width:760px; }
th, td { padding:13px 14px; border-bottom:1px solid var(--line); text-align:left; font-size:13px; white-space:nowrap; }
th { background:#f8fafc; color:#475467; font-size:12px; text-transform:uppercase; letter-spacing:.04em; }
tr:last-child td { border-bottom:0; }
.cost { font-weight:750; }

.notice { border-radius:13px; padding:13px 15px; background:#fffaeb; border:1px solid #fedf89; color:#93370d; display:flex; justify-content:space-between; gap:14px; align-items:center; margin-bottom:18px; }
.quick-actions { display:flex; gap:9px; flex-wrap:wrap; }

.modal-backdrop { position:fixed; inset:0; background:rgba(15,23,42,.48); display:grid; place-items:center; z-index:30; padding:20px; }
.modal { width:min(500px,100%); background:white; border-radius:18px; padding:24px; box-shadow:0 24px 70px rgba(15,23,42,.3); }
.modal h2 { margin:0 0 7px; }
.amount-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:9px; margin:18px 0; }
.amount { padding:12px; border-radius:10px; background:white; border:1px solid var(--line); font-weight:800; }
.amount.selected { border-color:var(--accent); background:#eff6ff; color:#1d4ed8; }
.modal-actions { display:flex; justify-content:flex-end; gap:9px; margin-top:20px; }

.settings-grid { display:grid; grid-template-columns:1.1fr .9fr; gap:18px; }
.setting-row { padding:14px 0; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; gap:20px; align-items:center; }
.setting-row:last-child { border-bottom:0; }
.toggle { width:42px; height:24px; border-radius:999px; background:#d0d5dd; border:0; padding:2px; }
.toggle::after { content:""; display:block; width:20px; height:20px; border-radius:50%; background:white; box-shadow:0 1px 3px rgba(0,0,0,.2); transform:translateX(0); transition:.15s; }
.toggle.on { background:var(--accent); }
.toggle.on::after { transform:translateX(18px); }

.toast { position:fixed; right:22px; bottom:22px; background:#101828; color:white; border-radius:10px; padding:11px 14px; z-index:50; box-shadow:var(--shadow); font-size:13px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns:repeat(2,1fr); }
  .grid-3 { grid-template-columns:1fr; }
  .settings-grid { grid-template-columns:1fr; }
}
@media (max-width: 760px) {
  .auth-shell { grid-template-columns:1fr; }
  .auth-side { display:none; }
  .auth-panel { min-height:100vh; padding:20px; }
  .portal { grid-template-columns:1fr; }
  .sidebar { position:fixed; inset:auto 0 0 0; height:auto; z-index:20; padding:8px; }
  .sidebar .brand, .sidebar-bottom { display:none; }
  .nav { grid-template-columns:repeat(5,1fr); }
  .nav button { justify-content:center; padding:10px 5px; font-size:0; }
  .nav .icon { font-size:18px; }
  .topbar { padding:0 18px; }
  .content { padding:20px 16px 95px; }
  .grid-4, .grid-2 { grid-template-columns:1fr; }
  .amount-grid { grid-template-columns:repeat(2,1fr); }
}
