/* === BIGSYS:CSS:TOKENS START === */
:root {
  --bg: #0b1220;
  --panel: #121c2e;
  --panel-2: #17243a;
  --text: #e9eef7;
  --muted: #94a3b8;
  --line: rgba(255,255,255,.10);
  --accent: #38bdf8;
  --good: #22c55e;
  --good-soft: rgba(34,197,94,.16);
  --warn: #f59e0b;
  --warn-soft: rgba(245,158,11,.18);
  --danger: #ef4444;
  --danger-soft: rgba(239,68,68,.18);
  --radius: 16px;
}
/* === BIGSYS:CSS:TOKENS END === */

/* === BIGSYS:CSS:BASE START === */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, Segoe UI, sans-serif; }
body { overflow: auto; }
button, input { font: inherit; }
button { cursor: pointer; }
/* === BIGSYS:CSS:BASE END === */

/* === BIGSYS:CSS:LAYOUT START === */
#bigsys-app {
  min-width: 1320px;
  min-height: 100vh;
  padding: 16px;
}

.app-region-top,
.app-region-bottom {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(660px, 1fr) 430px;
  gap: 12px;
  align-items: start;
}

.app-region {
  display: grid;
  gap: 12px;
}

.bigsys-zone {
  min-width: 0;
}

.panel-card,
.header-card,
.filters-bar,
.debug-panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(0,0,0,.22);
}

.panel-card { padding: 14px; }
.zone-title { font-size: 14px; color: var(--muted); margin-bottom: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
/* === BIGSYS:CSS:LAYOUT END === */

/* === BIGSYS:CSS:HEADER START === */
.header-card {
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.header-card h1 { margin: 0; font-size: 24px; }
.header-card p { margin: 4px 0 0; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.candidate-pill,
.loading-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  background: rgba(255,255,255,.04);
}
/* === BIGSYS:CSS:HEADER END === */

/* === BIGSYS:CSS:BUTTONS START === */
.btn,
.filter-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(255,255,255,.06);
  color: var(--text);
}
.btn:hover,
.filter-btn:hover { border-color: rgba(56,189,248,.45); }
.btn-success { background: var(--good-soft); border-color: rgba(34,197,94,.35); }
.btn-soft { background: rgba(56,189,248,.12); border-color: rgba(56,189,248,.35); }
.btn-footer { padding: 10px 14px; }
/* === BIGSYS:CSS:BUTTONS END === */

/* === BIGSYS:CSS:FILTERS START === */
.filters-bar {
  padding: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.filter-btn.active {
  background: rgba(56,189,248,.18);
  border-color: rgba(56,189,248,.55);
}
/* === BIGSYS:CSS:FILTERS END === */

/* === BIGSYS:CSS:CARDS START === */
.info-grid,
.totals-grid,
.supplier-card {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.supplier-card { grid-template-columns: 1fr 180px 180px; }

.info-grid div,
.totals-grid div,
.supplier-card div,
.empty-box {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line);
}
.info-grid span,
.totals-grid span,
.supplier-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.info-grid strong,
.totals-grid strong,
.supplier-card strong {
  display: block;
  margin-top: 4px;
}
.empty-box { color: var(--muted); }
/* === BIGSYS:CSS:CARDS END === */

/* === BIGSYS:CSS:INVOICE_LIST START === */
.manual-load {
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
}
.manual-load label { display: block; color: var(--muted); margin-bottom: 8px; }
.manual-load-row { display: flex; gap: 8px; }
.manual-load input {
  width: 100%;
  min-width: 0;
  padding: 9px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.2);
  color: var(--text);
}
.invoice-list { display: grid; gap: 8px; margin-top: 10px; }
.invoice-list-item {
  text-align: left;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--text);
}
.invoice-list-item strong,
.invoice-list-item span { display: block; }
.invoice-list-item span { color: var(--muted); font-size: 12px; margin-top: 4px; }
.invoice-list-item.active { border-color: rgba(56,189,248,.55); background: rgba(56,189,248,.12); }
/* === BIGSYS:CSS:INVOICE_LIST END === */

