/* ============================================================
   CERDAS AO ACHIEVEMENT - Mobile First
   Branding: Navy #0F2747 | Orange #F7931E | White | BG #F5F7FA
   ============================================================ */
:root {
    --navy: #0F2747;
    --navy-dark: #0A1B33;
    --orange: #F7931E;
    --white: #FFFFFF;
    --bg: #F5F7FA;
    --text: #1F2937;
    --muted: #6B7280;
    --border: #E5E9F0;
    --ok: #16A34A;
    --ok-bg: #DCFCE7;
    --warn: #B45309;
    --warn-bg: #FEF3C7;
    --danger: #DC2626;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(15, 39, 71, .08), 0 4px 14px rgba(15, 39, 71, .06);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    padding-bottom: 84px; /* ruang bottom nav */
}

/* ---------------- Header ---------------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--navy);
    color: var(--white);
    box-shadow: 0 2px 10px rgba(10, 27, 51, .35);
    padding-top: env(safe-area-inset-top);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 8px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .5px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--orange); flex: 0 0 auto; }
.brand-name { font-size: 17px; }
.brand-name em { font-style: normal; color: var(--orange); }
.header-user { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.user-name { font-weight: 600; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { background: rgba(247, 147, 30, .2); color: var(--orange); padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 10px; }
.btn-logout {
    color: var(--white); text-decoration: none; font-size: 12px; font-weight: 600;
    border: 1px solid rgba(255,255,255,.35); padding: 5px 12px; border-radius: 999px;
    min-height: 32px; display: inline-flex; align-items: center;
}
.btn-logout:active { background: rgba(255,255,255,.12); }

/* Top nav (admin) */
.top-nav {
    display: flex; gap: 6px; overflow-x: auto; padding: 0 12px 10px;
    scrollbar-width: none;
}
.top-nav::-webkit-scrollbar { display: none; }
.top-nav a {
    color: rgba(255,255,255,.75); text-decoration: none; font-size: 13px; font-weight: 600;
    padding: 7px 14px; border-radius: 999px; white-space: nowrap; min-height: 34px;
    display: inline-flex; align-items: center;
}
.top-nav a.on { background: var(--orange); color: var(--navy-dark); }

/* ---------------- Layout ---------------- */
.container { max-width: 720px; margin: 0 auto; padding: 16px 14px 24px; }

.page-head { margin: 4px 2px 14px; }
.page-head h2 { font-size: 22px; color: var(--navy); }
.page-date { color: var(--muted); font-size: 14px; margin-top: 2px; }
.section-title { font-size: 15px; color: var(--navy); margin: 20px 2px 10px; }
.mb { margin-bottom: 14px; }

/* ---------------- Card & Stat ---------------- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 14px;
}
.card-title { font-size: 16px; color: var(--navy); margin-bottom: 12px; }

.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    border-top: 4px solid var(--orange);
}
.stat-total {
    grid-column: 1 / -1;
    background: var(--navy);
    color: var(--white);
    border-top-color: var(--orange);
}
.stat-total .stat-label { color: rgba(255,255,255,.7); }
.stat-total .stat-value { color: var(--orange); }
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: .6px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 19px; font-weight: 800; color: var(--navy); word-break: break-word; }
.stat-link { text-decoration: none; display: block; }
.stat-link:active { transform: scale(.99); }
.stat-sub { font-size: 11px; font-weight: 700; color: var(--orange); margin-top: 8px; }

/* ---------------- Top 5 per produk ---------------- */
.top-card {
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px; border-top: 4px solid var(--navy);
}
.top-card-head {
    font-size: 12px; font-weight: 800; letter-spacing: .4px; color: var(--navy);
    text-transform: uppercase; margin-bottom: 10px;
}
.top-empty { font-size: 13px; color: var(--muted); padding: 6px 0; }
.top-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px dashed var(--border); font-size: 14px; }
.top-row:first-of-type { border-top: 0; }
.top-rank {
    flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%;
    background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 800;
    display: inline-flex; align-items: center; justify-content: center;
}
.top-rank-1 { background: var(--orange); color: var(--navy-dark); }
.top-rank-2, .top-rank-3 { background: var(--navy); color: var(--white); }
.top-name { flex: 1 1 auto; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-val { flex: 0 0 auto; color: var(--navy); }
.top-link { display: inline-block; margin-top: 10px; font-size: 12px; font-weight: 700; color: var(--orange); text-decoration: none; }

/* ---------------- AO card ---------------- */
.ao-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
}
.ao-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ao-name { font-weight: 700; font-size: 16px; color: var(--navy); }
.ao-kode { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ao-produk-list { border-top: 1px dashed var(--border); padding-top: 8px; margin-bottom: 10px; }
.ao-produk-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 14px; gap: 8px; }
.ao-produk-row span { color: var(--muted); }
.ao-produk-row strong { text-align: right; word-break: break-word; }
.ao-total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; }
.ao-total span { color: var(--navy); font-weight: 700; }
.ao-total strong { color: var(--orange); font-size: 16px; }

/* ---------------- Badge ---------------- */
.badge {
    font-size: 10px; font-weight: 800; letter-spacing: .5px;
    padding: 4px 10px; border-radius: 999px; white-space: nowrap; flex: 0 0 auto;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }

