:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --green: #16a34a;
    --red: #dc2626;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }

/* Layout */
.topbar { display: flex; align-items: center; gap: 24px; background: #0f172a; color: #fff; padding: 0 24px; height: 56px; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.topbar .brand { font-weight: 700; font-size: 17px; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #cbd5e1; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.topbar nav a:hover { background: #1e293b; color: #fff; }
.topbar nav a.active { background: var(--primary); color: #fff; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.container { width: 100%; margin: 24px auto; padding: 0 24px; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

/* Cards & panels */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.page-head h1 { font-size: 22px; }

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 20px; font-weight: 700; margin-top: 4px; }
.stat .sub { font-size: 12px; color: var(--muted); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #f8fafc; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:hover td { background: #f8fafc; }
td.right, th.right { text-align: right; }

/* Buttons */
.btn { display: inline-block; background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--primary-dark); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: #eff6ff; }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #991b1b; }
.btn-green { background: var(--green); }
.btn-green:hover { background: #15803d; }
.btn-grey { background: #64748b; }
.actions { display: flex; gap: 6px; }

/* Dropdown menu */
.dropdown-wrap { position: relative; display: inline-block; }
.dropdown-menu { display: none; position: absolute; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.12); min-width: 220px; z-index: 50; overflow: hidden; text-align: left; }
.dropdown-menu.show { display: block; }
.dropdown-menu a { display: block; padding: 10px 14px; text-decoration: none; color: var(--text); font-size: 13.5px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
.dropdown-menu a:last-child { border-bottom: none; }
.dropdown-menu a:hover { background: #eff6ff; color: var(--primary); }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: #e2e8f0; color: #334155; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: #334155; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 14px; }
.form-group { margin-bottom: 4px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a, #1e40af); }
.login-box { background: #fff; border-radius: 16px; padding: 36px; width: 360px; max-width: 92%; }
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box p { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

/* Tabs dokumen */
.doc-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.doc-tabs a { padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: 13px; }
.doc-tabs a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Item rows form */
.items-table input, .items-table select { padding: 8px 10px; font-size: 13.5px; }
.items-table input[type=number] { padding: 8px 8px; }
.items-table td { padding: 8px 6px; }

/* Chain link */
.chain { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chain a, .chain span { font-size: 12px; padding: 4px 10px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 999px; text-decoration: none; color: var(--primary-dark); }
.chain .me { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Print */
@media print {
    body { background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .topbar, .footer, .no-print { display: none !important; }
    .container { max-width: 100%; margin: 0; padding: 0; }
    .print-sheet { border: none; box-shadow: none; margin: 0; padding: 12px 16px 20px; position: relative; overflow: hidden; }
}
.print-sheet { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px 36px 28px; max-width: 800px; margin: 0 auto; position: relative; overflow: hidden; }
.print-head { display: flex; align-items: center; gap: 16px; border-bottom: 2.5px solid #0f172a; padding-bottom: 10px; margin-bottom: 14px; }
.print-head .logo { max-height: 70px; max-width: 105px; object-fit: contain; flex-shrink: 0; }
.print-head .co { font-size: 19px; font-weight: 800; }
.print-head .co-meta { font-size: 12px; color: var(--muted); line-height: 1.4; }
.print-title { text-align: center; margin-bottom: 8px; }
.print-title h2 { letter-spacing: 1px; text-decoration: underline; font-size: 17px; }
.print-title .doc-no { font-size: 13px; }
.print-parties { display: flex; justify-content: space-between; margin-bottom: 14px; font-size: 13.5px; gap: 24px; }
.print-parties .to { min-width: 45%; }
.print-parties .lbl { font-weight: 700; font-size: 12px; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.print-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: 13px; }
.print-table th { background: #f1f5f9; border: 1px solid #94a3b8; padding: 7px 8px; text-align: center; }
.print-table td { border: 1px solid #94a3b8; padding: 7px 8px; }
.print-totals { width: 300px; margin-left: auto; font-size: 13.5px; }
.print-totals td { padding: 3px 8px; }
.print-totals tr.total td { font-weight: 800; border-top: 2px solid #0f172a; font-size: 14.5px; }
.sign-area { display: flex; justify-content: space-between; margin-top: 24px; text-align: center; font-size: 13.5px; }
.sign-area .box { width: 40%; }
.sign-area .space { height: 56px; }
.sign-area .line { border-top: 1px solid #0f172a; padding-top: 4px; }

/* Watermark Lunas */
.watermark-lunas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    pointer-events: none;
    user-select: none;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.watermark-lunas-box {
    border: 6px dashed rgba(148, 163, 184, 0.42);
    color: rgba(148, 163, 184, 0.42);
    font-size: 82px;
    font-weight: 900;
    letter-spacing: 32px;
    text-indent: 32px;
    padding: 12px 60px;
    text-transform: uppercase;
    border-radius: 20px;
    line-height: 1.1;
    text-align: center;
    outline: 3px solid rgba(148, 163, 184, 0.42);
    outline-offset: 6px;
    font-family: 'Arial Black', Impact, 'Segoe UI', sans-serif;
    white-space: nowrap;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* Status Badge / Stamp on Document */
.status-lunas-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 14px;
    background: #dcfce7;
    color: #15803d;
    border: 1.5px solid #16a34a;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* Modal */
.modal-backdrop { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15, 23, 42, 0.6); z-index: 1000; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(2px); }
.modal-backdrop.show { display: flex; }
.modal-box { background: #fff; border-radius: 14px; max-width: 540px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2); animation: modalIn .2s ease-out; }
@keyframes modalIn { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; font-weight: 700; margin: 0; }
.modal-close { background: transparent; border: none; font-size: 20px; cursor: pointer; color: var(--muted); padding: 0 4px; }
.modal-close:hover { color: var(--red); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: #f8fafc; border-bottom-left-radius: 14px; border-bottom-right-radius: 14px; }
