:root {
    --pink-50: #fdf8f7;
    --pink-100: #f9edec;
    --pink-200: #f3dcdd;
    --pink-300: #e8c4c6;
    --pink-400: #d9a7ab;
    --rose: #c98b91;
    --rose-dark: #a86e75;
    --ink: #4a3f41;
    --ink-soft: #8c7a7d;
    --line: #ecdfe0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Jost', sans-serif;
    color: var(--ink);
    background:
        radial-gradient(900px 500px at 12% -10%, #fbe9ea 0%, transparent 60%),
        radial-gradient(800px 500px at 95% 5%, #f6eef0 0%, transparent 55%),
        var(--pink-50);
    min-height: 100vh;
    padding: 34px 26px 70px;
}

.page-title {
    text-align: center;
    margin-bottom: 30px;
}

.page-title h2 {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: 30px;
    letter-spacing: .5px;
}

.page-title p {
    color: var(--ink-soft);
    font-size: 14px;
    margin-top: 6px;
    font-weight: 300;
}

.layout {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---------- PANEL INPUT ---------- */

.panel {
    width: 360px;
    flex: 0 0 360px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 24px 22px;
    box-shadow: 0 18px 40px rgba(178, 124, 130, .13);
    position: sticky;
    top: 26px;
}

.panel h3 {
    font-family: 'Playfair Display', serif;
    font-size: 19px;
    font-weight: 600;
    margin-bottom: 4px;
}

.panel .hint {
    font-size: 12.5px;
    color: var(--ink-soft);
    font-weight: 300;
    margin-bottom: 18px;
}

fieldset {
    border: none;
    border-top: 1px dashed var(--pink-200);
    padding-top: 14px;
    margin-top: 16px;
}

legend {
    font-size: 11px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--rose);
    font-weight: 600;
    padding-right: 10px;
}

label {
    display: block;
    font-size: 11.5px;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin: 12px 0 5px;
    font-weight: 500;
}

input,
textarea,
select {
    width: 100%;
    font-family: 'Jost', sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--pink-50);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 12px;
    transition: .18s;
}

input:focus,
textarea:focus {
    outline: none;
    background: #fff;
    border-color: var(--pink-400);
    box-shadow: 0 0 0 3px rgba(217, 167, 171, .22);
}

textarea {
    resize: vertical;
    min-height: 66px;
}

.grid-2 {
    display: flex;
    gap: 10px;
}

.grid-2>div {
    flex: 1;
}

/* item rows */

.item-row {
    background: var(--pink-50);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    position: relative;
}

.item-row input {
    background: #fff;
}

.item-row label {
    margin-top: 8px;
}

.item-row label:first-child {
    margin-top: 0;
}

.remove-item {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    line-height: 1;
    border-radius: 50%;
    border: none;
    background: var(--pink-200);
    color: var(--rose-dark);
    font-size: 15px;
    cursor: pointer;
    transition: .18s;
}

.remove-item:hover {
    background: var(--pink-400);
    color: #fff;
}

.btn {
    font-family: 'Jost', sans-serif;
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: .4px;
    padding: 11px 18px;
    border: none;
    border-radius: 11px;
    cursor: pointer;
    transition: .2s;
}

.btn-soft {
    width: 100%;
    background: var(--pink-100);
    color: var(--rose-dark);
    border: 1px dashed var(--pink-400);
}

.btn-soft:hover {
    background: var(--pink-200);
}

.btn-main {
    width: 100%;
    margin-top: 20px;
    background: linear-gradient(135deg, var(--rose), #dba9ae);
    color: #fff;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    font-size: 12.5px;
    padding: 14px 18px;
    box-shadow: 0 10px 22px rgba(201, 139, 145, .35);
}

.btn-main:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.btn-ghost {
    width: 100%;
    margin-top: 9px;
    background: transparent;
    color: var(--ink-soft);
    border: 1px solid var(--line);
}

.btn-ghost:hover {
    color: var(--rose-dark);
    border-color: var(--pink-400);
}

.btn-outline {
    width: 100%;
    margin-top: 9px;
    background: #fff;
    color: var(--rose-dark);
    border: 1px solid var(--pink-400);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    font-size: 12.5px;
    padding: 13px 18px;
}

.btn-outline:hover {
    background: var(--pink-100);
}

.btn:disabled {
    opacity: .65;
    cursor: progress;
    transform: none;
    filter: none;
}

/* ---------- INVOICE ---------- */

.invoice {
    width: 800px;
    max-width: 100%;
    background: #fff;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 26px 60px rgba(178, 124, 130, .18);
    position: relative;
}

/* jangan potong elemen di tengah saat pindah halaman PDF / print */
tbody tr,
.box,
.sum-total,
.note,
.inv-foot,
.sign {
    page-break-inside: avoid;
    break-inside: avoid;
}

/* tampilan sementara saat di-render ke PDF */
.invoice.exporting {
    width: 800px;
    max-width: none;
    border-radius: 0;
    box-shadow: none;
}

.invoice-inner {
    padding: 44px 48px 40px;
    position: relative;
    z-index: 1;
}

.ribbon {
    height: 8px;
    background: linear-gradient(90deg, var(--pink-300), var(--rose), var(--pink-300));
}

.blob {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.blob-1 {
    width: 240px;
    height: 240px;
    right: -90px;
    top: -70px;
    background: radial-gradient(circle, rgba(232, 196, 198, .45) 0%, rgba(232, 196, 198, 0) 70%);
}

.blob-2 {
    width: 200px;
    height: 200px;
    left: -80px;
    bottom: 40px;
    background: radial-gradient(circle, rgba(246, 222, 224, .7) 0%, rgba(246, 222, 224, 0) 70%);
}

.inv-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.brand-name {
    font-family: 'Playfair Display', serif;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: .3px;
}

.brand-tag {
    font-size: 12px;
    letter-spacing: 2.4px;
    text-transform: uppercase;
    color: var(--rose);
    margin-top: 6px;
    font-weight: 500;
}

.inv-word {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 52px;
    font-weight: 500;
    line-height: 1;
    color: var(--rose);
    text-align: right;
}

.inv-meta {
    margin-top: 12px;
    text-align: right;
    font-size: 13px;
    color: var(--ink-soft);
    line-height: 1.9;
}

.inv-meta b {
    color: var(--ink);
    font-weight: 500;
}

.divider {
    height: 1px;
    background: linear-gradient(90deg, var(--pink-300), rgba(232, 196, 198, 0));
    margin: 28px 0;
}

.row {
    display: flex;
    gap: 26px;
}

.box {
    flex: 1;
    background: var(--pink-50);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px 20px;
}

.box h4 {
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--rose);
    font-weight: 600;
    margin-bottom: 12px;
}

.box .name {
    font-family: 'Playfair Display', serif;
    font-size: 19px;
    font-weight: 600;
    margin-bottom: 8px;
}

.box p {
    font-size: 13.5px;
    color: var(--ink-soft);
    line-height: 1.85;
    font-weight: 300;
}

.box p span {
    color: var(--ink);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 30px;
}

thead th {
    background: var(--pink-100);
    font-size: 10.5px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--rose-dark);
    font-weight: 600;
    padding: 13px 16px;
    text-align: left;
}

thead th:first-child {
    border-radius: 12px 0 0 12px;
}

thead th:last-child {
    border-radius: 0 12px 12px 0;
}

th.num,
td.num {
    text-align: right;
}

tbody td {
    padding: 15px 16px;
    font-size: 14px;
    border-bottom: 1px dashed var(--line);
    font-variant-numeric: tabular-nums;
}

tbody td:first-child {
    font-weight: 500;
}

.summary {
    display: flex;
    justify-content: flex-end;
    margin-top: 26px;
}

.summary-inner {
    width: 320px;
}

.sum-line {
    display: flex;
    justify-content: space-between;
    font-size: 13.5px;
    color: var(--ink-soft);
    padding: 7px 16px;
    font-variant-numeric: tabular-nums;
}

.sum-line span:last-child {
    color: var(--ink);
}

.sum-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding: 15px 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--pink-100), var(--pink-200));
}

