/* ============================================================
   NOTA — Design System 2025
   Elegan · Bersih · Beraksen warna toko (--accent)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --border: #e6e8ee;
    --border-strong: #d5d9e2;
    --text: #17181c;
    --text-2: #5b6070;
    --text-3: #9095a3;
    --accent: #1a5276;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-xs: 0 1px 2px rgba(23, 24, 28, .05);
    --shadow-sm: 0 1px 2px rgba(23,24,28,.05), 0 2px 8px rgba(23,24,28,.06);
    --shadow-md: 0 4px 12px rgba(23,24,28,.08), 0 12px 32px rgba(23,24,28,.09);
    --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg); color: var(--text); line-height: 1.55;
    min-height: 100vh; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }

::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* ===== APP LAYOUT ===== */
.app-layout { display: flex; min-height: 100vh; }
.main-content {
    flex: 1; padding: 2.25rem 2rem; padding-left: calc(248px + 2rem);
    max-width: 1440px; overflow-x: clip;
}
.main-content h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: 1.1rem; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: 248px; min-height: 100vh; position: fixed; top: 0; left: 0; z-index: 100;
    display: flex; flex-direction: column; padding: 0 .75rem .75rem;
    background: linear-gradient(180deg, #14161f 0%, #191c29 100%);
    color: #b9bdcc;
}
.sidebar-brand {
    padding: 1.35rem .65rem 1.15rem; font-size: 1.06rem; font-weight: 700;
    letter-spacing: -.01em; color: #fff; display: flex; align-items: center; gap: .55rem;
    border-bottom: 1px solid rgba(255,255,255,.07); margin-bottom: .6rem;
}
.sidebar-brand::before {
    content: ''; width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
    background: conic-gradient(from 210deg, #4f8fd9, #37c398, #f0b64c, #e46a6a, #4f8fd9);
    box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.sidebar-nav { flex: 1; display: flex; flex-direction: column; overflow-y: auto; scrollbar-width: thin; }
.sidebar-section-label {
    padding: .85rem .65rem .3rem; font-size: .66rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .1em; color: #63687d;
}
.sidebar-link {
    display: flex; align-items: center; gap: .6rem; padding: .52rem .65rem;
    margin: 1px 0; border-radius: 10px; font-size: .875rem; font-weight: 500;
    color: #aab0c2; transition: background .15s, color .15s; white-space: nowrap;
    border-left: 3px solid transparent;
}
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar-link.active {
    background: color-mix(in srgb, var(--accent) 30%, rgba(255,255,255,.05));
    border-left-color: var(--accent); color: #fff; font-weight: 600;
}
.sidebar-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 3px rgba(255,255,255,.06); }
.sidebar-footer { padding: .75rem .65rem 0; border-top: 1px solid rgba(255,255,255,.07); margin-top: .75rem; font-size: .78rem; color: #6d7387; }
.sidebar-footer a { color: #9aa0b4; }
.sidebar-footer a:hover { color: #fff; }

/* ===== HAMBURGER (mobile) ===== */
.hamburger {
    display: none; position: fixed; top: .9rem; left: .9rem; z-index: 200;
    width: 42px; height: 42px; align-items: center; justify-content: center;
    background: #14161f; border: none; border-radius: 12px; cursor: pointer;
    box-shadow: var(--shadow-md);
}
.hamburger span { display: block; width: 18px; height: 2px; background: #fff; margin: 3.5px auto; border-radius: 2px; transition: .3s; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,17,26,.5); backdrop-filter: blur(2px); z-index: 90; }

/* ===== CARDS ===== */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.4rem; margin-bottom: 1.1rem;
    box-shadow: var(--shadow-xs);
}
.card h2 { font-size: .98rem; font-weight: 650; letter-spacing: -.01em; margin-bottom: 1rem; }

/* ===== FORMS ===== */
.form-group { margin-bottom: .95rem; }
.form-group label { display: block; font-weight: 550; font-size: .8rem; margin-bottom: .3rem; color: var(--text-2); }
.form-group input, .form-group textarea, .form-group select,
.item-row input, select[name="stock_type"], input[type="number"][form], .status-select {
    width: 100%; padding: .52rem .8rem; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); font-size: .92rem; font-family: inherit;
    background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus,
.item-row input:focus {
    outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
.form-group small { color: var(--text-3); }
.form-row { display: flex; gap: .9rem; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 140px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .5rem 1.15rem; border-radius: 11px; font-size: .875rem; font-weight: 600;
    font-family: inherit; border: 1px solid transparent; cursor: pointer; text-align: center;
    transition: transform .12s ease, box-shadow .15s, background .15s, border-color .15s;
    letter-spacing: -.005em;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 40%, transparent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); text-decoration: none; }
.btn-success { background: #12946b; color: #fff; }
.btn-success:hover { background: #0d7a57; text-decoration: none; }
.btn-danger { background: #dc4b3f; color: #fff; }
.btn-danger:hover { background: #c03a2f; text-decoration: none; }
.btn-outline { background: #fff; border-color: var(--border-strong); color: var(--text-2); }
.btn-outline:hover { background: #f4f5f8; color: var(--text); text-decoration: none; }
.btn-sm { padding: .32rem .72rem; font-size: .79rem; border-radius: 9px; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead { background: transparent; }
th {
    padding: .55rem .8rem; text-align: left; font-weight: 600; font-size: .72rem;
    text-transform: uppercase; letter-spacing: .06em; color: var(--text-3);
    border-bottom: 1.5px solid var(--border-strong); white-space: nowrap;
}
td { padding: .62rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tr:hover td { background: #f8f9fb; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mono { font-family: 'SF Mono', ui-monospace, 'Cascadia Mono', Menlo, Consolas, monospace; font-size: .84em; }
.nowrap { white-space: nowrap; }

/* ===== STATUS BADGES ===== */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px; font-size: .73rem; font-weight: 600; }
.badge-draft { background: #fdf3d7; color: #946200; }
.badge-sent  { background: #e3ecfb; color: #2456b8; }
.badge-paid  { background: #dcf5ea; color: #0c7a54; }
.status-select { font-size: .76rem; padding: .22rem .45rem; }

/* ===== FLASH MESSAGES ===== */
.flash {
    padding: .8rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-size: .88rem;
    border: 1px solid transparent; animation: flashIn .25s ease;
}
.flash-success { background: #ebfaf2; color: #0b6b49; border-color: #bfe9d5; }
.flash-error { background: #fdf0ef; color: #a13327; border-color: #f5cdc9; }
@keyframes flashIn { from { opacity: 0; transform: translateY(-4px); } }

/* ===== ITEM ROWS (dynamic) ===== */
.item-row { display: flex; gap: .5rem; align-items: flex-end; margin-bottom: .5rem; flex-wrap: wrap; }
.item-row .desc { flex: 3; min-width: 180px; }
.item-row .num { flex: 1; min-width: 70px; max-width: 120px; }
.item-row .subtotal-cell { min-width: 110px; text-align: right; font-family: 'SF Mono', ui-monospace, monospace; font-weight: 600; font-size: .86rem; padding-top: .5rem; }
.item-row .btn-remove { background: none; border: none; color: #dc4b3f; font-size: 1.25rem; cursor: pointer; padding: .15rem .4rem; border-radius: 8px; }
.item-row .btn-remove:hover { background: #fdf0ef; }

/* ===== INVOICE PREVIEW (A4) ===== */
.invoice-page {
    background: #fff; max-width: 210mm; margin: 0 auto; padding: 15mm;
    border-radius: 6px; box-shadow: var(--shadow-md);
}
.invoice-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem; border-bottom: 3px solid var(--accent); padding-bottom: 1rem; }
.invoice-company-name { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
.invoice-company-info { font-size: .8rem; color: var(--text-2); line-height: 1.5; }
.invoice-meta { text-align: right; }
.invoice-number { font-family: 'SF Mono', ui-monospace, monospace; font-size: 1.05rem; font-weight: 700; color: var(--accent); }
.invoice-label { font-size: .74rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; }
.invoice-parties { display: flex; justify-content: space-between; margin-bottom: 1.5rem; gap: 2rem; }
.invoice-parties > div { flex: 1; }
.invoice-parties h4 { font-size: .72rem; text-transform: uppercase; color: var(--text-3); letter-spacing: .07em; margin-bottom: .25rem; }
.invoice-parties p { font-size: .88rem; line-height: 1.5; }

.invoice-table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .85rem; }
.invoice-table thead { border-bottom: 2px solid var(--accent); }
.invoice-table th { padding: .5rem .6rem; font-size: .72rem; text-transform: uppercase; color: var(--text-2); letter-spacing: .05em; border-bottom: none; }
.invoice-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
.invoice-table .col-num { width: 40px; text-align: center; }
.invoice-table .col-qty { width: 60px; text-align: center; }
.invoice-table .col-price, .invoice-table .col-total { width: 110px; text-align: right; font-family: 'SF Mono', ui-monospace, monospace; }

.invoice-totals { display: flex; justify-content: flex-end; margin: 1rem 0; }
.invoice-totals-box { width: 280px; }
.invoice-totals-row { display: flex; justify-content: space-between; padding: .3rem 0; font-size: .88rem; }
.invoice-totals-row.total { border-top: 2px solid var(--accent); font-weight: 700; font-size: 1.05rem; padding-top: .5rem; margin-top: .3rem; }
.invoice-totals-row .label { color: var(--text-2); }
.invoice-totals-row .amount { font-family: 'SF Mono', ui-monospace, monospace; }

.invoice-stamp {
    display: inline-flex; align-items: center; justify-content: center;
    width: 90px; height: 90px; border: 3px solid var(--accent); border-radius: 50%;
    font-size: .65rem; font-weight: 700; text-align: center; color: var(--accent);
    transform: rotate(-12deg); opacity: .65; line-height: 1.2; padding: .5rem;
}

.invoice-footer-section { display: flex; gap: 2rem; margin-top: 1.5rem; font-size: .82rem; color: var(--text-2); }
.invoice-footer-section > div { flex: 1; }
.invoice-footer-section h4 { font-size: .72rem; text-transform: uppercase; color: var(--text-3); margin-bottom: .25rem; letter-spacing: .06em; }

/* ===== RECEIPT (thermal) ===== */
.invoice-receipt { width: 72mm; margin: 0 auto; padding: 4mm; font-family: 'SF Mono', ui-monospace, 'Courier New', monospace; font-size: 9pt; background: #fff; border-radius: 6px; box-shadow: var(--shadow-md); }
.invoice-receipt .receipt-header { text-align: center; margin-bottom: 3mm; }
.invoice-receipt .receipt-company { font-size: 11pt; font-weight: bold; }
.invoice-receipt .receipt-address { font-size: 7pt; color: var(--text-2); }
.invoice-receipt .receipt-divider { border: none; border-top: 1px dashed #bbb; margin: 2mm 0; }
.invoice-receipt .receipt-row { display: flex; justify-content: space-between; font-size: 8pt; }
.invoice-receipt .receipt-item-desc { font-size: 8pt; margin-top: 1mm; }
.invoice-receipt .receipt-total-line { border-top: 1px dashed #bbb; margin: 2mm 0; }
.invoice-receipt .receipt-total { font-weight: bold; font-size: 10pt; }
.invoice-receipt .receipt-footer { text-align: center; font-size: 7pt; color: var(--text-3); margin-top: 3mm; }
.invoice-receipt .receipt-stamp { text-align: center; margin-top: 3mm; font-size: 8pt; font-weight: bold; color: var(--accent); }

/* ===== AUTH PAGES (login / lupa password / reset / registrasi) ===== */
.login-wrap, .auth-body {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    padding: 1rem; background:
        radial-gradient(600px 320px at 12% -4%, color-mix(in srgb, var(--accent) 14%, transparent), transparent),
        radial-gradient(520px 300px at 105% 108%, rgba(55,195,152,.13), transparent),
        radial-gradient(420px 260px at 88% 6%, rgba(240,182,76,.10), transparent),
        var(--bg);
}
.login-box, .auth-card {
    background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
    padding: 2.1rem 1.9rem; border: 1px solid rgba(255,255,255,.7);
    border-radius: 20px; box-shadow: var(--shadow-md); width: 100%; max-width: 380px;
}
.login-box h1, .auth-card h1 { text-align: center; margin-bottom: 1.4rem; font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
.auth-logo { display: flex; justify-content: center; margin-bottom: .9rem; }
.auth-logo span {
    width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
    background: conic-gradient(from 210deg, #4f8fd9, #37c398, #f0b64c, #e46a6a, #4f8fd9);
    color: #fff; font-weight: 800; font-size: 1.05rem; box-shadow: var(--shadow-sm);
}
.auth-alt { text-align: center; font-size: .82rem; color: var(--text-3); margin-top: 1rem; }

/* ===== SHARE BAR & TOGGLE ===== */
.share-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0; }
.btn-wa { background: #1fae53; color: #fff; }
.btn-wa:hover { background: #189147; text-decoration: none; }
.size-toggle { display: inline-flex; background: #ecedf2; border-radius: 11px; padding: 3px; gap: 2px; margin-bottom: 1rem; }
.size-toggle button {
    padding: .38rem 1.1rem; border: none; background: transparent; cursor: pointer;
    font-size: .8rem; font-weight: 600; font-family: inherit; color: var(--text-2);
    border-radius: 8px; transition: .15s;
}
.size-toggle button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-xs); }

/* ===== SCROLLBAR (webkit) ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cdd2de; border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ===== RESPONSIVE — MOBILE ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-102%); transition: transform .3s cubic-bezier(.4,0,.2,1); box-shadow: none; }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
    .sidebar.open ~ .sidebar-overlay { display: block; }
    .hamburger { display: flex; }
    .main-content { padding: 1rem; padding-top: 4.1rem; }
    .form-row { flex-direction: column; gap: 0; }
    .item-row { flex-direction: column; align-items: stretch; }
    .item-row input { width: 100%; }
    .item-row .num { max-width: none; }
    .invoice-parties { flex-direction: column; gap: 1rem; }
    .invoice-footer-section { flex-direction: column; gap: 1rem; }
    .hide-mobile { display: none; }
    .show-mobile-only { display: block !important; }
    .card { padding: 1.05rem; }
    .main-content h1 { font-size: 1.25rem; }
    .btn { padding: .55rem 1rem; }
    .share-bar .btn { flex: 1 1 45%; }
}

/* ===== PRINT ===== */
@media print {
    body { background: #fff; }
    .no-print, .hamburger, .sidebar, .sidebar-overlay, .flash, .share-bar, .size-toggle { display: none !important; }
    .app-layout { display: block; }
    .main-content { padding: 0; max-width: none; }
    .card { box-shadow: none; border: none; background: #fff; }
    .invoice-page { box-shadow: none; border-radius: 0; padding: 10mm; max-width: none; }
}

@media print and (min-width: 210mm) {
    @page { size: A4; margin: 12mm; }
}

@media print and (max-width: 85mm) {
    @page { size: 80mm auto; margin: 2mm; }
    .invoice-receipt { width: 72mm; padding: 2mm; font-size: 8pt; box-shadow: none; }
}
