:root {
  color-scheme: dark;
  --bg: #080b0f;
  --panel: #111821;
  --panel-2: #0d131b;
  --line: #24303d;
  --line-soft: #1a2430;
  --text: #eef3f8;
  --muted: #91a1b4;
  --green: #2fd38b;
  --red: #f46f72;
  --amber: #f2b84b;
  --blue: #6fa8ff;
  --teal: #2ec9d3;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.36);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow-x: hidden;
}

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

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand strong {
  font-size: 16px;
  line-height: 1.1;
}

.brand span,
.mini {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.back-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b1118;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px;
}

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

.span-12 {
  grid-column: span 12;
}

.span-8 {
  grid-column: span 8;
}

.span-6 {
  grid-column: span 6;
}

.span-4 {
  grid-column: span 4;
}

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

.panel.pad {
  padding: 14px;
}

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

.section-title h2 {
  margin: 0;
  font-size: 17px;
}

.section-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.metric {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-2);
}

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

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #172131;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.button.primary {
  border-color: rgba(47, 211, 139, 0.5);
  background: #123326;
  color: #c9ffe4;
}

.button.danger {
  border-color: rgba(244, 111, 114, 0.55);
  background: #321518;
  color: #ffd2d2;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 99px;
  border: 1px solid var(--line);
  padding: 0 8px;
  color: var(--muted);
  background: #0b1118;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.chip.green {
  color: #bfffe0;
  border-color: rgba(47, 211, 139, 0.45);
  background: rgba(47, 211, 139, 0.1);
}

.chip.amber {
  color: #ffe1a1;
  border-color: rgba(242, 184, 75, 0.45);
  background: rgba(242, 184, 75, 0.1);
}

.chip.red {
  color: #ffd3d3;
  border-color: rgba(244, 111, 114, 0.45);
  background: rgba(244, 111, 114, 0.1);
}

.chip.blue,
.chip.teal {
  color: #d5e6ff;
  border-color: rgba(111, 168, 255, 0.45);
  background: rgba(111, 168, 255, 0.1);
}

.tabs,
.bottom-nav {
  display: flex;
  gap: 6px;
}

.tabs {
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  color: var(--text);
  border-color: rgba(111, 168, 255, 0.55);
  background: #152033;
}

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 10;
  justify-content: space-around;
  justify-self: stretch;
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  overflow: hidden;
  border-top: 1px solid var(--line-soft);
  background: rgba(8, 11, 15, 0.96);
  backdrop-filter: blur(18px);
  padding: 8px;
}

.nav-button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  padding: 0 3px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-button.active {
  background: #121a25;
  color: var(--text);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 9px 10px;
  text-align: left;
  font-size: 12px;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.table td:last-child,
.table th:last-child {
  text-align: right;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.stack {
  display: grid;
  gap: 10px;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.strategy-builder {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 14px;
}

.field {
  display: grid;
  gap: 5px;
}

.field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.field input,
.field select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #0b1118;
  color: var(--text);
}

.check-row {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #0b1118;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.notice {
  border: 1px solid rgba(111, 168, 255, 0.35);
  border-radius: 8px;
  padding: 10px;
  background: rgba(111, 168, 255, 0.08);
  color: #d5e6ff;
  font-size: 12px;
  line-height: 1.45;
}

.notice.warn {
  border-color: rgba(242, 184, 75, 0.4);
  background: rgba(242, 184, 75, 0.08);
  color: #ffe1a1;
}

.heatmap-wrap,
.bars-wrap {
  overflow-x: auto;
}

.heatmap {
  display: grid;
  grid-template-columns: 68px repeat(24, 34px) 44px;
  gap: 3px;
  min-width: 940px;
  font-size: 10px;
}

.heat-cell,
.heat-head,
.heat-date,
.heat-total {
  min-height: 26px;
  border-radius: 5px;
  display: grid;
  place-items: center;
}

.heat-head,
.heat-date,
.heat-total {
  color: var(--muted);
  background: #0b1118;
  border: 1px solid var(--line-soft);
  font-weight: 800;
}

.heat-cell {
  border: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(46, 201, 211, 0.08);
  color: #e9fbff;
  font-weight: 800;
}

.heat-cell.l1 { background: rgba(46, 201, 211, 0.16); }
.heat-cell.l2 { background: rgba(46, 201, 211, 0.26); }
.heat-cell.l3 { background: rgba(47, 211, 139, 0.34); }
.heat-cell.l4 { background: rgba(242, 184, 75, 0.38); }

.bars {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 32px;
  align-items: end;
  gap: 6px;
  min-height: 170px;
  padding-top: 10px;
}

.bar-item {
  display: grid;
  grid-template-rows: 20px 110px 20px;
  gap: 4px;
  text-align: center;
  color: var(--muted);
  font-size: 10px;
}

.bar-track {
  align-self: stretch;
  display: flex;
  align-items: flex-end;
  border-radius: 6px;
  background: #0b1118;
  border: 1px solid var(--line-soft);
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  min-height: 2px;
  background: var(--teal);
}

.empty {
  color: var(--muted);
  font-size: 12px;
  padding: 14px;
}

.auth-card {
  width: min(430px, calc(100vw - 32px));
  margin: 48px auto;
}

@media (max-width: 840px) {
  .content {
    padding: 12px;
  }

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

  .span-8,
  .span-6,
  .span-4,
  .span-12 {
    grid-column: span 1;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .strategy-builder {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    min-height: 58px;
    padding: 10px 12px;
  }

  .bottom-nav {
    gap: 3px;
    padding: 6px;
  }

  .nav-button {
    font-size: 10px;
  }
}

@media (max-width: 520px) {
  .strategy-builder {
    grid-template-columns: 1fr;
  }
}
