/* ============================================================
   KAS ONLINE - COMPACT MODERN DESIGN
   Fit in one viewport on desktop, no excessive spacing
   Color Palette: Deep Navy + Gold Accent + Soft Neutrals
   ============================================================ */

:root {
    --primary: #1a1f36;
    --primary-light: #2d3561;
    --accent: #c9a84c;
    --accent-light: #e8d48b;
    --accent-glow: rgba(201, 168, 76, 0.12);
    --success: #10b981;
    --success-bg: #ecfdf5;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.1);
    --shadow-gold: 0 3px 10px rgba(201, 168, 76, 0.25);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --transition: all 0.15s ease;
}

/* === RESET & BASE === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--surface-2);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
}

/* === LAYOUT - FIT VIEWPORT === */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 20px;
    height: 100vh;
}

.container.app-main {
    display: flex;
    flex-direction: column;
}

.container.app-login {
    display: block;
    padding: 0;
    max-width: none;
    height: 100vh;
}

#page-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* === HEADER BAR === */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    background: var(--primary);
    border-radius: var(--radius);
    margin-bottom: 10px;
    flex-shrink: 0;
}

.header-bar .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 0.82rem;
}

.header-bar .user-info .avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--primary);
}

.header-bar .user-info span {
    font-weight: 500;
}

.header-bar .btn-logout {
    color: rgba(255,255,255,0.6);
    font-size: 0.78rem;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.15);
    transition: var(--transition);
}

.header-bar .btn-logout:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    text-decoration: none;
}

/* === NAVIGATION === */
nav {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

nav a {
    flex: 1;
    text-align: center;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}

nav a:hover {
    background: var(--surface-3);
    color: var(--text);
    text-decoration: none;
}

nav a.active {
    background: var(--primary);
    color: #fff;
}

/* === DASHBOARD === */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 10px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card.saldo::before {
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
}

.stat-card.status::before {
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}

.stat-card .stat-value.gold {
    background: linear-gradient(135deg, var(--accent), #b8860b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card .member-list {
    list-style: none;
    margin-top: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.stat-card .member-list li {
    padding: 6px 10px;
    border-radius: 4px;
    background: var(--surface-3);
    margin-bottom: 4px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text);
}

.stat-card .member-list li:hover {
    background: var(--accent-glow);
}

.stat-card .all-paid {
    color: var(--success);
    font-weight: 600;
    padding: 12px;
    background: var(--success-bg);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.82rem;
}

/* === PAGE TITLE === */
.page-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 2px;
}

.page-subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* === FORMS === */
.form-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    max-width: 520px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    color: var(--text);
    background: var(--surface);
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-gold {
    background: linear-gradient(135deg, var(--accent), #b8860b);
    color: #fff;
    box-shadow: var(--shadow-gold);
}

.btn-gold:hover {
    box-shadow: 0 5px 16px rgba(201, 168, 76, 0.35);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger-sm {
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-danger-sm:hover {
    background: var(--danger);
    color: #fff;
    text-decoration: none;
}

.btn-edit-sm {
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(26, 31, 54, 0.04);
    color: var(--primary);
    border: 1px solid rgba(26, 31, 54, 0.12);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-edit-sm:hover {
    background: var(--primary);
    color: #fff;
    text-decoration: none;
}

/* === FILTER BAR === */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 12px;
}

.filter-bar .form-group {
    margin-bottom: 0;
    flex: 1;
}

.filter-bar .btn {
    margin-bottom: 0;
}

/* === TABLE === */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

table thead th {
    background: var(--primary);
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

table tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
}

table tbody tr {
    transition: var(--transition);
}

table tbody tr:hover {
    background: var(--accent-glow);
}

table tbody tr:last-child td {
    border-bottom: none;
}

table tfoot th {
    padding: 10px 12px;
    text-align: right;
    font-size: 0.8rem;
}

table tfoot tr.total-row {
    background: var(--surface-3);
}

table tfoot tr.grand-total {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

table tfoot tr.grand-total th {
    color: #fff;
    font-size: 0.88rem;
    padding: 12px;
}

.aksi-cell {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* === MESSAGES === */
.alert {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 10px;
    animation: slideDown 0.2s ease;
}

.alert-success {
    background: var(--success-bg);
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-error {
    background: var(--danger-bg);
    color: #991b1b;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

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

/* === LOGIN === */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #0f1729 100%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-card .login-logo {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #b8860b);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    box-shadow: var(--shadow-gold);
}

.login-card .login-logo span {
    font-size: 1.3rem;
    font-weight: 800;
    color: #fff;
}

.login-card h2 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
}

.login-card .login-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.login-card .form-group {
    text-align: left;
}

.login-card .btn-gold {
    width: 100%;
    padding: 12px;
    font-size: 0.9rem;
    margin-top: 6px;
}

.login-card #login-msg {
    margin-top: 12px;
}

/* === GRAFIK === */
.chart-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    height: 100%;
}

.chart-container {
    position: relative;
    height: calc(100vh - 200px);
    max-height: 420px;
    width: 100%;
    margin: 0 auto;
}

/* === LOADING STATE === */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 10px;
}

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

/* === SCROLLBAR === */
#page-content::-webkit-scrollbar {
    width: 5px;
}

#page-content::-webkit-scrollbar-track {
    background: transparent;
}

#page-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

#page-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    html, body {
        overflow: auto;
        height: auto;
    }

    .container {
        padding: 10px 12px;
        height: auto;
        min-height: 100vh;
    }

    #page-content {
        overflow: visible;
    }

    .header-bar {
        padding: 8px 14px;
    }

    nav a {
        padding: 7px 8px;
        font-size: 0.72rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .stat-card .stat-value {
        font-size: 1.3rem;
    }

    .form-card {
        padding: 16px;
        max-width: 100%;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    table {
        font-size: 0.72rem;
    }

    table thead th,
    table tbody td,
    table tfoot th {
        padding: 7px 8px;
    }

    .chart-container {
        height: 280px;
        max-height: none;
    }

    .page-title {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    nav {
        flex-wrap: wrap;
    }

    nav a {
        flex: 0 0 calc(33.33% - 4px);
    }

    .header-bar .user-info span {
        display: none;
    }

    .aksi-cell {
        flex-direction: column;
        gap: 3px;
    }
}

/* === UTILITY === */
.text-success { color: var(--success); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
