:root {
    --black: #050505;
    --black-2: #151515;
    --red: #e30613;
    --red-2: #b4000b;
    --gold: #f4c64f;
    --white: #ffffff;
    --paper: rgba(255, 255, 255, .76);
    --glass: rgba(255, 255, 255, .84);
    --glass-strong: rgba(255, 255, 255, .92);
    --line: rgba(255, 255, 255, .34);
    --muted: #4d4d4d;
    --shadow: 0 18px 46px rgba(0, 0, 0, .24);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--black);
    background:
        linear-gradient(115deg, rgba(5, 5, 5, .72), rgba(130, 0, 9, .36) 42%, rgba(255, 255, 255, .42)),
        url("madura-culture.webp") center top / cover fixed no-repeat;
    font-family: Arial, Helvetica, sans-serif;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(circle at 18% 12%, rgba(244, 198, 79, .24), transparent 28%),
        linear-gradient(180deg, rgba(5, 5, 5, .72) 0 210px, rgba(255, 255, 255, .72) 460px, rgba(255, 255, 255, .9) 100%);
    pointer-events: none;
}

button,
input,
select {
    font: inherit;
}

img {
    display: block;
    max-width: 100%;
}

.shell {
    width: min(1320px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 42px;
}

.topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 20px;
    align-items: stretch;
    margin-bottom: 18px;
    padding: 24px;
    color: var(--white);
    background:
        linear-gradient(135deg, rgba(5, 5, 5, .86), rgba(120, 0, 8, .70)),
        rgba(5, 5, 5, .78);
    border: 1px solid rgba(255, 255, 255, .22);
    border-bottom: 6px solid var(--gold);
    border-radius: 8px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(13px);
}

.topbar h1 {
    margin: 4px 0 10px;
    font-size: clamp(34px, 5vw, 62px);
    line-height: 1;
}

.topbar p {
    max-width: 760px;
    margin: 0;
    color: #d8d8d8;
}

.topbar .eyebrow {
    color: var(--gold);
}

.brand-area {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    min-width: 0;
}

.brand-logo,
.login-logo {
    object-fit: contain;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(255, 255, 255, .84));
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 8px;
    box-shadow: 0 14px 30px rgba(0, 0, 0, .22);
}

.brand-logo {
    width: 96px;
    height: 96px;
    padding: 10px;
    flex: 0 0 96px;
}

.top-actions {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.top-actions form {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.branch-switch {
    min-width: 210px;
}

.branch-switch label {
    gap: 5px;
}

.branch-switch span {
    color: rgba(255, 255, 255, .82);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.branch-switch select {
    min-height: 44px;
    color: var(--black);
    border: 1px solid rgba(255, 255, 255, .36);
    background: rgba(255, 255, 255, .9);
}

.user-badge {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    color: var(--white);
    background: rgba(227, 6, 19, .88);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
    border-radius: 6px;
    font-weight: 900;
}

.eyebrow {
    margin: 0;
    color: var(--red);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
}

.date-card,
.panel,
.stats article,
.alert {
    background: var(--glass);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.date-card {
    min-width: 182px;
    padding: 16px;
    color: var(--black);
    border: 1px solid rgba(255, 255, 255, .42);
    background: rgba(255, 255, 255, .9);
}

.date-card span,
.stats span,
label span,
.mini-row span,
.debt-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.date-card strong,
.stats strong {
    display: block;
    margin-top: 5px;
    font-size: 27px;
    line-height: 1.1;
}

.alert {
    margin: 0 0 18px;
    padding: 14px 16px;
    color: var(--red-2);
    background: #fff5f6;
    border-color: #ffc5ca;
}

.alert.error {
    color: var(--white);
    background: var(--red-2);
    border-color: var(--red-2);
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stats article {
    position: relative;
    min-height: 128px;
    padding: 18px;
    border-top: 5px solid var(--red);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(255, 255, 255, .76)),
        var(--glass);
}

.stats article:nth-child(even) {
    border-top-color: var(--gold);
}

.stats small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    margin-top: 18px;
}

.grid.two {
    grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr);
}

.grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel {
    padding: 20px;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 2px solid rgba(5, 5, 5, .82);
}

.panel h1,
.panel h2 {
    margin: 4px 0 0;
}

.panel h1 {
    font-size: clamp(30px, 5vw, 48px);
}

.panel h2 {
    font-size: 24px;
}

.form {
    display: grid;
    gap: 14px;
}

.inline-fields,
.inline-fields.four {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.inline-fields.four {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.three-fields {
    grid-template-columns: 1fr 1.4fr .8fr;
}

label {
    display: grid;
    gap: 7px;
}

input,
select {
    width: 100%;
    min-height: 44px;
    color: var(--black);
    background: rgba(255, 255, 255, .88);
    border: 1px solid rgba(5, 5, 5, .18);
    border-radius: 6px;
    outline: none;
    padding: 10px 12px;
}

input:focus,
select:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(227, 6, 19, .14);
}

.sale-lines {
    display: grid;
    gap: 10px;
}

.sale-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px 92px;
    gap: 10px;
}

button {
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 900;
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.primary,
.secondary,
.danger {
    min-height: 46px;
    padding: 11px 18px;
}

.primary {
    color: var(--white);
    background: linear-gradient(180deg, var(--red), var(--red-2));
    box-shadow: 0 12px 26px rgba(179, 0, 11, .24);
}

.primary:hover {
    background: var(--red-2);
}

.secondary,
.link-button {
    color: var(--white);
    background: rgba(5, 5, 5, .88);
}

.secondary:hover,
.link-button:hover {
    background: var(--black-2);
}

.danger {
    color: var(--white);
    background: var(--red-2);
}

.remove-sale-row {
    min-height: 44px;
    padding: 8px 12px;
}

.line-action {
    min-height: 44px;
    color: var(--red);
    background: rgba(255, 255, 255, .72);
    border: 2px dashed var(--red);
}

.line-action:hover {
    color: var(--white);
    background: var(--red);
}

.link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    margin-left: 8px;
    padding: 11px 18px;
    border-radius: 6px;
    font-weight: 900;
    text-decoration: none;
}

.branch-panel {
    border-color: rgba(244, 198, 79, .68);
}

.branch-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
}

.margin-preview {
    padding: 12px 14px;
    color: var(--white);
    background: rgba(5, 5, 5, .88);
    border-left: 6px solid var(--gold);
    border-radius: 6px;
    font-weight: 900;
}

.report-filter {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.report-filter input {
    min-width: 160px;
}

.compact-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0 0 16px;
}

.table-wrap {
    overflow-x: auto;
    background: rgba(255, 255, 255, .86);
    border: 1px solid rgba(5, 5, 5, .72);
    border-radius: 8px;
}

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

.editable-table {
    min-width: 1240px;
}

.editable-table.stock-table {
    min-width: 1120px;
}

th,
td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--white);
    background: rgba(5, 5, 5, .92);
    font-size: 12px;
    text-transform: uppercase;
}

tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, .56);
}

.warning-row td,
tbody tr.warning-row:nth-child(even) td {
    background: rgba(255, 241, 242, .82);
}

.editable-table input {
    min-height: 36px;
    padding: 7px 9px;
}

.stock-table {
    font-size: 13px;
}

.stock-table th,
.stock-table td {
    padding: 9px 10px;
    line-height: 1.25;
}

.stock-table thead th {
    font-size: 11px;
}

.stock-table input {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 13px;
}

.stock-table .secondary,
.stock-table .danger {
    min-height: 36px;
    padding: 8px 11px;
    font-size: 13px;
}

.stock-table .table-actions {
    gap: 6px;
    min-width: 92px;
}

.stock-table .margin-cell {
    min-width: 96px;
}

.stock-table .margin-cell strong {
    font-size: 13px;
}

.stock-table .margin-cell span {
    font-size: 12px;
}

.editable-table td {
    vertical-align: top;
}

.editable-table td:nth-child(4),
.editable-table td:nth-child(5),
.editable-table td:nth-child(7),
.editable-table td:nth-child(8) {
    width: 92px;
}

.margin-cell {
    min-width: 118px;
}

.margin-cell strong,
.margin-cell span {
    display: block;
}

.margin-cell span {
    margin-top: 4px;
    color: var(--red);
    font-weight: 900;
}

.table-actions {
    display: grid;
    gap: 8px;
    min-width: 112px;
}

.stack {
    display: grid;
    gap: 10px;
}

.mini-row,
.debt-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px;
    background: var(--paper);
    border: 1px solid rgba(255, 255, 255, .48);
    border-left: 5px solid var(--red);
    border-radius: 8px;
}

.pay-row {
    display: grid;
    grid-template-columns: 110px 70px;
    gap: 8px;
}

.pay-row button {
    color: var(--white);
    background: var(--red);
}

.right-actions {
    display: grid;
    gap: 4px;
    justify-items: end;
}

.right-actions a,
td a {
    color: var(--red);
    font-weight: 900;
    text-decoration: none;
}

.install-panel,
.login-panel {
    margin: 8vh auto;
    border-top: 8px solid var(--gold);
}

.install-panel {
    max-width: 680px;
}

.login-panel {
    max-width: 520px;
}

.login-brand {
    display: grid;
    justify-items: center;
    gap: 12px;
    margin-bottom: 14px;
    text-align: center;
}

.login-logo {
    width: 132px;
    height: 122px;
    padding: 12px;
}

.login-brand h1 {
    margin-top: 6px;
}

.receipt-body {
    background: var(--white);
}

.receipt {
    width: min(380px, calc(100% - 24px));
    margin: 24px auto;
    padding: 20px;
    color: #111;
    background: var(--white);
    border: 1px solid #111;
}

