:root {
    --primary: #1565C0;
    --primary-dark: #0D47A1;
    --primary-light: #E3F2FD;
    --success: #2E7D32;
    --warning: #B26A00;
    --danger: #C62828;
    --danger-light: #FFEBEE;
    --bg: #F5F5F5;
    --surface: #FFFFFF;
    --text: #212121;
    --text-secondary: #757575;
    --border: #E0E0E0;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ── Header ── */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-logo { font-size: 18px; font-weight: 700; color: var(--primary); }
.header-divider { width: 1px; height: 24px; background: var(--border); }
.header-company { font-size: 14px; color: var(--text-secondary); }
.header-merchant { font-size: 13px; color: var(--text-secondary); }
.header-right { display: flex; align-items: center; gap: 12px; }
.btn-back {
    background: none; border: 1px solid var(--border); padding: 6px 16px;
    border-radius: var(--radius); cursor: pointer; font-size: 13px;
    color: var(--text-secondary); transition: all 0.15s;
}
.btn-back:hover { background: var(--bg); border-color: #BDBDBD; }
.btn-logout {
    background: none; border: none; color: var(--danger); cursor: pointer;
    font-size: 13px; padding: 6px 12px; border-radius: var(--radius);
}
.btn-logout:hover { background: var(--danger-light); }

/* ── Container ── */
.container { max-width: 960px; margin: 0 auto; padding: 24px 16px; }

/* ── Login Page ── */
.login-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
}
.login-card {
    background: var(--surface); border-radius: 12px; padding: 40px 36px;
    width: 400px; max-width: 90vw; box-shadow: var(--shadow-lg);
}
.login-title {
    font-size: 22px; font-weight: 700; color: var(--primary);
    text-align: center; margin-bottom: 8px;
}
.login-subtitle { text-align: center; color: var(--text-secondary); font-size: 14px; margin-bottom: 28px; }
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-input {
    width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 15px; outline: none; transition: border 0.15s;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.btn-primary {
    width: 100%; height: 44px; background: var(--primary); color: #fff;
    border: none; border-radius: var(--radius); font-size: 16px; font-weight: 600;
    cursor: pointer; transition: background 0.15s; margin-top: 8px;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: #90CAF9; cursor: not-allowed; }
.error-msg {
    color: var(--danger); font-size: 13px; text-align: center; margin-top: 12px;
    padding: 8px; background: var(--danger-light); border-radius: var(--radius);
    display: none;
}
.error-msg.show { display: block; }

/* ── Cards ── */
.card {
    background: var(--surface); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-header { font-size: 16px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-secondary); padding: 10px 12px; border-bottom: 2px solid var(--border); background: #FAFAFA; }
td { padding: 12px; border-bottom: 1px solid #F0F0F0; font-size: 14px; }
tr:hover td { background: #F5F8FF; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #E8F0FE; }
td.mono { font-family: monospace; font-size: 12px; }

/* ── Status Badges ── */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 600; text-transform: uppercase;
}
.badge-paid { background: #E8F5E9; color: #2E7D32; }
.badge-unpaid { background: #FFF3E0; color: #E65100; }
.badge-partial { background: #FFF8E1; color: #F57F17; }
.badge-void { background: #FCE4EC; color: #C62828; }

/* ── Payment Amount ── */
.amount-positive { color: #2E7D32; font-weight: 600; }
.amount-negative { color: #C62828; font-weight: 600; }

/* ── Summary Row ── */
.summary-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.summary-item {
    flex: 1; min-width: 140px; background: var(--surface);
    padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow);
    text-align: center;
}
.summary-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.summary-value { font-size: 22px; font-weight: 700; }

/* ── Bill Detail ── */
.bill-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.bill-meta-item { }
.bill-meta-label { font-size: 12px; color: var(--text-secondary); }
.bill-meta-value { font-size: 15px; font-weight: 600; }

/* ── Payment Section ── */
.payment-actions { margin-top: 20px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.payment-input {
    width: 160px; height: 42px; padding: 0 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 15px; outline: none;
}
.payment-input:focus { border-color: var(--primary); }
.btn-pay {
    height: 42px; padding: 0 24px; background: var(--success); color: #fff;
    border: none; border-radius: var(--radius); font-size: 15px; font-weight: 600;
    cursor: pointer; transition: background 0.15s;
}
.btn-pay:hover { background: #1B5E20; }
.btn-pay:disabled { background: #A5D6A7; cursor: not-allowed; }
.btn-refund {
    height: 34px; padding: 0 14px; border: 1px solid #C62828;
    color: #C62828; background: #fff; border-radius: var(--radius);
    cursor: pointer; font-weight: 600;
}
.btn-refund:hover { background: #FFEBEE; }
.form-label { display: block; margin: 14px 0 6px; color: var(--text-secondary); font-size: 13px; }
.refund-reason {
    width: 100%; min-height: 72px; resize: vertical; padding: 10px;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-family: inherit; box-sizing: border-box;
}

/* ── Loading ── */
.loading { text-align: center; padding: 48px; color: var(--text-secondary); }
.spinner {
    display: inline-block; width: 32px; height: 32px; border: 3px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite;
    margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ── */
.empty { text-align: center; padding: 48px; color: var(--text-secondary); font-size: 14px; }

/* ── Toast ── */
.toast {
    position: fixed; top: 72px; right: 24px; z-index: 999;
    padding: 12px 20px; border-radius: var(--radius); font-size: 14px;
    box-shadow: var(--shadow-lg); animation: slideIn 0.25s ease;
    max-width: 360px;
}
.toast-success { background: #E8F5E9; color: #2E7D32; border: 1px solid #A5D6A7; }
.toast-error { background: #FFEBEE; color: #C62828; border: 1px solid #EF9A9A; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Confirm Modal ── */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.45); z-index: 200;
    display: flex; align-items: center; justify-content: center;
}
.modal-card {
    background: var(--surface); border-radius: 12px; padding: 28px 32px;
    width: 360px; max-width: 90vw; box-shadow: var(--shadow-lg);
}
.modal-body { font-size: 15px; color: var(--text); margin-bottom: 20px; line-height: 1.5; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }
.payment-qr-card { width: 410px; }
.payment-qr-body { text-align: center; }
.payment-qr-body h3 { margin: 0 0 10px; }
.payment-qr-body p { margin: 0 0 14px; color: var(--text-secondary); }
.payment-qr-image {
    display: block; width: 320px; height: 320px; max-width: 100%;
    margin: 0 auto 12px; background: #fff;
}

/* ── Utility ── */
.hidden { display: none; }
.flex-row { display: flex; align-items: center; gap: 12px; }
.flex-row-narrow { display: flex; align-items: center; gap: 8px; }
.mt-16 { margin-top: 16px; }
.ml-auto { margin-left: auto; }
.text-mono { font-family: monospace; }
.text-hint { font-size: 13px; color: #999; }
.text-label { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.color-primary { color: var(--primary); }
.color-success { color: var(--success); }
.color-danger { color: var(--danger); }
.w-180 { width: 180px; }
.h-38 { height: 38px; }

/* ── Responsive ── */
@media (max-width: 640px) {
    .summary-row { flex-direction: column; }
    .header { padding: 0 12px; }
    .header-logo { font-size: 15px; }
    .container { padding: 12px 8px; }
}