.sum-total .lbl {
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--rose-dark);
    font-weight: 600;
}

.sum-total .val {
    font-family: 'Playfair Display', serif;
    font-size: 26px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.note {
    margin-top: 34px;
    background: var(--pink-50);
    border-left: 3px solid var(--pink-400);
    border-radius: 0 12px 12px 0;
    padding: 14px 18px;
}

.note h4 {
    font-size: 10.5px;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: var(--rose);
    font-weight: 600;
    margin-bottom: 5px;
}

.note p {
    font-size: 13.5px;
    color: var(--ink-soft);
    font-weight: 300;
    line-height: 1.7;
    white-space: pre-line;
}

.inv-foot {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-top: 40px;
}

.bank h4 {
    font-size: 10.5px;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: var(--rose);
    font-weight: 600;
    margin-bottom: 7px;
}

.bank p {
    font-size: 14px;
    line-height: 1.8;
}

.bank .method {
    font-size: 13px;
    color: var(--rose-dark);
    font-weight: 500;
    margin-bottom: 4px;
}

.bank .acc {
    font-variant-numeric: tabular-nums;
    letter-spacing: .5px;
    font-weight: 500;
}

.bank .holder {
    color: var(--ink-soft);
    font-weight: 300;
    font-size: 13px;
}

.sign {
    text-align: center;
    min-width: 200px;
}

.sign .place {
    font-size: 13px;
    color: var(--ink-soft);
    font-weight: 300;
}

.sign .who {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 18px;
    font-weight: 500;
    margin-top: 44px;
}

.sign .line {
    height: 1px;
    background: var(--pink-300);
    margin: 8px auto 6px;
}

.sign .role {
    font-size: 10.5px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--rose);
}

