:root {
    /* Light Theme (Default) */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface2: #f1f5f9;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-highlight: #cbd5e1;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    
    --radius-sm: 0.25rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;
    
    --sidebar-width: 260px;
}

[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --secondary: #475569;
    --secondary-hover: #64748b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface2: #334155;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --border-highlight: #475569;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.5);
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* Typography Utilities */
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-2xl { font-size: 1.5rem; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.uppercase { text-transform: uppercase; }

/* Spacing Utilities */
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.p-0 { padding: 0 !important; }
.p-4 { padding: 1rem; }
.p-8 { padding: 2rem; }
.pb-2 { padding-bottom: 0.5rem; }
.pb-4 { padding-bottom: 1rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }
.pl-5 { padding-left: 1.25rem; }

/* Layout Utilities */
.flex { display: flex; }
.grid { display: grid; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.col-span-3 { grid-column: span 3 / span 3; }
.col-span-4 { grid-column: span 4 / span 4; }
.flex-1 { flex: 1 1 0%; }
.w-full { width: 100%; }
.max-w-xl { max-width: 36rem; margin: 0 auto; }
.max-w-2xl { max-width: 42rem; margin: 0 auto; }
.max-w-lg { max-width: 32rem; }
.block { display: block; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.overflow-x-auto { overflow-x: auto; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.list-disc { list-style-type: disc; }

/* Other Utilities */
.bg-surface { background-color: var(--surface); }
.bg-surface2 { background-color: var(--surface2); }
.rounded { border-radius: var(--radius); }
.rounded-md { border-radius: var(--radius-lg); }
.border { border: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.border-t { border-top: 1px solid var(--border); }
.border-dashed { border-style: dashed; }
.hover\:underline:hover { text-decoration: underline; }
.cursor-not-allowed { cursor: not-allowed; }
.opacity-75 { opacity: 0.75; }

/* Admin Layout Components */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.brand-name {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
    letter-spacing: -0.025em;
}

.sidebar-user {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-full);
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.user-info .user-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.user-info .user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.nav-item {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    color: var(--text);
    background-color: var(--surface2);
}

.nav-item.active {
    color: var(--primary);
    background-color: var(--surface2);
    border-left-color: var(--primary);
}

.nav-divider {
    height: 1px;
    background-color: var(--border);
    margin: 1rem 1.5rem;
}

.btn-logout {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    color: var(--danger);
}

.btn-logout:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

.btn-theme-toggle {
    width: 100%;
    padding: 0.5rem;
    background-color: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: background-color 0.2s;
}

.btn-theme-toggle:hover {
    background-color: var(--border);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.page-header {
    padding: 2rem;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.content-wrapper {
    padding: 2rem;
    flex: 1;
}

/* Cards & Containers */
.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.guest-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background: linear-gradient(135deg, var(--background) 0%, var(--surface2) 100%);
}

.guest-container {
    width: 100%;
    max-width: 28rem;
}

.login-card, .public-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.public-card-wide {
    max-width: 48rem;
    margin: 0 auto;
}

.login-header, .public-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2, .public-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.login-header p, .public-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Forms */
.filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    align-items: end;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.form-control:disabled {
    background-color: var(--surface2);
    opacity: 0.7;
    cursor: not-allowed;
}

.form-control-lg {
    padding: 0.875rem 1rem;
    font-size: 1.125rem;
}

.form-control-sm {
    padding: 0.375rem 0.75rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.check-input {
    width: 1rem;
    height: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    accent-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    border-radius: var(--radius);
    transition: all 0.2s ease-in-out;
    font-family: inherit;
    white-space: nowrap;
}

.btn svg {
    flex-shrink: 0;
    position: relative;
    top: 1px;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-primary {
    color: #fff;
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-secondary {
    color: var(--text);
    background-color: var(--surface2);
    border-color: var(--border-highlight);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--border);
}

.btn-danger {
    color: #fff;
    background-color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    opacity: 0.9;
}

/* Action Buttons (Table) - Icon-only pill buttons */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius);
    transition: all 0.2s;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
}
.btn-action-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: 0.5rem;
    border: 1.5px solid rgba(37, 99, 235, 0.3);
    background-color: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.btn-action-edit:hover {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}
.btn-action-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: 0.5rem;
    border: 1.5px solid rgba(239, 68, 68, 0.3);
    background-color: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.btn-action-delete:hover {
    background-color: var(--danger);
    border-color: var(--danger);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.35);
    transform: translateY(-1px);
}
.btn-action-success {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: 0.5rem;
    border: 1.5px solid rgba(16, 185, 129, 0.3);
    background-color: rgba(16, 185, 129, 0.08);
    color: var(--success);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.btn-action-success:hover {
    background-color: var(--success);
    border-color: var(--success);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
    transform: translateY(-1px);
}
.btn-action-warning {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: 0.5rem;
    border: 1.5px solid rgba(245, 158, 11, 0.3);
    background-color: rgba(245, 158, 11, 0.08);
    color: var(--warning);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.btn-action-warning:hover {
    background-color: var(--warning);
    border-color: var(--warning);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
    transform: translateY(-1px);
}
/* Group wrapper for action buttons */
.btn-action-group {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Tables */
.table {
    width: 100%;
    margin-bottom: 1rem;
    color: var(--text);
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background-color: var(--surface2);
    text-align: left;
}

.table tbody tr {
    transition: background-color 0.2s;
}

.table tbody tr:hover {
    background-color: var(--surface2);
}

.row-highlight {
    background-color: rgba(16, 185, 129, 0.05) !important;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: var(--radius-full);
}

.badge-primary { background-color: rgba(37, 99, 235, 0.15); color: var(--primary); }
.badge-success { background-color: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-warning { background-color: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-danger { background-color: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-secondary { background-color: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }

/* Bulk Action Bar */
.bulk-action-bar {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(254, 226, 226, 0.95);
    border: 1px solid rgba(252, 165, 165, 0.5);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px -5px rgba(239, 68, 68, 0.2);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 50;
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.bulk-action-bar.show {
    bottom: 2rem;
}
.bulk-text {
    font-weight: 600;
    color: var(--danger);
    font-size: 0.875rem;
}
[data-theme="dark"] .bulk-action-bar {
    background-color: rgba(69, 10, 10, 0.95);
    border-color: rgba(153, 27, 27, 0.5);
}

/* Alerts */
.alert {
    position: relative;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.alert-error {
    color: var(--danger);
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

.alert-info {
    color: var(--primary);
    background-color: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.2);
}

/* Flash Messages */
.flash-message {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 50;
    min-width: 300px;
    max-width: 400px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    padding: 1rem;
    border: 1px solid var(--border);
    background-color: var(--surface);
    transition: opacity 0.3s ease;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.flash-content {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
}

.flash-sukses { border-left: 4px solid var(--success); }
.flash-error { border-left: 4px solid var(--danger); }
.flash-info { border-left: 4px solid var(--primary); }

.flash-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    margin-left: 1rem;
}

.flash-close:hover { color: var(--text); }

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-card {
    position: relative;
    background-color: var(--surface);
    width: 100%;
    max-width: 32rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    z-index: 101;
    animation: modalPop 0.2s ease-out;
}

@keyframes modalPop {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-weight: 700;
    font-size: 1.125rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-close:hover { color: var(--text); }

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    background-color: var(--surface2);
    border-top: 1px solid var(--border);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Tagihan Public */
.tagihan-item {
    transition: transform 0.2s, box-shadow 0.2s;
}
.tagihan-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Responsive */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
}
.mobile-menu-btn:hover {
    background-color: var(--surface2);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 35;
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
    .grid-cols-3, .grid-cols-2 {
        grid-template-columns: 1fr;
    }
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .col-span-3, .col-span-4 {
        grid-column: span 1 / span 1;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    .filter-form {
        grid-template-columns: 1fr;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    .sidebar-overlay.open {
        display: block;
        opacity: 1;
    }
    .page-header {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

/* Basic Pagination Styling */
.pagination {
    display: flex;
    padding-left: 0;
    list-style: none;
    gap: 0.25rem;
    margin-top: 1.5rem;
    justify-content: center;
}
.page-item .page-link {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    color: var(--text);
    background-color: var(--surface2);
    text-decoration: none;
    transition: all 0.2s;
}
.page-item .page-link:hover {
    background-color: var(--primary);
    color: white;
}
.page-item.active .page-link {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}
.page-item.disabled .page-link {
    opacity: 0.5;
    pointer-events: none;
}

/* Global Footer */
.global-footer {
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1rem 2rem;
    margin-top: auto;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05); /* Agak melayang */
}
