:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --text: #1f2733;
    --text-muted: #6b7785;
    --border: #e2e6ec;
    --primary: #3563e9;
    --primary-hover: #2a4fc4;
    --secondary: #eef1f6;
    --secondary-text: #33414f;
    --danger: #e35353;
    --green: #1faa59;
    --green-bg: #e4f8ec;
    --yellow: #b88a00;
    --yellow-bg: #fff6da;
    --red: #d6433f;
    --red-bg: #fde7e6;
    --shadow: 0 1px 3px rgba(20, 30, 50, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #11161f;
        --surface: #1b212d;
        --text: #e7ebf3;
        --text-muted: #97a3b6;
        --border: #2c3442;
        --primary: #5b85f5;
        --primary-hover: #4a6fe0;
        --secondary: #262e3d;
        --secondary-text: #d6dde8;
        --danger: #f17575;
        --green: #3fcf8e;
        --green-bg: #163326;
        --yellow: #f0c14b;
        --yellow-bg: #3a2f10;
        --red: #f17575;
        --red-bg: #3a1d1d;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Topbar ===== */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
    text-decoration: none;
}

.nav a {
    margin-left: 20px;
    text-decoration: none;
    color: var(--secondary-text);
    font-weight: 500;
}

.nav a:hover {
    color: var(--primary);
}

main.container {
    padding-top: 30px;
    padding-bottom: 50px;
    min-height: calc(100vh - 160px);
}

/* ===== Hero ===== */
.hero {
    text-align: center;
    padding: 50px 20px;
}

.hero h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.hero p {
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 25px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease;
}

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

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

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

.btn-secondary:hover {
    filter: brightness(0.95);
}

.btn-danger {
    background: var(--red-bg);
    color: var(--red);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    font-size: 1.2rem;
    line-height: 1;
}

/* ===== Stats grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin: 30px 0;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Card / Form ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.card h1 {
    margin-top: 0;
}

.auth-card {
    max-width: 420px;
    margin: 40px auto;
}

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

.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

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

.anggota-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
}

.form-actions {
    margin-top: 24px;
}

fieldset {
    border: none;
    padding: 0;
    margin: 0;
    min-width: 0;
}

fieldset:disabled {
    opacity: 0.6;
}

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success {
    background: var(--green-bg);
    color: var(--green);
}

.alert-error {
    background: var(--red-bg);
    color: var(--red);
}

/* ===== Progress page ===== */
.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.progress-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.last-updated {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.stats-grid-progress {
    margin-top: 24px;
}

.toolbar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
}

.sort-select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
}

.table-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow-x: auto;
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.data-table th {
    background: var(--secondary);
    color: var(--secondary-text);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.data-table tbody tr:hover {
    background: var(--secondary);
}

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

/* Lebar kolom tetap pada tabel progress agar semua kolom selalu terlihat (word wrap) */
#dataTable {
    table-layout: fixed;
}

#dataTable th:nth-child(1), #dataTable td:nth-child(1) { width: 8%; }
#dataTable th:nth-child(2), #dataTable td:nth-child(2) { width: 15%; }
#dataTable th:nth-child(3), #dataTable td:nth-child(3) { width: 21%; }
#dataTable th:nth-child(4), #dataTable td:nth-child(4) { width: 21%; }
#dataTable th:nth-child(5), #dataTable td:nth-child(5) { width: 10%; }
#dataTable th:nth-child(6), #dataTable td:nth-child(6) { width: 15%; }
#dataTable th:nth-child(7), #dataTable td:nth-child(7) { width: 10%; }

.member-list {
    margin: 0;
    padding-left: 18px;
}

.member-list li {
    margin-bottom: 2px;
}

.member-list li:last-child {
    margin-bottom: 0;
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
}

.badge-green {
    background: var(--green-bg);
    color: var(--green);
}

.badge-yellow {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.badge-red {
    background: var(--red-bg);
    color: var(--red);
}

.badge-cache {
    background: var(--yellow-bg);
    color: var(--yellow);
}

.hidden {
    display: none !important;
}

.link-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0;
}

.link-btn:hover {
    text-decoration: underline;
}

/* ===== Skeleton loading ===== */
.skeleton-cell {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--secondary) 25%, var(--border) 50%, var(--secondary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.4s ease infinite;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal {
    background: var(--surface);
    border-radius: 12px;
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

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

.modal-body {
    padding: 18px 24px;
    overflow-y: auto;
}

.commit-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.commit-item:last-child {
    border-bottom: none;
}

.commit-message {
    font-weight: 600;
    margin-bottom: 4px;
}

.commit-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

/* ===== Footer ===== */
.footer {
    border-top: 1px solid var(--border);
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== Responsive ===== */
@media (max-width: 720px) {
    .form-row {
        grid-template-columns: 1fr;
    }

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

    .progress-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .data-table th,
    .data-table td {
        padding: 8px;
        font-size: 0.8rem;
    }
}
