:root {
  color-scheme: light;
  --bg: #f3f6f7;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --surface-strong: #eef3f4;
  --sidebar: #173b35;
  --sidebar-hover: #214a43;
  --text: #172126;
  --text-soft: #53636b;
  --text-faint: #7a8990;
  --line: #dbe3e6;
  --line-strong: #c7d2d6;
  --brand: #087f6b;
  --brand-strong: #066856;
  --brand-soft: #e5f5f1;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --amber: #a85b05;
  --amber-soft: #fff5df;
  --red: #c93434;
  --red-soft: #fff0ef;
  --green: #13834d;
  --green-soft: #e8f7ef;
  --purple: #6b4db3;
  --purple-soft: #f1edfb;
  --shadow: 0 1px 2px rgba(23, 33, 38, 0.06), 0 8px 24px rgba(23, 33, 38, 0.05);
  --sidebar-width: 244px;
  --topbar-height: 66px;
}

* { box-sizing: border-box; letter-spacing: 0; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; letter-spacing: 0; border-radius: 6px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; line-height: 1.2; }
h2 { font-size: 16px; line-height: 1.25; }
h3 { font-size: 14px; line-height: 1.3; }
svg { width: 18px; height: 18px; flex: 0 0 auto; }
[hidden] { display: none !important; }
.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 18px 12px 14px;
  background: var(--sidebar);
  color: #fff;
}
.brand, .login-brand { display: flex; align-items: center; gap: 11px; }
.brand { min-height: 50px; padding: 0 10px; }
.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  background: #fff;
  color: var(--sidebar);
  font-size: 18px;
  font-weight: 800;
}
.brand-mark.large { width: 44px; height: 44px; font-size: 22px; }
.brand-copy { display: flex; align-items: baseline; gap: 5px; }
.brand-copy strong { font-size: 17px; }
.brand-copy span { color: #a8d8ce; font-size: 15px; }
.brand-copy.light span { color: #c6e6df; }

.main-nav { display: grid; gap: 4px; margin-top: 26px; }
.nav-item {
  position: relative;
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #c9ddd8;
  text-align: left;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: #fff; color: var(--sidebar); font-weight: 700; }
.nav-count {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  margin-left: auto;
  place-items: center;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.sidebar-status {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 12px 9px 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}
.status-line { display: flex; align-items: center; gap: 9px; }
.status-line div { display: grid; min-width: 0; gap: 1px; }
.status-line span:not(.status-dot) { color: #9fc1ba; font-size: 11px; }
.status-line strong {
  overflow: hidden;
  color: #fff;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}
.status-dot.ok { background: #3fd58b; }
.status-dot.warn { background: #f2b84b; }
.status-dot.error { background: #ff6b63; }
.status-dot.neutral { background: #91a6a1; }

.workspace { min-width: 0; min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
}
.topbar-left, .topbar-actions, .user-button, .toolbar-actions, .filter-group,
.panel-head, .orders-toolbar, .setting-row, .dialog-head, .confirm-actions {
  display: flex;
  align-items: center;
}
.topbar-left { min-width: 0; gap: 12px; }
.topbar-left div { min-width: 0; }
.topbar-left p, .page-toolbar p, .panel-head span {
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 12px;
}
.topbar-actions { gap: 9px; }
.last-refresh { color: var(--text-faint); font-size: 12px; white-space: nowrap; }

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-soft);
}
.icon-button:hover { border-color: var(--line-strong); background: var(--surface-soft); color: var(--brand); }
.icon-button.subtle { border-color: transparent; background: transparent; }
.icon-button.danger:hover { border-color: #edb6b2; background: var(--red-soft); color: var(--red); }
.icon-button.is-spinning svg { animation: spin 0.9s linear infinite; }
.mobile-menu { display: none; }

.user-menu-wrap { position: relative; }
.user-button {
  min-height: 38px;
  gap: 8px;
  padding: 4px 8px 4px 5px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}
.user-button > svg { width: 15px; height: 15px; color: var(--text-faint); }
.user-avatar {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.user-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 60;
  width: 150px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.user-menu button {
  display: flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.user-menu button:hover { background: var(--surface-soft); }

.content { width: 100%; max-width: 1780px; margin: 0 auto; padding: 20px 22px 32px; }
.view { display: none; }
.view.active { display: block; }
.loading-block, .empty-state, .error-state {
  display: grid;
  min-height: 128px;
  place-items: center;
  padding: 24px;
  color: var(--text-soft);
  text-align: center;
}
.error-state { color: var(--red); }
.skeleton { min-height: 15px; border-radius: 4px; background: #e8edef; animation: pulse 1.4s ease-in-out infinite; }

.critical-banner {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 13px;
  border: 1px solid #edb6b2;
  border-left: 4px solid var(--red);
  border-radius: 7px;
  background: var(--red-soft);
  color: #852020;
}
.critical-banner.warn { border-color: #ecd29d; border-left-color: var(--amber); background: var(--amber-soft); color: #764005; }
.critical-banner.ok { border-color: #b8dfca; border-left-color: var(--green); background: var(--green-soft); color: #0d6138; }
.critical-banner strong { margin-right: 4px; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 11px; margin-bottom: 14px; }
.kpi-grid.compact-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-card {
  display: grid;
  min-height: 102px;
  align-content: space-between;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 1px rgba(23, 33, 38, 0.03);
}
.metric-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text-soft); font-size: 12px; }
.metric-icon { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 6px; background: var(--surface-strong); color: var(--text-soft); }
.metric-icon svg { width: 16px; height: 16px; }
.metric-icon.green { background: var(--green-soft); color: var(--green); }
.metric-icon.blue { background: var(--blue-soft); color: var(--blue); }
.metric-icon.amber { background: var(--amber-soft); color: var(--amber); }
.metric-icon.red { background: var(--red-soft); color: var(--red); }
.metric-value { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.metric-value strong { overflow: hidden; font-size: 25px; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
.metric-value span { color: var(--text-faint); font-size: 11px; }
.metric-foot { color: var(--text-faint); font-size: 11px; }
.metric-card.positive .metric-value strong { color: var(--green); }
.metric-card.negative .metric-value strong { color: var(--red); }

.dashboard-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 13px; }
.dashboard-grid-main { align-items: start; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.panel {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 1px rgba(23, 33, 38, 0.025);
}
.panel-head { min-height: 38px; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head > div { min-width: 0; }

.text-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  padding: 5px 2px;
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.text-button:hover { color: var(--brand-strong); }
.text-button svg { width: 15px; height: 15px; }

.primary-button, .secondary-button, .danger-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
}
.primary-button { border-color: var(--brand); background: var(--brand); color: #fff; }
.primary-button:hover { border-color: var(--brand-strong); background: var(--brand-strong); }
.secondary-button { border-color: var(--line-strong); background: var(--surface); color: var(--text); }
.secondary-button:hover { border-color: #9fb0b7; background: var(--surface-soft); }
.danger-button { border-color: var(--red); background: var(--red); color: #fff; }
.danger-button:hover { background: #ad2929; }
.danger-text { color: var(--red); }

.page-toolbar, .orders-toolbar {
  display: flex;
  min-height: 50px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}
.filter-group, .toolbar-actions { gap: 8px; flex-wrap: wrap; }
.search-field { position: relative; display: block; }
.search-field svg { position: absolute; top: 10px; left: 10px; width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; }
.search-field input { width: 220px; padding-left: 34px; }
input, select, textarea {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  outline: none;
}
input, textarea { padding: 8px 10px; }
select { padding: 7px 32px 7px 10px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(8, 127, 107, 0.11); }

.table-shell { width: 100%; min-width: 0; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.data-table th {
  height: 36px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table td {
  min-height: 45px;
  padding: 9px;
  border-bottom: 1px solid #edf1f2;
  color: var(--text);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.clickable:hover { background: var(--surface-soft); }
.table-primary { display: grid; gap: 1px; min-width: 86px; }
.table-primary strong { font-size: 13px; }
.table-primary span, .table-secondary { color: var(--text-faint); font-size: 11px; }
.table-number { font-variant-numeric: tabular-nums; white-space: nowrap; }
.positive-text { color: var(--green) !important; }
.negative-text { color: var(--red) !important; }
.muted-text { color: var(--text-faint) !important; }

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.badge.ok, .badge.buy, .badge.live { border-color: #b8dfca; background: var(--green-soft); color: var(--green); }
.badge.warn, .badge.hold, .badge.pending { border-color: #ecd29d; background: var(--amber-soft); color: var(--amber); }
.badge.error, .badge.sell, .badge.closed-negative { border-color: #edb6b2; background: var(--red-soft); color: var(--red); }
.badge.info, .badge.running { border-color: #baccf4; background: var(--blue-soft); color: var(--blue); }
.badge.neutral, .badge.paused, .badge.closed { border-color: var(--line); background: var(--surface-strong); color: var(--text-soft); }
.badge.purple { border-color: #d7cbee; background: var(--purple-soft); color: var(--purple); }

.quote-cell { display: grid; gap: 2px; font-variant-numeric: tabular-nums; }
.quote-cell strong { white-space: nowrap; }
.decision-cell { max-width: 330px; }
.decision-cell p {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 12px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.countdown { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.countdown.running { color: var(--blue); }
.countdown.paused { color: var(--text-faint); }

.mini-position-list, .event-list, .alert-list { display: grid; gap: 8px; }
.mini-position {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 10px 0;
  border-bottom: 1px solid #edf1f2;
  cursor: pointer;
}
.mini-position:last-child { border-bottom: 0; }
.mini-position:hover strong { color: var(--brand); }
.mini-position-main { display: grid; gap: 2px; }
.mini-position-main span { color: var(--text-faint); font-size: 11px; }

.event-item, .alert-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #edf1f2;
}
.event-item:last-child, .alert-item:last-child { border-bottom: 0; }
.event-time { width: 58px; color: var(--text-soft); font-size: 12px; font-variant-numeric: tabular-nums; }
.event-copy, .alert-copy { display: grid; min-width: 0; gap: 2px; }
.event-copy strong, .alert-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-copy span, .alert-copy span { color: var(--text-faint); font-size: 11px; }
.alert-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 6px;
  background: var(--amber-soft);
  color: var(--amber);
}
.alert-icon.error { background: var(--red-soft); color: var(--red); }
.alert-icon.ok { background: var(--green-soft); color: var(--green); }
.alert-icon svg { width: 15px; height: 15px; }

.agents-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.agent-card {
  display: grid;
  min-width: 0;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}
.agent-card.active { border-top-color: var(--green); }
.agent-card.running { border-top-color: var(--blue); }
.agent-card.paused { border-top-color: var(--amber); }
.agent-card.error { border-top-color: var(--red); }
.agent-card-head, .agent-card-state, .agent-runtime, .agent-card-footer,
.agent-schedule-summary, .analysis-row-head, .audit-card-head, .service-row,
.instruction-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
}
.agent-symbol { display: flex; align-items: center; gap: 9px; }
.agent-symbol strong { font-size: 19px; }
.agent-model { display: flex; flex-wrap: wrap; gap: 5px 8px; color: var(--text-faint); font-size: 11px; }
.agent-card-state { padding: 10px 0; border-top: 1px solid #edf1f2; border-bottom: 1px solid #edf1f2; }
.agent-next { display: grid; gap: 1px; }
.agent-next span { color: var(--text-faint); font-size: 11px; }
.agent-next strong { font-size: 23px; }
.agent-runtime { align-items: flex-end; text-align: right; }
.agent-runtime div { display: grid; gap: 1px; }
.agent-runtime span { color: var(--text-faint); font-size: 11px; }
.agent-runtime strong { font-size: 12px; }
.agent-quote-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.agent-quote-grid div { display: grid; min-width: 0; gap: 2px; }
.agent-quote-grid span { color: var(--text-faint); font-size: 10px; }
.agent-quote-grid strong {
  overflow: hidden;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-decision {
  display: grid;
  min-height: 96px;
  align-content: start;
  gap: 6px;
  padding-left: 10px;
  border-left: 3px solid var(--brand);
}
.agent-decision-head { display: flex; align-items: center; gap: 7px; }
.agent-decision p {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 12px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}
.agent-schedule-summary { color: var(--text-faint); font-size: 11px; }
.agent-card-footer { align-items: flex-end; padding-top: 10px; border-top: 1px solid #edf1f2; }
.interval-control { display: grid; gap: 3px; }
.interval-control label { color: var(--text-faint); font-size: 10px; }
.interval-control input { width: 74px; min-height: 34px; }
.agent-actions { display: flex; gap: 6px; }

.segmented {
  display: inline-flex;
  min-width: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
}
.segmented button {
  min-height: 34px;
  padding: 6px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-soft);
  font-size: 12px;
  white-space: nowrap;
}
.segmented button.active {
  background: var(--surface);
  color: var(--brand-strong);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(23, 33, 38, 0.1);
}

.analysis-summary-strip { display: flex; gap: 9px; margin-bottom: 12px; overflow-x: auto; }
.summary-chip {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 11px;
  white-space: nowrap;
}
.summary-chip strong { color: var(--text); }
.analysis-list { display: grid; gap: 10px; }
.analysis-row {
  display: grid;
  gap: 9px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.analysis-row:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.analysis-row.buy { border-left-color: var(--green); }
.analysis-row.sell { border-left-color: var(--red); }
.analysis-row.hold { border-left-color: var(--amber); }
.analysis-row.error { border-left-color: var(--red); }
.analysis-row-main { min-width: 0; }
.analysis-row-main strong { font-size: 15px; }
.analysis-row-meta { display: flex; flex-wrap: wrap; gap: 6px 13px; margin-top: 3px; color: var(--text-faint); font-size: 11px; }
.analysis-row p { color: var(--text-soft); font-size: 12px; }
.analysis-reason { padding: 8px 10px; border-radius: 6px; background: var(--surface-soft); color: var(--text-soft); font-size: 12px; }
.inline-status { color: var(--text-soft); font-size: 12px; }

.candle-health-grid { display: grid; gap: 8px; }
.candle-pair {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #edf1f2;
}
.candle-pair:last-child { border-bottom: 0; }
.timeframe-strip { display: grid; grid-template-columns: repeat(7, minmax(42px, 1fr)); gap: 5px; }
.timeframe-chip {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 10px;
  text-align: center;
}
.timeframe-chip.ok { border-color: #b8dfca; background: var(--green-soft); color: var(--green); }
.timeframe-chip.warn { border-color: #ecd29d; background: var(--amber-soft); color: var(--amber); }
.timeframe-chip.error { border-color: #edb6b2; background: var(--red-soft); color: var(--red); }

.audit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.audit-card {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  cursor: pointer;
}
.audit-card:hover { border-color: var(--line-strong); background: var(--surface); }
.audit-card-head strong { font-size: 17px; }
.audit-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.audit-metrics div { display: grid; gap: 1px; }
.audit-metrics span { color: var(--text-faint); font-size: 10px; }
.audit-metrics strong { font-size: 13px; }
.audit-quality { display: flex; flex-wrap: wrap; gap: 5px; }
.audit-card p {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 12px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}
.mini-bar { display: flex; height: 5px; overflow: hidden; border-radius: 3px; background: var(--surface-strong); }
.mini-bar .wins { background: var(--green); }
.mini-bar .losses { background: var(--red); }
.win-meter {
  width: 100%;
  height: 7px;
  border: 0;
  border-radius: 4px;
  background: var(--red-soft);
  appearance: none;
}
.win-meter::-webkit-meter-bar { border: 0; border-radius: 4px; background: var(--red-soft); }
.win-meter::-webkit-meter-optimum-value { border-radius: 4px; background: var(--green); }
.win-meter::-moz-meter-bar { border-radius: 4px; background: var(--green); }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.setting-row { min-height: 74px; justify-content: space-between; gap: 20px; }
.setting-row p { margin-top: 4px; color: var(--text-soft); font-size: 12px; }
.switch { position: relative; width: 46px; height: 26px; flex: 0 0 auto; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #b7c2c6;
  cursor: pointer;
  transition: background 0.18s ease;
}
.switch span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(23, 33, 38, 0.2);
  content: "";
  transition: transform 0.18s ease;
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(8, 127, 107, 0.15); }
.services-list { display: grid; gap: 4px; }
.service-row { min-height: 44px; padding: 5px 0; border-bottom: 1px solid #edf1f2; }
.service-row:last-child { border-bottom: 0; }
.service-row-main { display: flex; align-items: center; gap: 8px; }
.setting-stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.setting-stat-grid div { display: grid; gap: 2px; padding: 9px; border-radius: 6px; background: var(--surface-soft); }
.setting-stat-grid span { color: var(--text-faint); font-size: 10px; }
.setting-stat-grid strong { font-size: 17px; }
.session-details { display: grid; gap: 8px; margin-bottom: 13px; }
.session-details div { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 7px; border-bottom: 1px solid #edf1f2; }
.session-details span { color: var(--text-faint); }

.detail-dialog, .confirm-dialog {
  max-width: none;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(23, 33, 38, 0.23);
}
.detail-dialog { width: min(980px, calc(100vw - 28px)); max-height: calc(100vh - 28px); }
.confirm-dialog { width: min(430px, calc(100vw - 28px)); }
.detail-dialog::backdrop, .confirm-dialog::backdrop { background: rgba(15, 25, 28, 0.54); }
.dialog-shell { display: grid; max-height: calc(100vh - 30px); grid-template-rows: auto minmax(0, 1fr); }
.dialog-head { min-height: 66px; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.dialog-eyebrow, .eyebrow { color: var(--brand); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.dialog-body { min-height: 0; overflow-y: auto; padding: 16px; }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.detail-metric { display: grid; min-height: 65px; align-content: center; gap: 2px; padding: 9px; border-radius: 6px; background: var(--surface-soft); }
.detail-metric span { color: var(--text-faint); font-size: 10px; }
.detail-metric strong { overflow-wrap: anywhere; font-size: 14px; }
.detail-section { margin-top: 15px; }
.detail-section > h3 { margin-bottom: 8px; }
.detail-copy { padding: 11px; border-left: 3px solid var(--brand); background: var(--surface-soft); color: var(--text-soft); white-space: pre-wrap; }
.json-details { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.json-details summary { color: var(--brand); cursor: pointer; font-weight: 700; }
.json-details pre {
  max-height: 360px;
  overflow: auto;
  margin: 9px 0 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f6f8f9;
  color: #26353b;
  font: 12px/1.5 Consolas, "Courier New", monospace;
  white-space: pre-wrap;
  word-break: break-word;
}
.confirm-shell { display: grid; justify-items: center; gap: 10px; padding: 24px; text-align: center; }
.confirm-shell p { color: var(--text-soft); }
.confirm-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 8px; background: var(--amber-soft); color: var(--amber); }
.confirm-actions { width: 100%; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; width: min(360px, calc(100vw - 30px)); gap: 8px; }
.toast {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--brand);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
.toast p { color: var(--text-soft); font-size: 12px; }
.toast button { display: grid; width: 24px; height: 24px; place-items: center; padding: 0; border: 0; background: transparent; color: var(--text-faint); }

.login-page { background: #eef3f4; }
.login-layout { display: grid; min-height: 100vh; grid-template-columns: minmax(320px, 0.85fr) minmax(440px, 1.15fr); }
.login-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  padding: 42px;
  background: var(--sidebar);
  color: #fff;
}
.login-brand-panel > p { color: #9fc1ba; font-size: 12px; }
.login-status-list { display: grid; gap: 18px; max-width: 360px; }
.login-status-list div { display: flex; align-items: center; gap: 12px; color: #d7e8e4; font-size: 15px; }
.login-status-list svg { width: 21px; height: 21px; color: #71d5bf; }
.login-form-panel { display: grid; min-height: 100vh; place-items: center; padding: 36px; background: var(--surface); }
.login-form { display: grid; width: min(100%, 410px); gap: 17px; }
.login-heading { margin-bottom: 8px; }
.login-heading h1 { margin-top: 5px; font-size: 28px; }
.login-heading p { margin-top: 7px; color: var(--text-soft); }
.field { display: grid; gap: 6px; }
.field > span { color: var(--text-soft); font-size: 12px; font-weight: 700; }
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; top: 11px; left: 11px; width: 17px; height: 17px; color: var(--text-faint); pointer-events: none; }
.input-wrap input { width: 100%; height: 42px; padding-left: 38px; padding-right: 42px; }
.password-toggle {
  position: absolute;
  top: 3px;
  right: 4px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-faint);
}
.password-toggle:hover { color: var(--brand); }
.login-submit { width: 100%; min-height: 43px; margin-top: 2px; }
.login-submit.is-loading svg { animation: spin 0.9s linear infinite; }
.form-alert { padding: 10px 11px; border: 1px solid #edb6b2; border-radius: 6px; background: var(--red-soft); color: #852020; font-size: 12px; }
.login-security { display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--text-faint); font-size: 11px; }
.login-security svg { width: 14px; height: 14px; }
.mobile-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(15, 25, 28, 0.45); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.45; } }

#auditView > .panel {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

@media (max-width: 1280px) {
  .agents-grid, .audit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid:not(.compact-kpis) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .kpi-grid:not(.compact-kpis) > .metric-card { grid-column: span 2; }
  .kpi-grid:not(.compact-kpis) > .metric-card:nth-last-child(-n + 2) { grid-column: span 3; }
  .dashboard-grid-main .span-8, .dashboard-grid-main .span-4,
  .dashboard-grid-main .span-7, .dashboard-grid-main .span-5 { grid-column: span 12; }
}

@media (max-width: 980px) {
  :root { --sidebar-width: 222px; }
  .content { padding: 16px; }
  .kpi-grid, .kpi-grid.compact-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid:not(.compact-kpis) > .metric-card { grid-column: auto; }
  .span-5, .span-7 { grid-column: span 12; }
  .settings-grid { grid-template-columns: 1fr; }
  .login-layout { grid-template-columns: 0.75fr 1.25fr; }
  .login-brand-panel { padding: 30px; }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); }
  .workspace { margin-left: 0; }
  .mobile-menu { display: inline-grid; }
  .last-refresh, .user-button > span:not(.user-avatar) { display: none; }
  .topbar { padding: 9px 13px; }
  .content { padding: 13px; }
  .agents-grid, .audit-grid { grid-template-columns: 1fr; }
  .page-toolbar, .orders-toolbar { align-items: stretch; flex-direction: column; }
  .orders-toolbar .segmented { width: 100%; overflow-x: auto; }
  .segmented button { flex: 0 0 auto; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-layout { display: block; }
  .login-brand-panel { min-height: auto; padding: 20px 24px; }
  .login-status-list, .login-brand-panel > p { display: none; }
  .login-form-panel { min-height: calc(100vh - 84px); padding: 28px 20px; }
}

@media (max-width: 560px) {
  h1 { font-size: 18px; }
  .topbar-left p { overflow: hidden; max-width: 220px; text-overflow: ellipsis; white-space: nowrap; }
  .kpi-grid, .kpi-grid.compact-kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric-card { min-height: 92px; padding: 11px; }
  .metric-value strong { font-size: 21px; }
  .kpi-grid > .metric-card:last-child:nth-child(odd) { grid-column: span 2; }
  .panel { padding: 12px; }
  .filter-group, .toolbar-actions { width: 100%; }
  .search-field, .search-field input, .filter-group select { width: 100%; }
  .toolbar-actions > button { flex: 1; }
  .agent-quote-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-card-footer { align-items: stretch; flex-direction: column; }
  .agent-actions { justify-content: flex-end; }
  .timeframe-strip { grid-template-columns: repeat(4, minmax(42px, 1fr)); }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .dialog-body { padding: 12px; }
  .setting-stat-grid { grid-template-columns: 1fr; }
  .login-heading h1 { font-size: 24px; }
}
