:root {
    --primary: #7F5AF0;
    --primary-hover: #9171F8;
    --bg-dark: #16161A;
    --glass-bg: rgba(22, 22, 26, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #FFFFFE;
    --text-muted: #94A1B2;
    --success: #2CB67D;
    --error: #EF4565;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-border: rgba(255, 255, 255, 0.2);
    --input-bg: rgba(255, 255, 255, 0.06);
    --popup-bg: #1e1e24;
    --swal-bg: #16161a;
    --swal-text: #fffffe;
}

:root[data-theme="light"] {
    --bg-dark: #EEF0F5;
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(15, 23, 42, 0.12);
    --text-main: #1F2430;
    --text-muted: #64748B;
    --surface: rgba(15, 23, 42, 0.045);
    --surface-border: rgba(15, 23, 42, 0.18);
    --input-bg: rgba(15, 23, 42, 0.05);
    --popup-bg: #FFFFFF;
    --swal-bg: #ffffff;
    --swal-text: #1f2430;
}

/* Belum memilih manual => default light */
:root:not([data-theme]) {
    --bg-dark: #EEF0F5;
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(15, 23, 42, 0.12);
    --text-main: #1F2430;
    --text-muted: #64748B;
    --surface: rgba(15, 23, 42, 0.045);
    --surface-border: rgba(15, 23, 42, 0.18);
    --input-bg: rgba(15, 23, 42, 0.05);
    --popup-bg: #FFFFFF;
    --swal-bg: #ffffff;
    --swal-text: #1f2430;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Background animated shapes */
.background-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite alternate ease-in-out;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: #7F5AF0;
    top: -100px;
    left: -100px;
}

.shape-2 {
    width: 300px;
    height: 300px;
    background: #2CB67D;
    bottom: 50px;
    right: -50px;
    animation-delay: -5s;
}

.shape-3 {
    width: 250px;
    height: 250px;
    background: #EF4565;
    bottom: -100px;
    left: 30%;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 50px) scale(1.2); }
}

/* Glassmorphism Panel — layout lebar agar pas 1 layar */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 28px 32px;
    width: 95%;
    max-width: 1100px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
}

/* Tombol toggle dark/light */
.theme-toggle {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 50;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--input-bg);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.25s ease;
}

.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: rotate(-15deg) scale(1.08);
}

body {
    align-items: flex-start;
    padding: 24px 0;
}

@media (min-width: 900px) {
    body {
        align-items: center;
        padding: 0;
    }
}

.layout-grid {
    display: grid;
    grid-template-columns: minmax(300px, 5fr) minmax(340px, 7fr);
    gap: 24px;
    align-items: start;
}

@media (max-width: 899px) {
    .layout-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .glass-panel {
        padding: 20px 16px;
    }

    header.compact h1 {
        font-size: 1.5rem;
    }

    .actions {
        flex-direction: column;
        gap: 10px;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }
}

.col-settings,
.col-upload {
    min-width: 0;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header.compact {
    margin-bottom: 20px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 10px;
    letter-spacing: -1px;
}

header.compact h1 {
    font-size: 1.9rem;
    margin-bottom: 4px;
}

header.compact p {
    font-size: 0.92rem;
}

.text-gradient {
    background: linear-gradient(135deg, #7F5AF0, #2CB67D);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--glass-border);
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: var(--surface);
    position: relative;
    overflow: hidden;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(127, 90, 240, 0.1);
}

.drop-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 15px;
    transition: transform 0.3s ease;
}

.drop-zone:hover .drop-icon {
    transform: translateY(-5px);
}

.drop-zone h3 {
    margin-bottom: 5px;
    font-weight: 600;
}

.drop-zone p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

#file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-list {
    margin-top: 15px;
    text-align: left;
    max-height: 150px;
    overflow-y: auto;
    padding: 0 10px;
    position: relative;
    z-index: 10;
}

/* Header daftar file: hitungan + tombol hapus semua */
.file-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 15px;
    padding: 0 10px;
    position: relative;
    z-index: 11;
    text-align: left;
}

.file-count-label {
    font-size: 0.82em;
    font-weight: 600;
    color: var(--text-muted);
}

.clear-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(239, 69, 101, 0.14);
    border: 1px solid rgba(239, 69, 101, 0.4);
    color: var(--error);
    border-radius: 999px;
    padding: 6px 14px;
    font-family: 'Inter', sans-serif;
    font-size: 0.78em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-all-btn:hover {
    background: var(--error);
    border-color: var(--error);
    color: #fff;
}

.file-item {
    background: var(--surface);
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    animation: slideIn 0.3s ease;
}

.delete-btn {
    background: #EF4565;
    color: white;
    width: 28px;
    height: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.delete-btn i {
    font-size: 14px;
    margin: 0;
    padding: 0;
}

.delete-btn:hover {
    background: #d93853;
    transform: scale(1.05);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hidden {
    display: none !important;
}

/* Section opsi (periode & template) */
.period-section,
.template-section {
    margin-bottom: 16px;
    padding: 14px 15px;
    background: var(--surface);
    border-radius: 12px;
    border: 1px dashed var(--surface-border);
}

.period-section label,
.template-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-main);
}

