/* =====================================================================
   PT AGRAPANA - Inventory ERP
   Stylesheet utama (tanpa CDN, jalan offline di VPS)
   Struktur: token -> dasar -> layout -> komponen -> halaman -> cetak
   ===================================================================== */

:root {
    --brand-50:  #eff6ff;
    --brand-100: #dbeafe;
    --brand-500: #3b82f6;
    --brand-600: #2563eb;
    --brand-700: #1d4ed8;
    --slate-50:  #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --green-50:  #f0fdf4;
    --green-100: #dcfce7;
    --green-600: #16a34a;
    --green-700: #15803d;
    --red-50:    #fef2f2;
    --red-100:   #fee2e2;
    --red-600:   #dc2626;
    --red-700:   #b91c1c;
    --amber-50:  #fffbeb;
    --amber-100: #fef3c7;
    --amber-600: #d97706;
    --amber-700: #b45309;
    --purple-100:#f3e8ff;
    --purple-700:#7e22ce;
    --radius:    12px;
    --radius-sm: 9px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
    --shadow-lg: 0 18px 45px rgba(15, 23, 42, .18);
}

/* ---------------- DASAR ---------------- */
* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--slate-50);
    color: var(--slate-800);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; color: var(--slate-800); }
p { margin: 0; }
table { width: 100%; border-collapse: collapse; }


/* ---------------- LAYOUT ---------------- */
.app {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: #fff;
    border-right: 1px solid var(--slate-200);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 18px;
    border-bottom: 1px solid var(--slate-100);
    margin-bottom: 10px;
}
.brand-logo {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--brand-600);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 13px;
    letter-spacing: .5px;
    flex-shrink: 0;
}
.brand-name { font-size: 15px; font-weight: 800; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--slate-400); font-weight: 600; }

.nav-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--slate-400);
    font-weight: 700;
    padding: 14px 10px 6px;
}
.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    color: var(--slate-600);
    font-weight: 500;
    font-size: 13.5px;
    transition: background .15s, color .15s;
}
.nav a:hover { background: var(--slate-100); color: var(--slate-900); }
.nav a.active { background: var(--brand-50); color: var(--brand-700); font-weight: 700; }
.nav a .badge-count {
    margin-left: auto;
    background: var(--red-50);
    color: var(--red-600);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
}
.sidebar-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--slate-100);
    font-size: 12px;
    color: var(--slate-400);
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.topbar {
    height: 62px;
    background: #fff;
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar h1 { font-size: 17px; font-weight: 800; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
    display: flex; align-items: center; gap: 9px;
    background: var(--slate-100);
    padding: 5px 12px 5px 5px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--slate-600);
}
.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--brand-600);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 800;
}
.user-role {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--brand-700);
    background: var(--brand-100);
    padding: 1px 7px;
    border-radius: 999px;
}

.content { padding: 24px; flex: 1; }

/* ---------------- PAGE HEAD ---------------- */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.page-title { font-size: 18px; font-weight: 800; }
.page-sub { font-size: 12.5px; color: var(--slate-500); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- GRID 2-COLUMN ---------------- */
.grid-2 {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 18px;
    align-items: start;
}
@media (max-width: 900px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* ---------------- CARDS ---------------- */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--slate-200);
    overflow: hidden;
    margin-bottom: 18px;
}
.card:last-child { margin-bottom: 0; }
.card-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--slate-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.card-head h2 { font-size: 14px; font-weight: 800; }
.card-body { padding: 18px; }

/* ---------------- STATS GRID ---------------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-label { font-size: 12px; color: var(--slate-500); font-weight: 600; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--slate-900); }
.stat-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    font-weight: 800;
    flex-shrink: 0;
}
.stat-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.stat-card.blue .stat-icon { background: var(--brand-100); color: var(--brand-700); }
.stat-card.green .stat-icon { background: var(--green-50); color: var(--green-700); }
.stat-card.amber .stat-icon { background: var(--amber-50); color: var(--amber-700); }
.stat-card.red .stat-icon { background: var(--red-50); color: var(--red-600); }

/* ---------------- LAYOUT UTILITIES ---------------- */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.section-title { font-size: 13px; font-weight: 800; color: var(--slate-700); margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }

/* ---------------- TABS ---------------- */
.tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--slate-200);
    margin-bottom: 18px;
}
.tabs a {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 700;
    color: var(--slate-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: color .15s, background .15s;
}
.tabs a:hover { color: var(--slate-800); background: var(--slate-100); }
.tabs a.active {
    color: var(--brand-700);
    border-bottom-color: var(--brand-600);
    background: var(--brand-50);
}

/* ---------------- BUTTONS ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
    line-height: 1.4;
    text-decoration: none;
}
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); color: #fff; }
.btn-success { background: var(--green-600); color: #fff; }
.btn-success:hover { background: var(--green-700); color: #fff; }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-danger:hover { background: var(--red-700); color: #fff; }
.btn-secondary {
    background: #fff;
    color: var(--slate-600);
    border-color: var(--slate-300);
}
.btn-secondary:hover { background: var(--slate-50); color: var(--slate-800); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---------------- TABLES ---------------- */
.table-wrap { overflow-x: auto; }
table.data {
    background: #fff;
    width: 100%;
    border-collapse: collapse;
}
table.data th {
    background: var(--slate-50);
    color: var(--slate-600);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--slate-200);
    white-space: nowrap;
}
table.data td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--slate-100);
    font-size: 13px;
    vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--slate-50); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.muted { color: var(--slate-400); }
.fw-bold { font-weight: 700; }
.fw-800 { font-weight: 800; }

/* ---------------- BADGES ---------------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.badge-green { background: var(--green-50); color: var(--green-700); }
.badge-red { background: var(--red-50); color: var(--red-600); }
.badge-amber { background: var(--amber-50); color: var(--amber-700); }
.badge-blue { background: var(--brand-100); color: var(--brand-700); }
.badge-slate { background: var(--slate-100); color: var(--slate-600); }

/* ---------------- FORMS ---------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
label.lbl { font-size: 12.5px; font-weight: 700; color: var(--slate-600); }
.req { color: var(--red-600); }
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=search],
select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--slate-800);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--brand-100);
}
.input-group { display: flex; }
.input-group .prefix {
    padding: 9px 12px;
    background: var(--slate-100);
    border: 1px solid var(--slate-300);
    border-right: 0;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    font-size: 13px;
    color: var(--slate-500);
    font-weight: 700;
}
.input-group input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.help { font-size: 11.5px; color: var(--slate-400); }

/* dynamic row (PO / Sales item picker) */
.item-rows { display: flex; flex-direction: column; gap: 8px; }
.item-row {
    display: grid;
    grid-template-columns: 1fr 90px 130px 140px 34px;
    gap: 8px;
    align-items: center;
}
.item-row .remove-row {
    width: 34px; height: 34px;
    border-radius: 8px;
    border: 1px solid var(--slate-300);
    background: #fff;
    color: var(--red-600);
    font-size: 16px;
    cursor: pointer;
    font-weight: 700;
}
.item-row .remove-row:hover { background: var(--red-50); }
.item-row .line-total {
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.totals-box { margin-top: 12px; display: flex; justify-content: flex-end; }
.totals-box .total-line {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 10px 16px;
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 800;
    min-width: 260px;
}


/* ---------------- FLASH MESSAGES ---------------- */
.flash-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
}
.flash-success { background: var(--green-50); color: var(--green-700); border-color: var(--green-100); }
.flash-error   { background: var(--red-50);   color: var(--red-700);   border-color: var(--red-100); }
.flash-warning { background: var(--amber-50); color: var(--amber-700); border-color: var(--amber-100); }
.flash-info    { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }
.flash .close-flash {
    margin-left: auto;
    background: none;
    border: 0;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: inherit;
    opacity: .6;
}
.flash .close-flash:hover { opacity: 1; }

