/* ==========================================================================
   SEWA Payment Follow-up Portal
   ========================================================================== */

:root {
  --sewa-navy:    #0f2545;
  --sewa-navy-2:  #16345d;
  --sewa-accent:  #0d6efd;
  --sewa-surface: #f4f6fa;
  --sewa-border:  #e3e8ef;
  --sewa-danger:  #dc3545;
  --radius:       .65rem;
}

body {
  background: var(--sewa-surface);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: .9rem;
  color: #1f2937;
}

/* ---------- Navbar ---------- */
.app-navbar {
  background: linear-gradient(100deg, var(--sewa-navy) 0%, var(--sewa-navy-2) 100%);
  box-shadow: 0 2px 12px rgba(15, 37, 69, .18);
  padding: .45rem 0;
}
.app-navbar .navbar-brand,
.app-navbar .nav-link { color: rgba(255, 255, 255, .82); }
.app-navbar .nav-link:hover,
.app-navbar .nav-link.active { color: #fff; }
.app-navbar .nav-link.active { font-weight: 600; position: relative; }
.app-navbar .nav-link.active::after {
  content: ""; position: absolute; left: .75rem; right: .75rem; bottom: -.2rem;
  height: 2px; background: #4dabf7; border-radius: 2px;
}
.app-navbar .navbar-toggler { color: #fff; }

.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #4dabf7, #0d6efd);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.05rem; box-shadow: 0 2px 8px rgba(13, 110, 253, .4);
}
.brand-mark.lg { width: 54px; height: 54px; font-size: 1.6rem; border-radius: 14px; }
.brand-text { color: #fff; font-weight: 700; letter-spacing: .2px; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: .72rem; font-weight: 700; flex-shrink: 0;
}
.avatar.sm { width: 24px; height: 24px; font-size: .62rem; }

.notif-badge {
  position: absolute; top: 2px; right: 2px;
  font-size: .58rem; padding: .2em .4em;
}
.notif-menu { width: 340px; max-height: 420px; overflow-y: auto; padding: 0; }

/* ---------- Global search ---------- */
.global-search { min-width: 260px; }
.global-search .form-control { padding-left: 2rem; border-radius: 20px; border: none; }
.global-search .search-icon {
  position: absolute; left: .7rem; top: 50%; transform: translateY(-50%);
  color: #94a3b8; font-size: .82rem; z-index: 5;
}
.search-dropdown {
  position: absolute; top: 110%; left: 0; right: 0; z-index: 1050;
  background: #fff; border: 1px solid var(--sewa-border); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .15); max-height: 420px; overflow-y: auto;
}
.search-dropdown .sd-group { padding: .35rem .75rem; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .5px; color: #94a3b8; background: #f8fafc; font-weight: 700; }
.search-dropdown a { display: block; padding: .5rem .75rem; color: inherit; text-decoration: none;
  border-bottom: 1px solid #f1f5f9; }
.search-dropdown a:hover { background: #f8fafc; }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--sewa-border); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(16,24,40,.04); }
.card-header {
  background: #fff; border-bottom: 1px solid var(--sewa-border);
  font-weight: 600; font-size: .86rem; padding: .7rem 1rem;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}

/* ---------- KPI cards ---------- */
.kpi {
  background: #fff; border: 1px solid var(--sewa-border); border-radius: var(--radius);
  padding: .85rem 1rem; height: 100%; position: relative; overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16,24,40,.09); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--kpi-color, #0d6efd); }
.kpi-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .4px; color: #64748b; font-weight: 600; }
.kpi-value { font-size: 1.32rem; font-weight: 700; color: #0f172a; line-height: 1.25; margin-top: .15rem; }
.kpi-sub   { font-size: .72rem; color: #94a3b8; }
.kpi-icon  { position: absolute; right: .7rem; top: .7rem; font-size: 1.25rem; opacity: .16; color: var(--kpi-color, #0d6efd); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { font-size: .84rem; margin-bottom: 0; }
.table > thead > tr > th {
  background: #f8fafc; border-bottom: 2px solid var(--sewa-border);
  font-size: .7rem; text-transform: uppercase; letter-spacing: .4px;
  color: #475569; font-weight: 700; white-space: nowrap; padding: .55rem .6rem;
  position: sticky; top: 0; z-index: 2;
}
.table > tbody > tr > td { padding: .55rem .6rem; vertical-align: middle; }
.table > tbody > tr:hover { background: #f8fbff; }
.table th a { color: inherit; text-decoration: none; }
.table th a:hover { color: var(--sewa-accent); }

/* Business rule: invoices above the high-value threshold read in red. */
tr.high-value td { background: #fff5f5; }
tr.high-value:hover td { background: #ffecec; }
tr.high-value .amount-pending { color: var(--sewa-danger); font-weight: 700; }

.amount { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.amount-pending { font-weight: 600; }

.overdue-pill {
  display: inline-block; min-width: 34px; text-align: center;
  padding: .1rem .4rem; border-radius: 10px; font-size: .72rem; font-weight: 700;
}
.ov-0  { background: #ecfdf5; color: #047857; }
.ov-30 { background: #fffbeb; color: #b45309; }
.ov-60 { background: #fff7ed; color: #c2410c; }
.ov-90 { background: #fef2f2; color: #b91c1c; }
.ov-180{ background: #7f1d1d; color: #fff; }

.badge-soft { font-weight: 600; font-size: .68rem; padding: .28em .55em; border-radius: 5px; }
.bs-primary  { background: #eff6ff; color: #1d4ed8; }
.bs-success  { background: #ecfdf5; color: #047857; }
.bs-warning  { background: #fffbeb; color: #b45309; }
.bs-danger   { background: #fef2f2; color: #b91c1c; }
.bs-secondary{ background: #f1f5f9; color: #475569; }
.bs-info     { background: #ecfeff; color: #0e7490; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 2.1rem; }
.timeline::before {
  content: ""; position: absolute; left: .72rem; top: .3rem; bottom: .3rem;
  width: 2px; background: linear-gradient(#e2e8f0, #f1f5f9);
}
.tl-item { position: relative; padding-bottom: 1.15rem; }
.tl-dot {
  position: absolute; left: -1.72rem; top: .05rem;
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; color: #fff; box-shadow: 0 0 0 3px #fff;
}
.tl-date { font-size: .72rem; color: #94a3b8; font-weight: 600; }
.tl-title { font-weight: 600; font-size: .87rem; color: #0f172a; }
.tl-desc { font-size: .81rem; color: #475569; }
.tl-actor { font-size: .72rem; color: #94a3b8; }

/* ---------- Filters ---------- */
.filter-bar { background: #fff; border: 1px solid var(--sewa-border); border-radius: var(--radius); padding: .75rem; }
.filter-bar .form-label { font-size: .7rem; font-weight: 600; color: #64748b; margin-bottom: .15rem; text-transform: uppercase; letter-spacing: .3px; }
.filter-bar .form-control, .filter-bar .form-select { font-size: .82rem; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  background: #eff6ff; color: #1d4ed8; border-radius: 14px;
  padding: .18rem .55rem; font-size: .72rem; font-weight: 600;
}
.chip a { color: inherit; text-decoration: none; opacity: .65; }
.chip a:hover { opacity: 1; }

/* ---------- Auth ---------- */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f2545 0%, #1e3a5f 55%, #2d5a8e 100%);
  padding: 1rem;
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card { background: #fff; border-radius: 14px; padding: 2rem 1.75rem; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }

/* ---------- Misc ---------- */
.stat-row { display: flex; justify-content: space-between; padding: .3rem 0; font-size: .82rem; border-bottom: 1px dashed #eef2f7; }
.stat-row:last-child { border-bottom: none; }
.stat-row .label { color: #64748b; }
.stat-row .value { font-weight: 600; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: #94a3b8; }
.empty-state i { font-size: 2.2rem; opacity: .35; display: block; margin-bottom: .5rem; }
.progress-thin { height: 5px; border-radius: 3px; }
.text-tiny { font-size: .72rem; }
.cursor-pointer { cursor: pointer; }
.sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; }
.table > tbody > tr:hover .sticky-col { background: #f8fbff; }

@media (max-width: 991.98px) {
  .global-search { min-width: 100%; margin: .5rem 0; }
  .kpi-value { font-size: 1.15rem; }
}
@media print {
  .app-navbar, .filter-bar, .btn, .no-print { display: none !important; }
  body { background: #fff; }
  .card { border: 1px solid #ddd; box-shadow: none; }
}
