@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Poppins:wght@400;500;600&display=swap');

:root {
  --ig-navy:        #162a3c;
  --ig-navy-deep:   #0b1a26;
  --ig-navy-darker: #131e2f;
  --ig-off-white:   #edeff2;
  --ig-white:       #ffffff;
  --ig-slate:       #53606b;
  --ig-slate-2:     #54595f;
  --ig-text:        #7a7a7a;
  --ig-border:      #dfe1e5;
  --ig-blue:        #6ec1e4;
  --ig-teal:        #00d2a9;
  --ig-green:       #61ce70;
  --ig-red:         #c0392b;
}

html, body {
  margin: 0; background: var(--ig-off-white); color: #1f2933;
  font-family: 'Poppins', system-ui, sans-serif; font-size: 14px; line-height: 1.45;
}
* { box-sizing: border-box; }

/* ---- Layout modes ---- */
body.fixed-viewport, body.scroll-page { margin: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
body.fixed-viewport .app-header, body.scroll-page .app-header { flex: 0 0 auto; }
body.fixed-viewport .app-footer, body.scroll-page .app-footer { position: static; flex: 0 0 auto; }
body.fixed-viewport .app-body, body.scroll-page .app-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: row; overflow: hidden; }
body.scroll-page   .app-main { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 18px 24px; }
body.fixed-viewport .app-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 18px 24px; gap: 14px; overflow: hidden; }

/* ---- Header / footer ---- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  background: var(--ig-navy); color: var(--ig-white);
  padding: 12px 24px;
  border-bottom: 3px solid var(--ig-teal);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ig-white); text-decoration: none; font-weight: 600; }
.brand-logo { height: 32px; width: auto; display: block; }
.brand-divider { width: 1px; height: 22px; background: rgba(255,255,255,0.3); }
.brand-name { font-weight: 500; font-size: 20px; letter-spacing: 0.01em; color: var(--ig-off-white); }

.user-strip { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; }
.logout { color: var(--ig-blue); text-decoration: none; }

/* ---- Left sidebar nav ---- */
.app-sidebar {
  flex: 0 0 220px; background: var(--ig-navy); border-right: 1px solid var(--ig-navy-deep);
  padding: 16px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  color: var(--ig-off-white); text-decoration: none; padding: 9px 12px; border-radius: 6px;
  font-weight: 500; font-size: 14px; opacity: 0.9;
}
.sidebar-link svg { width: 15px; height: 15px; flex: 0 0 auto; }
.sidebar-link:hover { background: rgba(255,255,255,0.08); opacity: 1; }
.sidebar-link.active { background: var(--ig-navy-deep); color: var(--ig-teal); opacity: 1; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,0.15); margin: 10px 4px; }
.sidebar-section-label {
  color: rgba(255,255,255,0.45); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 0 12px 4px;
}

/* ---- Collapsible sidebar groups (Collections > Policy App / Uconnect / Bank Statement Collections) ---- */
.sidebar-group-toggle {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; list-style: none; color: var(--ig-off-white); font-weight: 500; font-size: 14px;
  padding: 9px 12px; border-radius: 6px;
}
.sidebar-group-toggle::-webkit-details-marker { display: none; }
.sidebar-group-icon { width: 17px; height: 17px; flex: 0 0 auto; }
.sidebar-group-toggle span { flex: 1 1 auto; }
.sidebar-chevron { width: 14px; height: 14px; flex: 0 0 auto; color: var(--ig-slate); transition: transform .15s ease; }
.sidebar-group[open] > .sidebar-group-toggle .sidebar-chevron { transform: rotate(90deg); }
.sidebar-group-toggle:hover { background: rgba(255,255,255,0.08); }
.sidebar-group-menu { display: flex; flex-direction: column; gap: 2px; padding-left: 12px; margin-top: 2px; }
.sidebar-group-nested .sidebar-group-toggle { font-size: 13.5px; opacity: 0.95; }

