:root {
    --primary-color: #047857;
    --primary-light: #10B981;
    --primary-dark: #064E3B;
    --bg-color: #F0FDF4;
    --card-bg: #FFFFFF;
    --text-main: #1F2937;
    --border-color: #D1D5DB;
    --gradient-primary: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 55%, var(--primary-dark) 100%);
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(160deg, #F5FEFA 0%, var(--bg-color) 45%, #E7F9F0 100%);
    background-attachment: fixed;
    color: var(--text-main);
    margin: 0;
}

/* ---------- Auth (login) ---------- */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--card-bg);
    padding: 32px;
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(4, 120, 87, 0.14);
    border-top: 5px solid var(--primary-color);
}
.auth-brand { font-size: 20px; font-weight: 800; color: var(--primary-dark); }
.auth-sub { font-size: 13px; color: #6B7280; margin: 6px 0 20px 0; }

/* ---------- Forms / buttons (dipakai juga di dashboard tool) ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="file"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
.btn {
    display: inline-block;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: var(--gradient-primary);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}
.btn:hover { opacity: 0.92; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-outline { background: none; border: 1px solid #fff; color: #fff; }
.btn-danger { background: #DC2626; }
.btn-secondary { background: #6B7280; }

.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: #FEF2F2; color: #991B1B; border: 1px solid #F87171; }
.alert-success { background: #ECFDF5; color: #065F46; border: 1px solid #34D399; }

/* ---------- Top nav ---------- */
.app-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 12px 24px;
    background: linear-gradient(135deg, #033327 0%, #065F46 50%, #047857 100%);
    color: #fff;
}
.app-nav-brand { font-weight: 800; font-size: 16px; margin-right: 10px; }
.app-nav-links { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.app-nav-links a {
    color: #D1FAE5;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}
.app-nav-links a:hover, .app-nav-links a.active { background: rgba(255,255,255,0.15); color: #fff; }
.app-nav-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.app-nav-user small { opacity: 0.8; }

/* ---------- Status langganan: info bar tenang (kondisi normal) ---------- */
.sub-info-bar {
    padding: 6px 24px;
    font-size: 12px;
    text-align: center;
    color: var(--primary-dark);
    background: #F0FDF4;
    border-bottom: 1px solid #D1FAE5;
}

/* ---------- Status langganan: modal popup countdown (warning & expired) ---------- */
.expiry-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: expiryFadeIn 0.2s ease;
}
.expiry-modal-card {
    position: relative;
    width: 100%;
    max-width: 360px;
    background: #fff;
    border-radius: 20px;
    padding: 34px 26px 26px 26px;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0,0,0,0.30);
    animation: expiryPopIn 0.35s cubic-bezier(.16,1,.3,1);
}
.expiry-modal-card.severity-warning { border-top: 6px solid #F59E0B; }
.expiry-modal-card.severity-expired { border-top: 6px solid #EF4444; }

.expiry-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: #F3F4F6;
    color: #6B7280;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}
.expiry-modal-close:hover { background: #E5E7EB; }

.expiry-modal-ring {
    width: 104px;
    height: 104px;
    border-radius: 50%;
    margin: 0 auto 18px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.severity-warning .expiry-modal-ring { background: linear-gradient(135deg, #FBBF24 0%, #F59E0B 55%, #D97706 100%); box-shadow: 0 10px 24px rgba(245, 158, 11, 0.35); }
.severity-expired .expiry-modal-ring { background: linear-gradient(135deg, #F87171 0%, #EF4444 55%, #B91C1C 100%); box-shadow: 0 10px 24px rgba(239, 68, 68, 0.35); }

.expiry-modal-number { font-size: 34px; font-weight: 900; line-height: 1; }
.expiry-modal-unit { font-size: 10.5px; font-weight: 800; letter-spacing: 1px; opacity: 0.9; margin-top: 2px; }
.expiry-modal-icon { font-size: 40px; line-height: 1; }

.expiry-modal-title { font-size: 17px; font-weight: 800; color: #111827; margin-bottom: 8px; }
.expiry-modal-msg { font-size: 13px; color: #4B5563; line-height: 1.6; margin-bottom: 20px; }
.expiry-modal-date { font-weight: 800; color: #111827; }

@keyframes expiryFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes expiryPopIn {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 420px) {
    .expiry-modal-overlay {
        padding: 16px;
        padding-top: max(16px, env(safe-area-inset-top));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    .expiry-modal-card { padding: 28px 20px 20px 20px; border-radius: 16px; }
    .expiry-modal-ring { width: 88px; height: 88px; margin-bottom: 14px; }
    .expiry-modal-number { font-size: 28px; }
    .expiry-modal-icon { font-size: 34px; }
    .expiry-modal-title { font-size: 16px; }
    .expiry-modal-msg { font-size: 12.5px; }
}

/* ---------- Page shell ---------- */
.page-wrap { max-width: 1100px; margin: 24px auto; padding: 0 20px 40px 20px; }
.page-wrap.narrow { max-width: 620px; }
.page-title { font-size: 20px; font-weight: 800; color: var(--primary-dark); margin-bottom: 4px; }
.page-desc { font-size: 13px; color: #6B7280; margin-bottom: 20px; }

.card {
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(4, 120, 87, 0.1);
    margin-bottom: 20px;
    border-top: 4px solid var(--primary-color);
}

/* ---------- Table ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th, table.data-table td { padding: 9px 10px; border-bottom: 1px solid #E5E7EB; text-align: left; white-space: nowrap; }
table.data-table th { background: #F0FDF4; font-weight: 700; color: var(--primary-dark); }
table.data-table tr:hover { background: #FAFFFC; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-low { background: #ECFDF5; color: #065F46; border: 1px solid #34D399; }
.badge-medium { background: #FFFBEB; color: #92400E; border: 1px solid #F59E0B; }
.badge-high { background: #FEF2F2; color: #991B1B; border: 1px solid #F87171; }
.badge-role { background: #EEF2FF; color: #3730A3; border: 1px solid #A5B4FC; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar select, .filter-bar input { padding: 7px 10px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 13px; }

/* ---------- Paginasi ---------- */
.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 16px; }
.pagination .btn.disabled { opacity: 0.4; pointer-events: none; }

/* ---------- Risk matrix grid (settings) ---------- */
.matrix-table { border-collapse: collapse; font-size: 12px; }
.matrix-table th, .matrix-table td { border: 1px solid var(--border-color); padding: 4px; text-align: center; }
.matrix-table th { background: #F0FDF4; }
.matrix-table select { font-size: 11px; padding: 3px; border-radius: 4px; }

.text-muted { color: #6B7280; font-size: 12px; }
.timer-msg { font-size: 12px; font-weight: 700; color: var(--primary-dark); text-align: center; margin-top: 6px; }

/* ---------- Footer (semua halaman) ---------- */
.app-footer {
    margin-top: 40px;
    padding: 20px 20px 28px 20px;
    text-align: center;
    border-top: 1px solid #D1FAE5;
}
.app-footer-text {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--primary-dark);
    letter-spacing: 0.2px;
    margin-bottom: 4px;
}
.app-footer-copyright {
    font-size: 10.5px;
    font-weight: 700;
    color: #9CA3AF;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}
.logo-preview { max-height: 48px; max-width: 160px; object-fit: contain; margin-top: 8px; border: 1px dashed var(--border-color); padding: 4px; border-radius: 6px; }
