:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --line: #2c3847;
  --text: #e8eef5;
  --muted: #8b9aab;
  --accent: #3ecf8e;
  --warn: #e6a23c;
  --danger: #e35d6a;
  --font: "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(900px 500px at 10% -10%, #1d3a33 0%, transparent 55%),
    radial-gradient(700px 400px at 100% 0%, #243044 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.9rem 1rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

.top h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.sub {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.status-block {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot.off { background: var(--danger); }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  padding: 0.85rem 1rem 1.5rem;
}

.panel {
  background: color-mix(in srgb, var(--panel) 92%, black);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem 0.95rem 1rem;
}

.panel.wide { grid-column: 1 / -1; }

.panel h2 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
  font-weight: 600;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.metrics label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metrics strong { font-size: 1.05rem; }

.trade-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

.trade-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.trade-form input,
.trade-form select,
.trade-form button {
  font: inherit;
  padding: 0.6rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #121820;
  color: var(--text);
}

.trade-form button {
  grid-column: 1 / -1;
  background: var(--accent);
  color: #062016;
  border: none;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.trade-form button:hover { filter: brightness(1.05); }

.msg { min-height: 1.2rem; font-size: 0.85rem; color: var(--warn); }

.table-wrap { overflow: visible; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead { display: none; }

#adviceTable tbody tr {
  display: block;
  margin-bottom: 0.7rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121820;
}

#adviceTable td {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.28rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  text-align: right;
}

#adviceTable td:last-child { border-bottom: none; }

#adviceTable td::before {
  content: attr(data-label);
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
}

th { color: var(--muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; }

button.linkish,
a.linkish {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--accent);
  border-radius: 4px;
  padding: 0.28rem 0.5rem;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.8rem;
  display: inline-block;
}

.chart-preview {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-preview img {
  max-width: 100%;
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.muted { color: var(--muted); }

.install-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  background: #152018;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 0.88rem;
}

.install-banner[hidden] { display: none !important; }

.install-banner p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.install-btn { margin-left: 0; }
.install-btn.on {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}

.install-dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  max-width: min(28rem, calc(100vw - 2rem));
  width: 100%;
  padding: 1.1rem 1.15rem;
}

.install-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.install-dialog ol {
  padding-left: 1.2rem;
  line-height: 1.45;
}

.engine-pill {
  margin-left: 0;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
}

.engine-pill.on {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}

.small { font-size: 0.85rem; margin: 0 0 0.6rem; }

.empty-banner {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

.fill-hint {
  grid-column: 1 / -1;
  min-height: 1.1rem;
  font-size: 0.82rem;
  color: var(--accent);
}

.rec-list {
  display: grid;
  gap: 0.85rem;
}

.rec-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #121820;
  padding: 0.9rem 0.95rem 1rem;
}

.rec-card.selected {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.rec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  margin-bottom: 0.7rem;
}

.rec-badge {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.rec-ticker { font-size: 1.15rem; letter-spacing: 0.02em; }
.rec-time { margin-inline-start: auto; color: var(--muted); font-size: 0.75rem; }

.rec-money {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
  padding: 0.65rem 0.7rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, #0c1218);
}

.rec-money span,
.rec-grid span,
.plan-summary span,
.pos-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 0.15rem;
}

.rec-money strong { font-size: 1.2rem; color: var(--accent); }

.rec-grid,
.plan-summary,
.pos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.75rem;
  margin-bottom: 0.75rem;
}

.rec-actions,
.playbook-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.primary-btn {
  font: inherit;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #062016;
  font-weight: 600;
  padding: 0.55rem 0.85rem;
  min-height: 44px;
  cursor: pointer;
}

.primary-btn:hover { filter: brightness(1.05); }

.playbook h3 {
  margin: 1rem 0 0.4rem;
  font-size: 0.95rem;
  color: var(--text);
}

.steps {
  margin: 0;
  padding-inline-start: 1.2rem;
  line-height: 1.5;
  font-size: 0.9rem;
  color: var(--text);
}

.steps li { margin-bottom: 0.35rem; }
.steps em { color: var(--warn); font-style: normal; }

.plan-summary {
  grid-template-columns: repeat(2, 1fr);
  padding: 0.7rem;
  border-radius: 8px;
  background: #121820;
  border: 1px solid var(--line);
}

.plan-summary .danger { color: var(--danger); }
.plan-summary .ok { color: var(--accent); }

.tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.tab {
  flex: 1;
  font: inherit;
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #121820;
  color: var(--muted);
  cursor: pointer;
}

.tab.on {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, #121820);
}

.money-line { margin: 0.15rem 0; }

.pos-list {
  display: grid;
  gap: 0.7rem;
}

.pos-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.8rem;
  background: #121820;
}

.pos-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.55rem;
}

.pos-card .primary-btn { width: 100%; }

@media (min-width: 900px) {
  .rec-grid,
  .plan-summary { grid-template-columns: repeat(4, 1fr); }
  .pos-grid { grid-template-columns: repeat(3, 1fr); }
}

td.actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.login-card {
  width: min(22rem, 100%);
  background: color-mix(in srgb, var(--panel) 92%, black);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.4rem 1.25rem 1.35rem;
}

.login-card h1 {
  margin: 0 0 0.4rem;
  font-size: 1.3rem;
}

.login-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.login-form input {
  font: inherit;
  padding: 0.65rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #121820;
  color: var(--text);
}

.login-form button {
  font: inherit;
  min-height: 44px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #062016;
  font-weight: 600;
  cursor: pointer;
}

@media (min-width: 640px) {
  .trade-form { grid-template-columns: 1fr 1fr; }
  .trade-form .wide-field { grid-column: 1 / -1; }
}

@media (min-width: 900px) {
  .top {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
    padding: 1.5rem 2rem 1rem;
  }
  .top h1 { font-size: 1.6rem; }
  .grid {
    grid-template-columns: 1.4fr 1fr;
    padding: 1rem 2rem 2rem;
  }
  .metrics { grid-template-columns: repeat(4, 1fr); }
  thead { display: table-header-group; }
  #adviceTable tbody tr {
    display: table-row;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  #adviceTable td {
    display: table-cell;
    padding: 0.55rem 0.4rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
  }
  #adviceTable td::before { content: none; }
  .table-wrap { overflow-x: auto; }
}
