/* ========================================
   REKAPLY — Revenue & Invoice Reconciliation System
   Design System & Global Styles
   ======================================== */

:root {
    /* Color Palette — Clean Light Finance Theme */
    --bg-primary: #f4f6fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #fbfcfe;
    --bg-surface: #f1f4f9;
    --bg-input: #ffffff;

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #8a94a6;
    --text-heading: #0f172a;

    --accent-primary: #0f766e;    /* Teal */
    --accent-primary-hover: #0d9488;
    --accent-primary-subtle: rgba(15, 118, 110, 0.10);
    --accent-success: #059669;    /* Emerald */
    --accent-success-subtle: rgba(5, 150, 105, 0.10);
    --accent-warning: #b45309;    /* Amber */
    --accent-warning-subtle: rgba(217, 119, 6, 0.12);
    --accent-danger: #dc2626;     /* Red */
    --accent-danger-subtle: rgba(220, 38, 38, 0.08);
    --accent-info: #2563eb;       /* Blue */
    --accent-info-subtle: rgba(37, 99, 235, 0.10);
    --accent-cyan: #0891b2;
    --accent-purple: #7c3aed;

    /* Sidebar (light) */
    --sidebar-bg: #ffffff;
    --sidebar-text: #475569;
    --sidebar-text-active: #0f766e;
    --sidebar-active-bg: #f1f4f9;
    --sidebar-border: #e5e9f0;

    /* Borders */
    --border-color: #e5e9f0;
    --border-color-hover: #cbd3df;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
    --shadow-glow: 0 0 0 3px rgba(15, 118, 110, 0.15);

    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, monospace;

    /* Sidebar */
    --sidebar-width: 250px;
    --sidebar-collapsed: 68px;
}

/* ========================================
   Reset & Base
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    color: var(--accent-primary-hover);
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover { color: var(--accent-primary); }

/* ========================================
   Layout
   ======================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 0.3s ease;
}

.sidebar-brand {
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand h1 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--accent-primary);
    letter-spacing: -0.5px;
}

.sidebar-brand small {
    display: block;
    font-size: 0.68rem;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 12px 12px 6px;
    font-weight: 600;
}

.nav-group { margin-bottom: 2px; }
.nav-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}
.nav-group-title::-webkit-details-marker { display: none; }
.nav-group-title:hover { background: var(--sidebar-active-bg); color: var(--sidebar-text-active); }
.nav-group-title .nav-icon { width: 18px; text-align: center; font-size: 1rem; opacity: 0.7; }
.nav-caret { margin-left: auto; font-size: 0.75rem; opacity: 0.6; transition: transform 0.2s ease; }
.nav-group:not([open]) .nav-caret { transform: rotate(-90deg); }
.nav-subtitle {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 8px 14px 4px;
    font-weight: 600;
}
.nav-group-body { padding-left: 12px; margin-bottom: 6px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: 2px;
}

.nav-link:hover {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-active);
}

.nav-link.active {
    background: var(--accent-primary-subtle);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

.nav-link .nav-icon {
    width: 18px;
    text-align: center;
    font-size: 1rem;
    opacity: 0.7;
}
.nav-link.active .nav-icon,
.nav-link:hover .nav-icon { opacity: 1; }

.nav-badge {
    margin-left: auto;
    background: var(--accent-danger);
    color: white;
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 700;
}

/* Main content */
.main-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* Top bar */
.topbar {
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.88);
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-heading);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Lonceng info pinjaman intern di topbar */
.notif-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-surface);
    text-decoration: none;
    font-size: 0.95rem;
    line-height: 1;
}

.notif-bell:hover {
    filter: brightness(1.15);
}

.notif-count {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--accent-danger);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-surface);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
}

/* Page content */
.page-content {
    padding: 28px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.5px;
}

.page-header p {
    color: var(--text-muted);
    margin-top: 4px;
    font-size: 0.88rem;
}