.app-footer {
  padding: 8px 24px; background: var(--ig-navy-darker);
  color: var(--ig-off-white); font-size: 12px;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.app-footer code { color: var(--ig-teal); }

/* ---- Buttons ---- */
.btn-export, .btn-download {
  font: 500 13px/1 inherit; padding: 8px 18px;
  background: var(--ig-teal); color: var(--ig-navy);
  border: 1px solid transparent; border-radius: 4px; cursor: pointer; white-space: nowrap;
}
.btn-export:hover, .btn-download:hover { background: #00b797; }
.btn-export:active, .btn-download:active { transform: translateY(1px); }

.btn-reload {
  font: 500 13px/1 inherit; padding: 7px 16px;
  background: var(--ig-white); color: var(--ig-navy);
  border: 1px solid var(--ig-teal); border-radius: 4px; cursor: pointer;
}
.btn-reload:hover { background: rgba(0,210,169,0.10); }

.btn-link {
  font-size: 12px; font-weight: 600; color: var(--ig-teal); text-decoration: none;
  padding: 4px 10px; border: 1px solid var(--ig-teal); border-radius: 4px; display: inline-block;
}
.btn-link:hover { background: rgba(0,210,169,0.10); }

.btn-header-reload {
  background: transparent; color: var(--ig-off-white);
  border: 1px solid rgba(255,255,255,0.35); border-radius: 4px;
  font: 500 12px/1 inherit; padding: 6px 12px; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn-header-reload:hover { background: rgba(0,210,169,0.18); border-color: var(--ig-teal); color: var(--ig-teal); }

/* ---- Cards & KPI tiles ---- */
.card {
  background: var(--ig-white); border: 1px solid var(--ig-border);
  border-radius: 6px; box-shadow: 0 1px 2px rgba(22,42,60,0.04);
}

.kpi-grid { display: grid; gap: 12px; grid-template-columns: repeat(6, minmax(0,1fr)); }
.kpi-card { background: var(--ig-white); border: 1px solid var(--ig-border); border-radius: 6px;
            padding: 12px 13px; box-shadow: 0 1px 2px rgba(22,42,60,0.04); }
.kpi-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ig-slate); margin-bottom: 6px; }
.kpi-value { font-size: 21px; font-weight: 700; color: var(--ig-navy); line-height: 1.1; }
.kpi-delta { display: inline-block; margin-top: 7px; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px; }
.kpi-up   { color: #0a7d57; background: rgba(0,210,169,0.14); }
.kpi-down { color: #b42318; background: rgba(211,51,51,0.12); }
.kpi-flat { color: var(--ig-slate); background: rgba(100,116,139,0.12); }
@media (max-width: 1280px) { .kpi-grid { grid-template-columns: repeat(4, minmax(0,1fr)); } }
@media (max-width: 768px)  { .kpi-grid { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 480px)  { .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }

.filters { background: var(--ig-white); border: 1px solid var(--ig-teal); border-radius: 6px; padding: 14px 18px;
           display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; text-transform: uppercase;
                  letter-spacing: 0.04em; color: var(--ig-slate); }
.filters input, .filters select { border: 1px solid var(--ig-teal); border-radius: 4px; padding: 6px 10px; font: inherit; }
.filters input:focus, .filters select:focus { outline: none; box-shadow: 0 0 0 2px rgba(0,210,169,0.18); }

.banner-dummy {
  background: #fff7d6; border: 1px solid #e8c547; border-radius: 6px;
  padding: 8px 14px; font-size: 12.5px; color: #6c5500;
}

/* ---- Data tables ---- */
.table-scroll { overflow: auto; border: 1px solid var(--ig-border); border-radius: 6px; background: var(--ig-white);
                flex: 1 1 auto; min-height: 0; }

.data-table { border-collapse: separate; border-spacing: 0; width: 100%;
  font-family: 'Poppins', system-ui, sans-serif; font-size: 13px;
  font-feature-settings: 'tnum' 1, 'lnum' 1; color: #1f2933; }

.data-table thead th {
  background: var(--ig-teal); color: var(--ig-navy);
  position: sticky; top: 0; z-index: 2;
  padding: 8px 10px; text-align: left; font-weight: 600; white-space: nowrap;
  box-shadow: inset 0 -1px 0 rgba(22,42,60,0.20);
  border-right: 1px solid rgba(22,42,60,0.40);
}
.data-table td {
  padding: 6px 10px; white-space: nowrap;
  border-top: 1px solid rgba(0,210,169,0.35);
  border-right: 1px solid var(--ig-border);
}
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.neg { color: var(--ig-red); }

.data-table tbody td                    { background: var(--ig-white); }
.data-table tbody tr:nth-child(even) td { background: #f7f8fa; }
.data-table tbody tr:hover td           { background: #eef5fb; }

.data-table thead th.col-total { background: var(--ig-navy); color: var(--ig-teal); font-weight: 600; }
.data-table tbody td.col-total { background: #fff7d6; font-weight: 600; border-left: 2px solid var(--ig-teal); }

.data-table tfoot td { position: sticky; bottom: 0; background: #f5f7fa; font-weight: 600;
  color: var(--ig-navy); border-top: 2px solid var(--ig-teal); padding: 8px 10px; }

.table-pagination {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 6px 2px; font-size: 12px; color: var(--ig-slate);
}
.table-pagination button { padding: 4px 12px; font-size: 12px; }
.table-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

.edc-group-label {
  background: var(--ig-navy); color: var(--ig-off-white);
  font-weight: 600; padding: 6px 10px; font-size: 12.5px;
  letter-spacing: 0.02em;
}

/* ---- Conditional formatting ---- */
.fmt-pct-1 { background: #f8696b; }
.fmt-pct-2 { background: #fcaa7b; }
.fmt-pct-3 { background: #ffe684; }
.fmt-pct-4 { background: #b8d97a; }
.fmt-pct-5 { background: #63be7b; }

/* ---- Loader ---- */
#page-loader {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: var(--ig-teal); z-index: 100; transition: width .2s ease;
  opacity: 0;
}
#page-loader.visible { opacity: 1; width: 70%; }
.busy-text { font-style: italic; color: var(--ig-slate); font-size: 12px; }

/* ---- Login page ---- */
.login-wrap {
  display: flex; align-items: center; justify-content: center; height: 100vh;
  background: var(--ig-off-white);
}
.login-card {
  background: var(--ig-white); border: 1px solid var(--ig-border); border-radius: 8px;
  box-shadow: 0 4px 24px rgba(22,42,60,0.08); padding: 40px 44px; text-align: center; max-width: 380px;
}
.login-logo { height: 44px; margin-bottom: 18px; }
.login-title { font-size: 18px; font-weight: 600; color: var(--ig-navy); margin: 0 0 6px; }
.login-sub { font-size: 13px; color: var(--ig-slate); margin: 0 0 24px; }
.login-btn {
  display: inline-block; background: var(--ig-teal); color: var(--ig-navy);
  font-weight: 600; padding: 10px 22px; border-radius: 4px; text-decoration: none;
}
.login-btn:hover { background: #00b797; }
.login-denied { color: var(--ig-red); font-size: 13px; margin-top: 14px; }

/* ---- Generic per-control busy spinner — every button/dropdown app-wide,
   wired centrally in app.js (htmx:beforeRequest/afterRequest + submit).
   Positioned via JS (fixed, next to whichever control triggered the
   request), not inserted into document flow. ---- */
.inline-spinner {
  position: fixed; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(22,42,60,0.15); border-top-color: var(--ig-teal);
  animation: ask-spin 0.7s linear infinite; z-index: 300; pointer-events: none;
}

/* ---- Ask page: full-page-post spinner (Cortex round trips can take ~1min) ---- */
.ask-spinner-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(22,42,60,0.55); backdrop-filter: blur(1px);
  flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  color: var(--ig-white); text-align: center; padding: 20px;
}
.ask-spinner-overlay.visible { display: flex; }
.ask-spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.25); border-top-color: var(--ig-teal);
  animation: ask-spin 0.8s linear infinite;
}
@keyframes ask-spin { to { transform: rotate(360deg); } }

/* ============================================================
   Uconnect Payment Report additions (merged in from its own
   standalone app). Everything above is Collections' own CSS.
   ============================================================ */

/* Destructive action — used by /uconnect/reconciliation's Ignore button.
   Collections had no destructive-action button before this merge. */
.btn-reject {
  font: 500 13px/1 inherit; padding: 7px 16px;
  background: var(--ig-white); color: var(--ig-red);
  border: 1px solid var(--ig-red); border-radius: 4px; cursor: pointer;
}
.btn-reject:hover { background: rgba(192, 57, 43, 0.10); }
.btn-reject:active { transform: translateY(1px); }

/* Workflow-state pills — used by /uconnect/security's Active/Inactive column. */
.status-pill { display: inline-block; padding: 3px 10px; font-size: 12px; font-weight: 600;
  border-radius: 99px; letter-spacing: 0.02em; white-space: nowrap; }
.status-approved { background: rgba(46,204,113,0.18); color: #1a6b3a; }
.status-rejected { background: rgba(231,76,60,0.18);  color: #922b1f; }

/* Busy indicator inside a split-table card while its HTMX partial loads. */
.split-loading {
  font-style: italic;
  color: var(--ig-slate);
  font-size: 12px;
  padding: 12px;
}

/* ============================================================
   Policy Search / Create Users additions (merged in from the
   standalone "Data & AI Reporting App").
   ============================================================ */

.summary-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.summary-header h2 { margin: 0; font-size: 18px; color: var(--ig-navy); }

.table-section { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; }
.table-toolbar h3 { margin: 0; font-size: 14px; color: var(--ig-navy); }

.search-form { display: flex; align-items: end; gap: 12px; }
.search-form label,
.user-form label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ig-slate); display: block; margin-bottom: 6px; }
.user-form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; align-items: end; gap: 12px; }

.search-busy { font-style: italic; color: var(--ig-slate); font-size: 13px; opacity: 0; transition: opacity .15s ease; }
.search-busy.htmx-request { opacity: 1; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 10px 0; flex: 0 0 auto; }
.pagination-status { font-size: 13px; color: var(--ig-slate); }
.btn-reload.disabled { color: var(--ig-slate); border-color: var(--ig-border); cursor: default; pointer-events: none; }

.data-freshness { color: var(--ig-teal); }
.empty-state { color: var(--ig-slate); font-style: italic; padding: 12px 4px; }

/* ============================================================
   CX / Vetting Allocation additions (merged in from its own
   standalone app, "Silver Surfer Vetting Allocation").
   ============================================================ */

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 20px; color: var(--ig-navy); }
.section-title { margin: 20px 0 8px; font-size: 15px; color: var(--ig-navy); }
.hint { font-size: 12.5px; color: var(--ig-slate); }
.muted { color: var(--ig-slate); }
.warn-tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px; font-size: 10.5px; font-weight: 600;
  border-radius: 99px; background: rgba(211,51,51,0.12); color: #b42318; letter-spacing: 0.02em;
}
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Extra status-pill tones beyond approved/rejected — allocation & vetting workflow states. */
.status-progress { background: rgba(0,210,169,0.16); color: #0a6b57; }
.status-declined  { background: rgba(231,76,60,0.18); color: #922b1f; }
.status-pending   { background: rgba(232,197,71,0.22); color: #6c5500; }
.status-neutral   { background: rgba(100,116,139,0.14); color: var(--ig-slate); }
