:root {
  --bg-dark: #f6f8fa;
  --bg-card: #ffffff;
  --border-color: #d0d7de;
  --accent-cyan: #0969da;
  --accent-green: #1a7f37;
  --accent-red: #cf222e;
  --accent-gold: #9a6700;
  --text-main: #1f2328;
  --text-muted: #656d76;
  --card-bg: #ffffff;
  --border: #d0d7de;
  --accent: #0969da;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 10%, rgba(255,255,255,0.92), transparent 28%),
    linear-gradient(135deg, #eaf7ff 0%, #d8f0f7 48%, #c9ecf4 100%);
  color: var(--text-main);
  padding: 26px 30px;
}

body.auth-checking .app-container,
body.auth-locked .app-container,
body.auth-ready #auth-gate {
  display: none;
}

body.auth-ready .app-container {
  display: grid;
}

.auth-gate {
  min-height: calc(100vh - 52px);
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.72fr);
  gap: 22px;
  align-items: stretch;
}

.auth-hero,
.auth-status-panel {
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(208,215,222,0.9);
  box-shadow: 0 14px 38px rgba(31,35,40,0.12);
}

.auth-hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 620px;
  padding: 36px;
  border-radius: 18px;
}

.auth-brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  font-size: 15px;
}

.auth-brand-row h1 {
  font-size: 22px;
  line-height: 1;
}

.auth-brand-row p,
.auth-copy p,
.auth-feature-grid span {
  color: var(--text-muted);
}

.auth-brand-row p {
  margin-top: 5px;
  font-size: 13px;
}

.auth-copy {
  max-width: 650px;
}

.auth-kicker {
  display: inline-flex;
  margin-bottom: 14px;
  color: #0969da;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-copy h2 {
  max-width: 720px;
  font-size: clamp(40px, 6vw, 78px);
  line-height: 0.92;
  letter-spacing: 0;
  color: #1f2328;
}

.auth-copy p {
  max-width: 560px;
  margin-top: 20px;
  font-size: 16px;
  line-height: 1.55;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  min-height: 48px;
}

.auth-error {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #ff8182;
  border-radius: 8px;
  background: #ffebe9;
  color: #cf222e;
  font-size: 13px;
  font-weight: 600;
}

.auth-status-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  border-radius: 18px;
}

.auth-status-header {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: #30363d;
}

.auth-status-light {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #cf222e;
  box-shadow: 0 0 0 5px rgba(207,34,46,0.12);
}

.auth-terminal {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 12px;
  background: #111827;
  color: #dbeafe;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.5;
}

.auth-terminal span {
  font-family: inherit;
}

.auth-feature-grid {
  display: grid;
  gap: 10px;
}

.auth-feature-grid div {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  background: #f6f8fa;
}

.auth-feature-grid strong {
  font-size: 13px;
}

.auth-feature-grid span {
  font-size: 12px;
}

.app-container {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  max-width: 1500px;
  min-height: calc(100vh - 52px);
  margin: 0 auto;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid rgba(208,215,222,0.85);
  border-radius: 18px;
  box-shadow: 0 14px 38px rgba(31,35,40,0.12);
}

.workspace-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 12px 16px;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  border-top-left-radius: 18px;
  border-bottom-left-radius: 18px;
}

.workspace-brand {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #111827;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
}

.workspace-brand h1 {
  font-size: 14px;
  line-height: 1.1;
  font-weight: 700;
  color: #30363d;
}

.workspace-brand p {
  margin-top: 2px;
  font-size: 11px;
  color: #7d8590;
}

.brand-chevron {
  color: #7d8590;
  font-weight: 700;
}

.sidebar-panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 20px;
  font-weight: 700;
  color: #24292f;
}

.sidebar-tools {
  color: #6b7280;
  font-size: 14px;
  letter-spacing: 5px;
}

.header-tabs {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
  min-width: 0;
}

.tab-link {
  display: grid !important;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-height: 31px;
  min-width: 0;
  width: 100%;
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  color: #5f666d;
  padding: 6px 9px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
  transition: background-color 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.tab-icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: #7d8590;
  font-size: 15px;
  line-height: 1;
}

.tab-link span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-link.active, .tab-link:hover {
  color: #24292f;
  background: #f1f2f4;
}

.tab-link.active {
  background: #eeeeef;
  box-shadow: none;
}

.tab-link.active .tab-icon,
.tab-link:hover .tab-icon {
  color: #24292f;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.section-label {
  display: flex;
  justify-content: space-between;
  padding: 6px 8px 4px;
  color: #7d8590;
  font-size: 13px;
  font-weight: 700;
}

.sidebar-link {
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 7px;
  color: #4b5563;
  font-size: 14px;
  font-weight: 600;
}

.sidebar-link.muted {
  color: #5f666d;
}

.sidebar-link:hover {
  background: #f6f8fa;
}

.market-link {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  min-height: 42px;
  padding: 7px 9px;
  border-radius: 8px;
  color: #4b5563;
}

.market-link:hover {
  background: #f6f8fa;
}

.market-link strong {
  display: block;
  overflow: hidden;
  color: #3f4a57;
  font-size: 13px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-link small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: #8c959f;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-dot {
  width: 10px;
  height: 10px;
  margin-top: 3px;
  border: 1px solid #8c959f;
  border-radius: 50%;
  background: #ffffff;
}

.market-dot.live {
  border-color: #1f883d;
  background: #1f883d;
  box-shadow: 0 0 0 3px #dafbe1;
}

.sidebar-footer-chip {
  margin-top: auto;
  align-self: flex-start;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: #eaf8fb;
  color: #14424d;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.sidebar-footer-chip.active,
.sidebar-footer-chip:hover {
  background: #d7f2f7;
  color: #0f3440;
}

.workspace-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #ffffff;
}

