:root {
    --primary: #b91c1c;
    --primary-dark: #991b1b;
    --primary-light: #fee2e2;
    --sidebar-bg: #2d1212;
    --sidebar-text: #d9c6c6;
    --sidebar-active: #dc2626;
    --body-bg: #faf5f5;
    --ink: #1e293b;
    --muted: #64748b;
    --border: #f0e2e2;
    --card-bg: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--body-bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

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

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform .2s ease;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 40;
}

/* Sidebar internals */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: #fff;
}
.brand .logo {
    width: 46px; height: 46px;
    border-radius: 10px;
    background: rgba(255,255,255,.08);
    display: flex; align-items: center; justify-content: center;
    flex: none;
    overflow: hidden;
    padding: 4px;
}
.brand .logo .brand-img { max-width:100%; max-height:100%; object-fit:contain; }
.brand .title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.brand .subtitle { font-size: 11px; color: #94a3b8; }
.brand-logo-only { justify-content: center; }
.brand-logo-only .logo { width: auto; height: auto; border-radius: 0; background: none; padding: 0; overflow: visible; }
.brand-logo-only .logo .brand-img { max-width: 120px; max-height: 48px; width: auto; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 12px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; font-size: 13px; margin-bottom: 2px; transition: background .15s; }
.nav-item i { width: 20px; text-align: center; font-size: 15px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.user-card { display: flex; align-items: center; gap: 10px; color: #fff; margin-bottom: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,#b91c1c,#dc2626); display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px; color:#fff; flex:none; }
.user-card .u-name { font-weight: 600; font-size: 13px; }
.user-card .u-role { font-size: 11px; color: #94a3b8; }
.btn-logout { display:flex; align-items:center; gap:8px; width:100%; padding:8px 12px; border-radius:8px; background: rgba(239,68,68,.15); color:#fca5a5; border:none; cursor:pointer; font-weight:600; font-size:13px; }
.btn-logout:hover { background: rgba(239,68,68,.25); }

/* ------------------------------------------------------------------ */
/* Cards                                                               */
/* ------------------------------------------------------------------ */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; }
.card-body { padding: 20px; }
.card-header-row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:16px 20px; border-bottom:1px solid var(--border); }
.card-title { font-size:15px; font-weight:700; }

/* Page header */
.page-header { padding: 24px 24px 8px; }
.page-title { font-size: 22px; font-weight: 800; }
.page-subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }
.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }

.content { padding: 16px 24px 40px; }

/* ------------------------------------------------------------------ */
/* Stat cards                                                          */
/* ------------------------------------------------------------------ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 18px; display: flex; align-items: center; gap: 14px; transition: box-shadow .2s ease, transform .2s ease; }
.stat-card:hover { box-shadow: 0 8px 24px rgba(185, 28, 28, 0.10); transform: translateY(-2px); }
.stat-card.grad { background: linear-gradient(135deg, #ffffff 0%, #fdf7f7 100%); position: relative; overflow: hidden; }
.stat-card.grad::before { content: ''; position: absolute; top: -40px; right: -40px; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle, rgba(185, 28, 28, 0.06), transparent 70%); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex: none; box-shadow: 0 4px 10px rgba(0,0,0,0.06); }
.stat-icon.blue { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.violet { background: #ede9fe; color: #7c3aed; }
.stat-icon.sky { background: #e0f2fe; color: #0284c7; }
.stat-icon.rose { background: #ffe4e6; color: #e11d48; }
.stat-icon.grad-blue { background: linear-gradient(135deg, #2563eb, #60a5fa); color: #fff; }
.stat-icon.grad-green { background: linear-gradient(135deg, #16a34a, #4ade80); color: #fff; }
.stat-icon.grad-amber { background: linear-gradient(135deg, #d97706, #fbbf24); color: #fff; }
.stat-icon.grad-violet { background: linear-gradient(135deg, #7c3aed, #a78bfa); color: #fff; }
.stat-icon.grad-orange { background: linear-gradient(135deg, #ea580c, #fb923c); color: #fff; }
.stat-icon.grad-teal { background: linear-gradient(135deg, #0f766e, #2dd4bf); color: #fff; }
.stat-icon.grad-cyan { background: linear-gradient(135deg, #0284c7, #38bdf8); color: #fff; }
.stat-icon.grad-pink { background: linear-gradient(135deg, #db2777, #f472b6); color: #fff; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-value { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.flex-1 { flex: 1; min-width: 0; }
.stat-spark { font-size: 18px; color: var(--primary-light); opacity: 0.7; }

/* Chart cards */
.chart-grid { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.chart-card { flex: 1; min-width: 340px; }
.chart-wrap { position: relative; }
.chart-card .card-body { padding: 8px 16px 16px; }
.chart-card .card-title i { color: var(--primary); }

/* ------------------------------------------------------------------ */
/* Tables                                                              */
/* ------------------------------------------------------------------ */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th { background: #f8fafc; text-align: left; padding: 10px 12px; font-weight: 700; color: var(--ink); border-bottom: 2px solid var(--border); white-space: nowrap; }
.table tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #f8fafc; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions a, .table .actions button { margin-left: 6px; }

/* ------------------------------------------------------------------ */
/* Badges                                                              */
/* ------------------------------------------------------------------ */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-orange { background: #ffedd5; color: #ea580c; }
.badge-gray { background: #e2e8f0; color: #475569; }
.badge-purple { background: #ede9fe; color: #7c3aed; }

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */
.btn { display:inline-flex; align-items:center; gap:6px; padding:8px 14px; border-radius:8px; font-weight:600; font-size:13px; border:none; cursor:pointer; transition: background .15s; line-height:1.2; }
.btn-primary { background: var(--primary); color:#fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background:#fff; color:var(--primary); border:1px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-success { background:#16a34a; color:#fff; }
.btn-success:hover { background:#15803d; }
.btn-danger { background:#dc2626; color:#fff; }
.btn-danger:hover { background:#b91c1c; }
.btn-secondary { background:#e2e8f0; color:#334155; }
.btn-secondary:hover { background:#cbd5e1; }
.btn-warning { background:#f59e0b; color:#fff; }
.btn-warning:hover { background:#d97706; }
.btn-sm { padding:5px 10px; font-size:12px; border-radius:6px; }
.btn-icon { padding:5px 8px; font-size:13px; }
.btn-block { width:100%; justify-content:center; }

/* ------------------------------------------------------------------ */
/* Forms                                                               */
/* ------------------------------------------------------------------ */
.form-group { margin-bottom: 16px; }
.form-label { display:block; font-weight:600; font-size:13px; margin-bottom:6px; color:var(--ink); }
.form-label .req { color:#dc2626; }
.form-control, .form-select, .form-input {
    width:100%; padding:9px 12px; border:1px solid var(--border); border-radius:8px; font-size:14px; font-family:inherit; background:#fff; color:var(--ink);
}
.form-control:focus, .form-select:focus { outline:2px solid var(--primary-light); border-color:var(--primary); }
textarea.form-control { min-height: 90px; resize: vertical; }
.form-hint { font-size:12px; color:var(--muted); margin-top:4px; }
.form-check { display:flex; align-items:center; gap:8px; }
.form-check input { width:16px; height:16px; }
.form-error { color:#dc2626; font-size:12px; margin-top:4px; }
.invalid { border-color:#dc2626 !important; }

.form-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap:0 16px; }
.form-grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* Permission checkboxes (Manajemen User) */
.permission-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap:8px 16px; }
.permission-check {
    display:flex; align-items:center; gap:8px;
    padding:8px 10px; border:1px solid var(--border); border-radius:8px;
    background:#fff; font-size:13px; font-weight:500; cursor:pointer;
    transition:border-color .15s, background .15s;
}
.permission-check:hover { border-color:var(--primary); background:#fff8f0; }
.permission-check input[type=checkbox] { accent-color:var(--primary); width:16px; height:16px; cursor:pointer; }


/* Rp. prefix inside a money input */
.input-rp { position:relative; }
.input-rp .rp-prefix {
    position:absolute; left:12px; top:50%; transform:translateY(-50%);
    font-size:13px; font-weight:700; color:var(--muted); pointer-events:none; z-index:1;
}
.input-rp .form-control, .input-rp input { padding-left:42px; }

/* Dynamic custom-cost rows */
.cost-row {
    display:grid; grid-template-columns: 1fr 220px 40px; gap:8px; align-items:center; margin-bottom:8px;
}
.cost-row .form-control { margin-bottom:0; }
.cost-row-remove {
    height:38px; width:38px; display:flex; align-items:center; justify-content:center;
    border:1px solid #fca5a5; background:#fee2e2; color:#b91c1c; border-radius:8px; cursor:pointer; font-size:14px;
}
.cost-row-remove:hover { background:#fecaca; }

/* Dynamic custom ops rows (label + value) */
.ops-row {
    display:grid; grid-template-columns: 1fr 1.4fr 40px; gap:8px; align-items:center; margin-bottom:8px;
}
.ops-row .form-control { margin-bottom:0; }

/* ------------------------------------------------------------------ */
/* Alerts / flash                                                      */
/* ------------------------------------------------------------------ */
.alert { padding:12px 16px; border-radius:8px; margin-bottom:16px; font-weight:500; font-size:13px; display:flex; align-items:center; gap:8px; }
.alert-success { background:#dcfce7; color:#166534; }
.alert-danger { background:#fee2e2; color:#991b1b; }
.alert-info { background:#dbeafe; color:#1e40af; }
.alert-warning { background:#fef3c7; color:#92400e; }
.alert .close { margin-left:auto; cursor:pointer; background:none; border:none; font-size:16px; color:inherit; }

/* ------------------------------------------------------------------ */
/* Filters bar                                                         */
/* ------------------------------------------------------------------ */
.filter-bar { display:flex; flex-wrap:wrap; gap:12px; align-items:flex-end; background:#fff; border:1px solid var(--border); border-radius:12px; padding:16px; margin-bottom:16px; }
.filter-bar .form-group { margin-bottom:0; }
.filter-bar .btn { margin-bottom:0; }

/* ------------------------------------------------------------------ */
/* Misc                                                               */
/* ------------------------------------------------------------------ */
.text-muted { color: var(--muted); }
.text-right { text-align:right; }
.text-center { text-align:center; }
.mt-0 { margin-top:0 } .mt-1 { margin-top:4px } .mt-2 { margin-top:8px } .mt-3 { margin-top:16px } .mt-4 { margin-top:24px }
.mb-0 { margin-bottom:0 } .mb-1 { margin-bottom:4px } .mb-2 { margin-bottom:8px } .mb-3 { margin-bottom:16px } .mb-4 { margin-bottom:24px }
.ml-auto { margin-left:auto; }
.d-flex { display:flex; align-items:center; gap:8px; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 16px; }
.font-bold { font-weight:700; }
.fs-12 { font-size:12px; } .fs-13 { font-size:13px; } .fs-15 { font-size:15px; } .fs-18 { font-size:18px; }
.w-100 { width:100%; }

/* Grid helpers */
.row { display:flex; flex-wrap:wrap; gap:16px; }
.col { flex:1; min-width:260px; }

/* Detail view */
.detail-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:0 20px; }
.detail-item { padding:8px 0; border-bottom:1px dashed var(--border); }
.detail-item .k { font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; }
.detail-item .v { font-weight:600; font-size:14px; margin-top:2px; }

/* Empty state */
.empty { text-align:center; padding:40px 20px; color:var(--muted); }
.empty i { font-size:40px; display:block; margin-bottom:10px; opacity:.4; }

/* COA code chip */
.code-chip { display:inline-block; padding:2px 8px; border-radius:6px; background:#eef2ff; color:#4338ca; font-weight:700; font-size:12px; font-family:ui-monospace,monospace; }

/* Journal form lines */
.journal-lines .table tbody td { padding:6px 8px; }
.totals { font-size:13px; }

/* Two-column report layout */
.report-two-col { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:16px; }
@media (max-width: 900px) { .report-two-col { grid-template-columns:1fr; } }

/* Printable report document */
.report-doc { max-width:760px; margin:0 auto; }
.report-doc .doc-logo { height:48px; width:auto; object-fit:contain; margin-bottom:8px; }
.report-doc .doc-head { text-align:center; border-bottom:3px double var(--ink); padding-bottom:14px; margin-bottom:20px; }
.report-doc .doc-head h2 { font-size:18px; font-weight:800; }
.report-doc .doc-head h3 { font-size:15px; font-weight:800; letter-spacing:.06em; margin-top:2px; }
.report-doc .doc-head div { font-size:12px; color:var(--muted); }
.report-doc .doc-head .doc-contact { font-size:11px; color:var(--muted); margin-top:3px; line-height:1.5; }
.report-doc .doc-foot { display:flex; justify-content:flex-end; margin-top:40px; font-size:12px; }
.report-doc .sig-line { border-bottom:1px solid var(--ink); width:200px; height:36px; }

.table-compact th, .table-compact td { padding:7px 12px; font-size:13px; }
.row-total { background:#f8fafc; }
.row-total td { border-top:2px solid var(--ink); border-bottom:2px solid var(--ink); }
.pl-3 { padding-left:24px !important; }

/* Print sheet (A4-like) */
.sheet-a4 { background:#fff; border:1px solid var(--border); border-radius:12px; padding:28px; }
.sheet-header { display:flex; justify-content:space-between; align-items:center; border-bottom:3px double var(--ink); padding-bottom:14px; margin-bottom:20px; }
.sheet-header .sh-title { font-size:20px; font-weight:800; }
.sheet-header .sh-sub { font-size:12px; color:var(--muted); }

/* Login */
.auth-wrapper { min-height:100vh; display:flex; align-items:center; justify-content:center; background: linear-gradient(135deg,#7f1d1d,#b91c1c 40%,#dc2626); padding:20px; }
.auth-card { background:#fff; border-radius:16px; box-shadow:0 25px 60px rgba(0,0,0,.25); width:100%; max-width:400px; padding:36px; }
.auth-logo { width:auto; height:72px; border-radius:0; background:transparent; box-shadow:none; display:flex; align-items:center; justify-content:center; margin-bottom:16px; }
.auth-logo .auth-brand { max-height:72px; max-width:100%; object-fit:contain; }
.auth-title { font-size:22px; font-weight:800; margin-bottom:4px; }
.auth-sub { color:var(--muted); font-size:13px; margin-bottom:24px; }

/* Responsive */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .sidebar-backdrop { position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:45; display:none; }
    .sidebar-backdrop.open { display:block; }
}
.sidebar-toggle { background:none; border:none; font-size:22px; cursor:pointer; color:var(--ink); display:flex; }

@media print {
    .sidebar, .topbar, .no-print, .filter-bar, .page-header .btn { display:none !important; }
    .main-content { margin-left:0 !important; }
    .content { padding:0; }
    .sheet-a4 { border:none; border-radius:0; padding:0; }
    body { background:#fff; }
}