/* ========================================
   Cards
   ======================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all 0.3s ease;
}

.card:hover {
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-heading);
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    container-type: inline-size;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card.kpi-primary::before { background: linear-gradient(90deg, var(--accent-primary), var(--accent-cyan)); }
.kpi-card.kpi-success::before { background: linear-gradient(90deg, var(--accent-success), #34d399); }
.kpi-card.kpi-warning::before { background: linear-gradient(90deg, var(--accent-warning), #fbbf24); }
.kpi-card.kpi-danger::before { background: linear-gradient(90deg, var(--accent-danger), #f87171); }
.kpi-card.kpi-info::before { background: linear-gradient(90deg, var(--accent-info), var(--accent-cyan)); }
.kpi-card.kpi-purple::before { background: linear-gradient(90deg, var(--accent-purple), #c084fc); }

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-color-hover);
}

.kpi-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.kpi-value {
    /* Angka tidak pernah turun baris: hurufnya mengecil mengikuti lebar kartu. */
    font-size: clamp(0.8rem, 9cqi, 1.6rem);
    white-space: nowrap;
    font-weight: 800;
    color: var(--text-heading);
    letter-spacing: -1px;
    font-variant-numeric: tabular-nums;
}

.kpi-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ========================================
   Tables
   ======================================== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

table.data-table thead {
    background: var(--bg-surface);
    position: sticky;
    top: 0;
}

table.data-table th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.8px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

table.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

table.data-table tbody tr {
    transition: background 0.15s ease;
}

table.data-table tbody tr:hover {
    background: var(--bg-card-hover);
}

table.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

table.data-table .num.positive { color: var(--accent-success); }
table.data-table .num.negative { color: var(--accent-danger); }

/* ========================================
   Badges / Status
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-matched     { background: var(--accent-success-subtle); color: var(--accent-success); }
.badge-discrepancy { background: var(--accent-danger-subtle); color: var(--accent-danger); }
.badge-unmatched   { background: var(--accent-warning-subtle); color: var(--accent-warning); }
.badge-partial     { background: var(--accent-info-subtle); color: var(--accent-info); }
.badge-completed   { background: var(--accent-success-subtle); color: var(--accent-success); }
.badge-processing  { background: var(--accent-info-subtle); color: var(--accent-info); }
.badge-pending     { background: var(--accent-warning-subtle); color: var(--accent-warning); }
.badge-failed      { background: var(--accent-danger-subtle); color: var(--accent-danger); }
.badge-open        { background: var(--accent-warning-subtle); color: var(--accent-warning); }
.badge-resolved    { background: var(--accent-success-subtle); color: var(--accent-success); }

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: var(--font-sans);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 1px 2px rgba(15, 118, 110, 0.25);
}
.btn-primary:hover {
    background: var(--accent-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(15, 118, 110, 0.25);
    color: white;
}

.btn-success {
    background: var(--accent-success);
    color: white;
}
.btn-success:hover {
    background: #059669;
    color: white;
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color-hover);
    color: var(--text-secondary);
}
.btn-outline:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 0.95rem;
}

.btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
    opacity: 0.85;
}
.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 15px;
    height: 15px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}
.btn-outline.is-loading::after {
    border-color: rgba(15, 118, 110, 0.3);
    border-top-color: var(--accent-primary);
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Forms
   ======================================== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-subtle);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236b7280'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    padding-right: 36px;
}

/* ========================================
   Pagination
   ======================================== */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
    justify-content: center;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.pagination a:hover {
    background: var(--accent-primary-subtle);
    color: var(--accent-primary-hover);
}

.pagination .active {
    background: var(--accent-primary);
    color: white;
    font-weight: 700;
}

.pagination .disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* ========================================
   Alerts / Flash Messages
   ======================================== */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
}

.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ========================================
   Search Bar
   ======================================== */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-bar .form-control {
    flex: 1;
    min-width: 200px;
}

/* ========================================
   Grid helpers
   ======================================== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ========================================
   Summary stats
   ======================================== */
.stat-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.82rem;
}

.stat-pill .label { color: var(--text-muted); }
.stat-pill .value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ========================================
   Empty state
   ======================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* ========================================
   Login page
   ======================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 30% 20%, rgba(15, 118, 110, 0.10) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(8, 145, 178, 0.08) 0%, transparent 50%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-card h1 {
    font-size: 1.8rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 4px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 32px;
}

.login-card .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 0.95rem;
}

/* ========================================
   Detail page
   ======================================== */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.detail-item {
    padding: 12px 16px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
}

.detail-item .label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 4px;
}

