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

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #f7f9fc 0%, #e7ebf6 100%);
    min-height: 100vh;
    color: #2d3748;
    padding: 24px 16px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== Header ===== */
header {
    background: linear-gradient(118deg, #081f4d 0%, #0b2b6b 32%, #12296b 46%, #8f1116 76%, #b91c1c 100%);
    border-radius: 16px;
    padding: 22px 28px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    box-shadow: 0 10px 28px rgba(11, 43, 107, 0.28);
    border-bottom: 4px solid #d4af37;
    margin-bottom: 24px;
}

/* ===== Logo unit dalam header ===== */
.header-brand {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.brand-logos {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-logo {
    height: 68px;
    width: auto;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.4));
}

.header-content {
    min-width: 0;
}

.header-content h1::after {
    content: '';
    display: block;
    width: 56px;
    height: 3px;
    margin-top: 8px;
    border-radius: 2px;
    background: linear-gradient(90deg, #d4af37, rgba(212, 175, 55, 0));
}

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.subtitle {
    opacity: 0.9;
    font-size: 0.95rem;
    margin-top: 4px;
}

/* ===== Buttons ===== */
.btn {
    border: none;
    border-radius: 10px;
    padding: 12px 22px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: #fff;
    color: #0b2b6b;
}

.btn-primary:hover {
    background: #e6ecfb;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    color: #718096;
    cursor: pointer;
    line-height: 1;
}

.btn-close:hover {
    color: #dc2626;
}

/* ===== Statistik Cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    border-left: 5px solid transparent;
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.stat-total { border-left-color: #dc2626; }
.stat-korporat { border-left-color: #1d4ed8; }
.stat-sukan { border-left-color: #0b2b6b; }
.stat-customers { border-left-color: #d69e2e; }

.stat-icon {
    font-size: 2.2rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #f7fafc;
}

.stat-info h3 {
    font-size: 0.85rem;
    font-weight: 500;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 2px 0;
}

.stat-label {
    font-size: 0.8rem;
    color: #a0aec0;
}

/* ===== Toolbar ===== */
.toolbar {
    background: #fff;
    border-radius: 14px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    margin-bottom: 24px;
}

.search-box input {
    padding: 11px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    width: 320px;
    max-width: 100%;
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: #1d4ed8;
}

.filter-buttons {
    display: flex;
    gap: 8px;
}

.btn-filter {
    padding: 10px 20px;
    border: 2px solid #e2e8f0;
    background: #fff;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-filter:hover {
    border-color: #1d4ed8;
    color: #1d4ed8;
}

.btn-filter.active {
    background: #0b2b6b;
    border-color: #0b2b6b;
    color: #fff;
}

/* ===== Jadual ===== */
.table-section {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    overflow-x: auto;
    padding-bottom: 8px;
}

.customer-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

.customer-table thead {
    background: #f7fafc;
}

.customer-table th {
    text-align: left;
    padding: 15px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
}

.customer-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #edf2f7;
    font-size: 0.92rem;
}

.customer-table tbody tr:hover {
    background: #f7fafc;
}

.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
}

.badge-korporat {
    background: #eef2fd;
    color: #14357a;
}

.badge-sukan {
    background: #dbe6fd;
    color: #14357a;
}

.amount {
    font-weight: 600;
    color: #0b2b6b;
}

.action-btns {
    display: flex;
    gap: 6px;
}

