/* ══════════════════════════════════════════════════════════════
   SPU – Smart Production Unit  |  Global Stylesheet
   Color system:
     Gradient bg : #0f5b73 → #1581a3
     Cards/btns  : #093442
     Text        : #ffffff / #c8dde5
   ══════════════════════════════════════════════════════════════ */

:root {
  --spu-bg-from    : #0f5b73;
  --spu-bg-to      : #1581a3;
  --spu-surface    : #093442;
  --spu-surface2   : #0b3d4f;
  --spu-border     : rgba(255,255,255,0.1);
  --spu-text       : #ffffff;
  --spu-muted      : #8db8c9;
  --spu-accent     : #1581a3;
  --spu-accent-hover:#1a96bd;
  --sidebar-w      : 240px;
  --topbar-h       : 60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(160deg, var(--spu-bg-from) 0%, var(--spu-bg-to) 100%);
  background-attachment: fixed;
  color: var(--spu-text);
  min-height: 100vh;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--spu-border); border-radius: 3px; }

/* ── Auth Layout ─────────────────────────────────────────── */
.spu-auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: var(--spu-surface);
  border: 1px solid var(--spu-border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  backdrop-filter: blur(10px);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo i {
  font-size: 3rem;
  color: var(--spu-accent);
}
.login-logo h2 { margin-top: 0.5rem; font-weight: 700; }
.login-logo p  { color: var(--spu-muted); font-size: 0.875rem; }

/* ── Sidebar ─────────────────────────────────────────────── */
.spu-sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--spu-surface);
  border-right: 1px solid var(--spu-border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1.5rem;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--spu-text);
  border-bottom: 1px solid var(--spu-border);
}
.sidebar-brand i { color: var(--spu-accent); font-size: 1.4rem; }

.sidebar-nav { list-style: none; padding: 0.75rem 0; flex: 1; }
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.5rem;
  color: var(--spu-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.15s;
  position: relative;
}
.sidebar-nav li a:hover { color: var(--spu-text); background: rgba(255,255,255,0.05); }
.sidebar-nav li a.active {
  color: var(--spu-text);
  background: rgba(21,129,163,0.25);
}
.sidebar-nav li a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--spu-accent);
}
.sidebar-nav li a i { font-size: 1rem; width: 20px; text-align: center; }

.nav-section {
  padding: 0.75rem 1.5rem 0.25rem;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--spu-muted);
  opacity: 0.6;
}