/* ---------------- Form ---------------- */
.form-label { display: block; font-size: 13px; font-weight: 700; color: var(--navy); margin: 14px 0 6px; }
.form-label.sm { font-size: 12px; margin: 10px 0 4px; }
.form-input {
    width: 100%;
    font-size: 17px;
    padding: 13px 14px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--white);
    color: var(--text);
    min-height: 50px;
    outline: none;
    transition: border-color .15s;
    -webkit-appearance: none;
    appearance: none;
}
select.form-input {
    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 12px center;
    background-size: 22px;
    padding-right: 40px;
}
.form-input:focus { border-color: var(--orange); }

.input-rupiah { position: relative; }
.input-rupiah .prefix {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    font-weight: 700; color: var(--muted); font-size: 15px; pointer-events: none;
}
.input-rupiah .form-input { padding-left: 44px; font-weight: 700; }
.input-rupiah .suffix {
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
    font-weight: 700; color: var(--muted); font-size: 13px; pointer-events: none;
}
.input-rupiah.has-suffix .form-input { padding-left: 14px; padding-right: 88px; }

.filter-form { display: flex; flex-direction: column; gap: 4px; }
.filter-form .form-input { margin-bottom: 6px; }

.hint { font-size: 13px; color: var(--muted); margin: 10px 0; }
.satuan-form { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 8px; }
.satuan-row { display: flex; gap: 8px; }
.satuan-row .form-input { flex: 1 1 auto; min-height: 44px; font-size: 15px; padding: 10px 12px; }
.satuan-row .btn { flex: 0 0 auto; }
.empty {
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 14px;
}

/* ---------------- Button ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700; text-decoration: none;
    border: 0; border-radius: 12px; cursor: pointer;
    padding: 12px 18px; min-height: 48px;
    transition: transform .05s, opacity .15s;
}
.btn:active { transform: scale(.98); opacity: .9; }
.btn-block { display: flex; width: 100%; margin-top: 12px; }
.btn-lg { min-height: 56px; font-size: 16px; letter-spacing: .5px; }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn-primary { background: var(--orange); color: var(--navy-dark); }
.btn-outline { background: var(--white); color: var(--navy); border: 2px solid var(--border); }
.btn-danger { background: #FEE2E2; color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn-row .btn { flex: 1 1 auto; }
form.inline { display: contents; }

/* ---------------- Alert & Toast ---------------- */
.alert { padding: 12px 14px; border-radius: 12px; font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.alert-error { background: #FEE2E2; color: var(--danger); }
.toast {
    position: fixed; top: 12px; left: 14px; right: 14px; z-index: 100;
    max-width: 692px; margin: 0 auto;
    padding: 14px 16px; border-radius: 12px; font-weight: 700; font-size: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
    animation: toastIn .25s ease-out;
}
.toast-success { background: var(--ok); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
@keyframes toastIn { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- Log ---------------- */
.log-card { padding: 12px 16px; }
.log-detail { font-size: 14px; margin: 6px 0 2px; }
.log-user { font-size: 12px; color: var(--muted); }

/* ---------------- Tabel (laporan) ---------------- */
.table-wrap { overflow-x: auto; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.tbl thead th { background: var(--navy); color: var(--white); font-size: 11px; letter-spacing: .5px; text-transform: uppercase; }
.tbl tfoot th { background: #FFF4E5; color: var(--navy); border-top: 2px solid var(--orange); }
.tbl .num { text-align: right; }
.total-summary {
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px 16px; margin-bottom: 14px; border-top: 4px solid var(--orange);
}

/* ---------------- Print header ---------------- */
.print-header { display: none; }

/* ---------------- Bottom nav ---------------- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    display: flex; background: var(--white);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 18px rgba(15, 39, 71, .08);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 9px 2px 8px; text-decoration: none; color: var(--muted);
    font-size: 10px; font-weight: 700; min-height: 58px; justify-content: center;
}
.bottom-nav a svg { width: 22px; height: 22px; fill: currentColor; }
.bottom-nav a.on { color: var(--orange); }

/* ---------------- Login ---------------- */
.login-page {
    min-height: 100vh; min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 60%, #12315a 100%);
    padding: 20px; padding-bottom: 20px;
}
.login-card {
    width: 100%; max-width: 400px;
    background: var(--white); border-radius: 20px; padding: 28px 22px;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-brand { text-align: center; margin-bottom: 20px; }
.login-logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 10px; }
.login-brand h1 { font-size: 24px; color: var(--navy); letter-spacing: 1px; }
.login-brand h1 em { font-style: normal; color: var(--orange); }
.login-brand p { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------------- Desktop ---------------- */
@media (min-width: 640px) {
    .card-grid { grid-template-columns: repeat(4, 1fr); }
    .stat-total { grid-column: auto; }
    .filter-form { flex-direction: row; align-items: flex-end; flex-wrap: wrap; gap: 10px; }
    .filter-form > div { flex: 1 1 160px; }
    .filter-form .btn { flex: 0 0 auto; margin-top: 0; }
}

/* ---------------- PRINT ---------------- */
@media print {
    body { background: #fff; padding-bottom: 0; font-size: 12px; }
    .no-print, .bottom-nav, .app-header, .toast, .btn { display: none !important; }
    .container { max-width: 100%; padding: 0; }
    .card, .stat-card, .table-wrap, .total-summary { box-shadow: none; border: 1px solid #ccc; }
    .print-header { display: block; text-align: center; margin-bottom: 16px; }
    .print-header h2 { font-size: 18px; color: #000; }
    .print-header p { font-size: 13px; color: #333; }
    .tbl thead th { background: #eee !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .tbl tfoot th { background: #f5f5f5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .stat-total { background: #fff; color: #000; }
    .stat-total .stat-label, .stat-total .stat-value { color: #000; }
}
