/* =====================================================================
   Archi Invoice - stylesheet tunggal
   ---------------------------------------------------------------------
   Palet merek: oranye #FF7043, hitam #0D0D0D, abu #B3B3B3, putih #FFFFFF.

   Catatan kontras: teks putih di atas oranye merek hanya 2,7:1 - gagal
   WCAG AA. Karena itu tombol oranye memakai teks HITAM (7,6:1), dan
   untuk tautan dipakai varian oranye yang lebih gelap (--accent, 5,2:1
   di atas putih). Marka logo memakai aset transparan berwarna putih.
   ===================================================================== */

:root {
    --bg: #f4f4f5;
    --surface: #ffffff;
    --surface-2: #fafafa;
    --ink: #0d0d0d;
    --muted: #6b6b6b;
    --line: #e4e4e4;
    --line-strong: #b3b3b3;

    --brand: #ff7043;          /* oranye merek - tombol utama dan aksen */
    --on-brand: #0d0d0d;       /* teks di atas oranye */
    --accent: #c2410c;         /* oranye gelap - tautan & teks aksen */
    --accent-soft: #ffede6;

    --ok: #0f7b45;
    --ok-soft: #e2f5eb;
    --warn: #9a6210;
    --warn-soft: #fdf1dc;
    --bad: #b52020;
    --bad-soft: #fdeaea;

    --shadow: 0 1px 2px rgba(13, 13, 13, .06), 0 1px 3px rgba(13, 13, 13, .08);
    --radius: 10px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d0d0d;
        --surface: #171717;
        --surface-2: #1f1f1f;
        --ink: #f2f2f2;
        --muted: #a3a3a3;
        --line: #2a2a2a;
        --line-strong: #4a4a4a;

        --brand: #ff7043;
        --on-brand: #0d0d0d;
        --accent: #ff8a65;
        --accent-soft: #2c1811;

        --ok: #4ec98a;
        --ok-soft: #14301f;
        --warn: #e0ab5c;
        --warn-soft: #33260f;
        --bad: #f4776e;
        --bad-soft: #3a1a1a;

        --shadow: 0 1px 2px rgba(0, 0, 0, .5);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.55 ui-sans-serif, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Header ------------------------------------------------------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-inner {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.75rem;
    min-height: 58px;
    flex-wrap: wrap;
}
.brand {
    font-weight: 700;
    font-size: 1.02rem;
    color: var(--ink);
    letter-spacing: -.01em;
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav a {
    padding: .4rem .7rem;
    border-radius: 7px;
    color: var(--muted);
    font-weight: 500;
    font-size: .93rem;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.is-active { background: var(--accent-soft); color: var(--accent); }

/* ---- Layout ------------------------------------------------------- */
.wrap { max-width: 1140px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.page-head h1 { font-size: 1.4rem; margin: 0; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: .9rem; margin: .2rem 0 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.card-head {
    padding: .9rem 1.15rem;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    font-size: .95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.card-body { padding: 1.15rem; }

/* ---- Statistik ---------------------------------------------------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: .85rem;
    margin-bottom: 1.25rem;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    box-shadow: var(--shadow);
}
.stat .label {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    font-weight: 600;
}
.stat .value { font-size: 1.45rem; font-weight: 700; margin-top: .3rem; letter-spacing: -.02em; }
.stat .value.sm { font-size: 1.2rem; }
.stat .hint { font-size: .82rem; color: var(--muted); margin-top: .15rem; }

/* ---- Tabel -------------------------------------------------------- */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td {
    padding: .68rem .9rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.data thead th {
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88em; }

.empty { padding: 2.5rem 1.25rem; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 1rem; }

/* ---- Badge -------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-draft     { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line-strong); }
.badge-sent      { background: var(--accent-soft); color: var(--accent); }
.badge-paid      { background: var(--ok-soft); color: var(--ok); }
.badge-overdue   { background: var(--bad-soft); color: var(--bad); }
.badge-partial   { background: var(--warn-soft, var(--accent-soft)); color: var(--warn, var(--accent)); }
.badge-cancelled { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }

/* ---- Tombol ------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .48rem .9rem;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
.btn-primary:hover { background: var(--brand); filter: brightness(1.06); }
.btn-danger { color: var(--bad); border-color: var(--line-strong); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { padding: .3rem .6rem; font-size: .84rem; }
.btn-link { border: 0; background: none; color: var(--accent); padding: .2rem .3rem; }
.btn-group { display: flex; gap: .45rem; flex-wrap: wrap; }

/* ---- Form --------------------------------------------------------- */
.field { margin-bottom: 1rem; }
.field label {
    display: block;
    font-size: .86rem;
    font-weight: 600;
    margin-bottom: .35rem;
    color: var(--ink);
}
.field .help { font-size: .8rem; color: var(--muted); margin-top: .3rem; }

input[type=text], input[type=email], input[type=date], input[type=number],
input[type=search], select, textarea {
    width: 100%;
    padding: .5rem .65rem;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: .92rem;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: var(--accent);
}
textarea { resize: vertical; min-height: 78px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1rem; }

.form-actions {
    display: flex;
    gap: .6rem;
    justify-content: flex-end;
    padding-top: .25rem;
    flex-wrap: wrap;
}

/* ---- Toolbar / filter --------------------------------------------- */
.toolbar {
    display: flex;
    gap: .6rem;
    align-items: center;
    flex-wrap: wrap;
    padding: .9rem 1.15rem;
    border-bottom: 1px solid var(--line);
}
.toolbar input[type=search] { max-width: 260px; }
.toolbar select { max-width: 170px; }
.toolbar .spacer { flex: 1; }

/* ---- Baris item invoice ------------------------------------------- */
table.items { width: 100%; border-collapse: collapse; }
table.items th {
    text-align: left;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    padding: 0 .5rem .45rem 0;
    font-weight: 600;
}
table.items td { padding: 0 .5rem .5rem 0; vertical-align: top; }
table.items td:last-child, table.items th:last-child { padding-right: 0; }
.col-qty { width: 110px; }
.col-price { width: 160px; }
.col-total { width: 150px; }
.col-act { width: 42px; }
.line-total {
    display: block;
    padding: .5rem .1rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}
.btn-remove {
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--bad);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}
.btn-remove:hover { background: var(--bad-soft); }

.totals {
    margin-left: auto;
    width: min(330px, 100%);
    margin-top: 1rem;
    font-size: .93rem;
}
.totals .row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .38rem 0;
}
.totals .row.grand {
    border-top: 1px solid var(--line-strong);
    margin-top: .3rem;
    padding-top: .6rem;
    font-weight: 700;
    font-size: 1.08rem;
}
.totals .num { font-variant-numeric: tabular-nums; }

/* ---- Flash & alert ------------------------------------------------ */
.flash { margin-bottom: 1rem; }
.alert {
    padding: .7rem 1rem;
    border-radius: 8px;
    border: 1px solid;
    font-size: .92rem;
    margin-bottom: .6rem;
}
.alert-success { background: var(--ok-soft);   border-color: var(--ok);   color: var(--ok); }
.alert-error   { background: var(--bad-soft);  border-color: var(--bad);  color: var(--bad); }
.alert-warning { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* ---- Pagination --------------------------------------------------- */
.pagination {
    display: flex;
    gap: .3rem;
    align-items: center;
    padding: .85rem 1.15rem;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
    font-size: .88rem;
}
.pagination .info { color: var(--muted); margin-right: auto; }
.pagination a, .pagination span.current {
    padding: .3rem .6rem;
    border-radius: 7px;
    border: 1px solid var(--line-strong);
    min-width: 32px;
    text-align: center;
}
.pagination span.current { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
.pagination a:hover { background: var(--surface-2); text-decoration: none; }

/* ---- Detail invoice ----------------------------------------------- */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}
dl.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; font-size: .92rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

.status-form { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.status-form select { width: auto; min-width: 140px; }

@media (max-width: 640px) {
    .col-qty, .col-price, .col-total { width: auto; }
    .page-head { align-items: flex-start; flex-direction: column; }
}

/* ---- Logo & merek -------------------------------------------------- */
.logo-mark { display: block; flex: none; object-fit: contain; }
.brand {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
}
.brand-name { font-weight: 800; letter-spacing: -.02em; }
.brand-name em { font-style: normal; color: var(--brand); }

/* ---- Menu pengguna di kanan atas ---------------------------------- */
.topbar .user-area {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .6rem;
}
.user-chip {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .25rem .55rem .25rem .25rem;
    border-radius: 999px;
    color: var(--ink);
    font-size: .88rem;
    font-weight: 500;
}
.user-chip:hover { background: var(--surface-2); text-decoration: none; }
.avatar {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--brand);
    color: var(--on-brand);
    display: grid;
    place-items: center;
    font-size: .8rem;
    font-weight: 700;
    flex: none;
}

/* ---- Halaman masuk / pendaftaran awal ------------------------------ */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1.25rem;
    background:
        radial-gradient(1100px 500px at 50% -12%, var(--accent-soft), transparent 70%),
        var(--bg);
}
.auth-box { width: 100%; max-width: 400px; }
.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .7rem;
    margin-bottom: 1.5rem;
    text-align: center;
}
.auth-logo {
    width: 66px;
    height: 66px;
    border-radius: 18px;
    background: transparent;
    display: grid;
    place-items: center;
    box-shadow: none;
}
.auth-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.auth-title em { font-style: normal; color: var(--brand); }
.auth-sub { color: var(--muted); font-size: .9rem; margin: 0; }
.auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
}
.auth-card h2 { margin: 0 0 .3rem; font-size: 1.05rem; }
.auth-card .lead { color: var(--muted); font-size: .88rem; margin: 0 0 1.25rem; }
.auth-card .btn { width: 100%; justify-content: center; padding: .6rem 1rem; }
.auth-foot {
    text-align: center;
    color: var(--muted);
    font-size: .82rem;
    margin-top: 1.25rem;
    line-height: 1.7;
}
.auth-foot a { color: var(--muted); text-decoration: underline; }

/* --- Archi Invoice: gaya tambahan --------------------------------- */
.checkline {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 400;
    cursor: pointer;
}
.checkline input { width: auto; margin: 0; }
