:root {
  --bg: #f2f0e8;
  --ink: #16211c;
  --muted: #5d6e67;
  --line: rgba(22, 33, 28, 0.12);
  --panel: rgba(255, 252, 245, 0.9);
  --panel-strong: #fffdf8;
  --green: #16724f;
  --green-deep: #0e5037;
  --gold: #d9a441;
  --navy: #16374f;
  --rose: #b85648;
  --bullish: #d9f1e4;
  --bearish: #fde0d8;
  --shadow: 0 24px 50px rgba(50, 55, 44, 0.1);
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 0% 0%, rgba(217, 164, 65, 0.22), transparent 24%),
    radial-gradient(circle at 100% 0%, rgba(22, 114, 79, 0.16), transparent 22%),
    linear-gradient(180deg, #f8f4ea 0%, #ece6d8 100%);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  background: rgba(250, 244, 232, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.7);
}

.brand-kicker,
.eyebrow,
.tile-kicker {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--green-deep);
}

.brand-title {
  margin-top: 6px;
  font-size: 25px;
  font-weight: 800;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.nav-links a,
.nav-button {
  appearance: none;
  border: 1px solid rgba(22, 33, 28, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  text-decoration: none;
  padding: 11px 15px;
  cursor: pointer;
  font: inherit;
}

.logout-form {
  margin: 0;
}

.time-chip {
  display: inline-flex;
  align-items: center;
  min-height: 43px;
  border: 1px solid rgba(22, 33, 28, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
}

.login-page {
  min-height: 100vh;
}

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

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 252, 245, 0.94);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 10px 0 8px;
  font-size: 34px;
  line-height: 1.08;
}

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

.form-error {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(184, 86, 72, 0.26);
  background: rgba(253, 224, 216, 0.9);
  color: var(--rose);
  font-weight: 700;
}

.page-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 28px auto 48px;
}

.hero-grid,
.content-grid,
.orders-grid {
  display: grid;
  gap: 20px;
}

.hero-grid {
  grid-template-columns: 1.18fr 0.82fr;
}

.content-grid,
.orders-grid {
  grid-template-columns: 1fr 1fr;
  margin-top: 20px;
}

.hero-card,
.panel-card,
.orders-card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
  border-radius: var(--radius-xl);
  padding: 24px;
}

.compact-card {
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.75), rgba(246, 255, 250, 0.92)),
    var(--panel);
}

.control-card {
  background:
    linear-gradient(145deg, rgba(255, 246, 223, 0.84), rgba(250, 255, 252, 0.9)),
    var(--panel);
}

.card-heading h1,
.card-heading h2 {
  margin: 8px 0 0;
  line-height: 1.08;
}

.card-heading h1 {
  font-size: clamp(30px, 4vw, 42px);
}

.lede {
  color: var(--muted);
  max-width: 68ch;
}

.lede.small {
  font-size: 14px;
}

.status-panel,
.callback-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  margin-bottom: 10px;
}

.status-live {
  background: var(--bullish);
  color: var(--green-deep);
}

.status-idle {
  background: rgba(93, 110, 103, 0.14);
  color: var(--muted);
}

.strategy-form,
.broker-form {
  display: grid;
  gap: 14px;
}

.compact-form {
  margin-top: 20px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
}

.checkbox-stack {
  display: grid;
  align-content: center;
  gap: 10px;
  padding-top: 22px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
}

.primary-button {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--green), var(--navy));
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
}

.danger {
  color: var(--rose);
  border-color: rgba(184, 86, 72, 0.22);
}

.action-stack {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.action-tile {
  appearance: none;
  text-align: left;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  display: grid;
  gap: 6px;
}

.action-tile strong {
  font-size: 18px;
}

.action-tile span:last-child {
  color: var(--muted);
}

.add-tile {
  background: linear-gradient(135deg, rgba(217, 164, 65, 0.18), rgba(255, 255, 255, 0.78));
}

.init-tile {
  background: linear-gradient(135deg, rgba(22, 114, 79, 0.14), rgba(255, 255, 255, 0.78));
}

.callback-card code {
  display: block;
  margin-top: 8px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: #18231d;
  color: #dcf6e7;
  overflow: auto;
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 13px;
}

.callback-card p {
  margin: 10px 0 0;
  color: var(--muted);
}

.broker-panel {
  transition: max-height 260ms ease, opacity 220ms ease, transform 220ms ease, padding 220ms ease;
  max-height: 1200px;
  opacity: 1;
  transform: translateY(0);
  overflow: hidden;
}

.broker-panel.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  transform: translateY(-8px);
  border-width: 0;
  margin-top: 0;
}

.broker-list {
  display: grid;
  gap: 14px;
}

.broker-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.meta-line {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

th {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

.bullish-card {
  background: linear-gradient(180deg, rgba(217, 241, 228, 0.88), rgba(255, 252, 245, 0.94));
}

.bearish-card {
  background: linear-gradient(180deg, rgba(253, 224, 216, 0.9), rgba(255, 252, 245, 0.94));
}

.log-box {
  min-height: 320px;
  margin: 0;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: #111b16;
  color: #d8f2e4;
  overflow: auto;
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 13px;
  line-height: 1.45;
}

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

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
}

.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(14, 22, 18, 0.52);
  backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  width: min(560px, calc(100% - 24px));
  padding: 24px;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255, 252, 245, 0.98), rgba(247, 244, 235, 0.98));
  box-shadow: 0 30px 70px rgba(16, 26, 21, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 30px;
  cursor: pointer;
  line-height: 1;
}

.modal-callback {
  margin-bottom: 18px;
}

@media (max-width: 1024px) {
  .hero-grid,
  .content-grid,
  .orders-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .navbar {
    padding: 16px;
    align-items: flex-start;
    flex-direction: column;
  }

  .page-shell {
    width: min(100% - 20px, 1380px);
  }
}
