:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --text: #162033;
  --muted: #667085;
  --line: #dfe5ef;
  --navy: #0f172a;
  --blue: #2563eb;
  --blue2: #dbeafe;
  --green: #138a56;
  --red: #c0392b;
  --amber: #b7791f;
  --shadow: 0 8px 28px rgba(15, 23, 42, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --panel: #11182a;
    --text: #eef3ff;
    --muted: #aeb8ca;
    --line: #26324a;
    --navy: #e8eefb;
    --blue: #79a7ff;
    --blue2: #193a73;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button, .file-button { min-height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); padding: 9px 14px; cursor: pointer; }
button.primary { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 700; }
button.compact { min-height: 40px; white-space: nowrap; }
button.danger { color: #fff; background: var(--red); border-color: var(--red); }
button:disabled { opacity: .55; cursor: wait; }
input, select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); padding: 9px 11px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: .92rem; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.35rem, 4vw, 2rem); }
h2 { font-size: 1.08rem; margin-bottom: 10px; }
p { color: var(--muted); line-height: 1.45; }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; background: rgba(15, 23, 42, .97); color: #fff; box-shadow: 0 2px 16px rgba(0,0,0,.18); }
.topbar h1 { color: #fff; }
.eyebrow { font-size: .68rem; font-weight: 800; letter-spacing: .12em; color: #a9c6ff; }
main { width: min(1500px, 100%); margin: 0 auto; padding: 14px 12px 100px; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--panel); padding: 6px; border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 14px; position: sticky; top: 82px; z-index: 15; }
.tab { border: 0; background: transparent; min-height: 42px; }
.tab.active { background: var(--blue2); color: var(--blue); font-weight: 800; }
.view { display: none; }
.view.active { display: block; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.metric { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 16px; padding: 15px; min-height: 112px; display: grid; align-content: center; gap: 8px; }
.metric span, .metric small { color: var(--muted); }
.metric strong { font-size: clamp(1.2rem, 3vw, 1.75rem); overflow-wrap: anywhere; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-head.wrap { flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select { width: auto; min-width: 170px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 1080px; font-size: .88rem; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2), th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4) { text-align: left; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; background: var(--panel); }
.status-pill { display: inline-flex; border-radius: 999px; padding: 4px 8px; font-size: .76rem; font-weight: 700; background: var(--blue2); color: var(--blue); }
.status-pill.warn { background: #fff3cd; color: #8a5b00; }
.status-pill.bad { background: #fde2e0; color: #a02b20; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.category-chart { width: min(230px, 70vw); aspect-ratio: 1; border-radius: 50%; margin: 4px auto 16px; position: relative; background: #dfe5ef; }
.category-chart::after { content: ''; position: absolute; inset: 24%; border-radius: 50%; background: var(--panel); }
.category-list { display: grid; gap: 7px; }
.category-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 7px; }
.bars { display: grid; gap: 12px; }
.bar-item { display: grid; gap: 5px; }
.bar-label { display: flex; justify-content: space-between; gap: 12px; font-size: .88rem; }
.bar-track { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--blue); border-radius: inherit; }
.cards { display: grid; gap: 10px; }
.position-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 10px; }
.position-card .mainline { display: flex; justify-content: space-between; gap: 10px; }
.position-card .meta { color: var(--muted); font-size: .86rem; display: flex; flex-wrap: wrap; gap: 8px 14px; }
.position-card .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.position-card.disabled { opacity: .62; }
.settings-form { display: grid; gap: 12px; }
.settings-form h2 { margin-bottom: 0; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.file-button { display: inline-flex; align-items: center; justify-content: center; color: var(--text); }
.file-button input { display: none; }
.export-panel { display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; }
.status-banner { padding: 10px 12px; margin-bottom: 10px; border-radius: 12px; background: #eaf3ff; color: #144d8a; border: 1px solid #cfe3ff; }
.hidden { display: none !important; }
.warning-item { border-left: 4px solid var(--amber); padding: 10px 12px; background: rgba(183,121,31,.08); margin: 8px 0; border-radius: 8px; }
.warning-item .actions { margin-top: 8px; }
.provider-status { border: 1px solid var(--line); padding: 10px; border-radius: 10px; margin-bottom: 10px; }
.danger-zone { border-color: rgba(192,57,43,.4); }
dialog { border: 0; border-radius: 18px; padding: 0; width: min(720px, calc(100vw - 20px)); max-height: calc(100dvh - 24px); background: var(--panel); color: var(--text); box-shadow: 0 24px 80px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(4,10,20,.68); }
.dialog-form { padding: 16px; display: grid; gap: 12px; overflow-y: auto; max-height: calc(100dvh - 24px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; position: sticky; top: -16px; background: var(--panel); padding: 12px 0 8px; z-index: 3; }
.dialog-head h2 { margin: 0; }
.icon-btn { width: 44px; padding: 0; }
.form-grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 8px; color: var(--text); }
.check input { width: 20px; min-height: auto; height: 20px; }
details { border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
details[open] { display: grid; gap: 10px; }
summary { cursor: pointer; font-weight: 700; }
.dialog-actions { position: sticky; bottom: -16px; display: flex; justify-content: flex-end; gap: 8px; background: var(--panel); padding: 10px 0 14px; }
.symbol-box { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 9px; }
.resolve-result { display: grid; gap: 7px; }
.resolve-candidate { border: 1px solid var(--line); border-radius: 10px; padding: 9px; display: grid; gap: 5px; }
.resolve-candidate.good { border-color: var(--green); }
.resolve-candidate button { justify-self: start; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); max-width: min(92vw, 560px); background: #111827; color: #fff; padding: 11px 14px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .18s ease; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 900px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .topbar { align-items: flex-end; }
  .topbar .compact { font-size: .82rem; padding: 8px 10px; }
  main { padding-inline: 8px; }
  .tabs { top: 77px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
  .metric { min-height: 100px; padding: 11px; }
  .metric strong { font-size: 1.12rem; }
  .panel { padding: 11px; border-radius: 14px; }
  .form-grid.two { grid-template-columns: 1fr; }
  .filters { width: 100%; }
  .filters select { width: 100%; }
  .position-card .mainline { display: grid; }
}

/* v2.1 diagnostics and provider transparency */
.position-warning {
  margin-top: .65rem;
  padding: .65rem .75rem;
  border-radius: .8rem;
  background: rgba(220, 38, 38, .10);
  color: #f2b5af;
  font-size: .88rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.field-help {
  display: block;
  margin: -.2rem 0 .55rem;
  color: var(--muted);
  line-height: 1.35;
}
.diagnostics-result {
  display: grid;
  gap: .55rem;
  margin-top: .8rem;
}
.diag-row {
  display: grid;
  gap: .2rem;
  padding: .7rem .8rem;
  border: 1px solid var(--border);
  border-radius: .8rem;
  background: rgba(255,255,255,.025);
  overflow-wrap: anywhere;
}
.diag-row.ok strong { color: #8ee3b5; }
.diag-row.fail strong { color: #f4aaa3; }
.diag-row span { color: var(--muted); font-size: .86rem; }

.position-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.position-values > div { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; display: grid; gap: 3px; background: rgba(255,255,255,.015); }
.position-values span { color: var(--muted); font-size: .76rem; }
.position-values strong { font-size: .92rem; overflow-wrap: anywhere; }
@media (max-width: 420px) { .position-values { grid-template-columns: 1fr; } }

.field-hint { color: var(--muted); font-size: .78rem; line-height: 1.35; }
.field-hint.ok { color: var(--good); }
.field-hint.warn { color: var(--warn); }
.export-panel .small-note { flex-basis: 100%; margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.export-panel .button-row button { min-width: 190px; }
