:root {
  color-scheme: light;
  --ink: #101010;
  --ink-soft: #1a2128;
  --cyan: #19bcc9;
  --cyan-dark: #117984;
  --blue: #0000ee;
  --green: #51c48a;
  --amber: #ffc77e;
  --red: #e8485e;
  --canvas: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --border: #d0d7de;
  --muted: #69737d;
  --silver: #afb8c1;
  --radius: 18px;
  --shadow: 0 12px 34px rgba(16, 16, 16, 0.07);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-width: 320px; min-height: 100%; }
body {
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.boot {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  color: var(--silver);
  background: radial-gradient(circle at 50% 40%, #233039 0, #12171c 46%, #0d1013 100%);
}
.boot-mark, .brand-mark {
  display: grid;
  place-items: center;
  background: var(--cyan);
  color: var(--ink);
  font-weight: 950;
  letter-spacing: -0.05em;
}
.boot-mark { width: 64px; height: 64px; border-radius: 20px; box-shadow: 0 0 60px rgba(25,188,201,.28); }
.boot-logo { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 0 28px rgba(25,188,201,.25)); }

.shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  color: #f5f7fa;
  background: var(--ink);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto; }
.brand-logo { width: 88px; height: 22px; flex: 0 0 auto; object-fit: contain; }
.brand b, .brand small { display: block; }
.brand b { font-size: 14px; letter-spacing: .015em; }
.brand small { margin-top: 4px; color: #9e9ea4; font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
.nav { display: grid; gap: 6px; margin-top: 32px; }
.nav button, .nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 12px;
  color: var(--silver);
  background: transparent;
  text-align: left;
  font-weight: 750;
  text-decoration: none;
}
.nav button:hover, .nav button.active, .nav a:hover, .nav a.active { background: #252525; color: #fff; }
.nav svg { width: 18px; height: 18px; stroke-width: 1.8; }
.nav-symbol { width: 18px; text-align: center; font-size: 19px; line-height: 1; }
.sidebar-foot { margin-top: auto; padding: 18px 4px 0; border-top: 1px solid #35393f; }
.sidebar-foot small { display: block; margin-top: 6px; color: #999; line-height: 1.45; }
.user-foot small { overflow-wrap: anywhere; }
.sidebar-logout { margin-top: 13px; padding: 0; border: 0; color: var(--cyan); background: transparent; font-size: 12px; font-weight: 850; }

.workspace { min-width: 0; }
.topbar {
  height: 58px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}
.topbar-right { display: flex; align-items: center; gap: 9px; }
.state-pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  font-weight: 850;
  white-space: nowrap;
}
.state-pill { padding: 7px 10px; background: var(--surface-soft); border: 1px solid var(--border); }
.state-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.state-pill.ok::before { background: var(--green); }

.content { max-width: 1600px; margin: 0 auto; padding: 28px 28px 60px; }
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.eyebrow { color: var(--cyan-dark); font-size: 11px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.pagehead h1 { margin: 7px 0 8px; font-size: clamp(29px, 3vw, 40px); line-height: 1.04; letter-spacing: -.045em; }
.pagehead p { margin: 0; max-width: 720px; color: var(--muted); line-height: 1.55; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn {
  min-height: 42px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 850;
  text-decoration: none;
}
.btn.primary { background: var(--ink); color: #fff; }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--border); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.range-switch { display: inline-flex; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.range-switch button { padding: 7px 10px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 850; }
.range-switch button.active { color: var(--ink); background: #fff; box-shadow: 0 1px 5px rgba(16,16,16,.1); }

.notice {
  margin-bottom: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid #b8e8ed;
  border-left: 4px solid var(--cyan);
  border-radius: 14px;
  background: #eaf9fb;
  color: #245e64;
  font-size: 13px;
  line-height: 1.5;
}
.notice b { color: var(--ink); }
.notice.warning { border-color: #f0d5ae; border-left-color: var(--amber); background: #fff7eb; color: #765326; }
.notice.success { border-color: #bfe4d2; border-left-color: var(--green); background: #ebf8f1; color: #14633f; }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric { min-height: 124px; padding: 17px; display: flex; flex-direction: column; }
.metric small { color: var(--muted); font-size: 11px; font-weight: 750; }
.metric strong { margin-top: auto; font-size: 24px; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.metric span { margin-top: 7px; color: var(--muted); font-size: 11px; }
.metric .up { color: #14784a; }
.metric .down { color: #b42d2d; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .75fr); gap: 16px; }
.panel { padding: 21px; min-width: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.chart { min-height: 260px; display: grid; align-items: stretch; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-grid { stroke: #e8ecef; stroke-width: 1; }
.chart-area { fill: url(#area); }
.chart-line { fill: none; stroke: var(--cyan); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { fill: #fff; stroke: var(--cyan); stroke-width: 2; }

.alert-list { display: grid; gap: 10px; }
.alert-card { padding: 13px 14px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface-soft); }
.alert-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.alert-card b { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.alert-card p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.badge { padding: 5px 8px; font-size: 10px; }
.badge.risk { color: #b42d2d; background: #fdecec; }
.badge.stock { color: #8a5d18; background: #fff3df; }
.badge.stale { color: #555; background: #eef1f3; }
.badge.healthy { color: #14784a; background: #e8f8f0; }
.badge.demo { color: var(--cyan-dark); background: #eaf9fb; }

.toolbar { margin-bottom: 16px; padding: 13px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.toolbar input, .toolbar select {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.toolbar input { flex: 1 1 260px; min-width: 0; }
.toolbar select { flex: 0 1 220px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(25,188,201,.13); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 12px; border-bottom: 1px solid #e8ecef; text-align: left; font-size: 12px; }
th { color: var(--muted); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
td { font-variant-numeric: tabular-nums; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: var(--muted); }
td.numeric, th.numeric { text-align: right; white-space: nowrap; }
.profit-positive { color: #14784a; font-weight: 850; }
.profit-negative { color: #b42d2d; font-weight: 850; }

.integration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.connection { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.connection-main { display: flex; align-items: center; gap: 14px; }
.service-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 15px; background: #ff5a00; color: #fff; font-size: 22px; font-weight: 950; }
.service-mark.enova { background: var(--ink-soft); }
.connection h2 { margin: 0 0 5px; }
.connection p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.account-list { display: grid; gap: 9px; margin-top: 18px; }
.account-card { padding: 13px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid #bfe4d2; border-radius: 13px; background: #f3fbf7; }
.account-card h3 { margin: 8px 0 4px; font-size: 14px; }
.account-card p, .account-card small { display: block; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.account-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.connection-empty { margin-top: 18px; padding: 14px; display: grid; gap: 5px; border: 1px dashed var(--border); border-radius: 13px; color: var(--muted); background: var(--surface-soft); font-size: 12px; line-height: 1.5; }
.connection-empty b { color: var(--ink); }
.btn.compact { min-height: 34px; padding: 7px 10px; font-size: 11px; }
.scope-list { display: grid; gap: 9px; margin-top: 18px; }
.scope { padding: 11px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.scope code { overflow-wrap: anywhere; font-size: 11px; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; margin-bottom: 7px; color: var(--ink); font-size: 16px; }

.auth-body { min-height: 100vh; background: radial-gradient(circle at 50% 30%, #243139 0, #12171c 45%, #0d1013 100%); }
.auth-shell { width: min(440px, calc(100% - 28px)); min-height: 100vh; margin: 0 auto; display: grid; align-content: center; gap: 22px; padding: 40px 0; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 13px; color: #fff; text-decoration: none; font-weight: 850; }
.auth-brand img { width: 106px; height: 28px; object-fit: contain; }
.auth-brand span { padding-left: 13px; border-left: 1px solid #4b555c; }
.auth-card { padding: 30px; border: 1px solid #dfe4e8; border-radius: 22px; background: #fff; box-shadow: 0 22px 70px rgba(0,0,0,.28); }
.auth-card h1 { margin: 8px 0 9px; font-size: 30px; letter-spacing: -.04em; }
.form-intro { margin: 0 0 23px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.form-stack { display: grid; gap: 16px; }
.form-stack label, .admin-form-grid label, .user-edit-grid label, .password-reset-form label { display: grid; gap: 7px; }
.form-stack label > span, .admin-form-grid label > span, .user-edit-grid label > span, .password-reset-form label > span { color: #454f58; font-size: 11px; font-weight: 850; }
.form-stack input, .admin-form-grid input, .admin-form-grid select, .user-edit-grid input, .user-edit-grid select, .password-reset-form input {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 11px; color: var(--ink); background: #fff; outline: none;
}
.form-stack input:focus, .admin-form-grid input:focus, .admin-form-grid select:focus, .user-edit-grid input:focus, .user-edit-grid select:focus, .password-reset-form input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(25,188,201,.13); }
.form-stack .check-row { display: flex; align-items: center; gap: 9px; }
.check-row input { width: 17px; min-height: 17px; accent-color: var(--cyan-dark); }
.btn.wide { width: 100%; }
.auth-help { margin: 18px 0 0; color: var(--muted); text-align: center; font-size: 11px; line-height: 1.5; }
.auth-logout { margin-top: 18px; text-align: center; }
.auth-logout button { padding: 5px; border: 0; color: var(--muted); background: transparent; font-size: 12px; text-decoration: underline; }
.form-alert, .form-success { margin-bottom: 18px; padding: 12px 14px; border-radius: 12px; font-size: 12px; line-height: 1.5; }
.form-alert { border: 1px solid #f1c2c7; color: #8d2531; background: #fdeff1; }
.form-success { border: 1px solid #bfe4d2; color: #14633f; background: #ebf8f1; }
.form-alert ul { margin: 0; padding-left: 18px; }

.admin-content { max-width: 1280px; }
.count-pill { padding: 9px 12px; border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--muted); font-size: 12px; font-weight: 850; white-space: nowrap; }
.create-user-panel { margin-bottom: 16px; }
.admin-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }
.form-action { display: flex; align-items: end; }
.user-list { display: grid; gap: 12px; }
.user-card { padding-bottom: 15px; }
.user-card.inactive { opacity: .72; }
.user-card-head { display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 13px; color: #073d43; background: #c9f1f4; font-weight: 950; }
.user-identity { min-width: 0; }
.user-identity h2 { overflow: hidden; margin: 0; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.user-identity p { overflow: hidden; margin: 4px 0 0; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.user-badges { display: flex; gap: 7px; margin-left: auto; }
.protected-note { margin-top: 17px; padding: 13px 14px; display: grid; gap: 5px; border: 1px solid #b8e8ed; border-radius: 12px; background: #eefafb; font-size: 12px; }
.protected-note span { color: var(--muted); }
.user-edit-grid { margin-top: 17px; display: grid; grid-template-columns: 1.5fr 1fr 1fr auto; gap: 12px; align-items: end; }
.password-reset { margin-top: 13px; border-top: 1px solid #e8ecef; padding-top: 12px; }
.password-reset summary { color: var(--cyan-dark); cursor: pointer; font-size: 12px; font-weight: 850; }
.password-reset-form { margin-top: 12px; display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.user-meta { margin-top: 14px; padding-top: 11px; display: flex; flex-wrap: wrap; gap: 8px 18px; border-top: 1px solid #e8ecef; color: var(--muted); font-size: 10px; }

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; padding: 15px; }
  .brand { padding: 0; }
  .nav { margin-top: 15px; display: flex; overflow-x: auto; padding-bottom: 2px; }
  .nav button { width: auto; flex: 0 0 auto; }
  .sidebar-foot { display: none; }
  .topbar { display: none; }
  .content { padding: 21px 14px 44px; }
  .pagehead { display: grid; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .integration-grid { grid-template-columns: 1fr; }
  .admin-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-edit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .password-reset-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .brand small, .nav button span, .nav a span:not(.nav-symbol) { display: none; }
  .nav button, .nav a { padding: 10px; }
  .pagehead h1 { font-size: 29px; }
  .actions, .range-switch { width: 100%; }
  .range-switch button { flex: 1; }
  .metrics { grid-template-columns: 1fr; }
  .metric { min-height: 105px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar input, .toolbar select { width: 100%; }
  .connection { align-items: stretch; flex-direction: column; }
  .account-card { align-items: stretch; flex-direction: column; }
  .account-actions { justify-content: stretch; }
  .account-actions form, .account-actions .btn { width: 100%; }
  .auth-card { padding: 23px 19px; }
  .admin-form-grid, .user-edit-grid, .password-reset-form { grid-template-columns: 1fr; }
  .user-card-head { align-items: flex-start; flex-wrap: wrap; }
  .user-badges { width: 100%; margin-left: 56px; }
}
