:root {
  --brand-teal:        #13b5a3;
  --brand-teal-dark:   #0e8c7e;
  --brand-teal-soft:   rgba(19, 181, 163, 0.18);
  --brand-grey:        #4b5563;
  --sidebar-bg:        #ffffff;
  --sidebar-hover:     #f1f5f4;
  --sidebar-active:    var(--brand-teal);
  --sidebar-text:      #475569;
  --topbar-bg:         #ffffff;
  --content-bg:        #f4f6f8;
  --brand-color:       var(--brand-teal);
}

a, .btn-link { color: var(--brand-teal); }
a:hover { color: var(--brand-teal-dark); }
.btn-primary {
  --bs-btn-bg: var(--brand-teal);
  --bs-btn-border-color: var(--brand-teal);
  --bs-btn-hover-bg: var(--brand-teal-dark);
  --bs-btn-hover-border-color: var(--brand-teal-dark);
  --bs-btn-active-bg: var(--brand-teal-dark);
  --bs-btn-active-border-color: var(--brand-teal-dark);
  --bs-btn-disabled-bg: var(--brand-teal);
  --bs-btn-disabled-border-color: var(--brand-teal);
  color: #fff;
}
.btn-outline-primary {
  --bs-btn-color: var(--brand-teal);
  --bs-btn-border-color: var(--brand-teal);
  --bs-btn-hover-bg: var(--brand-teal);
  --bs-btn-hover-border-color: var(--brand-teal);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--brand-teal-dark);
  --bs-btn-active-border-color: var(--brand-teal-dark);
}
.text-primary { color: var(--brand-teal) !important; }
.bg-primary   { background: var(--brand-teal) !important; }
.border-primary { border-color: var(--brand-teal) !important; }
.form-control:focus,
.form-select:focus {
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 0.18rem rgba(19,181,163,0.18);
}

html, body { height: 100%; }
body {
  background: var(--content-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- Login ---------- */
.login-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1.25rem;
}
.login-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 80% at 50% 0%, rgba(0,0,0,0.0) 0%, rgba(0,0,0,0.45) 100%);
  pointer-events: none;
}
.login-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 2.5rem 2.25rem 2rem;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  color: #f8fafc;
}
.login-card .brand-mark {
  font-size: 2rem;
  color: var(--brand-color);
}
.login-card .form-label { color: rgba(255, 255, 255, 0.85); }
.login-card .form-control {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
}
.login-card .form-control::placeholder { color: rgba(255, 255, 255, 0.55); }
.login-card .form-control:focus {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 0.18rem rgba(19, 181, 163, 0.32);
  color: #fff;
}
.login-card .alert { color: #fff; }
.login-card .text-muted, .login-card .text-muted code { color: rgba(255, 255, 255, 0.75) !important; }
.login-card .btn-primary {
  background: var(--brand-teal);
  border-color: var(--brand-teal);
}

/* CSS-rendered VARDĀN wordmark – no background, looks good on any backdrop. */
.brand-wordmark {
  display: inline-block;
  text-align: center;
  font-family: "Avenir Next", "Futura", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: #ffffff;
  user-select: none;
}
.brand-wordmark .brand-mark-top {
  display: block;
  width: 26px;
  height: 3px;
  border-radius: 2px;
  background: var(--brand-teal);
  margin: 0 auto 4px;
  transform: translateX(36%);
}
.brand-wordmark .brand-word {
  font-size: 3.4rem;
  font-weight: 200;
  letter-spacing: 0.18em;
  line-height: 1;
}
.brand-wordmark .brand-tagline {
  margin-top: .6rem;
  font-size: .95rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: rgba(255, 255, 255, 0.88);
}

/* ---------- Animated gradient ---------- */
.animated-gradient-host {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  animation: agb-intro 1.6s cubic-bezier(.25,.1,.25,1) both;
}
.animated-gradient-layer {
  position: absolute;
  inset: 0;
  transition: background .1s linear;
  will-change: background;
}
@keyframes agb-intro {
  from { opacity: 0; transform: scale(1.4); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; }

.app-sidebar {
  width: 250px;
  min-width: 250px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid #e5e7eb;
  box-shadow: 0 0 24px rgba(15,23,42,0.04);
}
.sidebar-brand {
  padding: 1.3rem 1.1rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  text-align: center;
}
.sidebar-wordmark { color: var(--brand-grey); }
.sidebar-wordmark .brand-word {
  font-size: 1.7rem;
  font-weight: 200;
  letter-spacing: 0.15em;
  color: var(--brand-grey);
}
.sidebar-wordmark .brand-mark-top {
  width: 16px;
  height: 2.5px;
  margin-bottom: 3px;
  transform: translateX(38%);
  background: var(--brand-teal);
}
.sidebar-wordmark .brand-tagline {
  margin-top: .3rem;
  font-size: .7rem;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--brand-teal);
  font-weight: 500;
}

.sidebar-nav {
  padding: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav .nav-link {
  color: var(--sidebar-text);
  padding: 0.6rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.91rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  margin: 0 .4rem;
  border-radius: 8px;
}
.sidebar-nav .nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--brand-teal-dark);
}
.sidebar-nav .nav-link.active {
  background: var(--brand-teal-soft);
  color: var(--brand-teal-dark);
  font-weight: 600;
}
.sidebar-nav .nav-link i {
  width: 18px;
  text-align: center;
  color: var(--brand-teal);
  font-size: 1.05rem;
}
.sidebar-nav .nav-link:hover i,
.sidebar-nav .nav-link.active i { color: var(--brand-teal-dark); }