.thanks {
    text-align: center;
    margin-top: 36px;
    padding-top: 20px;
    border-top: 1px dashed var(--line);
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 16px;
    color: var(--rose);
}

/* ---------- TOP NAV (authenticated pages) ---------- */

.topnav {
    max-width: 1200px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.topnav .brand-link {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: 18px;
    color: var(--ink);
    text-decoration: none;
}

.topnav nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.topnav a.nav-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-soft);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 10px;
    transition: .18s;
}

.topnav a.nav-link:hover {
    background: var(--pink-100);
    color: var(--rose-dark);
}

.topnav a.nav-link.active {
    background: var(--pink-200);
    color: var(--rose-dark);
}

.topnav .user-chip {
    font-size: 12.5px;
    color: var(--ink-soft);
    margin-right: 4px;
}

.topnav .logout-form {
    display: inline;
}

.topnav .logout-btn {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink-soft);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13px;
    font-family: 'Jost', sans-serif;
    cursor: pointer;
    transition: .18s;
}

.topnav .logout-btn:hover {
    border-color: var(--pink-400);
    color: var(--rose-dark);
}

/* ---------- FLASH MESSAGES ---------- */

.flash {
    max-width: 1200px;
    margin: 0 auto 20px;
    padding: 13px 18px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 500;
}

.flash-success {
    background: #eaf7ee;
    color: #2f7a43;
    border: 1px solid #cdeed7;
}

.flash-error {
    background: #fdecec;
    color: #b4423a;
    border: 1px solid #f6cfcd;
}

/* ---------- AUTH (login) ---------- */

