:root {
  --bg: #080b12;
  --surface: #10151f;
  --surface-2: #151b27;
  --line: #242d3d;
  --text: #edf3ff;
  --muted: #8490a5;
  --cyan: #31d7f4;
  --cyan-dim: rgba(49, 215, 244, .12);
  --green: #46e6a3;
  --amber: #ffc75a;
  --red: #ff637d;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--text); background: radial-gradient(circle at 85% -20%, #12243a 0, transparent 34rem), var(--bg); min-height: 100vh; font-size: 16px; }
button, input, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: rgba(8, 11, 18, .9); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; margin-bottom: 40px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid rgba(49,215,244,.5); border-radius: 11px; color: var(--cyan); background: linear-gradient(145deg, rgba(49,215,244,.18), rgba(49,215,244,.03)); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 800; box-shadow: 0 0 24px rgba(49,215,244,.09); }
.brand b, .brand small { display: block; }
.brand b { letter-spacing: -.02em; }
.brand small { color: var(--muted); margin-top: 2px; font-size: 12px; }
nav { display: grid; gap: 6px; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 13px; border-radius: 11px; color: var(--muted); font-size: 15px; font-weight: 600; }
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.active { color: var(--cyan); background: var(--cyan-dim); box-shadow: inset 2px 0 var(--cyan); }
.nav-icon { width: 20px; text-align: center; font-size: 20px; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 14px; padding: 0 8px; }
.zone-pill { display: flex; align-items: center; gap: 8px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, monospace; font-size: 13px; }
.zone-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }
.logout { border: 0; padding: 0; background: none; color: var(--muted); cursor: pointer; }
.logout:hover { color: var(--text); }

.content { min-width: 0; width: 100%; max-width: 1500px; margin: 0 auto; padding: 34px 40px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(30px, 3vw, 42px); letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: 19px; letter-spacing: -.02em; }
.eyebrow { margin-bottom: 7px; color: var(--cyan); font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .18em; }
.muted { color: var(--muted); }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; border-radius: 10px; padding: 0 17px; border: 1px solid transparent; color: var(--text); cursor: pointer; font-weight: 750; font-size: 14px; transition: .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button.primary { background: var(--cyan); color: #041016; box-shadow: 0 8px 30px rgba(49,215,244,.16); }
.button.secondary { background: var(--surface-2); border-color: var(--line); }
.button.danger { background: rgba(255,99,125,.1); color: var(--red); border-color: rgba(255,99,125,.3); }
.button.wide { width: 100%; }

.status-strip { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; min-height: 78px; padding: 16px 20px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(100deg, var(--surface), rgba(16,21,31,.75)); }
.status-light { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: rgba(132,144,165,.08); }
.status-light span { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status-strip.running { border-color: rgba(70,230,163,.28); background: linear-gradient(100deg, rgba(70,230,163,.07), var(--surface)); }
.status-strip.running .status-light span { background: var(--green); box-shadow: 0 0 14px var(--green); animation: pulse 1.8s infinite; }
.status-copy strong, .status-copy span, .next-run small, .next-run b { display: block; }
.status-copy span { margin-top: 5px; color: var(--muted); font-size: 14px; }
.next-run { text-align: right; }
.next-run small { color: var(--muted); margin-bottom: 5px; }
.next-run b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--cyan); }
@keyframes pulse { 50% { opacity: .45; box-shadow: 0 0 4px var(--green); } }