.receipt h1 {
    margin: 0;
    font-size: 26px;
    text-align: center;
}

.receipt p {
    color: #555;
    text-align: center;
}

.receipt hr {
    border: 0;
    border-top: 1px dashed #111;
    margin: 12px 0;
}

.receipt-line,
.receipt-total {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 7px 0;
}

.receipt-item {
    display: grid;
    gap: 3px;
    margin: 10px 0;
}

.receipt-item span {
    color: #555;
    font-size: 13px;
}

.receipt-item b {
    text-align: right;
}

.receipt-total strong {
    font-size: 22px;
}

.thanks {
    font-size: 12px;
}

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

    .stats,
    .grid.two,
    .grid.three {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .compact-stats {
        grid-template-columns: 1fr;
    }

    .inline-fields.four {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .three-fields,
    .branch-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    body::before {
        height: 220px;
    }

    .shell {
        width: min(100% - 20px, 1320px);
        padding: 12px 0 30px;
    }

    .topbar,
    .top-actions,
    .mini-row,
    .debt-card {
        align-items: stretch;
    }

    .topbar {
        padding: 18px;
    }

    .topbar h1 {
        font-size: 36px;
    }

    .brand-area {
        gap: 12px;
    }

    .brand-logo {
        width: 74px;
        height: 74px;
        padding: 8px;
        flex-basis: 74px;
    }

    .login-logo {
        width: 112px;
        height: 104px;
    }

    .top-actions,
    .top-actions form {
        flex-direction: column;
    }

    .stats,
    .grid.two,
    .grid.three,
    .inline-fields,
    .inline-fields.four,
    .sale-row {
        grid-template-columns: 1fr;
    }

    .date-card {
        min-width: 0;
    }

    .panel {
        padding: 16px;
    }

    .panel-head,
    .report-filter {
        align-items: stretch;
        flex-direction: column;
    }

    .link-button {
        margin-left: 0;
    }

    .pay-row {
        grid-template-columns: 1fr 82px;
    }

    .stock-wrap {
        overflow: visible;
        background: transparent;
        border: 0;
    }

    .stock-table,
    .stock-table tbody,
    .stock-table tr,
    .stock-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .stock-table thead {
        display: none;
    }

    .stock-table tbody {
        display: grid;
        gap: 10px;
    }

    .stock-table tr {
        display: grid;
        gap: 8px;
        padding: 12px;
        background:
            linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .78)),
            var(--glass);
        border: 1px solid rgba(255, 255, 255, .52);
        border-left: 5px solid var(--red);
        border-radius: 8px;
        box-shadow: 0 12px 28px rgba(0, 0, 0, .16);
        backdrop-filter: blur(14px);
    }

    .stock-table tr.warning-row {
        background:
            linear-gradient(180deg, rgba(255, 242, 243, .94), rgba(255, 255, 255, .8)),
            var(--glass);
        border-left-color: var(--gold);
    }

    .stock-table td,
    .stock-table tbody tr:nth-child(even) td,
    .stock-table tbody tr.warning-row td,
    .stock-table tbody tr.warning-row:nth-child(even) td {
        padding: 0;
        background: transparent;
        border: 0;
    }

    .stock-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        color: var(--red);
        font-size: 10px;
        font-weight: 900;
        letter-spacing: .08em;
        text-transform: uppercase;
    }

    .stock-table td:first-child::before {
        color: var(--black);
    }

    .stock-table td:first-child input,
    .stock-table td:first-child {
        font-weight: 900;
    }

    .stock-table input {
        min-height: 38px;
    }

    .stock-table td[data-label="Satuan / Modal"] {
        display: grid;
        grid-template-columns: .8fr 1fr;
        gap: 8px;
    }

    .stock-table td[data-label="Satuan / Modal"]::before {
        grid-column: 1 / -1;
    }

    .stock-table td.margin-cell,
    .stock-table tbody tr:nth-child(even) td.margin-cell,
    .stock-table tbody tr.warning-row td.margin-cell,
    .stock-table tbody tr.warning-row:nth-child(even) td.margin-cell {
        min-width: 0;
        padding: 9px 10px;
        color: var(--white);
        background: rgba(5, 5, 5, .88);
        border-left: 4px solid var(--gold);
        border-radius: 6px;
    }

    .stock-table .margin-cell::before {
        color: var(--gold);
    }

    .stock-table .margin-cell span {
        color: var(--gold);
    }

    .stock-table .table-actions {
        display: grid;
        min-width: 0;
        grid-template-columns: 1fr 1fr;
    }

    .stock-table .secondary,
    .stock-table .danger {
        min-height: 38px;
    }
}

@media print {
    body,
    body::before {
        background: var(--white);
    }

    body::before {
        display: none;
    }

    .receipt {
        width: 100%;
        margin: 0;
        border: 0;
    }

    .no-print {
        display: none !important;
    }
}