.badge-count {
  margin-left: auto;
  background: #e63946;
  color: white;
  border-radius: 10px;
  padding: 0 6px;
  font-size: 0.7rem;
  font-weight: 700;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--spu-border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.user-info { flex: 1; overflow: hidden; }
.user-info .fw-semibold { font-size: 0.875rem; }
.user-info .text-muted  { font-size: 0.75rem; color: var(--spu-muted) !important; }
.btn-logout {
  color: var(--spu-muted);
  font-size: 1.1rem;
  text-decoration: none;
  padding: 4px;
  transition: color 0.15s;
}
.btn-logout:hover { color: #e63946; }

/* ── Main layout ─────────────────────────────────────────── */
.spu-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.spu-topbar {
  height: var(--topbar-h);
  background: rgba(9,52,66,0.7);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--spu-border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.btn-toggle-sidebar {
  background: none;
  border: none;
  color: var(--spu-text);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
}

.page-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.content-area {
  padding: 1.5rem;
  flex: 1;
}

/* ── Cards ───────────────────────────────────────────────── */
.spu-card {
  background: var(--spu-surface);
  border: 1px solid var(--spu-border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 0;
}

.card-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--spu-muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
}

/* ── KPI Cards ───────────────────────────────────────────── */
.kpi-card {
  background: var(--spu-surface);
  border: 1px solid var(--spu-border);
  border-radius: 12px;
  padding: 1.25rem;
  height: 100%;
  text-align: center;
}

.kpi-icon { font-size: 1.75rem; margin-bottom: 0.5rem; color: var(--spu-accent); }
.kpi-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em;
             color: var(--spu-muted); margin-bottom: 0.25rem; }
.kpi-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; }
.kpi-sub   { font-size: 0.75rem; color: var(--spu-muted); margin-top: 0.25rem; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-spu {
  background: var(--spu-accent);
  border: 1px solid var(--spu-accent);
  color: white;
  font-weight: 500;
}
.btn-spu:hover { background: var(--spu-accent-hover); border-color: var(--spu-accent-hover); color: white; }
.btn-spu:active { background: var(--spu-bg-from); }

.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.75rem; }

/* ── Forms ───────────────────────────────────────────────── */
.spu-input,
.spu-input:focus {
  background: var(--spu-surface2) !important;
  border: 1px solid var(--spu-border) !important;
  color: var(--spu-text) !important;
  border-radius: 8px;
}
.spu-input::placeholder { color: var(--spu-muted); }
.spu-input:focus { outline: none; box-shadow: 0 0 0 2px rgba(21,129,163,0.4) !important; }
.spu-input option { background: var(--spu-surface2); color: var(--spu-text); }

.form-check-input:checked { background-color: var(--spu-accent); border-color: var(--spu-accent); }

.section-divider {
  color: var(--spu-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--spu-border);
  padding-bottom: 0.5rem;
  margin-bottom: 0;
}

/* ── Tables ──────────────────────────────────────────────── */
.spu-table {
  color: var(--spu-text);
  font-size: 0.875rem;
}
.spu-table thead th {
  background: var(--spu-surface2);
  border-color: var(--spu-border);
  color: var(--spu-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.spu-table tbody tr { border-color: var(--spu-border); }
.spu-table tbody tr:hover { background: rgba(21,129,163,0.08); }
.spu-table td { vertical-align: middle; border-color: var(--spu-border); }

/* ── Charts ──────────────────────────────────────────────── */
.chart-wrapper { position: relative; height: 260px; }

/* ── KPI Pills ───────────────────────────────────────────── */
.kpi-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}
.kpi-pill.success { background: rgba(46,204,113,0.2);  color: #2ecc71; }
.kpi-pill.warning { background: rgba(244,162,97,0.2);  color: #f4a261; }
.kpi-pill.danger  { background: rgba(230,57,70,0.2);   color: #e63946; }

/* ── Progress mini ───────────────────────────────────────── */
.progress-mini {
  display: inline-block;
  width: 60px;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--spu-accent);
  border-radius: 3px;
  transition: width 0.3s;
}

/* ── AI Insights ─────────────────────────────────────────── */
.insight-card {
  background: var(--spu-surface);
  border: 1px solid var(--spu-border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.insight-card.severity-critical { border-left: 4px solid #e63946; }
.insight-card.severity-warning  { border-left: 4px solid #f4a261; }
.insight-card.severity-info     { border-left: 4px solid #1581a3; }
.insight-header { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
.insight-title  { margin-bottom: 0.5rem; font-size: 1rem; }
.insight-summary { color: var(--spu-muted); font-size: 0.875rem; }

.severity-badge-critical { background: #e63946 !important; }
.severity-badge-warning  { background: #f4a261 !important; color: #000 !important; }
.severity-badge-info     { background: #1581a3 !important; }

.module-badge     { background: var(--spu-surface2); }
.insight-type-badge { background: rgba(255,255,255,0.1); }

.recommendation-box {
  background: rgba(21,129,163,0.15);
  border: 1px solid rgba(21,129,163,0.3);
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

details summary {
  cursor: pointer;
  color: var(--spu-muted);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* ── Alert items (dashboard) ─────────────────────────────── */
.alert-item {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border-left: 3px solid var(--spu-accent);
  font-size: 0.875rem;
}
.alert-item.severity-critical { border-color: #e63946; }
.alert-item.severity-warning  { border-color: #f4a261; }

/* ── Quick actions ───────────────────────────────────────── */
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.qa-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--spu-surface2);
  border: 1px solid var(--spu-border);
  border-radius: 10px;
  color: var(--spu-text);
  text-decoration: none;
  font-size: 0.8rem;
  text-align: center;
  transition: all 0.15s;
}
.qa-btn:hover { background: rgba(21,129,163,0.2); color: white; border-color: var(--spu-accent); }
.qa-btn i { font-size: 1.5rem; color: var(--spu-accent); }

/* ── KPI list ────────────────────────────────────────────── */
.kpi-list { display: flex; flex-direction: column; gap: 0.75rem; }
.kpi-row  { display: flex; justify-content: space-between; align-items: center;
            padding: 0.5rem; background: rgba(255,255,255,0.04); border-radius: 6px;
            font-size: 0.875rem; }
.kpi-row span { color: var(--spu-muted); }

/* ── Report cards ────────────────────────────────────────── */
.report-card { text-align: center; }
.report-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.report-card h6 { margin-bottom: 0.25rem; font-size: 1rem; }

/* ── Environmental ───────────────────────────────────────── */
.env-score-bar {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin: 0.5rem 0;
  position: relative;
  overflow: hidden;
}
.env-score-bar::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--score, 0%);
  background: linear-gradient(90deg, #e63946, #f4a261, #2ecc71);
  border-radius: 2px;
}

/* ── Badges ──────────────────────────────────────────────── */
.role-admin    { background: #e63946 !important; }
.role-operator { background: #f4a261 !important; color: #000 !important; }
.role-user     { background: #1581a3 !important; }

.shift-day   { background: #f4a261 !important; color: #000 !important; }
.shift-night { background: #1581a3 !important; }
.shift-all   { background: #6c757d !important; }

/* ── Modals ──────────────────────────────────────────────── */
.spu-modal {
  background: var(--spu-surface) !important;
  border: 1px solid var(--spu-border) !important;
  color: var(--spu-text) !important;
}
.spu-modal .modal-header { border-color: var(--spu-border); }
.spu-modal .modal-footer { border-color: var(--spu-border); }

/* ── Pagination ──────────────────────────────────────────── */
.page-link { background: var(--spu-surface2); border-color: var(--spu-border); color: var(--spu-text); }
.page-item.active .page-link { background: var(--spu-accent); border-color: var(--spu-accent); }
.page-link:hover { background: var(--spu-accent); color: white; border-color: var(--spu-accent); }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--spu-muted);
}
.empty-state i { font-size: 3rem; display: block; margin-bottom: 1rem; opacity: 0.5; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .spu-sidebar { transform: translateX(-100%); }
  .spu-sidebar.open { transform: translateX(0); }
  .spu-main { margin-left: 0; }
}

/* ── Provider pills ──────────────────────────────────────── */
.provider-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  border: 1px solid var(--spu-border);
  background: var(--spu-surface2);
  color: var(--spu-muted);
}
.provider-pill.configured  { border-color: rgba(46,204,113,0.4); color: #2ecc71; }
.provider-pill.unconfigured{ border-color: rgba(230,57,70,0.3);  color: #e63946; }
.provider-pill.active      { background: rgba(21,129,163,0.2); border-color: var(--spu-accent); color: white; }

/* ════════════════════════════════════════════════════════════
   AI ASSISTANT PANEL
   ════════════════════════════════════════════════════════════ */

/* Floating button */
.ai-fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 2000;
  background: linear-gradient(135deg, #1581a3, #0f5b73);
  border: none;
  border-radius: 50px;
  padding: 12px 20px;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(15,91,115,0.5);
  transition: all 0.25s;
}
.ai-fab:hover  { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(15,91,115,0.6); }
.ai-fab.active { background: #093442; }
.fab-label     { font-size: 0.85rem; font-weight: 600; }

/* Overlay */
.ai-overlay { position:fixed;inset:0;background:rgba(0,0,0,0.4);z-index:2001;opacity:0;pointer-events:none;transition:opacity 0.3s; }
.ai-overlay.show { opacity:1;pointer-events:auto; }

/* Panel */
.ai-panel {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 400px;
  max-width: 95vw;
  background: #0a2d3a;
  border-left: 1px solid var(--spu-border);
  z-index: 2002;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 40px rgba(0,0,0,0.4);
}
.ai-panel.open { transform: translateX(0); }

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--spu-border);
  background: var(--spu-surface);
}
.ai-panel-context { background: rgba(21,129,163,0.3); color: #7ecfe8; font-size: 0.7rem; }

.btn-panel-icon {
  background: none; border: none; color: var(--spu-muted);
  padding: 4px 6px; cursor: pointer; border-radius: 4px;
  transition: color 0.15s;
}
.btn-panel-icon:hover { color: white; background: rgba(255,255,255,0.08); }

/* Chat body */
.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ai-welcome {
  text-align: center;
  padding: 1.5rem 0.5rem;
  color: var(--spu-muted);
}
.ai-welcome i   { font-size: 2.5rem; color: var(--spu-accent); display: block; margin-bottom: 0.75rem; }
.ai-welcome p   { font-size: 0.9rem; margin-bottom: 0.25rem; }

.suggestion-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 1rem; }
.suggestion-chip {
  background: var(--spu-surface2);
  border: 1px solid var(--spu-border);
  color: var(--spu-muted);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}
.suggestion-chip:hover { border-color: var(--spu-accent); color: white; background: rgba(21,129,163,0.15); }

/* Messages */
.chat-msg {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}
.chat-msg.user  { flex-direction: row-reverse; }

.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--spu-surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.chat-msg.user .msg-avatar { background: rgba(21,129,163,0.3); }

.msg-bubble {
  max-width: 82%;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.55;
  white-space: pre-wrap;
}
.chat-msg.assistant .msg-bubble {
  background: var(--spu-surface);
  border: 1px solid var(--spu-border);
  border-radius: 4px 12px 12px 12px;
}
.chat-msg.user .msg-bubble {
  background: rgba(21,129,163,0.25);
  border: 1px solid rgba(21,129,163,0.4);
  border-radius: 12px 4px 12px 12px;
}

/* Typing dots */
.typing-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--spu-muted);
  animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); opacity:0.5; }
  30%          { transform: translateY(-6px); opacity:1; }
}

/* Footer */
.ai-panel-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--spu-border);
  background: var(--spu-surface);
}
.ai-input-row { display:flex; gap:6px; }
.ai-input {
  flex:1;
  background: var(--spu-surface2);
  border: 1px solid var(--spu-border);
  border-radius: 8px;
  color: white;
  padding: 8px 12px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}
.ai-input:focus { border-color: var(--spu-accent); }
.ai-input::placeholder { color: var(--spu-muted); }

.btn-send {
  background: var(--spu-accent);
  border: none;
  border-radius: 8px;
  color: white;
  width: 38px; height: 38px;
  display:flex; align-items:center; justify-content:center;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-send:hover    { background: #1a96bd; }
.btn-send:disabled { background: #555; cursor:not-allowed; }
.ai-panel-hint { font-size:0.7rem; color:var(--spu-muted); text-align:center; margin-top:4px; }

/* ── Scope pills (operational form) ─────────────────────── */
.scope-info-box {
  display: flex; gap: 0.75rem; flex-wrap: wrap;
  margin-top: 0.5rem;
}
.scope-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px;
  font-size: 0.8rem; border: 1px solid;
}
.scope-pill.s1 { border-color:rgba(230,57,70,0.4);  background:rgba(230,57,70,0.1);  color:#e63946; }
.scope-pill.s2 { border-color:rgba(244,162,97,0.4); background:rgba(244,162,97,0.1); color:#f4a261; }
.scope-pill.s3 { border-color:rgba(46,204,113,0.4); background:rgba(46,204,113,0.1); color:#2ecc71; }
.scope-badge {
  font-weight:800; font-size:0.7rem; letter-spacing:0.05em;
  padding: 1px 5px; border-radius: 4px; background:rgba(255,255,255,0.15);
}
.s3-badge { background:rgba(46,204,113,0.2); color:#2ecc71; }

/* ── Product link ─────────────────────────────────────── */
.product-link { text-decoration:none; }
.product-link:hover code { color:#7ecfe8; }

/* ════════════════════════════════════════════════════════════
   DATA MANAGEMENT PAGE
   ════════════════════════════════════════════════════════════ */

/* Tabs */
.spu-tabs { border-bottom: 1px solid var(--spu-border); }
.spu-tabs .nav-link {
  color: var(--spu-muted);
  border: none;
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
  border-bottom: 2px solid transparent;
  background: none;
  transition: all 0.15s;
}
.spu-tabs .nav-link:hover  { color: var(--spu-text); }
.spu-tabs .nav-link.active {
  color: var(--spu-text);
  border-bottom-color: var(--spu-accent);
  background: none;
}

/* Stat chips */
.stat-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: var(--spu-surface);
  border: 1px solid var(--spu-border);
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--spu-muted);
}

/* Input addon */
.spu-input-addon {
  background: var(--spu-surface2);
  border: 1px solid var(--spu-border);
  border-right: none;
  color: var(--spu-muted);
}

/* AG Grid dark theme integration */
.ag-theme-quartz-dark {
  --ag-background-color: transparent;
  --ag-foreground-color: #c8dde5;
  --ag-border-color: rgba(255,255,255,0.08);
  --ag-header-background-color: #0b3d4f;
  --ag-header-foreground-color: #8db8c9;
  --ag-odd-row-background-color: rgba(255,255,255,0.02);
  --ag-row-hover-color: rgba(21,129,163,0.12);
  --ag-selected-row-background-color: rgba(21,129,163,0.2);
  --ag-font-size: 13px;
  --ag-font-family: 'Segoe UI', system-ui, sans-serif;
  --ag-row-border-color: rgba(255,255,255,0.04);
  --ag-cell-horizontal-border: rgba(255,255,255,0.04);
  --ag-filter-tool-panel-header-height: 32px;
  --ag-input-focus-border-color: #1581a3;
  --ag-checkbox-checked-color: #1581a3;
}
.ag-theme-quartz-dark .ag-header-cell-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.ag-theme-quartz-dark .ag-filter-toolpanel-header,
.ag-theme-quartz-dark .ag-column-drop { background: #093442 !important; }

/* Upload drop zone */
.upload-dropzone {
  border: 2px dashed var(--spu-border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255,255,255,0.02);
}
.upload-dropzone:hover,
.upload-dropzone.drag-over {
  border-color: var(--spu-accent);
  background: rgba(21,129,163,0.08);
}
.upload-icon { font-size: 2.5rem; color: var(--spu-muted); display: block; margin-bottom: 0.5rem; }
.upload-hint { color: var(--spu-muted); margin-bottom: 0; font-size: 0.9rem; }

/* Preview scroll */
.preview-scroll { max-height: 180px; overflow-y: auto; }
.ref-scroll     { max-height: 320px; overflow-y: auto; }

/* Type badges */
.type-date  { background: rgba(21,129,163,0.3)  !important; color: #7ecfe8 !important; }
.type-float { background: rgba(46,204,113,0.2)  !important; color: #2ecc71 !important; }
.type-int   { background: rgba(244,162,97,0.2)  !important; color: #f4a261 !important; }
.type-str   { background: rgba(255,255,255,0.1) !important; color: #c8dde5 !important; }

/* Offcanvas */
.spu-offcanvas {
  background: var(--spu-surface) !important;
  border-left: 1px solid var(--spu-border) !important;
  color: var(--spu-text) !important;
}
.spu-offcanvas .offcanvas-header { border-bottom: 1px solid var(--spu-border); }
.spu-offcanvas .form-check-input:checked { background-color: var(--spu-accent); border-color: var(--spu-accent); }

/* ════════════════════════════════════════════════════════════
   REPORTING PAGE
   ════════════════════════════════════════════════════════════ */

.report-full-card { padding: 0; overflow: hidden; }

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 12px;
}
.report-header:hover { background: rgba(255,255,255,0.04); }

.report-icon-sm {
  font-size: 1.6rem;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  flex-shrink: 0;
}

.report-chevron {
  font-size: 1rem;
  color: var(--spu-muted);
  transition: transform 0.25s;
}
.report-chevron.rotated { transform: rotate(180deg); }

.report-body {
  border-top: 1px solid var(--spu-border);
  animation: slideDown 0.2s ease;
}
@keyframes slideDown {
  from { opacity:0; transform:translateY(-8px); }
  to   { opacity:1; transform:translateY(0); }
}

.report-controls {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--spu-border);
  background: rgba(255,255,255,0.02);
}

/* Stats strip */
.stats-strip { min-height: 60px; border-bottom: 1px solid var(--spu-border); }
.stats-loading {
  padding: 1rem 1.25rem;
  color: var(--spu-muted);
  font-size: 0.85rem;
}

/* KPI chips in stats strip */
.stat-kpi-chip {
  background: var(--spu-surface2);
  border: 1px solid var(--spu-border);
  border-radius: 8px;
  padding: 6px 12px;
  min-width: 110px;
}
.stat-kpi-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--spu-muted);
  margin-bottom: 2px;
}
.stat-kpi-val {
  font-size: 1rem;
  font-weight: 700;
}
.stat-kpi-chip.kpi-green  { border-color: rgba(46,204,113,0.35); }
.stat-kpi-chip.kpi-green  .stat-kpi-val { color: #2ecc71; }
.stat-kpi-chip.kpi-amber  { border-color: rgba(244,162,97,0.35); }
.stat-kpi-chip.kpi-amber  .stat-kpi-val { color: #f4a261; }
.stat-kpi-chip.kpi-red    { border-color: rgba(230,57,70,0.35); }
.stat-kpi-chip.kpi-red    .stat-kpi-val { color: #e63946; }
.stat-kpi-chip.kpi-neutral .stat-kpi-val { color: var(--spu-text); }

/* AI analysis panel */
.ai-analysis-area {
  border-top: 1px solid var(--spu-border);
  animation: slideDown 0.2s ease;
}
.ai-analysis-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: rgba(21,129,163,0.08);
  border-bottom: 1px solid rgba(21,129,163,0.2);
  font-size: 0.875rem;
}
.ai-model-tag {
  font-size: 0.7rem;
  color: var(--spu-muted);
  margin-left: 4px;
}
.ai-analysis-body {
  padding: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.7;
  color: #d0e8f0;
}
/* Markdown output styling */
.ai-analysis-body h6,
.ai-section-heading {
  color: white;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 1.25rem 0 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--spu-border);
}
.ai-analysis-body h6:first-child,
.ai-section-heading:first-child { margin-top: 0; }
.ai-analysis-body strong { color: white; }
.ai-analysis-body ul     { padding-left: 1.25rem; margin: 0.5rem 0; }
.ai-analysis-body li     { margin-bottom: 0.4rem; }

.ai-typing {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--spu-muted);
  font-size: 0.875rem;
  padding: 0.5rem 0;
}

/* ════════════════════════════════════════════════════════════
   FINANCIAL & RECONCILIATION
   ════════════════════════════════════════════════════════════ */

/* Reconcile flag badges */
.reconcile-flag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.flag-matched   { background: rgba(46,204,113,0.2);  color: #2ecc71; }
.flag-unmatched { background: rgba(200,200,200,0.1); color: #8db8c9; }
.flag-flagged   { background: rgba(244,162,97,0.2);  color: #f4a261; }
.flag-approved  { background: rgba(21,129,163,0.3);  color: #7ecfe8; }
.flag-excluded  { background: rgba(150,150,150,0.15);color: #6c757d; }

/* Category badge */
.cat-badge {
  background: rgba(255,255,255,0.08) !important;
  color: var(--spu-muted) !important;
  font-size: 0.7rem;
}

/* Alert strips */
.recon-alert {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  border-left: 3px solid;
}
.recon-alert.alert-warning { background: rgba(244,162,97,0.1); border-color: #f4a261; }
.recon-alert.alert-danger  { background: rgba(230,57,70,0.1);  border-color: #e63946; }
.recon-alert.alert-info    { background: rgba(21,129,163,0.1); border-color: #1581a3; }

/* OEE ring for reconciliation rate */
.kpi-gauge-ring {
  position: relative; width: 70px; height: 70px; margin: 0 auto 4px;
}
.kpi-gauge-ring svg { width: 100%; height: 100%; }
.kpi-gauge-ring span {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700;
}

/* Unmatched rows */
.unmatched-row {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--spu-border);
}
.unmatched-row:last-child { border-bottom: none; }

/* Column map chips */
.col-map-row { display: flex; flex-wrap: wrap; gap: 6px; }
.col-map-chip {
  background: var(--spu-surface2);
  border: 1px solid var(--spu-border);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.72rem;
  color: var(--spu-muted);
  font-family: monospace;
}

/* ════════════════════════════════════════════════════════════
   INTELLIGENCE PANELS
   ════════════════════════════════════════════════════════════ */

.intel-section-header {
  display: flex; align-items: center;
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--spu-muted);
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--spu-border);
  margin-bottom: 0.75rem;
}

/* Alert cards */
.alerts-grid { display: flex; flex-direction: column; gap: 0.6rem; }
.alert-card {
  border-radius: 10px; padding: 0.875rem;
  border-left: 3px solid;
}
.alert-card.severity-critical { background: rgba(230,57,70,0.08); border-color: #e63946; }
.alert-card.severity-warning  { background: rgba(244,162,97,0.08); border-color: #f4a261; }
.alert-card.severity-info     { background: rgba(21,129,163,0.08); border-color: #1581a3; }
.alert-card-header { display:flex; align-items:center; gap:0.5rem; margin-bottom:0.4rem; font-size:0.875rem; }
.alert-badge-critical { background: #e63946 !important; }
.alert-badge-warning  { background: #f4a261 !important; color:#000 !important; }
.alert-badge-info     { background: #1581a3 !important; }
.alert-card-detail    { font-size:0.8rem; color:var(--spu-muted); margin-bottom:0.4rem; }
.alert-action         { font-size:0.8rem; background:rgba(255,255,255,0.04); padding:0.4rem 0.6rem; border-radius:6px; }

/* Correlation cards */
.correlations-grid { display:flex; flex-direction:column; gap:0.6rem; }
.correlation-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--spu-border);
  border-radius:10px; padding:0.875rem;
}
.correlation-icon { font-size:1.25rem; margin-top:2px; }
.correlation-icon.severity-warning { color:#f4a261; }
.correlation-icon.severity-info    { color:#1581a3; }
.correlation-icon.severity-critical{ color:#e63946; }

/* Lessons */
.lessons-list { list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:0.5rem; }
.lessons-list li {
  font-size:0.875rem; padding:0.5rem 0.75rem;
  background:rgba(255,255,255,0.03);
  border-radius:8px; border-left:2px solid var(--spu-accent);
}

/* AI deep analysis */
.intel-ai-section {
  background: rgba(21,129,163,0.05);
  border: 1px solid rgba(21,129,163,0.2);
  border-radius:10px; padding:1rem;
}

/* KPI slim cards */
.kpi-card-slim {
  background:var(--spu-surface); border:1px solid var(--spu-border);
  border-radius:10px; padding:0.875rem; height:100%;
}
.kpi-card-slim.kpi-slim-danger { border-color:rgba(230,57,70,0.4); }
.kpi-card-slim.kpi-slim-good   { border-color:rgba(46,204,113,0.4); }
.kpi-slim-label { font-size:0.7rem; text-transform:uppercase; letter-spacing:0.07em; color:var(--spu-muted); }
.kpi-slim-val   { font-size:1.4rem; font-weight:700; line-height:1.2; }
.kpi-slim-val small { font-size:0.65rem; font-weight:400; color:var(--spu-muted); }
.kpi-slim-spark { margin:4px 0; color:var(--spu-accent); }
.sparkline      { width:100%; height:24px; }

/* Trend badges */
.trend-up   { font-size:0.7rem; color:#e63946; font-weight:600; }
.trend-down { font-size:0.7rem; color:#2ecc71; font-weight:600; }
.trend-flat { font-size:0.7rem; color:var(--spu-muted); }
.vs-prev    { font-size:0.68rem; padding:1px 6px; border-radius:4px; display:inline-block; margin-top:2px; }
.vs-prev.bad  { background:rgba(230,57,70,0.15); color:#e63946; }
.vs-prev.good { background:rgba(46,204,113,0.15); color:#2ecc71; }

/* Period selector */
.btn-xs { padding:0.15rem 0.5rem; font-size:0.72rem; border-radius:4px; }