.detail-item .value {
    font-size: 0.92rem;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-word;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .kpi-grid { grid-template-columns: 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
}

/* ========================================
   Hub (pilih aplikasi)
   ======================================== */
.hub-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 30% 20%, rgba(15, 118, 110, 0.10) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(8, 145, 178, 0.08) 0%, transparent 50%);
}

.hub-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border-color);
}

.hub-topbar .topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hub-brand h1 {
    font-size: 1.3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hub-brand small {
    display: block;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.hub-main {
    flex: 1;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 48px 24px 64px;
}

.hub-heading { margin-bottom: 32px; }
.hub-heading h2 { font-size: 1.6rem; font-weight: 700; color: var(--text-heading); }
.hub-heading p { color: var(--text-secondary); margin-top: 4px; }

.hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.hub-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.hub-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--hub-accent, var(--accent-primary));
}

.hub-card--indigo { --hub-accent: var(--accent-primary); --hub-accent-subtle: var(--accent-primary-subtle); }
.hub-card--cyan   { --hub-accent: var(--accent-cyan);    --hub-accent-subtle: rgba(6, 182, 212, 0.12); }
.hub-card--emerald{ --hub-accent: var(--accent-success); --hub-accent-subtle: var(--accent-success-subtle); }
.hub-card--purple { --hub-accent: var(--accent-purple);  --hub-accent-subtle: rgba(168, 85, 247, 0.12); }

a.hub-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-lg);
    background: var(--bg-card-hover);
}

.hub-card--disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.hub-card-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    border-radius: var(--radius-lg, 12px);
    background: var(--hub-accent-subtle);
}

.hub-card-body h3 { font-size: 1.15rem; font-weight: 700; color: var(--text-heading); }
.hub-card-tagline { display: block; font-size: 0.75rem; color: var(--hub-accent); font-weight: 600; margin: 2px 0 10px; }
.hub-card-body p { color: var(--text-secondary); font-size: 0.875rem; line-height: 1.5; }

.hub-card-action {
    margin-top: auto;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--hub-accent);
}

/* ========================================
   App switcher (topbar)
   ======================================== */
.app-switcher { position: relative; }
.app-switcher summary {
    list-style: none;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    user-select: none;
}
.app-switcher summary::-webkit-details-marker { display: none; }
.app-switcher summary .caret { color: var(--text-muted); margin-left: 4px; }
.app-switcher[open] summary { border-color: var(--border-color-hover); }

.app-switcher-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 260px;
    background: var(--bg-card);
    border: 1px solid var(--border-color-hover);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 100;
}

.app-switcher-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
}
.app-switcher-item span { font-size: 1.2rem; }
.app-switcher-item strong { display: block; font-size: 0.85rem; }
.app-switcher-item small { display: block; font-size: 0.7rem; color: var(--text-muted); }
a.app-switcher-item:hover { background: var(--bg-card-hover); }
.app-switcher-item.active { background: var(--accent-primary-subtle); }
.app-switcher-item.disabled { opacity: 0.5; cursor: not-allowed; }
.app-switcher-item.hub-link {
    margin-top: 4px;
    border-top: 1px solid var(--border-color);
    border-radius: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    justify-content: center;
}

/* ========================================
   CASH FLOW module
   ======================================== */
.sidebar-brand--cashflow h1 { color: var(--accent-primary); }

/* Administrasi: kerangka netral, bukan milik salah satu program. */
.sidebar-brand--admin h1 { color: var(--text-muted); letter-spacing: 0.04em; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.ob-table td { vertical-align: middle; }
.ob-table .form-control { padding: 8px 10px; font-size: 13px; }
.ob-table .row-no { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ob-table .amount-input { text-align: right; }

/* Modal */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color-hover);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 760px;
    max-height: calc(100vh - 40px);
    display: flex; flex-direction: column;
}
.modal--danger { border: 2px solid var(--accent-danger); box-shadow: 0 0 40px rgba(220, 38, 38, 0.2), var(--shadow-lg); }
.modal-header {
    display: flex; gap: 14px; align-items: flex-start;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--accent-danger-subtle);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-header h3 { margin: 0 0 6px; color: var(--accent-danger); font-size: 17px; letter-spacing: 0.02em; }
