:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #dbe3ec;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --blue: #2563eb;
  --amber: #b45309;
  --green: #15803d;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 34%),
    linear-gradient(135deg, #f8fafc 0%, #e9eef5 100%);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-brand img {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-form input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
}

.login-form input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

.login-error {
  padding: 10px 12px;
  border: 1px solid rgba(185, 28, 28, 0.18);
  border-radius: 7px;
  color: #991b1b;
  background: #fef2f2;
  font-size: 13px;
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  font-weight: 760;
}

h2 {
  font-size: 18px;
  font-weight: 740;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}

.brand img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.topbar p,
.muted,
small {
  color: var(--muted);
  font-size: 13px;
}

.eyebrow,
.label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.top-actions,
.segments,
.filter-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.top-actions {
  justify-content: flex-end;
  position: relative;
}

.segments {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.segments a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.segments a.active {
  color: #ffffff;
  background: var(--text);
}

.filter-form {
  gap: 8px;
}

.filter-form label {
  display: grid;
  gap: 3px;
}

.filter-form label span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.filter-form select,
.filter-form input {
  height: 38px;
  min-width: 112px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 34px 0 10px;
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
}

.filter-form input {
  padding-right: 10px;
}

.top-link {
  display: inline-flex;
  align-items: center;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.top-link:hover {
  background: #ffffff;
}

button {
  height: 38px;
  border: 0;
  border-radius: 7px;
  padding: 0 15px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.settings-popover {
  position: relative;
}

.settings-popover summary {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  cursor: pointer;
  list-style: none;
}

.settings-popover summary::-webkit-details-marker {
  display: none;
}

.settings-popover summary:hover {
  border-color: #c4ceda;
  background: #ffffff;
}

.settings-popover svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: var(--text);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(420px, calc(100vw - 28px));
  max-height: calc(100vh - 110px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
  z-index: 30;
}

.settings-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.settings-divider {
  height: 1px;
  margin: 16px 0;
  background: var(--line);
}

main {
  width: min(1480px, calc(100% - 32px));
  margin: 18px auto 42px;
  display: grid;
  gap: 16px;
}

.hero,
.panel,
.kpis article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 20px;
}

.hero h2 {
  margin-top: 4px;
  font-size: 28px;
}

.hero p {
  margin-top: 6px;
  color: var(--muted);
}

.connection {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.connection strong,
.connection span {
  display: block;
}

.connection span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.dot {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border-radius: 50%;
}

.dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(21, 128, 61, 0.13);
}

.dot.warn {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(180, 83, 9, 0.13);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.kpis article {
  padding: 16px;
}

.kpis span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.kpis strong {
  display: block;
  margin: 8px 0 3px;
  font-size: 30px;
  line-height: 1;
}

.kpis strong em {
  margin-left: 6px;
  color: var(--muted);
  font-size: 15px;
  font-style: normal;
  font-weight: 800;
}

.panel {
  padding: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.table-filter {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.table-filter label {
  display: grid;
  gap: 3px;
}

.table-filter label span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.table-filter select,
.table-filter input {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
}

.table-filter select {
  min-width: 170px;
  padding-right: 34px;
}

.table-filter input {
  width: 130px;
  text-transform: uppercase;
}

.table-filter a {
  display: inline-flex;
  align-items: center;
  height: 38px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.table-filter a:hover {
  color: var(--text);
}

.table-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: -6px 0 12px;
}

.settings {
  display: grid;
  gap: 14px;
}

.switch-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.check-grid label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

input[type="number"] {
  width: 170px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  font: inherit;
  background: #ffffff;
}

.status-list {
  display: grid;
  gap: 10px;
}

.status-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.status-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.status-list span {
  color: var(--muted);
}

.status-list strong {
  text-align: right;
  overflow-wrap: anywhere;
}

.status-list.compact div {
  font-size: 13px;
}

.outcomes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.pie-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.pie-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.pie {
  width: 108px;
  height: 108px;
  flex: 0 0 108px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, var(--panel-soft) 0 55%, transparent 56%),
    conic-gradient(var(--accent) 0 var(--value), #d8e0ea var(--value) 360deg);
}

.pie span {
  font-size: 20px;
  font-weight: 850;
}

.pie-card strong,
.pie-card p,
.pie-card small {
  display: block;
}

.pie-card p {
  margin-top: 5px;
  color: var(--text);
  font-size: 14px;
}

.pie-card small {
  margin-top: 4px;
}

.outcome {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.outcome span {
  color: var(--muted);
  font-size: 13px;
}

.outcome strong {
  text-transform: capitalize;
}

.outcome b {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  font-size: 26px;
}

.table-wrap {
  overflow-x: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: fixed;
  background: #ffffff;
}

.report-table table {
  min-width: 0;
}

.report-kpis article strong {
  white-space: nowrap;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  overflow-wrap: anywhere;
  word-break: normal;
}

tbody tr:hover {
  background: #f8fafc;
}

tbody tr:last-child td {
  border-bottom: 0;
}

th {
  position: sticky;
  top: 0;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.th-filter {
  width: 100%;
  min-width: 0;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  border: 0;
  border-radius: 6px;
  padding: 4px 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-transform: inherit;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
}

.th-filter::after {
  content: "";
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.65;
}

.th-filter:hover,
.th-filter.active {
  color: var(--text);
  background: #e8eef5;
}

.th-filter.active::after {
  opacity: 1;
}

.grid-filter-popover[hidden] {
  display: none;
}

.grid-filter-popover {
  position: fixed;
  z-index: 70;
  width: 250px;
  max-height: 320px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
}

.grid-filter-head,
.grid-filter-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.grid-filter-head button,
.grid-filter-actions button {
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 12px;
}

.grid-filter-options {
  max-height: 220px;
  overflow: auto;
  padding: 8px;
}

.grid-filter-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
}

.grid-filter-options label:hover {
  background: var(--panel-soft);
}

.score {
  color: var(--danger);
  font-weight: 800;
}

.score-high {
  color: var(--success);
}

.score-mid {
  color: var(--amber);
}

.score-low {
  color: var(--danger);
}

.logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  margin-top: 14px;
  border: 1px solid rgba(185, 28, 28, 0.22);
  border-radius: 8px;
  color: #991b1b;
  background: rgba(254, 242, 242, 0.8);
  font-weight: 800;
  text-decoration: none;
}

.logout-link:hover {
  background: #fee2e2;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.pill.neutral {
  color: var(--blue);
  background: rgba(37, 99, 235, 0.1);
}

.pill.pending {
  color: var(--amber);
  background: rgba(180, 83, 9, 0.1);
}

.pill.done {
  color: var(--green);
  background: rgba(21, 128, 61, 0.1);
}

.trade-call {
  display: inline-flex;
  align-items: center;
  min-width: 66px;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.trade-call.go {
  color: var(--green);
  background: rgba(21, 128, 61, 0.14);
}

.trade-call.wait {
  color: #a16207;
  background: rgba(202, 138, 4, 0.16);
}

.trade-call.avoid {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.13);
}

.binary-respected {
  display: inline-flex;
  align-items: center;
  min-width: 42px;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--muted);
  background: #e8eef5;
  font-size: 12px;
  font-weight: 800;
}

.binary-respected.yes {
  color: var(--green);
  background: rgba(21, 128, 61, 0.14);
}

.binary-respected.no {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.13);
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0;
  background: var(--panel-soft);
  color: var(--text);
}

.icon-button:hover {
  background: #ffffff;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reason-modal[hidden] {
  display: none;
}

.reason-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.reason-dialog {
  width: min(560px, 100%);
  max-height: min(520px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 26px 70px rgba(15, 23, 42, 0.28);
}

.reason-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.reason-dialog pre {
  margin: 0;
  padding: 16px;
  white-space: pre-wrap;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
}

.setup-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--muted);
  background: #e8eef5;
  font-size: 12px;
  font-weight: 800;
}

.setup-pill.waiting-touch,
.setup-pill.touched-waiting-candle-close {
  color: #a16207;
  background: rgba(202, 138, 4, 0.16);
}

.setup-pill.confirmed-go {
  color: var(--green);
  background: rgba(21, 128, 61, 0.14);
}

.setup-pill.rejected-setup,
.setup-pill.trade-lost,
.setup-pill.legacy-respected {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.13);
}

.setup-pill.trade-won {
  color: var(--green);
  background: rgba(21, 128, 61, 0.14);
}

.trade-reason {
  display: block;
  margin-top: 5px;
  max-width: 100%;
}

.empty,
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 20px;
}

@media (max-width: 1100px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pie-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar,
  .hero,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-popover {
    position: static;
  }

  .settings-popover summary {
    width: 100%;
  }

  .settings-panel {
    left: 0;
    right: auto;
    width: 100%;
  }

  .segments {
    width: 100%;
    justify-content: stretch;
  }

  .segments a {
    flex: 1;
    text-align: center;
  }

  .kpis {
    grid-template-columns: 1fr;
  }

  .connection {
    min-width: 0;
  }

  main {
    width: min(100% - 20px, 1480px);
  }
}
