:root {
  --bg0: #16120f;
  --bg1: #1f1914;
  --bg2: #2a221b;
  --line: #3d3228;
  --text: #f3ebe1;
  --muted: #b9a99a;
  --accent: #c45c26;
  --accent2: #2f6f5e;
  --high: #c43c3c;
  --med: #e0a04a;
  --low: #4a9bc4;
  --font: "Be Vietnam Pro", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --bs-body-bg: var(--bg0);
  --bs-body-color: var(--text);
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--muted);
  --bs-tertiary-bg: var(--bg2);
  --bs-emphasis-color: var(--text);
}

* { box-sizing: border-box; }

html, body {
  font-family: var(--font);
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(196,92,38,.16), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(47,111,94,.12), transparent 50%),
    var(--bg0);
  color: var(--text) !important;
  min-height: 100%;
}

a, p, span, label, td, th, li, dt, dd, h1, h2, h3, h4, h5, h6, small, div {
  color: inherit;
}

.brand, .brand-mark { font-family: var(--display); color: var(--accent) !important; }
.brand { font-size: 2.4rem; }
.brand-mark { font-size: 1.35rem; }
.page-title { font-family: var(--display); color: var(--text) !important; }

.text-secondary, .form-label, .metric-label, small.text-secondary {
  color: var(--muted) !important;
}