.modal-header p { margin: 0; color: var(--text-secondary); font-size: 13.5px; line-height: 1.5; }
.modal-body { padding: 20px 24px; overflow: auto; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.bank-group-head { display: flex; align-items: center; gap: 12px; flex: 1; }
.bank-group-no { color: var(--text-muted); font-size: 12px; font-weight: 600; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.04em; }
.bank-group-head .bank-select { max-width: 360px; font-weight: 600; }
.bank-group .card-header { gap: 12px; }

/* ========================================
   Searchable select (.ss)
   ======================================== */
.ss { position: relative; width: 100%; }
.ss .ss-native {
    position: absolute; width: 1px; height: 1px; opacity: 0;
    pointer-events: none; overflow: hidden; clip: rect(0 0 0 0);
}
.ss-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    text-align: left; cursor: pointer;
}
.ss-toggle:disabled { cursor: not-allowed; opacity: 0.6; background: var(--bg-surface); }
.ss-toggle .ss-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-toggle.is-placeholder .ss-label { color: var(--text-muted); }
.ss-toggle .ss-caret { color: var(--text-muted); font-size: 0.8rem; transition: transform 0.15s ease; }
.ss.is-open .ss-toggle { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-primary-subtle); }
.ss.is-open .ss-caret { transform: rotate(180deg); }

.ss-menu {
    /* Melayang di atas halaman (posisinya dihitung JS) supaya tidak terpotong oleh
       tabel atau kartu yang punya overflow sendiri. */
    position: fixed; z-index: 1000;
    display: flex; flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color-hover);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    min-width: 220px;
}
.ss-menu[hidden] { display: none; }
.ss-search-wrap { flex: 0 0 auto; padding: 8px; border-bottom: 1px solid var(--border-color); background: var(--bg-surface); }
.ss-search {
    width: 100%; padding: 8px 10px 8px 30px;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--bg-input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a94a6' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 10px center;
    font: inherit; font-size: 0.85rem; color: var(--text-primary);
}
.ss-search:focus { outline: none; border-color: var(--accent-primary); }
.ss-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px; }
.ss-list::-webkit-scrollbar { width: 8px; }
.ss-list::-webkit-scrollbar-thumb { background: var(--border-color-hover); border-radius: 8px; }
.ss-item {
    height: 36px; display: flex; align-items: center;
    padding: 0 10px; border-radius: var(--radius-sm);
    font-size: 0.86rem; color: var(--text-primary); cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ss-item.is-active { background: var(--accent-primary-subtle); color: var(--accent-primary); }
.ss-item.is-selected { font-weight: 600; }
.ss-item.is-selected::after { content: '✓'; margin-left: auto; color: var(--accent-primary); }
.ss-item--placeholder { color: var(--text-muted); }
.ss-item.is-disabled { opacity: 0.45; cursor: not-allowed; }
/* Kategori induk tampil sebagai judul kelompok: kelihatan, tapi bukan pilihan. */
.ss-item--group { font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-muted); background: var(--bg-surface);
    opacity: 1; cursor: default; margin-top: 2px; }
.ss-item--group.is-active { background: var(--bg-surface); color: var(--text-muted); }
.ss-item--group::before { content: ''; }
/* Sub-kategori menjorok supaya jelas nempel ke judul di atasnya. */
.ss-item--child { padding-left: 26px; position: relative; }
.ss-item--child::before { content: '↳'; position: absolute; left: 10px; color: var(--text-muted); }
.ss-empty { padding: 14px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* Select di dalam sel tabel tetap rapat */
.ob-table .ss-toggle { padding: 8px 10px; font-size: 13px; }

.ss-item mark { background: transparent; color: inherit; font-weight: 700; text-decoration: underline; text-decoration-color: var(--accent-primary); text-underline-offset: 2px; }
.ss-item.is-active mark { color: var(--accent-primary); }
.ss-item[hidden] { display: none !important; }
#client-errors ul { margin: 6px 0 0 18px; }
#client-errors[hidden] { display: none; }

.form-label.is-invalid { color: var(--accent-danger); }
.form-label.is-invalid input[type=checkbox] { outline: 2px solid var(--accent-danger); outline-offset: 2px; border-radius: 2px; }

.form-control.is-invalid { border-color: var(--accent-danger); box-shadow: 0 0 0 3px var(--accent-danger-subtle); }
.field-error { color: var(--accent-danger); font-size: 0.72rem; margin-top: 4px; line-height: 1.3; }

.filter-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; align-items: end; }
.filter-row .form-group { margin: 0; min-width: 0; }
.filter-row .filter-actions { display: flex; gap: 8px; }
.filter-hint { font-size: 0.74rem; color: var(--text-muted); margin-top: 8px; }
.is-loading { opacity: 0.5; pointer-events: none; transition: opacity 0.15s ease; }