.workspace-topbar {
  display: grid;
  grid-template-columns: minmax(280px, 430px) 1fr;
  align-items: center;
  gap: 16px;
  min-height: 58px;
  padding: 9px 22px;
  background: #f4f4f5;
  border-bottom: 1px solid #e5e7eb;
}

.search-shell {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 430px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(31,35,40,0.06);
  color: #8c959f;
}

.search-shell input {
  width: 100%;
  border: 0;
  outline: 0;
  color: #24292f;
  font-size: 14px;
  background: transparent;
}

.workspace-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 50px;
  padding: 10px 22px;
  border-bottom: 1px solid #e5e7eb;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #7d8590;
  font-size: 14px;
  font-weight: 600;
}

.breadcrumbs strong {
  color: #5f666d;
}

.workspace-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 22px;
  background: #ffffff;
}

.control-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.mode-chip,
.user-chip {
  display: inline-flex;
  align-items: center;
  height: 38px;
  border: 1px solid #e5e7eb;
  background: var(--card-bg);
  color: var(--text-main);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(31,35,40,0.05);
}

.mode-chip {
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.user-chip {
  gap: 8px;
  height: 34px;
  max-width: 270px;
  padding: 0 8px 0 10px;
  font-size: 12px;
}

.role-chip {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: #0969da;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.user-email {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-main);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  background: #f6f8fa;
  border: 1px solid #d8dee4;
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}

.topbar-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  font-weight: 700;
  cursor: pointer;
}

.topbar-icon:hover {
  background: #ffffff;
  border-color: #e5e7eb;
}

.logout-button {
  min-height: 34px;
  background: #cf222e !important;
  color: #ffffff !important;
  border-color: #cf222e !important;
  font-size: 13px;
}

.icon-button:hover {
  color: var(--text-main);
  background: #eef1f4;
}

.bot-actions {
  display: inline-flex;
  gap: 8px;
}

.btn {
  min-height: 34px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.1);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary { background: #1f883d; color: #fff; }
.btn-danger { background: #cf222e; color: #fff; }
.btn-small { padding: 4px 8px; font-size: 12px; background: #eef1f4; color: var(--text-main); border: 1px solid var(--border-color); }
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.status-ribbon {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.status-item {
  min-height: 96px;
  padding: 18px 18px;
  border: 1px solid #e5e7eb;
  border-radius: 11px;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(31,35,40,0.08);
}

.status-item .badge,
.status-item .metric-val {
  display: block;
  margin: 18px 0 0;
  font-size: 23px;
  line-height: 1;
  font-weight: 700;
}

.status-item .badge {
  display: inline-block;
  padding: 0;
  border-radius: 0;
  background: transparent !important;
}

.card {
  background: var(--bg-card);
  border: 1px solid #e5e7eb;
  border-radius: 11px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(31,35,40,0.08);
}

.card h2 {
  color: #30363d;
  font-size: 16px;
  font-weight: 700;
}

.status-label { font-size: 13px; color: var(--text-muted); }
.metric-val { font-size: 16px; font-weight: 700; margin-left: 6px; }
.positive { color: var(--accent-green); }
.negative { color: var(--accent-red); }

.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
}
.badge.online { background: #dafbe1; color: var(--accent-green); }
.badge.stopped { background: #ffebe9; color: var(--accent-red); }
.badge.running { background: #ddf4ff; color: var(--accent-cyan); }
.badge.clear { background: #fff8c5; color: var(--accent-gold); }

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

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 13px;
}

.data-table th, .data-table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid #edf0f2;
}

.data-table th {
  color: #7d8590;
  font-size: 12px;
  font-weight: 700;
  background: #fafafa;
}

.signal-tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}
.signal-tag.buy { background: #dafbe1; color: var(--accent-green); border: 1px solid #aceebb; }
.signal-tag.sell { background: #ffebe9; color: var(--accent-red); border: 1px solid #ffc1c0; }
.signal-tag.neutral { background: #f3f4f6; color: var(--text-muted); border: 1px solid var(--border-color); }

.signal-action-stack {
  display: grid;
  grid-template-columns: minmax(120px, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 180px;
}

.signal-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.signal-action-stack .btn {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.action-optimal {
  width: 100%;
  background: #0969da !important;
  color: #ffffff !important;
  border-color: #0969da !important;
}

.action-mr {
  background: #ddf4ff !important;
  color: #0969da !important;
  border-color: #b6e3ff !important;
}

.action-tf {
  background: #dafbe1 !important;
  color: #1a7f37 !important;
  border-color: #aceebb !important;
}

.tab-view { display: none; }
.tab-view.active { display: block; }

@media (max-width: 1180px) {
  body {
    padding: 14px;
  }

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

  .app-container {
    grid-template-columns: minmax(210px, 240px) minmax(0, 1fr);
  }

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

  .control-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

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

  .grid-col-8,
  .grid-col-4 {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .auth-hero {
    min-height: auto;
    gap: 42px;
    padding: 26px;
  }

  .auth-copy h2 {
    font-size: 42px;
  }

  .app-container {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .workspace-sidebar {
    display: none;
  }

  .workspace-content {
    padding: 14px;
  }

  .workspace-page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .bot-actions {
    width: 100%;
  }

  .bot-actions .btn {
    flex: 1 1 0;
  }

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

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
}

.log-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
  margin-bottom: 12px;
}

.log-filter-select, .log-search-input {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 13px;
}

.terminal-box {
  background: #f8fafc;
  color: #0f172a;
  font-family: 'JetBrains Mono', monospace;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  height: 420px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.5;
}
