@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@400;500;600;700&display=swap');

:root {
    --navy: #0f2b46;
    --navy-dark: #0a1f33;
    --navy-light: #1c4266;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --green: #16a34a;
    --yellow: #ca8a04;
    --orange: #ea580c;
    --red: #dc2626;
    --gray: #64748b;
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --sidebar-w: 240px;
    --header-h: 140px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ SIDEBAR LAYOUT ============ */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 44px; /* ruang untuk footer fixed */
}
.app-layout-main {
    display: flex;
    flex: 1;
    min-height: 0;
}

.sidebar {
    width: var(--sidebar-w);
    color: #fff;
    display: flex; flex-direction: column;
    position: fixed;
    top: var(--header-h); /* SEBELUMNYA: top: 0; — sekarang mulai di bawah header, bukan di belakang/atasnya */
    left: 0;
    bottom: 44px;
    z-index: 100;
    overflow: hidden;
    background:
        linear-gradient(180deg,
        #0f2b46 0%,
        #0f2b46 50%,          /* solid navy diperpanjang — nutupin sampai akhir menu "Laporan" */
        rgba(15, 43, 70, .55) 62%,   /* mulai transisi */
        rgba(15, 43, 70, .30) 78%,   /* foto makin kelihatan */
        rgba(15, 43, 70, .25) 100%), /* foto + tagline emas paling jelas di bawah */
        url('../img/sidebar-coast.jpeg??v=999') center bottom / cover no-repeat,
        linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
}
.sidebar-nav { padding: 16px 0; flex: 1; overflow-y: auto; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    margin: 2px 10px;
    padding: 11px 14px;
    color: rgba(255,255,255,.75);
    text-decoration: none; font-size: 13.5px; font-weight: 500;
    border-radius: 10px; transition: all .15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.09); color: #fff; text-decoration: none; }
.sidebar-nav a.active {
    background: #2563eb;
    color: #fff; font-weight: 600;
    box-shadow: 0 4px 12px rgba(37,99,235,.35);
}
.sidebar-nav a .nav-icon { width: 20px; height: 20px; flex-shrink: 0; display: inline-flex; }
.sidebar-nav a .nav-icon svg { width: 100%; height: 100%; }

.sidebar-motto {
    padding: 0 55px 26px;
    font-family: 'Dancing Script', 'Segoe Script', cursive;
    font-weight: 600;
    font-size: 26px; line-height: 1.3;
    color: rgba(255,255,255,.85);
    opacity: 0.7;
    text-shadow: 0 2px 8px rgba(0,0,0,.45);
    text-align: left;
    transform: rotate(-12deg);        /* baru — memutar seluruh blok teks */
    transform-origin: left bottom;   /* baru — titik putar di kiri-bawah, biar posisi awal teks tidak geser */
}