.match-banner { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; margin-bottom: 18px; border: 1px solid rgba(70,230,163,.4); border-radius: var(--radius); background: linear-gradient(110deg, rgba(70,230,163,.14), rgba(49,215,244,.04)); }
.match-banner span, .match-banner strong { display: block; }
.match-banner span { color: var(--green); font: 700 11px ui-monospace, monospace; letter-spacing: .16em; }
.match-banner strong { font: 700 25px ui-monospace, monospace; margin-top: 4px; }
.match-banner p { margin: 0; color: var(--muted); font-size: 14px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.metric { min-height: 124px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.metric span, .metric strong, .metric small { display: block; }
.metric span { color: var(--muted); font-size: 14px; }
.metric strong { margin: 12px 0 6px; font: 700 30px ui-monospace, SFMono-Regular, monospace; }
.metric small { color: #596478; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 14px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.legend-dot { color: var(--muted); font-size: 13px; }
.legend-dot::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 2px; background: var(--cyan); }
.bar-chart { height: 210px; display: flex; align-items: stretch; gap: 6px; padding-top: 10px; }
.bar-column { flex: 1; min-width: 3px; display: grid; grid-template-rows: 1fr 18px; gap: 8px; }
.bar-track { position: relative; overflow: hidden; border-radius: 4px; background: rgba(255,255,255,.025); }
.bar-track i { position: absolute; left: 0; right: 0; bottom: 0; min-height: 2px; border-radius: 4px 4px 2px 2px; background: linear-gradient(180deg, var(--cyan), #1687c5); box-shadow: 0 0 14px rgba(49,215,244,.14); }
.bar-column small { color: #566176; text-align: center; font: 11px ui-monospace, monospace; }
.outcomes-panel { position: relative; }
.outcome-total { display: flex; align-items: baseline; gap: 8px; margin-bottom: 24px; }
.outcome-total strong { font: 700 34px ui-monospace, monospace; }
.outcome-total span { color: var(--muted); }
.outcome-row { display: flex; justify-content: space-between; margin: 13px 0 7px; font-size: 14px; }
.outcome-row span { color: var(--muted); }
.outcome-row i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 8px; }
.progress { height: 5px; overflow: hidden; border-radius: 6px; background: #1d2431; }
.progress i { display: block; height: 100%; border-radius: inherit; }
.cyan { background: var(--cyan) !important; }.green { background: var(--green) !important; }.amber { background: var(--amber) !important; }.red { background: var(--red) !important; }
.settings-panel { grid-column: 2; }
.log-panel { grid-column: 1; grid-row: 2 / span 2; }

label { display: grid; gap: 7px; color: #aeb8c9; font-size: 14px; font-weight: 650; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; background: #0c1119; color: var(--text); outline: none; resize: vertical; }
input:focus, textarea:focus { border-color: rgba(49,215,244,.7); box-shadow: 0 0 0 3px rgba(49,215,244,.08); }
input:disabled { color: #657086; }
.settings-form, .form-stack, .edit-form { display: grid; gap: 16px; }
.form-hint { margin: -5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 0 10px 12px; color: #667187; text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
td { padding: 13px 10px; border-top: 1px solid var(--line); font-size: 14px; }
td small { display: block; max-width: 200px; overflow: hidden; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.status-tag { display: inline-block; padding: 5px 8px; border-radius: 6px; background: #1c2431; color: var(--muted); font: 700 11px ui-monospace, monospace; text-transform: uppercase; }
.status-tag.matched { color: var(--green); background: rgba(70,230,163,.09); }
.status-tag.rejected { color: var(--cyan); background: var(--cyan-dim); }
.status-tag.error { color: var(--red); background: rgba(255,99,125,.09); }
.status-tag.limited { color: var(--amber); background: rgba(255,199,90,.09); }

.accounts-layout { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }
.add-account { position: sticky; top: 24px; }
.account-list { display: grid; gap: 12px; }
.account-card { padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.account-card.disabled { opacity: .58; }
.account-top, .account-id { display: flex; align-items: center; }
.account-top { justify-content: space-between; gap: 16px; }
.account-id { gap: 12px; min-width: 0; }
.account-id > span { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; background: var(--cyan-dim); color: var(--cyan); font: 700 13px ui-monospace, monospace; }
.account-id strong, .account-id small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-id small { color: var(--muted); margin-top: 4px; font: 12px ui-monospace, monospace; }
.toggle { position: relative; width: 42px; height: 24px; border: 0; border-radius: 20px; background: #2b3444; cursor: pointer; }
.toggle i { position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #7e899d; transition: .2s; }
.toggle.on { background: rgba(70,230,163,.24); }.toggle.on i { left: 21px; background: var(--green); }
.account-stats { display: grid; grid-template-columns: 1.3fr .7fr 1fr; gap: 12px; padding: 16px 0; margin-top: 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.account-stats small, .account-stats b { display: block; }
.account-stats small { color: #667187; margin-bottom: 5px; font-size: 12px; }
.account-stats b { font-size: 13px; }
.account-error { margin-top: 12px; padding: 10px; border-radius: 8px; color: var(--amber); background: rgba(255,199,90,.07); font-size: 13px; }
details { margin-top: 13px; }
summary { color: var(--muted); cursor: pointer; font-size: 13px; }
.edit-form { margin-top: 16px; }
.text-danger { margin-top: 14px; padding: 0; border: 0; background: none; color: var(--red); cursor: pointer; font-size: 13px; }
.counter { color: var(--muted); font: 13px ui-monospace, monospace; }
.empty { display: grid; place-items: center; min-height: 160px; color: var(--muted); text-align: center; }
.account-empty { min-height: 240px; border: 1px dashed var(--line); border-radius: var(--radius); }
.account-empty strong, .account-empty span { display: block; }

.flash-stack { position: fixed; z-index: 20; top: 22px; right: 24px; display: grid; gap: 8px; }
.flash { max-width: 440px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 10px; background: #161d29; box-shadow: 0 14px 40px rgba(0,0,0,.35); font-size: 14px; }
.flash.success { border-color: rgba(70,230,163,.35); }.flash.error { border-color: rgba(255,99,125,.4); color: #ffb1bd; }

.login-page { display: grid; place-items: center; padding: 22px; background: radial-gradient(circle at 50% 0, #14253b, transparent 38rem), var(--bg); }
.login-card { width: min(420px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: rgba(16,21,31,.92); box-shadow: 0 30px 80px rgba(0,0,0,.36); }
.login-brand { margin-bottom: 30px; }.login-card h1 { font-size: 30px; margin-bottom: 8px; }.login-card .muted { margin-bottom: 28px; }
.lock-notice { margin: 14px 0; padding: 11px; border-radius: 9px; color: var(--amber); background: rgba(255,199,90,.08); font-size: 14px; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .settings-panel, .log-panel { grid-column: auto; grid-row: auto; }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 16px; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0 auto 0 0; }.brand small { display: none; }.sidebar nav { display: flex; }.sidebar-bottom { margin: 0 0 0 12px; }.sidebar-bottom .zone-pill { display: none; }
  .nav-link { font-size: 0; padding: 0 13px; }.nav-icon { font-size: 20px; }
  .content { padding: 24px 16px 40px; }
  .accounts-layout { grid-template-columns: 1fr; }.add-account { position: static; }
  .status-strip { grid-template-columns: auto 1fr; }.next-run { grid-column: 2; text-align: left; }
}
@media (max-width: 520px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }.metric { min-height: 108px; padding: 14px; }.metric strong { font-size: 25px; }
  .match-banner, .page-head { align-items: flex-start; }.match-banner { display: grid; gap: 10px; }
  .account-stats { grid-template-columns: 1fr 1fr; }.account-stats span:last-child { grid-column: 1 / -1; }
}