/* ---------------- EMPTY STATE / PAGINATION ---------------- */
.empty {
    text-align: center;
    padding: 44px 20px;
    color: var(--slate-400);
}
.empty h3 { font-size: 14px; color: var(--slate-600); margin-bottom: 6px; }
.empty p { font-size: 12.5px; }
.pagination {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
    padding: 14px 18px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    min-width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 9px;
    border-radius: 8px;
    border: 1px solid var(--slate-200);
    background: #fff;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--slate-600);
}
.pagination a:hover { background: var(--slate-50); }
.pagination .current { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.pagination .disabled { color: var(--slate-300); }

/* ---------------- LOGIN / GATE PAGE ---------------- */
.gate-wrap {
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 45%, #e0f2fe 100%);
}
.gate-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 36px 30px;
    border: 1px solid var(--slate-200);
}
.gate-card.wide { max-width: 560px; }
.gate-logo {
    width: 56px; height: 56px;
    border-radius: 14px;
    background: var(--brand-600);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-size: 16px;
    letter-spacing: .5px;
    margin: 0 auto 16px;
    box-shadow: 0 4px 14px rgba(37, 99, 235, .3);
}
.gate-title { font-size: 20px; font-weight: 800; text-align: center; }
.gate-text {
    font-size: 13px;
    color: var(--slate-500);
    text-align: center;
    margin: 6px 0 22px;
}
.gate-card .form-field + .form-field { margin-top: 14px; }
.gate-card .btn { margin-top: 20px; }
.gate-foot {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--slate-100);
    font-size: 11.5px;
    color: var(--slate-400);
    text-align: center;
}



/* ---------------- DOKUMEN CETAK (PO / INVOICE) ---------------- */
.doc {
    background: #fff;
    max-width: 820px;
    margin: 0 auto;
    padding: 40px;
    border: 1px solid var(--slate-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
.doc-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--slate-200);
}
.doc-company h2 { font-size: 19px; font-weight: 800; letter-spacing: .02em; }
.doc-company p { font-size: 12px; color: var(--slate-500); }
.doc-title { text-align: right; }
.doc-title h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: .1em;
    color: var(--brand-700);
}
.doc-title p { font-size: 12px; color: var(--slate-500); }
.doc-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px 0;
}
.doc-meta h4 {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--slate-400);
    margin-bottom: 4px;
}
.doc-meta p { font-size: 13px; }
.doc table { font-size: 13px; border: 1px solid var(--slate-200); }
.doc table th {
    background: var(--slate-100);
    padding: 9px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    text-align: left;
    border-bottom: 1px solid var(--slate-300);
}
.doc table td { padding: 9px 12px; border-bottom: 1px solid var(--slate-100); }
.doc-totals { margin-top: 16px; display: flex; justify-content: flex-end; }
.doc-totals table { width: 300px; }
.doc-totals td { padding: 8px 12px; border: 0; }
.doc-totals .grand td {
    border-top: 2px solid var(--slate-800);
    font-size: 15px;
    font-weight: 800;
    padding-top: 12px;
}
.doc-sign {
    margin-top: 44px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    text-align: center;
    font-size: 12.5px;
}
.doc-sign .line { margin-top: 56px; border-top: 1px solid var(--slate-400); padding-top: 6px; }

/* ---------------- RESPONSIVE ---------------- */
.menu-toggle {
    display: none;
    width: 36px; height: 36px;
    border: 1px solid var(--slate-300);
    border-radius: 9px;
    background: #fff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--slate-600);
}
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 55;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: inline-flex; }
    .content { padding: 16px; }
    .topbar { padding: 0 14px; }
    .topbar h1 { font-size: 15px; }
    .item-row { grid-template-columns: 1fr 80px 110px 34px; }
    .item-row .line-total { display: none; }
    .doc { padding: 20px; }
    .doc-meta, .doc-sign { grid-template-columns: 1fr; }
    .doc-head { flex-direction: column; }
    .doc-title { text-align: left; }
}

/* ---------------- PRINT ---------------- */
@media print {
    body { background: #fff; font-size: 12px; }
    .sidebar, .topbar, .no-print, .sidebar-backdrop, .flash-list { display: none !important; }
    .content { padding: 0; }
    .app { display: block; }
    .doc {
        border: 0;
        border-radius: 0;
        padding: 0;
        max-width: none;
        box-shadow: none;
    }
    .card { box-shadow: none; border-color: var(--slate-300); }
    a { color: inherit; text-decoration: none; }
    table.data tbody tr:hover { background: transparent; }
    @page { margin: 14mm; }
}