/* Main Content — header full-width, sidebar overlap di atasnya */
.app-content { flex: 1; min-height: 0; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Hero Header — full-width, sticky, sidebar overlap di atasnya ---------- */
.app-hero {
    position: sticky; top: 0; z-index: 40;
    min-height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 28px;
    color: #fff;
    background:
    linear-gradient(90deg,
        #0f2b46 0%,
        #0f2b46 28%,
        rgba(15, 43, 70, .05) 38%,
        rgba(15, 43, 70, .05) 45%,
        rgba(15, 43, 70, .18) 55%,
        rgba(15, 43, 70, .40) 65%,
        rgba(15, 43, 70, .70) 75%,
        #0f2b46 88%,
        #0f2b46 100%
    ),
    url('../img/header-bridge.jpg?v=999') 55% center / 65% auto no-repeat,
    linear-gradient(90deg, var(--navy) 0%, #14456e 100%);
    box-shadow: 0 2px 12px rgba(10,31,51,.25);
}
.app-hero .hero-left { display: flex; align-items: center; gap: 24px; z-index: 1; }
.hero-logo-block { display: flex; align-items: center; gap: 12px; }
.hero-logo-badge {
    width: 54px; height: 54px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    /* hapus: border-radius:50%, background: radial-gradient(...), 
       font-weight/font-size/color, box-shadow — itu semua untuk badge inisial,
       tidak dipakai lagi karena sekarang isinya logo asli */
}
.hero-logo-badge img {
    width: 100%;
    height: 100%;
    object-fit: contain;   /* logo di-scale proporsional, tidak gepeng & tidak overflow */
    display: block;
}
.hero-instansi { line-height: 1.25; font-size: 10px; letter-spacing: .5px; color: rgba(255,255,255,.85); }
.hero-instansi strong { display: block; font-size: 12.5px; letter-spacing: .5px; }
.hero-instansi span { display: block; }
.hero-titles {
    padding-left: 24px;
    border-left: 1px solid rgba(255,255,255,.25);
}
.hero-title { font-size: 26px; font-weight: 800; letter-spacing: .5px; line-height: 1.1; }
.hero-subtitle { font-size: 13.5px; font-weight: 600; color: rgba(255,255,255,.95); margin-top: 2px; }
.hero-tagline { font-size: 12px; color: #f5c76b; margin-top: 2px; }
.app-hero .hero-right { display: flex; align-items: center; gap: 22px; z-index: 1; }
.hero-motto {
    font-family: 'Dancing Script', 'Segoe Script', cursive;
    font-weight: 600;
    font-size: 26px; line-height: 1.3;
    color: rgba(255,255,255,.9);
    opacity: 0.7;
    text-shadow: 0 2px 6px rgba(0,0,0,.45);
    text-align: left;
    transform: translateY(-25px) rotate(-12deg);         /* baru — sama seperti sidebar */
    transform-origin: right bottom;   /* baru — dikunci di kanan-bawah (dekat avatar), biar sisi kiri teks yang "turun", bukan malah mendorong ke arah avatar */
}
.header-user { display: flex; align-items: center; gap: 10px; }
.header-user .user-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, #64748b, #334155);
    color: #fff; font-weight: 700; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid rgba(255,255,255,.5);
}
.header-user .user-info { line-height: 1.3; }
.header-user .user-name { font-size: 13px; font-weight: 600; }
.header-user .user-role { font-size: 11px; color: rgba(255,255,255,.75); }
.header-user .btn-logout {
    color: rgba(255,255,255,.8); font-size: 13px;
    padding: 6px 8px; text-decoration: none; border-radius: 6px;
}
.header-user .btn-logout:hover { background: rgba(255,255,255,.15); color: #fff; text-decoration: none; }

/* Page Body — offset from sidebar, beri ruang untuk footer fixed */
.page-body {
    padding: 24px 28px 68px;
    flex: 1;
    max-width: 100%;
    overflow-x: hidden;
    min-width: 0;
    margin-left: var(--sidebar-w);
}
/* Footer — FIXED di bawah viewport, selalu terlihat */
.app-footer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 90;
    padding: 12px 28px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12.5px;
    color: var(--text);
    background: #fff;
    min-height: 44px;
    box-shadow: 0 -2px 8px rgba(0,0,0,.04);
}
.app-footer .footer-left strong,
.app-footer .footer-brand { font-weight: 600; color: #0f172a; }
.app-footer .footer-right {
    display: flex;
    align-items: center;
}
.app-footer .footer-right span {
    color: #334155;
}
.app-footer .footer-right span + span {
    border-left: 1px solid #cbd5e1;
    margin-left: 14px;
    padding-left: 14px;
}

/* ============ LOGIN ============ */
.login-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--navy) 0%, #0e3355 60%, #14538a 100%);
}
.login-card {
    background: #fff; padding: 40px 36px; border-radius: 16px;
    width: 100%; max-width: 400px; box-shadow: 0 25px 60px rgba(0,0,0,.35);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .logo-circle {
    width: 64px; height: 64px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #60a5fa);
    color: #fff; font-weight: 800; font-size: 22px;
    display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.login-brand h1 { font-size: 18px; margin: 0; color: var(--navy); }
.login-brand p { color: var(--text-muted); font-size: 13px; margin: 4px 0 0; }
.login-card label { display: block; font-size: 13px; margin-bottom: 5px; font-weight: 600; }
.login-card input[type="text"], .login-card input[type="password"] {
    width: 100%; padding: 11px 14px; margin-bottom: 18px;
    border: 1.5px solid var(--border); border-radius: 10px; font-size: 14px; transition: border .2s;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
    width: 100%; padding: 12px; background: var(--accent); color: #fff;
    border: none; border-radius: 10px; font-size: 14px; font-weight: 700; cursor: pointer; transition: background .2s;
}
.login-card button:hover { background: var(--accent-hover); }
.error-box {
    background: #fef2f2; color: #b91c1c; padding: 10px 14px;
    border-radius: 8px; font-size: 13px; margin-bottom: 18px; border: 1px solid #fecaca;
}
.login-hint { margin-top: 18px; font-size: 12px; color: var(--text-muted); text-align: center; }

/* ============ DASHBOARD COMPONENTS ============ */
.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card {
    background: #fff; border-radius: 14px; padding: 18px 20px;
    border: 1px solid var(--border);
    display: flex; align-items: flex-start; gap: 14px;
    min-width: 0;
}
.kpi-card .kpi-icon {
    width: 50px; height: 50px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    color: #fff;
}
.kpi-card .kpi-icon svg { width: 24px; height: 24px; }
.kpi-card .kpi-data { flex: 1; min-width: 0; }
.kpi-card .kpi-number { font-size: 26px; font-weight: 800; line-height: 1.1; color: #111827; }
.kpi-card .kpi-label { font-size: 12.5px; color: #374151; margin-top: 2px; font-weight: 600; line-height: 1.3; }
.kpi-card .kpi-sub { font-size: 11px; color: #6b7280; margin-top: 6px; line-height: 1.5; }
.kpi-card .kpi-progress { margin-top: 8px; height: 8px; border-radius: 4px; background: #e5e7eb; overflow: hidden; }
.kpi-card .kpi-progress .bar { height: 100%; border-radius: 4px; }

/* Ikon lingkaran SOLID (putih di atas warna penuh) — sesuai mockup */
.kpi-icon-blue { background: #2563eb; }
.kpi-icon-navy { background: #1e40af; }
.kpi-icon-green { background: #16a34a; }
.kpi-icon-yellow { background: #d4a72c; }
.kpi-icon-red { background: #dc2626; }

.charts-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.chart-card { background: #fff; border-radius: 12px; border: 1px solid var(--border); padding: 20px; }
.chart-card h3 { font-size: 14px; font-weight: 700; margin: 0 0 16px; color: var(--navy); }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut-legend { font-size: 12.5px; }
.donut-legend .leg-item { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.donut-legend .leg-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.donut-legend .leg-count { font-weight: 700; margin-left: auto; padding-left: 12px; }
.donut-legend .leg-pct { color: var(--text-muted); font-size: 11px; width: 38px; text-align: right; }

/* Gauge */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge-center { font-size: 36px; font-weight: 800; color: var(--navy); line-height: 1; }
.gauge-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* Horizontal bar */
.hbar-item { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.hbar-item .hbar-label { width: 110px; font-size: 12px; color: var(--text-muted); text-align: right; flex-shrink: 0; }
.hbar-item .hbar-track { flex: 1; height: 18px; background: #e9ecef; border-radius: 4px; overflow: hidden; }
.hbar-item .hbar-fill { height: 100%; border-radius: 4px; transition: width .5s ease; }
.hbar-item .hbar-val { width: 32px; font-size: 12px; font-weight: 700; text-align: right; }

/* Dashboard tables */
.dash-tables { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-bottom: 24px; }
.dash-table-card { background: #fff; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.dash-table-card .dtc-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 12px; }
.dash-table-card .dtc-head h3 { font-size: 14px; font-weight: 700; margin: 0; color: var(--navy); }
.dash-table-card .dtc-head a { font-size: 12px; color: var(--accent); font-weight: 600; }
.dash-table-card table { font-size: 12.5px; }
.dash-table-card th { padding: 8px 12px; font-size: 11px; }
.dash-table-card td { padding: 9px 12px; }
.dash-table-card tbody tr:last-child td { border-bottom: none; }

.status-dot { display: inline-flex; align-items: center; gap: 6px; }
.status-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; }
.status-dot.dot-green::before { background: var(--green); }
.status-dot.dot-yellow::before { background: var(--yellow); }
.status-dot.dot-red::before { background: var(--red); }

/* Quick actions — sesuai mockup: pill-shaped dengan panah kanan */
.actions-row {
    display: flex !important;
    gap: 16px;
    margin-bottom: 24px;
}
.action-card {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 18px 20px 22px;
    border-radius: 16px;
    color: #fff;
    text-decoration: none;
    transition: transform .15s, box-shadow .15s;
    cursor: pointer;
}
.action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0,0,0,.28);
    text-decoration: none;
    color: #fff;
}
.action-card .ac-icon {
    width: 50px; height: 50px;
    border-radius: 13px;
    background: rgba(255,255,255,.18);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.action-card .ac-icon svg { width: 26px; height: 26px; }
.action-card .ac-text { flex: 1; min-width: 0; }
.action-card .ac-text h4 { font-size: 15px; margin: 0 0 3px; font-weight: 700; line-height: 1.25; }
.action-card .ac-text p { font-size: 11.5px; margin: 0; opacity: .8; line-height: 1.3; }
.action-card .ac-arrow {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,.22);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.action-card .ac-arrow svg { width: 16px; height: 16px; }

/* Warna card — Biru, Emas, Navy gelap, Emas */
.ac-blue  { background: linear-gradient(135deg, #1a3a7a, #2563eb); }
.ac-gold  { background: linear-gradient(135deg, #7a5c12, #b8922a 40%, #d4a833 100%); }
.ac-navy  { background: linear-gradient(135deg, #0a1e3a, #142d50 50%, #1c3d6a); }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 18px;
    overflow-x: auto;
    min-width: 0;
}
.card h2 { font-size: 15px; margin: 0 0 14px; }
.card h3 { font-size: 13px; margin: 0 0 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }

/* ============ GENERIC ============ */

/* Backward-compat for mitra_edit / mitra_validasi pages */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-value { font-size: 26px; font-weight: 700; }
.kpi-card.kpi-success .kpi-value { color: var(--green); }
.kpi-card.kpi-danger .kpi-value { color: var(--red); }
.kpi-card.kpi-warning .kpi-value { color: var(--yellow); }
.kpi-card.kpi-muted .kpi-value { color: var(--gray); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-wrap { overflow-x: auto; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:hover td { background: #fafbfc; }
.table-wrap { overflow-x: auto; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-primary { background: #dbeafe; color: #1d4ed8; }
.badge-warning { background: #fef3c7; color: #a16207; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-secondary { background: #f1f5f9; color: #475569; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: var(--text-muted); }
.field input, .field select, .field textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
    font-family: inherit; background: #fff;
}
.field textarea { min-height: 64px; resize: vertical; }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: #f1f5f9; color: #94a3b8; }

.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 7px;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f1f5f9; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Indikator blocks ---------- */
.indikator-block {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 14px;
    overflow: hidden;
}
.indikator-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
.indikator-head .kode { font-weight: 700; color: var(--navy); margin-right: 8px; }
.indikator-head .bobot { font-size: 12px; color: var(--text-muted); }
.indikator-body { padding: 16px; }
.indikator-desc { font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; white-space: pre-line; }
.indikator-baseline {
    background: #f8fafc; border-left: 3px solid var(--accent);
    padding: 8px 12px; font-size: 12.5px; margin-bottom: 12px; color: var(--text);
}
.cek-pill { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }

.autosave-note { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.section-title { font-size: 16px; font-weight: 700; margin: 26px 0 12px; color: var(--navy); }
.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.flex-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select, .filters input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Responsive */
@media (max-width: 1200px) {
    .hero-motto { display: none; }
    .ai-toast { width: 320px; }
}
@media (max-width: 1024px) {
    .kpi-row { grid-template-columns: repeat(3, 1fr); }
    .charts-row { grid-template-columns: 1fr; }
    .dash-tables { grid-template-columns: 1fr; }
    .actions-row { flex-wrap: wrap; }
    .action-card { flex: 1 1 calc(50% - 16px); min-width: 240px; }
    .hero-instansi { display: none; }
}
@media (max-width: 768px) {
    .sidebar { display: none; }
    .app-content { margin-left: 0; }
    .page-body { margin-left: 0; padding-bottom: 68px; }
    .app-layout { padding-bottom: 56px; }
    .kpi-row { grid-template-columns: 1fr 1fr; }
    .action-card { flex: 1 1 100%; }
    .app-hero { flex-direction: column; align-items: flex-start; gap: 12px; padding-left: 28px; }
    .hero-title { font-size: 20px; }
    .header-user { align-self: flex-end; }
    .ai-toast { width: calc(100vw - 32px); right: 16px; bottom: 56px; }
    .ai-trigger-btn { bottom: 64px; right: 16px; }
}

/* ── AI Insight Floating Toast ─────────────────────────── */
.ai-toast {
    position: fixed;
    bottom: 60px;
    right: 20px;
    width: 380px;
    max-height: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(15,43,70,.18), 0 2px 8px rgba(0,0,0,.06);
    z-index: 1000;
    animation: aiSlideUp 0.35s cubic-bezier(.4,0,.2,1);
    border-left: 5px solid var(--accent);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
@keyframes aiSlideUp {
    from { opacity: 0; transform: translateY(24px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-toast-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}
.ai-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ai-sparkle { font-size: 18px; }
.ai-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--navy);
}
.ai-provider { margin-left: 6px; }
.ai-provider-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: .3px;
    text-transform: uppercase;
    vertical-align: middle;
}
.ai-prov-gemini      { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.ai-prov-openrouter  { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.ai-prov-groq        { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.ai-prov-cache       { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.ai-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ai-timestamp {
    font-size: 10px;
    color: var(--text-muted);
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-refresh, .ai-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.ai-refresh:hover { background: #eff6ff; color: var(--accent); }
.ai-close { font-size: 18px; line-height: 1; }
.ai-close:hover { background: #fef2f2; color: #dc2626; }

.ai-toast-body {
    padding: 14px 16px 16px;
    overflow-y: auto;
    flex: 1;
    max-height: 340px;
}
.ai-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
    padding: 8px 0;
}
.ai-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid #e9ecef;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: aiSpin .7s linear infinite;
}
@keyframes aiSpin { to { transform: rotate(360deg); } }

.ai-content p {
    font-size: 13px;
    line-height: 1.65;
    color: #334155;
    margin: 0 0 10px;
}
.ai-content p:last-child { margin-bottom: 0; }
.ai-content strong { color: var(--navy); }

.ai-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    font-size: 12.5px;
    color: #991b1b;
}
.ai-error-icon { font-size: 16px; flex-shrink: 0; }

/* ── AI Trigger Floating Button ────────────────────────── */
.ai-trigger-btn {
    position: fixed;
    bottom: 64px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--navy));
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(37,99,235,.35);
    z-index: 999;
    transition: transform .2s, box-shadow .2s;
    padding: 6px;
}

.ai-trigger-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.ai-trigger-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(37,99,235,.45);
}
.ai-trigger-btn svg { width: 22px; height: 22px; }
.ai-trigger-btn { display: none; /* shown via JS when toast is dismissed */ }

/* ============================================================
 * PRINT & PDF STYLES
 * ============================================================ */
@media print {
    @page {
        size: A4 portrait;
        margin: 1.5cm 1cm 1.5cm 1cm;
    }
    .sidebar, .app-hero, .app-footer, .no-print, .btn, .btn-sm, .actions-row, .filters, #aiToast, #aiTriggerBtn {
        display: none !important;
    }
    .print-header, .signature-block {
        display: block !important;
    }
    .app-layout, .app-layout-main, .app-content, .page-body {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    body {
        background: #fff !important;
        color: #000 !important;
        font-family: Arial, "Helvetica Neue", Helvetica, sans-serif !important;
        font-size: 10pt !important;
    }
    .card {
        border: 1px solid #cbd5e1 !important;
        box-shadow: none !important;
        margin-bottom: 16px !important;
        padding: 12px !important;
        page-break-inside: avoid;
    }
    .card h2 {
        font-size: 12pt !important;
        margin-top: 0 !important;
        border-bottom: 1px solid #e2e8f0;
        padding-bottom: 4px;
    }
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 8.5pt !important;
    }
    th, td {
        border: 1px solid #cbd5e1 !important;
        padding: 4px 6px !important;
        color: #000 !important;
    }
    th {
        background: #f1f5f9 !important;
        font-weight: 700 !important;
    }
    .kpi-row, .kpi-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
        margin-bottom: 14px !important;
    }
    .kpi-card {
        border: 1px solid #cbd5e1 !important;
        box-shadow: none !important;
        padding: 8px !important;
    }
    .badge {
        border: 1px solid #94a3b8 !important;
        color: #000 !important;
        background: #f8fafc !important;
        font-size: 8pt !important;
        padding: 2px 4px !important;
    }
}

/* ---------- Searchable Combobox & Dropdown Autocomplete ---------- */
.searchable-combobox-wrap {
    position: relative;
    width: 100%;
}
.searchable-combobox-input {
    width: 100%;
    padding: 8px 32px 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    cursor: text;
    box-sizing: border-box;
}
.searchable-combobox-input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.searchable-combobox-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #64748b;
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s ease;
}
.searchable-combobox-wrap.open .searchable-combobox-arrow {
    transform: translateY(-50%) rotate(180deg);
}
.searchable-combobox-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 1050;
    display: none;
    padding: 4px 0;
}
.searchable-combobox-wrap.open .searchable-combobox-list {
    display: block;
}
.searchable-combobox-option {
    padding: 8px 12px;
    font-size: 12.5px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.12s ease;
}
.searchable-combobox-option:last-child {
    border-bottom: none;
}
.searchable-combobox-option:hover,
.searchable-combobox-option.active {
    background: #eff6ff;
}
.searchable-combobox-option .opt-title {
    font-weight: 600;
    color: #1e293b;
}
.searchable-combobox-option:hover .opt-title,
.searchable-combobox-option.active .opt-title {
    color: #1d4ed8;
}
.searchable-combobox-option .opt-sub {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
    line-height: 1.3;
}
.searchable-combobox-empty {
    padding: 12px;
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
}

/* KPI Card & Badge Text Overflow Fix */
.kpi-card {
    word-break: break-word;
    overflow: hidden;
}
.kpi-card .badge {
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.25 !important;
    text-align: center;
}