/* ---- Cash Flow Report */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.charts-row { margin-bottom: 20px; }
.chart-wrap { position: relative; height: 260px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.78rem; color: var(--text-secondary); margin: -6px 0 10px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

table.cf-report { font-size: 0.8rem; font-variant-numeric: tabular-nums; }
table.cf-report th, table.cf-report td { padding: 6px 10px; white-space: nowrap; }
table.cf-report th.cf-col { text-align: center; border-left: 1px solid var(--border-color); }
table.cf-report td.num { text-align: right; font-family: var(--font-mono); font-size: 0.78rem; }
table.cf-report .pct { color: var(--text-muted); font-size: 0.72rem; border-right: 1px solid var(--border-color); }
table.cf-report .cf-label { min-width: 260px; position: sticky; left: 0; background: var(--bg-card); z-index: 1; }
table.cf-report .cf-indent { padding-left: 26px; color: var(--text-secondary); }
/* Sub-kategori (mis. Gaji > Outsource): induk jadi subtotal, sub menjorok lebih dalam. */
table.cf-report .cf-indent-2 { padding-left: 46px; color: var(--text-muted); }
table.cf-report .cf-indent-3 { padding-left: 66px; color: var(--text-muted); }
table.cf-report tr.cf-subtotal td { font-weight: 600; }
/* Induk bisa dibuka-tutup: tombolnya menyatu dengan label barisnya. */
table.cf-report .cf-toggle { display: inline-flex; align-items: center; gap: 6px; background: none;
    border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
table.cf-report .cf-toggle:hover { color: var(--accent-primary); }
table.cf-report .cf-caret { display: inline-block; width: 10px; color: var(--text-muted);
    font-size: 0.7rem; transition: transform 0.12s ease; }
table.cf-report .cf-toggle:hover .cf-caret { color: var(--accent-primary); }
table.cf-report tr.cf-subtotal.is-open td.cf-label { color: var(--text-heading); }
table.cf-report tr.cf-sub[hidden], table.cf-report tr.cf-subtotal[hidden] { display: none; }
table.cf-report.hide-empty tr.cf-empty { display: none; }
table.cf-report .cf-total { background: var(--bg-surface); font-weight: 600; }
table.cf-report tr.cf-header td, table.cf-report tr.cf-section td { font-weight: 700; color: var(--text-heading); text-transform: uppercase; font-size: 0.74rem; letter-spacing: 0.04em; }
table.cf-report tr.cf-header td.cf-label, table.cf-report tr.cf-section td.cf-label { background: var(--bg-surface); }
table.cf-report tr.cf-opening td, table.cf-report tr.cf-surplus td, table.cf-report tr.cf-closing td { font-weight: 700; color: var(--text-heading); }
table.cf-report tr.cf-closing td { border-top: 2px solid var(--accent-primary); border-bottom: 2px solid var(--accent-primary); background: var(--accent-primary-subtle); }
table.cf-report tr.cf-surplus td { background: #f8fafc; }
table.cf-report tr.cf-gap td { height: 8px; padding: 0; border: 0; background: transparent; }
table.cf-report .zero { color: var(--text-muted); opacity: 0.5; }
table.cf-report .negative { color: var(--accent-danger); }

@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } .charts-row { grid-template-columns: 1fr; } }
@media print {
    .sidebar, .topbar, .filter-row, .charts-row, .btn { display: none !important; }
    .main-content { margin-left: 0; }
    .card { border: 0; box-shadow: none; padding: 0; }
}

/* ---- Bulk bar & check list */
.bulk-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 20px; margin-bottom: 14px; flex-wrap: wrap; }
.bulk-bar.is-active { border-color: var(--accent-primary); background: var(--accent-primary-subtle); }
.bulk-bar-left, .bulk-bar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bulk-bar .ss { width: auto; }
tr.row-ungrouped td { background: rgba(217, 119, 6, 0.04); }
.badge-warning { background: var(--accent-warning-subtle); color: var(--accent-warning); }

