:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --ink: #111827;
  --muted: #667085;
  --line: #d8dee6;
  --green: #0f9f6e;
  --red: #d84c4c;
  --amber: #c88316;
  --blue: #2563eb;
  --shadow: 0 18px 44px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 10px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h2,
.empty-state h3,
.empty-state p {
  margin: 0;
}

.brand h1 {
  font-size: 19px;
  line-height: 1.1;
}

.brand p,
.topbar p,
.empty-state p,
.upload-zone small,
.metric-list span,
.analysis-strip span {
  color: var(--muted);
}

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

.panel h2 {
  margin-bottom: 14px;
  font-size: 14px;
  text-transform: uppercase;
  color: #344054;
}

.upload-zone {
  display: grid;
  gap: 7px;
  place-items: center;
  padding: 22px 16px;
  border: 1px dashed #aab4c0;
  border-radius: 8px;
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
}

.upload-zone svg,
.primary-btn svg,
.secondary-btn svg,
.danger-btn svg,
.empty-state svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
  border: 1px solid var(--line);
}

#chartInput {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.field-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.field-grid label {
  display: grid;
  gap: 6px;
  color: #475467;
  font-size: 13px;
  font-weight: 650;
}

.field-grid .check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 28px;
}

.check-row input {
  width: 16px;
  height: 16px;
}

.field-grid input,
.field-grid select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 0 11px;
  color: var(--ink);
}

.primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  margin-top: 14px;
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

.secondary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #263241;
  font-weight: 750;
  cursor: pointer;
}

.camera-only {
  display: none;
}

.secondary-btn:hover {
  border-color: #98a2b3;
  background: #f8fafc;
}

.danger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  margin-top: 10px;
  border: 1px solid #efb6b6;
  border-radius: 7px;
  background: #fff7f7;
  color: #b42318;
  font-weight: 750;
  cursor: pointer;
}

.danger-btn:hover {
  background: #fee4e2;
}

.primary-btn:disabled {
  cursor: not-allowed;
  background: #aab4c0;
}

.input-hint {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.signal-card {
  display: grid;
  gap: 6px;
  padding: 13px;
  border-radius: 8px;
  background: #f7faf8;
  border: 1px solid #cfe7dc;
}

.signal-card.empty {
  background: #f8fafc;
  border-color: var(--line);
}

.signal-card.bearish {
  background: #fff7f7;
  border-color: #f0caca;
}

.signal-card.neutral {
  background: #fffbeb;
  border-color: #ead8a2;
}

.signal-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #98a2b3;
}

.metric-list {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.metric-list div,
.analysis-strip div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 36px;
  border-top: 1px solid var(--line);
}

.metric-list strong,
.analysis-strip strong {
  text-align: right;
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100vh;
  padding: 22px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
}

.topbar h2 {
  font-size: 22px;
}

.mode-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 8px 12px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.chart-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(#eef2f5 1px, transparent 1px),
    linear-gradient(90deg, #eef2f5 1px, transparent 1px),
    #fff;
  background-size: 42px 42px;
  box-shadow: var(--shadow);
  min-height: 0;
}

#chartCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  color: #475467;
}

.analysis-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding-top: 18px;
}

.analysis-strip div {
  border-top: 0;
  border-left: 1px solid var(--line);
  padding-left: 14px;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: none;
    overflow: visible;
  }

  .workspace {
    height: auto;
    min-height: 72vh;
    padding: 16px;
    overflow: visible;
  }

  .topbar {
    align-items: flex-start;
  }

  .chart-stage {
    height: 62vh;
    min-height: 420px;
  }

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

  .camera-only {
    display: flex;
  }
}

@media (max-width: 560px) {
  .sidebar {
    padding: 14px;
  }

  .workspace {
    padding: 12px;
  }

  .topbar {
    display: grid;
  }

  .mode-pill {
    width: max-content;
  }

  .chart-stage {
    height: 58vh;
    min-height: 360px;
  }

  .analysis-strip div {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
  }
}
