/* DrawbackOS Institutional Trade OS Theme */

:root {
  --bg: #070b12;
  --surface: #0d1420;
  --surface-2: #121c2d;
  --border: #1e2d44;
  --border-bright: #2b3f5e;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.14);
  --sky: #38bdf8;
  --sky-soft: rgba(56, 189, 248, 0.14);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --rose: #f43f5e;
  --rose-soft: rgba(244, 63, 94, 0.14);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #10b981, #0ea5e9);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  color: #04131c;
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-weight: 700;
  padding: 0 10px 8px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: #ecfdf5;
  font-weight: 600;
}

.nav-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  color: var(--emerald);
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.nav-badge.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.dataset-switcher {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dataset-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.dataset-btn:hover {
  border-color: var(--border-bright);
}

.dataset-btn.active {
  border-color: var(--emerald);
  background: rgba(16, 185, 129, 0.08);
}

.dataset-btn strong {
  display: block;
  font-size: 13px;
}

.dataset-btn small {
  color: var(--text-muted);
  font-size: 11px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.engine-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--emerald);
  font-weight: 600;
  margin-bottom: 8px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 10px var(--emerald);
}

.sidebar-footnote {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.45;
}

.sidebar-footnote code {
  color: var(--sky);
  font-size: 10.5px;
}

/* Main area */
.main-area {
  padding: 24px 32px 48px;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.company-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--emerald);
  font-weight: 700;
}

.company-title {
  margin: 2px 0 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fee-control {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.fee-control strong {
  color: var(--emerald);
  font-variant-numeric: tabular-nums;
}

.fee-control input[type="range"] {
  width: 90px;
  accent-color: var(--emerald);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--emerald);
  color: #03150e;
}

.btn-primary:hover {
  background: #34d399;
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border-bright);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--sky);
  color: #fff;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 14px;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--sky);
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}

.full-width { width: 100%; }

/* Views */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.18s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.kpi-card.highlight {
  background: linear-gradient(155deg, rgba(16, 185, 129, 0.14), var(--surface) 65%);
  border-color: rgba(16, 185, 129, 0.4);
}

.kpi-card.accent {
  background: linear-gradient(155deg, rgba(56, 189, 248, 0.12), var(--surface) 65%);
  border-color: rgba(56, 189, 248, 0.35);
}

.kpi-card.warn {
  background: linear-gradient(155deg, rgba(245, 158, 11, 0.13), var(--surface) 65%);
  border-color: rgba(245, 158, 11, 0.35);
}

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
}

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.kpi-card.highlight .kpi-value { color: #34d399; }
.kpi-card.accent .kpi-value { color: var(--sky); }
.kpi-card.warn .kpi-value { color: #fbbf24; }

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* Panels & Layouts */
.two-col-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.panel-header h2, .panel-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.panel-desc {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.meta-tag {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.meta-tag.warn-tag {
  background: var(--amber-soft);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

/* Bars */
.composition-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}

.bar-label-line {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.bar-label-line strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.bar-track {
  height: 9px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease;
}

.bar-fill.emerald { background: linear-gradient(90deg, #059669, #34d399); }
.bar-fill.sky { background: linear-gradient(90deg, #0284c7, #38bdf8); }
.bar-fill.mint { background: linear-gradient(90deg, #10b981, #a7f3d0); }

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.strip-label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.stats-strip strong {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

/* Warnings & Quick Actions */
.warnings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.warning-item {
  background: var(--amber-soft);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: #fde68a;
}

.warning-item.ok {
  background: var(--emerald-soft);
  border-color: rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
}

.quick-actions-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

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

.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(30, 45, 68, 0.65);
  vertical-align: top;
}

.data-table tr:hover td {
  background: rgba(18, 28, 45, 0.65);
}

.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sub-text {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.note-pill {
  display: inline-block;
  font-size: 11px;
  background: rgba(56, 189, 248, 0.1);
  color: #bae6fd;
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 6px;
  padding: 2px 7px;
  margin-top: 4px;
  margin-right: 4px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ready { background: var(--emerald-soft); color: #34d399; }
.status-pill.blocked { background: var(--amber-soft); color: #fbbf24; }
.status-pill.critical { background: var(--rose-soft); color: #fb7185; }
.status-pill.chased { background: var(--sky-soft); color: var(--sky); }

/* Filters & Inputs */
.filter-bar {
  display: flex;
  gap: 10px;
}

.input-field {
  background: var(--bg);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
}

.input-field:focus {
  outline: none;
  border-color: var(--emerald);
}

.code-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 12px;
  padding: 10px 12px;
  resize: vertical;
}

.form-group {
  margin-bottom: 14px;
}

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

.file-input {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.btn-row {
  display: flex;
  gap: 10px;
}

.json-preview {
  margin-top: 14px;
  background: #04070c;
  border: 1px solid var(--emerald);
  border-radius: 8px;
  padding: 12px;
  color: #a7f3d0;
  font-size: 12px;
  overflow-x: auto;
}

.hidden { display: none !important; }

/* Anomalies */
.cards-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.anomaly-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
}

.anomaly-hts-shift {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  padding: 5px 10px;
  border-radius: 7px;
  font-family: ui-monospace, monospace;
  font-size: 12.5px;
  margin: 8px 0;
  border: 1px solid var(--border);
}

.anomaly-money {
  text-align: right;
}

.anomaly-money .amt {
  font-size: 22px;
  font-weight: 800;
  color: #34d399;
  font-variant-numeric: tabular-nums;
}

/* Autonomous Chaser Agent */
.agent-hero {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.14), rgba(56, 189, 248, 0.09) 60%, var(--surface));
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.agent-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sky);
  font-weight: 700;
}

.agent-hero h2 { margin: 4px 0 6px; font-size: 20px; }
.agent-hero p { margin: 0; color: var(--text-muted); max-width: 660px; font-size: 13px; }

.agent-workspace {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 20px;
}

.chase-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chase-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 15px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chase-card:hover { border-color: var(--border-bright); }
.chase-card.selected { border-color: var(--emerald); background: rgba(16, 185, 129, 0.08); }

.chase-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.chase-email-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 16px;
}

.email-meta {
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.email-body {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
  color: #e2e8f0;
  margin: 0 0 14px;
}

.activity-log-wrap {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.activity-log-wrap h4 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.agent-log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.log-item {
  background: var(--bg);
  border-left: 3px solid var(--sky);
  padding: 8px 11px;
  border-radius: 6px;
  font-size: 12px;
}

.log-item.resolved {
  border-left-color: var(--emerald);
}

.log-empty, .empty-state {
  color: var(--text-dim);
  font-size: 13px;
  padding: 18px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

/* Reports & Trade Finance */
.deliverable-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.deliverable-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.deliverable-card h3 { margin: 0 0 4px; font-size: 15px; }
.deliverable-card p { margin: 0; font-size: 12.5px; color: var(--text-muted); }

.finance-sliders {
  margin-top: 16px;
}

.finance-sliders input[type="range"] {
  width: 100%;
  accent-color: var(--emerald);
}

.finance-output {
  margin-top: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fin-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.fin-row strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.fin-row.total {
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 14.5px;
  color: var(--text);
}

.emerald-text { color: #34d399 !important; }
.sky-text { color: var(--sky) !important; }

.template-links {
  font-size: 12px;
  display: flex;
  gap: 6px;
  color: var(--text-dim);
}

.template-links a {
  color: var(--sky);
  text-decoration: none;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 28px;
  background: #064e3b;
  border: 1px solid var(--emerald);
  color: #ecfdf5;
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  z-index: 999;
}

@media (max-width: 1120px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col-grid, .agent-workspace { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}