.auth-wrap {
    min-height: calc(100vh - 40px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: 360px;
    max-width: 92vw;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 32px 28px;
    box-shadow: 0 18px 40px rgba(178, 124, 130, .13);
}

.auth-card h2 {
    font-family: 'Playfair Display', serif;
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 6px;
    text-align: center;
}

.auth-card p.hint {
    text-align: center;
    font-size: 12.5px;
    color: var(--ink-soft);
    margin-bottom: 20px;
    font-weight: 300;
}

/* ---------- CARD (settings, generic content blocks) ---------- */

.settings-wrap {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 26px 28px;
    box-shadow: 0 18px 40px rgba(178, 124, 130, .10);
}

.card h3 {
    font-family: 'Playfair Display', serif;
    font-size: 19px;
    font-weight: 600;
    margin-bottom: 4px;
}

.card .hint {
    font-size: 12.5px;
    color: var(--ink-soft);
    font-weight: 300;
    margin-bottom: 18px;
}

.card .btn {
    width: auto;
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
}

.field-grid .full {
    grid-column: 1 / -1;
}

@media (max-width: 640px) {
    .field-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- HISTORY TABLE ---------- */

.history-wrap {
    max-width: 1100px;
    margin: 0 auto;
}

.history-table-scroll {
    overflow-x: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 18px 40px rgba(178, 124, 130, .10);
}

table.history {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
    margin-top: 0;
}

table.history thead th {
    white-space: nowrap;
}

table.history tbody td {
    vertical-align: middle;
}

table.history tbody tr:last-child td {
    border-bottom: none;
}

table.history .row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

table.history .row-actions a,
table.history .row-actions button {
    font-family: 'Jost', sans-serif;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 8px;
    text-decoration: none;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-soft);
    cursor: pointer;
    transition: .18s;
}

table.history .row-actions a:hover {
    border-color: var(--pink-400);
    color: var(--rose-dark);
}

table.history .row-actions .danger:hover {
    border-color: #e39a94;
    color: #b4423a;
}

.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--ink-soft);
    font-size: 14px;
}

/* ---------- INVOICE VIEW ACTIONS PANEL ---------- */

.view-actions .btn {
    margin-top: 9px;
}

.view-actions .btn:first-child {
    margin-top: 0;
}

.preview-tag {
    display: block;
    font-size: 10.5px;
    color: var(--ink-soft);
    font-weight: 300;
    font-style: italic;
    margin-top: 2px;
}

/* ---------- SAVE RESULT BANNER (create page) ---------- */

.save-banner {
    background: linear-gradient(135deg, var(--pink-100), var(--pink-200));
    border-radius: 14px;
    padding: 14px 18px;
    margin-top: 14px;
    font-size: 13px;
    color: var(--ink);
    line-height: 1.7;
}

.save-banner a {
    color: var(--rose-dark);
    font-weight: 500;
}

.save-banner.error {
    background: #fdecec;
    color: #b4423a;
}

.field-error {
    font-size: 12px;
    color: #b4423a;
    margin-top: 6px;
}

@media(max-width:1240px) {
    .panel {
        position: static;
        width: 100%;
        flex: 1 1 420px;
        max-width: 520px;
    }
}

@media(max-width:640px) {
    body {
        padding: 18px 12px 50px
    }

    .invoice-inner {
        padding: 26px 20px
    }

    .inv-head,
    .row,
    .inv-foot {
        flex-direction: column
    }

    .inv-word,
    .inv-meta {
        text-align: left
    }

    .summary-inner {
        width: 100%
    }
}

@media print {
    @page {
        margin: 12mm
    }

    body {
        background: #fff;
        padding: 0;
    }

    .page-title,
    .panel,
    .topnav,
    .flash {
        display: none !important
    }

    .layout {
        display: block
    }

    .invoice {
        width: 100%;
        box-shadow: none;
        border-radius: 0;
    }

    .invoice-inner {
        padding: 0 4mm
    }

    .box,
    .sum-total,
    .note,
    thead th {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}