.login-art {
  background:
    linear-gradient(135deg, rgba(22,18,15,.25), rgba(22,18,15,.7)),
    linear-gradient(160deg, #3a2418, #1a2a24 60%, #16120f);
  border-left: 1px solid var(--line);
}

.app-nav {
  background: rgba(20,16,12,.94) !important;
  backdrop-filter: blur(8px);
}
.app-nav .nav-link {
  color: var(--muted) !important;
  text-decoration: none;
  padding: .5rem .75rem !important;
}
.app-nav .nav-link.active,
.app-nav .nav-link:hover { color: var(--text) !important; }

.btn-accent { background: var(--accent); border-color: #a84a1c; color: #fff !important; }
.btn-accent:hover { background: #d4682e; color: #fff !important; border-color: #a84a1c; }
.btn-teal { background: var(--accent2); border-color: #24574a; color: #fff !important; }
.btn-teal:hover { background: #3a8672; color: #fff !important; }
.btn-outline-light { color: var(--text) !important; border-color: var(--line) !important; }
.btn-outline-light:hover { background: var(--bg2) !important; color: #fff !important; }

.card, .card-soft, .modal-content, .offcanvas {
  background: var(--bg1) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
}
.card-soft { border-radius: .75rem; background: linear-gradient(180deg, var(--bg1), var(--bg0)) !important; }
.card-body, .modal-body, .offcanvas-body { color: var(--text) !important; }

.card-metric { cursor: pointer; transition: transform .12s, border-color .12s; min-height: 100%; }
.card-metric:hover { transform: translateY(-2px); border-color: var(--accent) !important; }
.metric-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; color: var(--text) !important; }
.metric-hint { font-size: .7rem; color: var(--accent) !important; margin-top: .35rem; }

.form-control, .form-select {
  background: var(--bg0) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}
.form-control:focus, .form-select:focus {
  background: var(--bg0) !important;
  color: var(--text) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 .2rem rgba(196,92,38,.2);
}
.form-control::placeholder { color: #8a7b6c !important; }
.form-select option { background: var(--bg1); color: var(--text); }
.form-check-input { background-color: var(--bg2); border-color: var(--line); }
.form-check-label { color: var(--text) !important; }

/* Tables — one style only */
.table-responsive-annb {
  max-height: min(55vh, 480px);
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--bg1);
}
.table-annb {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-striped-bg: rgba(255,255,255,.04);
  --bs-table-striped-color: var(--text);
  --bs-table-hover-bg: rgba(196,92,38,.12);
  --bs-table-hover-color: var(--text);
  --bs-table-border-color: var(--line);
  color: var(--text) !important;
  font-size: .8125rem;
  margin-bottom: 0;
}
.table-annb > :not(caption) > * > * {
  color: var(--text) !important;
  background-color: transparent;
  border-bottom-color: var(--line);
}
.table-annb thead th {
  background: var(--bg2) !important;
  color: var(--muted) !important;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 600;
}
.table-annb td {
  vertical-align: middle;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text) !important;
}
.table-annb td.td-wrap {
  white-space: normal;
  max-width: 320px;
  word-break: break-word;
}

/* Badges — light text always on colored bg */
.badge { color: #fff !important; font-weight: 600; }
.badge-high { background: var(--high) !important; }
.badge-med { background: var(--med) !important; color: #1a1208 !important; }
.badge-low { background: var(--low) !important; }
.badge-none { background: #6a6258 !important; }
.badge.text-bg-secondary,
.badge.text-bg-dark,
.badge.text-bg-success {
  color: #fff !important;
}

/* Alerts empty / info — no Bootstrap gray black-text */
.alert-annb {
  background: var(--bg2) !important;
  border: 1px solid var(--line) !important;
  color: var(--text) !important;
}
.alert-danger {
  background: rgba(196,60,60,.2) !important;
  border-color: var(--high) !important;
  color: #ffc9c9 !important;
}

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: .75rem;
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  background: rgba(0,0,0,.15);
}
.dropzone.drag { border-color: var(--accent); color: var(--text); background: rgba(196,92,38,.08); }
.dropzone .upload-file-list {
  text-align: left;
  max-height: 120px;
  overflow: auto;
  margin-top: .75rem;
  font-size: .78rem;
}
.upload-progress-wrap {
  margin-top: .75rem;
}
.upload-progress-wrap .progress {
  height: .65rem;
  background: rgba(255,255,255,.08);
  border-radius: 999px;
  overflow: hidden;
}
.upload-progress-wrap .progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #e8a05a);
  width: 0%;
  transition: width .15s ease;
}
.sample-pack-box {
  border: 1px solid var(--line);
  border-radius: .5rem;
  padding: .75rem;
  background: rgba(0,0,0,.12);
}
.ws-wizard-tabs .nav-link {
  font-size: .9rem;
}
.ws-wizard-tabs .nav-link i {
  margin-right: .35rem;
}

.offcanvas-header .btn-close,
.modal-header .btn-close { filter: invert(1); }
.modal-header, .modal-footer, .offcanvas-header { border-color: var(--line) !important; }

.nav-pills .nav-link {
  color: var(--muted) !important;
  border: 1px solid var(--line);
  margin: 0 .25rem .35rem 0;
  background: transparent;
}
.nav-pills .nav-link.active {
  background: #3a2618 !important;
  border-color: var(--accent) !important;
  color: var(--text) !important;
}

.list-group-item-annb {
  background: var(--bg0) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
  cursor: pointer;
}
.list-group-item-annb:hover,
.list-group-item-annb:focus {
  background: var(--bg2) !important;
  color: var(--text) !important;
}
.list-group-item-annb strong { color: var(--text) !important; }

pre.detail-json {
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: .5rem;
  padding: .75rem;
  font-size: .75rem;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.admin-tab-pane { display: none; }
.admin-tab-pane.active { display: block; }
.fl-scroll { max-height: 360px; overflow: auto; }
.fl-ai-pre {
  white-space: pre-wrap;
  max-height: 320px;
  overflow: auto;
  background: rgba(0,0,0,.2);
  padding: .75rem;
  border-radius: .35rem;
}

.fb-canvas-wrap {
  position: relative;
  overflow: hidden;
  height: min(70vh, 640px);
  min-height: 480px;
  background:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: #14100c;
  border-radius: 0 0 .75rem .75rem;
  cursor: default;
}
.fb-canvas-wrap.fb-panning { cursor: grabbing; }
.fb-world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.fb-edges {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}
.fb-canvas {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
}
.fb-zoom-bar {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(20,16,12,.85);
  border: 1px solid var(--line);
  border-radius: .5rem;
  padding: 4px 8px;
}
.fb-ctx-menu {
  position: fixed;
  z-index: 1080;
  min-width: 160px;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: .5rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  padding: .35rem;
}
.fb-ctx-menu.d-none { display: none !important; }
.fb-ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: .4rem .55rem;
  border-radius: .35rem;
  font-size: .85rem;
}
.fb-ctx-menu button:hover { background: rgba(255,255,255,.06); }
.fb-ctx-menu hr {
  margin: .25rem 0;
  border-color: var(--line);
  opacity: 1;
}
.fb-node {
  position: absolute;
  width: 220px;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: .6rem;
  padding: .5rem .6rem .55rem;
  cursor: grab;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  color: var(--text);
  user-select: none;
  box-sizing: border-box;
}
.fb-node.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(196,92,38,.35); }
.fb-node.is-start { border-color: var(--accent2); }
.fb-node.fb-condition { border-left: 3px solid #4a9bc4; }
.fb-node.fb-action { border-left: 3px solid var(--accent); }
.fb-node.fb-end { border-left: 3px solid #6a6258; }
.fb-node-head { font-size: .65rem; color: var(--muted); letter-spacing: .04em; }
.fb-node-title { font-size: .85rem; font-weight: 600; margin: .15rem 0; }
.fb-node-sub { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-ports { display: flex; flex-wrap: wrap; gap: 4px; margin-top: .4rem; }
.fb-port {
  font-size: .65rem;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg0);
  color: var(--text);
  cursor: pointer;
}
.fb-port:hover { border-color: var(--accent); }
.fb-lib-list { max-height: 220px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.fb-lib { max-height: calc(100vh - 220px); overflow: auto; }
.nav-tabs .nav-link {
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
}
.nav-tabs .nav-link.active {
  color: var(--text);
  background: transparent;
  border-bottom-color: var(--accent);
}
.brand-footer, .app-footer { color: var(--muted) !important; }
.app-footer { background: rgba(0,0,0,.2); }
.cell-detail-btn {
  background: transparent;
  border: 0;
  color: var(--accent) !important;
  padding: 0;
  text-align: left;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: inherit;
}
.cell-detail-btn:hover { color: #e07a3f !important; }
.detail-full-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  color: var(--text);
}
.ai-report-md {
  line-height: 1.55;
  word-break: break-word;
}
.ai-report-md ul { padding-left: 1.2rem; }
.ai-report-md code {
  font-size: 0.85em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
}
.ai-report-md hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin: 1rem 0;
}

@media (max-width: 576px) {
  .metric-value { font-size: 1.25rem; }
  .table-annb td { max-width: 140px; }
}