.check-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 8px; background: var(--bg-input); }
.check-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; font-weight: 400; }
.check-item:hover { background: var(--bg-surface); }
.check-item:has(input:checked) { background: var(--accent-primary-subtle); }
.check-item input { margin: 0; }

.bulk-bar.is-error { border-color: var(--accent-danger); background: var(--accent-danger-subtle); }
.bulk-error { width: 100%; margin: 0; padding: 10px 14px; }
.bulk-error[hidden] { display: none; }

tr.row-flash td { background: var(--accent-success-subtle) !important; transition: background 1s ease; }

/* ---- Confirm modal */
.modal--confirm { max-width: 460px; }
.confirm-body { display: flex; gap: 16px; padding: 24px 24px 8px; align-items: flex-start; }
.confirm-icon { font-size: 30px; line-height: 1; flex-shrink: 0; }
.confirm-title { margin: 0 0 6px; font-size: 1.05rem; color: var(--text-heading); }
.confirm-message { margin: 0; color: var(--text-secondary); line-height: 1.55; }
.confirm-message strong { color: var(--text-heading); }
.modal--confirm .modal-footer { border-top: 0; padding-top: 12px; }
.filter-inline { display: flex; gap: 8px; }
.filter-inline .form-group { min-width: 150px; }
a.stat-pill { color: inherit; }
a.stat-pill:hover { border-color: var(--accent-primary); }

/* ---- Penerimaan & Pengeluaran (mutasi kas) ---- */
.badge-success { background: var(--accent-success-subtle); color: var(--accent-success); }
.badge-danger  { background: var(--accent-danger-subtle);  color: var(--accent-danger); }

.type-toggle { display: flex; gap: 12px; flex-wrap: wrap; }
.type-option {
    flex: 1 1 200px;
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: border-color .15s, background .15s;
}
.type-option:hover { border-color: var(--accent-primary); }
.type-option input { accent-color: var(--accent-primary); }
.type-option:has(input:checked) { border-color: var(--accent-primary); background: var(--accent-info-subtle); }
.type-option--in:has(input:checked)  { border-color: var(--accent-success); background: var(--accent-success-subtle); }
.type-option--out:has(input:checked) { border-color: var(--accent-danger);  background: var(--accent-danger-subtle); }

/* Input satu baris di dalam modal konfirmasi (appPrompt) */
.confirm-prompt { margin-top: 14px; }
.confirm-prompt .form-label { display: block; margin-bottom: 6px; }

/* Audit log Cash Flow */
.audit-detail summary { cursor: pointer; font-size: 0.82rem; }
.audit-detail summary:hover { color: var(--accent-primary); }
.audit-detail-body { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; }
.audit-detail-body > div { min-width: 220px; }
.audit-tag {
    display: inline-block; padding: 1px 8px; border-radius: 10px;
    font-size: 0.68rem; font-weight: 700; margin-bottom: 6px;
}
.audit-tag--old { background: var(--accent-danger-subtle); color: var(--accent-danger); }
.audit-tag--new { background: var(--accent-success-subtle); color: var(--accent-success); }
.audit-kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; font-size: 0.8rem; }
.audit-kv dt { color: var(--text-muted); }
.audit-kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.audit-lines { margin-top: 10px; }
.audit-lines .data-table { font-size: 0.76rem; }

/* Master kategori cash flow: urutan baris diatur dengan drag. */
table.cat-table td.drag-cell { cursor: grab; text-align: center; color: var(--text-muted);
    user-select: none; letter-spacing: 2px; }
table.cat-table tr[draggable="true"]:hover td.drag-cell { color: var(--text-secondary); }
table.cat-table tr.is-dragging { opacity: 0.45; }
table.cat-table.is-saving { opacity: 0.6; pointer-events: none; }

/* Input saldo awal hutang: kolom "Pihak / Bank" hanya menampilkan satu bentuk isian
   sesuai kategori barisnya. display dipasang lewat kelas, bukan style inline, supaya
   atribut hidden tetap menang saat isian itu tidak dipakai. */
.line-bank { display: grid; gap: 6px; }
.line-bank[hidden] { display: none; }
.line-field { display: grid; gap: 2px; }
.line-field > span { font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-muted); }
table .debt-row > td { vertical-align: middle; }