.btn-icon {
    border: none;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-view {
    background: #fde2e2;
    color: #7f1d1d;
}

.btn-view:hover {
    background: #fbc4c4;
}

.btn-wa {
    background: #dbe6fd;
    color: #0b2b6b;
}

.btn-wa:hover {
    background: #bcd0fa;
}

.btn-wa[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-edit {
    background: #feebc8;
    color: #c05621;
}

.btn-edit:hover {
    background: #fbd38d;
}

.btn-delete {
    background: #fde2e2;
    color: #b91c1c;
}

.btn-delete:hover {
    background: #fbc4c4;
}

/* ===== Empty State ===== */
.empty-state {
    display: none;
    text-align: center;
    padding: 60px 20px;
    color: #a0aec0;
}

.empty-state.show {
    display: block;
}

.empty-icon {
    font-size: 3.5rem;
    margin-bottom: 12px;
}

.empty-state h3 {
    color: #718096;
    margin-bottom: 6px;
}

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 55, 72, 0.6);
    z-index: 100;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 16px;
    overflow-y: auto;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 28px;
    border-bottom: 1px solid #edf2f7;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal form,
.history-content {
    padding: 24px 28px;
}

/* ===== Form ===== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #1d4ed8;
}

.form-group input[readonly] {
    background: #f7fafc;
    color: #4a5568;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.total-display {
    background: linear-gradient(135deg, #eef2fd 0%, #c9d8f7 100%);
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 1.3rem;
    font-weight: 700;
    color: #14357a;
    text-align: center;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 28px 24px;
}

/* ===== Sejarah ===== */
.history-summary {
    background: #f7fafc;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 18px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.history-summary div {
    font-size: 0.9rem;
}

.history-summary strong {
    color: #0b2b6b;
}

.history-item {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.history-item .details {
    font-size: 0.9rem;
}

.history-item .details .date {
    color: #a0aec0;
    font-size: 0.8rem;
}

.history-item .amount {
    font-size: 1.05rem;
}

.history-note {
    width: 100%;
    font-size: 0.82rem;
    color: #718096;
    font-style: italic;
    margin-top: 6px;
}

.no-history {
    text-align: center;
    color: #a0aec0;
    padding: 30px 0;
}

/* ===== Statistik ikut Saiz ===== */
.size-section,
.payment-section,
.ansuran-section {
    background: #fff;
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    margin-bottom: 24px;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.size-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 12px;
}

.size-chip {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 12px;
    padding: 14px 10px;
    text-align: center;
    transition: transform 0.2s ease;
}

.size-chip:hover {
    transform: translateY(-2px);
}

.size-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.size-count {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #0b2b6b;
    margin-top: 4px;
}

.size-sub {
    display: block;
    font-size: 0.7rem;
    color: #718096;
    margin-top: 2px;
    line-height: 1.3;
}

/* ===== Statistik ikut Cara Bayaran ===== */
.payment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.payment-card {
    border-radius: 12px;
    padding: 18px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.payment-tunai {
    background: linear-gradient(135deg, #0b2b6b 0%, #1d4ed8 100%);
}

.payment-pindahan {
    background: linear-gradient(135deg, #8f1116 0%, #b91c1c 100%);
}

.payment-ansuran {
    background: linear-gradient(135deg, #b7791f 0%, #d69e2e 100%);
}

.payment-title {
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.95;
    margin-bottom: 8px;
}

.payment-amount {
    font-size: 1.5rem;
    font-weight: 700;
}

.payment-count {
    font-size: 0.8rem;
    opacity: 0.85;
    margin-top: 4px;
}

/* ===== Ansuran Aktif ===== */
.ansuran-section { padding: 22px; }

.ansuran-card {
    background: #fffaf0;
    border: 1px solid #f6e05e;
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.ansuran-card.settle {
    background: #f0f4fe;
    border-color: #bcd0fa;
}

.ansuran-card .info {
    flex: 1;
    min-width: 240px;
}

.ansuran-card .info strong {
    font-size: 1rem;
    color: #2d3748;
}

.ansuran-card .info .meta {
    font-size: 0.82rem;
    color: #718096;
    margin-top: 4px;
}

.ansuran-progress {
    width: 100%;
    margin-top: 10px;
}

.progress-bar-bg {
    background: #edf2f7;
    border-radius: 20px;
    height: 10px;
    overflow: hidden;
    margin-top: 6px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #d69e2e 0%, #ecc94b 100%);
    border-radius: 20px;
    transition: width 0.3s ease;
}

.settle .progress-bar-fill {
    background: linear-gradient(90deg, #1d4ed8 0%, #3b82f6 100%);
}

.progress-text {
    font-size: 0.8rem;
    color: #718096;
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
}

.btn-ansuran {
    background: #d69e2e;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-ansuran:hover {
    background: #b7791f;
}

.btn-ansuran:disabled {
    background: #a0aec0;
    cursor: not-allowed;
}

.no-ansuran {
    text-align: center;
    color: #a0aec0;
    padding: 20px 0;
    font-size: 0.9rem;
}

/* ===== Badge Bayaran ===== */
.badge-tunai {
    background: #dbe6fd;
    color: #14357a;
}

.badge-pindahan {
    background: #c9d8f7;
    color: #0b2b6b;
}

.badge-ansuran {
    background: #feebc8;
    color: #975a16;
}

/* Badge Sel */
.badge-sel {
    background: #fde2e2;
    color: #7f1d1d;
}

/* ===== Monitor Sel ===== */
.sel-section {
    background: #fff;
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
    margin-bottom: 24px;
}

.sel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.sel-card {
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    border: 1px solid #e1e4e8;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.sel-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    border-color: #1d4ed8;
}

.sel-card.active {
    border-color: #0b2b6b;
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

.sel-card-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: #2c3e50;
    padding-bottom: 8px;
    margin-bottom: 10px;
    border-bottom: 2px solid #1d4ed8;
}

.sel-card-empty {
    text-align: center;
    color: #a0aec0;
    font-size: 0.85rem;
    padding: 10px 0;
    font-style: italic;
}

.sel-card-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sel-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: #4a5568;
}

.sel-stat-row span {
    color: #718096;
}

.sel-stat-row strong {
    color: #2c3e50;
}

.sel-stat-row strong.green { color: #14357a; }
.sel-stat-row strong.red { color: #b91c1c; }

.sel-mini-bar {
    height: 8px;
    background: #edf2f7;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
}

.sel-mini-bar > div {
    height: 100%;
    transition: width 0.3s ease;
}

.mini-green {
    background: linear-gradient(90deg, #1d4ed8, #3b82f6);
}

.sel-card-pct {
    font-size: 0.72rem;
    color: #718096;
    margin-top: 4px;
    text-align: right;
}

.sel-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: #a0aec0;
    padding: 30px 0;
    font-size: 0.9rem;
}

/* Dropdown penapis Sel */
select.btn-filter {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #4a5568 50%),
                      linear-gradient(135deg, #4a5568 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 32px;
}

/* ===== Badge LUNAS / Baki Hutang ===== */
.badge-lunas {
    background: #dbe6fd;
    color: #0b2b6b;
    font-weight: 600;
}

.badge-belum-lunas {
    background: #fde2e2;
    color: #7f1d1d;
    font-weight: 600;
}

.baki-hutang {
    color: #b91c1c;
    font-weight: 700;
}

.baki-lunas {
    color: #14357a;
    font-weight: 700;
}

/* ===== Status Bar LUNAS ===== */
.status-lunas-bar {
    background: linear-gradient(135deg, #dbe6fd 0%, #bcd0fa 100%);
    color: #0b2b6b;
    font-weight: 600;
    text-align: center;
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.status-hutang-bar {
    background: linear-gradient(135deg, #fde2e2 0%, #fbc4c4 100%);
    color: #7f1d1d;
    font-weight: 600;
    text-align: center;
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

/* ===== Modal Bayar Ansuran ===== */
.pay-list {
    margin-top: 16px;
}

.pay-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #f7fafc;
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.pay-item .pay-date { color: #718096; font-size: 0.82rem; }
.pay-item .pay-amount { font-weight: 600; color: #14357a; }

.pay-form {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pay-form input {
    flex: 1;
    min-width: 140px;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
}

.pay-form input:focus { border-color: #1d4ed8; }

.pay-form button {
    background: #1d4ed8;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 20px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.pay-form button:hover { background: #14357a; }

/* ===== Radio Payment Options ===== */
.payment-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.payment-option input {
    display: none;
}

.payment-option-label {
    display: block;
    text-align: center;
    padding: 12px 8px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 500;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
}

.payment-option input:checked + .payment-option-label {
    border-color: #0b2b6b;
    background: #eef2fd;
    color: #0b2b6b;
}

/* ===== Medan Ansuran dalam Form ===== */
.ansuran-fields { margin-bottom: 18px; }

.ansuran-box {
    background: #fffaf0;
    border: 2px dashed #d69e2e;
    border-radius: 12px;
    padding: 18px;
}

.ansuran-box h4 {
    font-size: 0.95rem;
    color: #975a16;
    margin-bottom: 14px;
}

.ansuran-calc {
    background: #fff;
    border-radius: 10px;
    padding: 14px 16px;
}

.ansuran-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.9rem;
    color: #4a5568;
    border-bottom: 1px dashed #edf2f7;
}

.ansuran-row:last-child { border-bottom: none; }
.ansuran-row span:last-child { font-weight: 600; color: #0b2b6b; }

/* ===== Export Buttons ===== */
.export-buttons {
    display: flex;
    gap: 8px;
}

.btn-export {
    padding: 10px 16px;
    border: 2px solid #e2e8f0;
    background: #fff;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-export:hover {
    border-color: #1d4ed8;
    color: #1d4ed8;
}

.btn-export-danger:hover {
    border-color: #dc2626;
    color: #dc2626;
}

.btn-export-excel {
    background: #eef2fd;
    color: #0b2b6b;
    border-color: #c9d8f7;
}

.btn-export-excel:hover {
    border-color: #1d4ed8;
    color: #1d4ed8;
    background: #c9d8f7;
}

/* ===== Ticker Nama Pembeli ===== */
.buyer-ticker {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(118deg, #081f4d 0%, #0b2b6b 45%, #8f1116 100%);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-top: 3px solid #d4af37;
    box-shadow: 0 -4px 20px rgba(26, 86, 219, 0.3);
    z-index: 50;
}

.ticker-label {
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    margin-left: 16px;
    margin-right: 12px;
    flex-shrink: 0;
}

.ticker-viewport {
    overflow: hidden;
    flex: 1;
    position: relative;
    height: 24px;
}

/* Gradien tepi kanan & kiri */
.ticker-viewport::before,
.ticker-viewport::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 30px;
    z-index: 2;
    pointer-events: none;
}

.ticker-viewport::before {
    left: 0;
    background: linear-gradient(to right, #0b2b6b, transparent);
}

.ticker-viewport::after {
    right: 0;
    background: linear-gradient(to left, #1d4ed8, transparent);
}

.ticker-track {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    animation: tickerScroll 30s linear infinite;
    will-change: transform;
}

/* Pause animation on hover */
.ticker-viewport:hover .ticker-track {
    animation-play-state: paused;
}

/* Loop lancar: kandungan diduplikasi 2x dalam JS,
   animasi bergerak -50% supaya penyambungannya tak kelihatan */
@keyframes tickerScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.ticker-item {
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 20px;
}

.ticker-item .dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c9d8f7;
}

.ticker-item strong {
    color: #fff;
    font-weight: 600;
}

.ticker-separator {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
}

/* Ruang untuk ticker di bawah supaya jadual tak tertutup */
.container {
    padding-bottom: 70px;
}

/* ===== Set Box (Baju Korporat + Sukan) ===== */
.set-box {
    background: #eef2fd;
    border: 2px solid #c9d8f7;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
}

.set-box h4 {
    font-size: 0.95rem;
    color: #14357a;
    margin-bottom: 6px;
}

.set-info {
    font-size: 0.82rem;
    color: #4a5568;
    margin-bottom: 14px;
}

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

.set-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.set-item span {
    font-size: 0.85rem;
    font-weight: 500;
    color: #4a5568;
}

.set-item input {
    width: 60px;
    padding: 6px 8px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    text-align: center;
    outline: none;
}

.set-item input:focus {
    border-color: #1d4ed8;
}

.set-item span:last-child {
    font-size: 0.78rem;
    color: #718096;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    body { padding: 12px 8px; }

    header { padding: 20px; }
    header h1 { font-size: 1.4rem; }

    .form-row { grid-template-columns: 1fr; }

    .search-box input { width: 100%; }

    .toolbar { flex-direction: column; align-items: stretch; }
    .filter-buttons { justify-content: center; flex-wrap: wrap; }
    .export-buttons { justify-content: center; flex-wrap: wrap; }

    .modal form,
    .history-content { padding: 18px; }
    .form-actions { padding: 0 18px 18px; }

    .payment-options { grid-template-columns: 1fr; }
    .size-grid { grid-template-columns: repeat(4, 1fr); }
    .set-quantity { grid-template-columns: 1fr; }
}

/* ===== Resit Pembayaran ===== */
.resit-upload-area {
    border: 2px dashed #c9d8f7;
    border-radius: 12px;
    background: #eef2fd;
    transition: border-color 0.2s, background 0.2s;
}

.resit-upload-area:hover {
    border-color: #1d4ed8;
}

.resit-placeholder {
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.resit-icon {
    font-size: 2rem;
}

.resit-text {
    font-size: 0.92rem;
    font-weight: 500;
    color: #14357a;
}

.resit-hint {
    font-size: 0.75rem;
    color: #718096;
}

.resit-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    flex-wrap: wrap;
}

.resit-preview img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #c9d8f7;
    cursor: pointer;
    transition: transform 0.2s;
}

.resit-preview img:hover {
    transform: scale(1.05);
}

.resit-preview-info {
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.resit-preview-info span:first-child {
    font-size: 0.88rem;
    font-weight: 500;
    color: #2d3748;
    word-break: break-all;
}

.resit-preview-info span:last-child {
    font-size: 0.75rem;
    color: #718096;
}

.resit-remove {
    background: #fde2e2;
    color: #b91c1c;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.resit-remove:hover {
    background: #fbc4c4;
}

/* Thumbnail resit dalam jadual */
.resit-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #c9d8f7;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    display: block;
}

.resit-thumb:hover {
    transform: scale(1.1);
    border-color: #1d4ed8;
}

.resit-none-cell {
    color: #cbd5e0;
    font-size: 0.9rem;
}

/* Modal lihat resit */
.resit-modal {
    max-width: 640px;
}

.resit-viewer-content {
    padding: 20px 28px;
    text-align: center;
}

.resit-viewer-content img {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

/* Resit dalam sejarah */
.history-resit {
    margin-top: 10px;
    width: 100%;
}

.history-resit-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 6px;
}

.history-resit-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid #c9d8f7;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.history-resit-thumb:hover {
    transform: scale(1.05);
    border-color: #1d4ed8;
}

.history-resit-file {
    font-size: 0.72rem;
    color: #a0aec0;
    margin-top: 4px;
}

/* ===== Resit PDF ===== */
.resit-pdf-icon {
    object-fit: contain !important;
    padding: 8px;
    background: #fde2e2;
    border-radius: 8px;
}

.resit-pdf-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    width: 48px;
}

.resit-pdf-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: #b91c1c;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-resit-pdf {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    width: 80px;
}

.history-resit-pdf .resit-pdf-label {
    font-size: 0.68rem;
}

/* PDF viewer dalam modal */
#resitModalPdf {
    width: 100%;
    height: 60vh;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f7fafc;
}

/* ===== Resit Bayaran Ansuran ===== */
.pay-item-resit {
    flex-direction: column;
    align-items: stretch !important;
    gap: 8px;
}

.pay-item-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pay-resit-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-resit-mini {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 5px 10px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
    color: #4a5568;
}

.btn-resit-add {
    background: #eef2fd;
    color: #14357a;
    border-color: #c9d8f7;
}

.btn-resit-add:hover {
    background: #c9d8f7;
    border-color: #1d4ed8;
}

.btn-resit-view {
    background: #f0f4fe;
    color: #14357a;
    border-color: #dbe6fd;
}

.btn-resit-view:hover {
    background: #dbe6fd;
}

.btn-resit-change {
    background: #feebc8;
    color: #c05621;
    border-color: #fbd38d;
}

.btn-resit-change:hover {
    background: #fbd38d;
}

.btn-resit-remove {
    background: #fde2e2;
    color: #b91c1c;
    border-color: #fbc4c4;
}

.btn-resit-remove:hover {
    background: #fbc4c4;
}

.pay-resit-hint {
    font-size: 0.76rem;
    color: #718096;
    margin-top: 8px;
    font-style: italic;
    text-align: center;
}

/* Grid resit ansuran dalam sejarah */
.history-resit-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 4px;
}

.history-resit-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.history-resit-item-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #4a5568;
}

/* ===== Watermark logo Rejimen 881 PUTD (samar, corak berulang) ===== */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: url('logos/rejimen881.png');
    background-repeat: repeat;
    background-position: center top;
    background-size: min(26vmin, 260px) auto;
    opacity: 0.05;
}

/* ===== Tema Merah-Biru: penyesuaian mudah alih ===== */
@media (max-width: 768px) {
    .brand-logo { height: 52px; }
    .brand-logos { gap: 8px; }
    .header-brand { gap: 12px; }
    body::before { background-size: min(34vmin, 170px) auto; opacity: 0.045; }
}

@media (max-width: 480px) {
    .brand-logo { height: 44px; }
    .header-content h1 { font-size: 1.25rem; }
    body::before { background-size: min(40vmin, 130px) auto; }
}

/* Kad Status Bayaran (selesai vs masih ansuran) */
.payment-lunas { border-left-color: #16a34a; }
.payment-lunas .payment-amount { color: #16a34a; }
.payment-masih { border-left-color: #f59e0b; }
.payment-masih .payment-amount { color: #d97706; }

/* Kad Total Terkutuk & Baki Tertunggak */
.stat-terkutuk { border-left-color: #16a34a; }
.stat-terkutuk .stat-value { color: #16a34a; }
.stat-baki { border-left-color: #ea580c; }
.stat-baki .stat-value { color: #ea580c; }