/* ---------- Top bar & content ---------- */
.app-main { display: flex; flex-direction: column; }
.app-topbar {
  background: var(--topbar-bg);
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  position: sticky; top: 0; z-index: 5;
}
.app-content { padding: 1.5rem; }

/* ---------- KPI cards (flat, minimal) ---------- */
.kpi-card {
  background: #fff;
  border-radius: 12px;
  padding: 0.95rem 1.05rem;
  border: 1px solid #eef2f7;
  position: relative;
  overflow: hidden;
  transition: border-color .15s ease;
}
.kpi-card:hover { border-color: #cbd5e1; }
.kpi-card .kpi-label { color: #6b7280; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.kpi-card .kpi-value { font-size: 1.5rem; font-weight: 600; color: #111827; margin-top: 0.2rem; line-height: 1.15; }
.kpi-card .kpi-foot  { font-size: 0.74rem; color: #94a3b8; margin-top: 0.3rem; }
.kpi-card .kpi-icon  { position: absolute; top: 12px; right: 14px; font-size: 1.05rem; opacity: 0.25; color: #94a3b8; }
.kpi-card.kpi-revenue,
.kpi-card.kpi-eligible,
.kpi-card.kpi-warning,
.kpi-card.kpi-danger,
.kpi-card.kpi-neutral { border-left: 1px solid #eef2f7; }
.kpi-card.kpi-mini { padding: .65rem .85rem; }
.kpi-card.kpi-mini .kpi-label { font-size: .66rem; }
.kpi-card.kpi-mini .kpi-value { font-size: 1.2rem; }

/* ---------- Sub-tabs (used inside pages) ---------- */
.nav-tabs .nav-link { color: #4b5563; }
.nav-tabs .nav-link.active { color: #1e3a8a; font-weight: 600; }
.nav-tabs .nav-link .badge { font-weight: 500; }

/* ---------- Hero KPI cards (flat, no accents) ---------- */
.kpi-hero {
  border-radius: 12px;
  padding: 1rem 1.15rem 0.6rem;
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid #eef2f7;
  min-height: 110px;
  transition: border-color .15s ease;
}
.kpi-hero:hover { border-color: #cbd5e1; }
.kpi-hero .kpi-label { color: #6b7280; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.kpi-hero .kpi-value { font-size: 1.7rem; font-weight: 600; color: #111827; margin-top: 0.2rem; letter-spacing: -0.01em; }
.kpi-hero .kpi-foot  { color: #94a3b8; font-size: 0.74rem; margin-top: 0.2rem; }
.kpi-hero .kpi-icon  { position: absolute; top: 12px; right: 14px; font-size: 1.05rem; opacity: 0.25; color: #94a3b8; }
.kpi-hero .kpi-spark { position: absolute; bottom: 4px; left: 6px; right: 6px; height: 28px; opacity: 0.18; }

/* All variants now look identical (no tint, no accent stripe) */
.kpi-hero.h-blue,
.kpi-hero.h-green,
.kpi-hero.h-orange,
.kpi-hero.h-violet,
.kpi-hero.h-pink,
.kpi-hero.h-teal,
.kpi-hero.h-red,
.kpi-hero.h-slate { background: #fff; }

/* ---------- Tables ---------- */
.table thead th { background: #f9fafb; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: #4b5563; }
.table-card { background: #fff; border-radius: 12px; border: 1px solid #eef2f7; padding: 1rem; }

/* ---------- Chart cards (flat) ---------- */
.chart-card {
  background: #fff;
  border: 1px solid #eef2f7;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  transition: border-color .15s ease;
}
.chart-card:hover { border-color: #d8dee7; }
.chart-card h6 {
  color: #1f2937; font-weight: 600;
  margin-bottom: 0.85rem;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.9rem;
}
.chart-card h6 .sub { color: #6b7280; font-weight: 500; font-size: 0.75rem; }
.chart-card .chart-legend { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.5rem; }
.chart-card .chart-legend span { font-size: 0.75rem; color: #4b5563; display: inline-flex; align-items: center; gap: 4px; }
.chart-card .chart-legend i.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Chart.js MUST have a fixed-height parent or it grows on every redraw. */
.chart-wrap { position: relative; height: 280px; width: 100%; }
.chart-wrap.tall { height: 360px; }
.chart-wrap.short { height: 220px; }
.chart-wrap canvas { max-height: 100%; }

/* center-of-doughnut total */
.donut-wrap { position: relative; }
.donut-center {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
.donut-center .num { font-size: 1.55rem; font-weight: 800; color: #111827; line-height: 1; }
.donut-center .lbl { font-size: 0.72rem; color: #6b7280; text-transform: uppercase; letter-spacing: 0.05em; }

/* Top referrers list (sidebar style) */
.ref-list { display: flex; flex-direction: column; }
.ref-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 0; gap: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}
.ref-row:last-child { border-bottom: 0; }
.ref-main { min-width: 0; }
.ref-name { font-size: 0.92rem; font-weight: 600; color: #111827; line-height: 1.2; }
.ref-meta { font-size: 0.74rem; color: #94a3b8; margin-top: 2px; }
.ref-amount { font-size: 0.95rem; font-weight: 600; color: #111827; white-space: nowrap; }

/* ---------- Compact data tables (eligibility, daily log, etc.) ---------- */
.elig-table { table-layout: auto; font-size: 0.86rem; }
.elig-table thead th {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: #6b7280; font-weight: 600;
  border-bottom: 1px solid #e5e7eb; white-space: nowrap;
  padding: 0.55rem 0.5rem;
}
.elig-table tbody td {
  padding: 0.55rem 0.5rem; vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}
.elig-table tbody tr:last-child td { border-bottom: 0; }
.elig-table .col-num     { width: 84px; }
.elig-table .col-tiny    { width: 78px; }
.elig-table .col-date    { width: 120px; }
.elig-table .col-money   { width: 110px; }
.elig-table .col-actions { width: 110px; }
.elig-table .col-reason  { max-width: 240px; }

.elig-pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.01em;
  white-space: nowrap; border: 1px solid transparent;
}
.elig-success { background: #e6f4ea; color: #137333; border-color: #c5e3cf; }
.elig-info    { background: #e8f0fa; color: #1d4f91; border-color: #c7d8ee; }
.elig-warning { background: #fdf3e1; color: #8a5a00; border-color: #f0d8a4; }
.elig-danger  { background: #fde7e7; color: #9b2c2c; border-color: #efc1c1; }
.elig-primary { background: #ecebfb; color: #4338ca; border-color: #cfcdf3; }
.elig-secondary,
.elig-light   { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.elig-dark    { background: #1f2937; color: #fff; border-color: #1f2937; }

.why-info {
  appearance: none; background: transparent; border: 0;
  color: #94a3b8; padding: 0; line-height: 1; cursor: pointer;
  transition: color .15s ease;
}
.why-info:hover, .why-info:focus { color: #1e3a8a; outline: none; }
.popover { max-width: 360px; font-size: 0.82rem; }
.popover-body { white-space: pre-line; }

/* ---------- Rule builder ---------- */
.rule-section { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.rule-section h6 { color: #1f2937; font-weight: 700; }
.rule-section .form-text { font-size: 0.78rem; }

.condition-row { display: grid; grid-template-columns: 1fr 80px; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.condition-row label { font-size: 0.85rem; color: #374151; margin: 0; }

/* ---------- Highlights ---------- */
.badge-highlight { background: #fde68a; color: #92400e; }
.col-highlighted { background: #fef9c3 !important; }