/* === BIGSYS:CSS:LINES START === */
.lines-stack { display: grid; gap: 10px; }
.invoice-line-card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 12px;
  background: rgba(255,255,255,.04);
}
.invoice-line-card.status-soft-green { border-color: rgba(34,197,94,.35); background: var(--good-soft); }
.invoice-line-card.status-yellow { border-color: rgba(245,158,11,.42); background: var(--warn-soft); }
.invoice-line-card.status-red { border-color: rgba(239,68,68,.42); background: var(--danger-soft); }

.line-main {
  display: grid;
  grid-template-columns: 95px minmax(260px, 1fr) 90px 76px 110px 110px 170px;
  gap: 8px;
  align-items: stretch;
}
.line-status-pill,
.line-description,
.line-field {
  border-radius: 12px;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.08);
  padding: 8px;
}
.line-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.line-value {
  margin-top: 4px;
  font-weight: 700;
  line-height: 1.25;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.line-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}
.line-actions .btn { padding: 7px 9px; }

.line-bubbles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}
.bubble {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  background: rgba(255,255,255,.06);
  font-size: 12px;
}
.bubble strong { color: var(--muted); }
.bubble em { font-style: normal; color: var(--text); }
.bubble-info { border-color: rgba(56,189,248,.28); }
.bubble-success { border-color: rgba(34,197,94,.30); }
.bubble-warning { border-color: rgba(245,158,11,.30); }
.bubble-danger { border-color: rgba(239,68,68,.30); }
/* === BIGSYS:CSS:LINES END === */

/* === BIGSYS:CSS:PREVIEW START === */
.preview-panel {
  position: sticky;
  top: 12px;
}
.preview-image {
  width: 100%;
  max-height: calc(100vh - 170px);
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.2);
}
/* === BIGSYS:CSS:PREVIEW END === */

/* === BIGSYS:CSS:PREVIEW_LINKS_V2 START === */
.preview-empty {
  line-height: 1.45;
}

.preview-file-name {
  display: inline-block;
  margin-top: 6px;
  color: var(--text);
  font-weight: 700;
  word-break: break-word;
}

.preview-test-title {
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.preview-links {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.preview-test-btn {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(56,189,248,.45);
  background: rgba(56,189,248,.13);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.preview-test-btn:hover {
  border-color: rgba(56,189,248,.85);
  background: rgba(56,189,248,.22);
}

.preview-test-btn small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  word-break: break-all;
}

.preview-meta {
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,.18);
  color: var(--muted);
  word-break: break-all;
}
/* === BIGSYS:CSS:PREVIEW_LINKS_V2 END === */


/* === BIGSYS:CSS:FOOTER_ACTIONS START === */
.footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
/* === BIGSYS:CSS:FOOTER_ACTIONS END === */

/* === BIGSYS:CSS:DEBUG START === */
.debug-panel {
  padding: 12px;
  color: var(--muted);
}
.debug-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
/* === BIGSYS:CSS:DEBUG END === */

/* === BIGSYS:CSS:RESPONSIVE START === */
@media (max-width: 1320px) {
  #bigsys-app {
    min-width: 1280px;
    padding: 12px;
  }

  .app-shell {
    grid-template-columns: 280px minmax(620px, 1fr) 380px;
  }

  .line-main {
    grid-template-columns: 85px minmax(240px, 1fr) 82px 70px 100px 100px 155px;
  }
}

@media (max-width: 760px) {
  #bigsys-app {
    min-width: 390px;
    width: 100%;
    padding: 10px;
  }

  .app-shell {
    display: block;
  }

  .app-region-left,
  .app-region-center,
  .app-region-right {
    margin-bottom: 12px;
  }

  .header-card {
    display: block;
  }

  .header-actions {
    margin-top: 10px;
    flex-wrap: wrap;
  }

  .filters-bar {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .info-grid,
  .totals-grid,
  .supplier-card {
    grid-template-columns: 1fr;
  }

  .line-main {
    grid-template-columns: 1fr;
  }

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

  .preview-panel {
    position: static;
  }
}
/* === BIGSYS:CSS:RESPONSIVE END === */