.period-section .hint,
.template-section .hint {
    font-size: 0.85em;
    margin-bottom: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.period-section input[type="file"],
.template-section input[type="file"] {
    font-size: 0.9em;
    color: var(--text-main);
}

/* Calendar month picker — rounded & minimal, tanggal aktif lingkaran biru */
.picker {
    position: relative;
}

.picker-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 9px 18px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.picker-pill:hover,
.picker-pill.open {
    border-color: var(--primary);
    background: rgba(127, 90, 240, 0.12);
}

.picker-pill i {
    color: var(--primary);
}

.picker-clear {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85em;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s ease;
    margin-left: 4px;
}

.picker-clear:hover {
    color: var(--error);
    background: rgba(239, 69, 101, 0.12);
}

.picker-popup {
    position: absolute;
    z-index: 100;
    top: calc(100% + 8px);
    left: 0;
    width: 280px;
    background: var(--popup-bg);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
    animation: slideIn 0.18s ease;
}

.picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.picker-title {
    font-weight: 600;
    font-size: 0.95em;
    text-transform: capitalize;
}

.picker-nav {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.picker-nav:hover {
    background: var(--surface);
    color: var(--text-main);
}

.picker-dow {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.68em;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.picker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.picker-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82em;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    transition: background 0.15s ease, color 0.15s ease;
}

.picker-day:hover {
    background: var(--surface);
}

.picker-day.other-month {
    color: rgba(148, 161, 178, 0.35);
}

.picker-day.today {
    border: 1px solid var(--primary);
}

.picker-day.selected {
    background: #2F80ED;
    color: #fff;
    font-weight: 700;
}

.picker-day.selected:hover {
    background: #4a94f2;
}

.picker-day.empty {
    cursor: default;
}

.period-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.day-label {
    font-size: 0.85em;
    color: var(--text-muted);
}

.day-input {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 8px 10px;
    width: 64px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9em;
    color: var(--text-main);
    color-scheme: dark light;
    text-align: center;
}

.day-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(127, 90, 240, 0.25);
}

.tpl-download-link {
    color: var(--success);
    font-weight: 600;
    text-decoration: none;
}

.tpl-download-link:hover {
    text-decoration: underline;
}

/* Tombol "Pilih File" kustom (pengganti input file bawaan browser) */
.file-choose {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.file-choose-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary), #5f3dc4);
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.88em;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(127, 90, 240, 0.35);
    flex-shrink: 0;
}

.file-choose-btn:hover {
    filter: brightness(1.12);
    transform: translateY(-1px);
}

.file-choose-name {
    font-size: 0.85em;
    color: var(--text-muted);
    overflow-wrap: anywhere;
    min-width: 0;
}

.file-choose-name.has-file {
    color: var(--success);
    font-weight: 600;
}

.file-choose-clear {
    background: rgba(239, 69, 101, 0.15);
    border: none;
    color: var(--error);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.file-choose-clear:hover {
    background: var(--error);
    color: #fff;
}

.file-choose-input {
    display: none;
}

/* Ringkasan hasil */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 15px 0 20px;
    text-align: left;
}

.summary-item {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.summary-label {
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.summary-value {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--text-main);
}

.summary-total {
    grid-column: 1 / -1;
    background: rgba(44, 182, 125, 0.12);
    border-color: rgba(44, 182, 125, 0.3);
}

.summary-total .summary-value {
    color: var(--success);
    font-size: 1.15em;
}

/* Kotak peringatan */
.warnings-box {
    text-align: left;
    background: rgba(255, 184, 0, 0.08);
    border: 1px solid rgba(255, 184, 0, 0.35);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 18px;
    font-size: 0.88em;
}

.warnings-box summary {
    cursor: pointer;
    font-weight: 600;
    color: #FFB800;
    list-style: none;
}

.warnings-box summary::-webkit-details-marker {
    display: none;
}

.warnings-box summary i {
    display: inline !important;
    font-size: 1em !important;
    margin: 0 6px 0 0 !important;
}

.warnings-box ul {
    margin: 10px 0 4px;
    padding-left: 20px;
    color: var(--text-main);
}

.warnings-box li {
    margin-bottom: 6px;
    line-height: 1.45;
}

/* Actions */
.actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.btn {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.primary-btn {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(127, 90, 240, 0.3);
}

.primary-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.primary-btn:disabled {
    background: #3a3a42;
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.secondary-btn:hover {
    background: var(--surface);
}

.danger-btn {
    background: var(--error);
    color: white;
    box-shadow: 0 4px 15px rgba(239, 69, 101, 0.3);
}

.danger-btn:hover {
    background: #d93853;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 69, 101, 0.45);
}

.success-btn {
    background: var(--success);
    color: white;
    box-shadow: 0 4px 15px rgba(44, 182, 125, 0.3);
    text-decoration: none;
}

.success-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
}

/* Loading */
.loading-state {
    text-align: center;
    margin-top: 25px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--glass-border);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* Result */
.result-message {
    margin-top: 25px;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    background: rgba(44, 182, 125, 0.1);
    border: 1px solid rgba(44, 182, 125, 0.2);
    animation: slideIn 0.5s ease;
}

.result-message.error {
    background: rgba(239, 69, 101, 0.1);
    border-color: rgba(239, 69, 101, 0.2);
}

.result-message h3 {
    margin-bottom: 15px;
}

.result-message i {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
}

.text-success { color: var(--success); }
.text-error { color: var(--error); }

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

/* Progress Bar */
.progress-container {
    width: 100%;
    height: 8px;
    background: var(--surface);
    border-radius: 4px;
    margin-top: 15px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 4px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(127, 90, 240, 0.5);
}
