* {
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    margin: 0;
    background: #f1f5f9;
    color: #1e293b;
}

/* =====================================================================
   OVERLAY & MODAL
   ===================================================================== */
#systemOverlay,
#supervisionSavingOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.92);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    z-index: 9000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-card {
    background: #ffffff;
    border-radius: 14px;
    padding: 22px;
    max-width: 540px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
}

.conflict-box {
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 12.5px;
}

.kangtoa-pulse-logo {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    margin-bottom: 12px;
    animation: pulseGlow 1.8s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 6px rgba(0, 168, 132, 0.4)); }
    50% { transform: scale(1.06); filter: drop-shadow(0 0 16px rgba(0, 210, 165, 0.85)); }
}

/* =====================================================================
   LOGIN VIEW
   ===================================================================== */
.login-container {
    display: none;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #064e3b 100%);
    padding: 20px;
}

.login-box {
    background: #ffffff;
    padding: 32px 28px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

.login-logo {
    display: block;
    max-width: 240px;
    width: 100%;
    height: auto;
    margin: 0 auto 14px auto;
}

/* =====================================================================
   FORM INPUTS & BUTTONS
   ===================================================================== */
label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 5px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="time"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    color: #0f172a;
    background: #ffffff;
    margin-bottom: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #00a884;
    box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    background: #00a884;
    color: #ffffff;
    transition: background 0.15s, transform 0.1s;
}

.btn:hover:not(:disabled) {
    background: #008f6f;
}

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

.btn-primary { background: #2563eb; color: #ffffff; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }

.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-secondary:hover:not(:disabled) { background: #cbd5e1; }

.btn-warning { background: #f59e0b; color: #ffffff; }
.btn-warning:hover:not(:disabled) { background: #d97706; }

.btn-danger { background: #dc2626; color: #ffffff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-purple { background: #7c3aed; color: #ffffff; }
.btn-purple:hover:not(:disabled) { background: #6d28d9; }

/* =====================================================================
   APP LAYOUT & SIDEBAR
   ===================================================================== */
.app-layout {
    display: none;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.25s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar.collapsed {
    width: 68px;
}

.sidebar.collapsed .sidebar-brand-full,
.sidebar.collapsed .sidebar-user-box,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .btn-text {
    display: none;
}

.sidebar.collapsed .sidebar-brand-mini {
    display: block;
}

.sidebar-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 12px;
    border-bottom: 1px solid #1e293b;
}

.sidebar-brand-full {
    max-width: 175px;
    height: auto;
}

.sidebar-brand-mini {
    display: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
}

.sidebar-toggle-btn {
    background: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
}

.sidebar-user-box {
    padding: 12px 14px;
    background: #1e293b;
    margin: 10px 12px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.5;
}

.role-pill {
    display: inline-block;
    background: #00a884;
    color: #ffffff;
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    margin: 2px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #cbd5e1;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
    background: #1e293b;
    color: #ffffff;
}

.nav-item.active {
    background: #00a884;
    color: #ffffff;
    font-weight: 600;
}

.nav-icon {
    font-size: 16px;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.restart-btn,
.shutdown-btn,
.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.restart-btn { background: #1e40af; color: #ffffff; }
.shutdown-btn { background: #991b1b; color: #ffffff; }
.logout-btn { background: #334155; color: #f8fafc; }

/* =====================================================================
   MAIN CONTENT & LIVE CMD MONITOR
   ===================================================================== */
.main-content {
    flex: 1;
    padding: 16px 20px;
    min-width: 0;
    overflow-x: hidden;
}

.global-cmd-wrap {
    background: #0c0c0c;
    border: 1px solid #334155;
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cmd-titlebar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1e293b;
    color: #e2e8f0;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    flex-wrap: wrap;
    gap: 6px;
}

.cmd-title-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-menu-btn {
    display: none;
    background: #334155;
    border: none;
    color: white;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
}

.cmd-badge-icon {
    background: #00a884;
    color: #0f172a;
    font-family: Consolas, monospace;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 4px;
}

.cmd-controls {
    display: flex;
    gap: 4px;
}

.cmd-filter-btn,
.cmd-win-btn {
    background: #334155;
    border: none;
    color: #cbd5e1;
    font-size: 10.5px;
    padding: 3px 7px;
    border-radius: 4px;
    cursor: pointer;
}

.cmd-filter-btn.active {
    background: #00a884;
    color: #ffffff;
    font-weight: 700;
}

.cmd-body {
    height: 115px;
    overflow-y: auto;
    padding: 8px 12px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 11.5px;
    line-height: 1.45;
    color: #d1d5db;
    transition: height 0.2s;
}

.cmd-body.collapsed {
    height: 0;
    padding: 0 12px;
    overflow: hidden;
}

.cmd-time { color: #64748b; }
.cmd-tag-munding { color: #38bdf8; font-weight: bold; }
.cmd-tag-kuli { color: #a78bfa; font-weight: bold; }
.cmd-tag-sys { color: #34d399; font-weight: bold; }
.cmd-msg-active { color: #f8fafc; }
.cmd-msg-idle { color: #94a3b8; }
.cmd-msg-err { color: #f87171; font-weight: bold; }

/* =====================================================================
   CARDS, GRIDS & PAGES
   ===================================================================== */
.page-section {
    display: none;
}

.page-section.active {
    display: block;
}

.card {
    background: #ffffff;
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.menu-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.grid-pool {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px;
}

/* =====================================================================
   SOP BOX, ROLE CHIPS & MUNDING POOL STATUS
   ===================================================================== */
.sop-box {
    display: none;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 12px 14px;
    margin-top: 10px;
    margin-bottom: 12px;
    font-size: 12px;
}

.sop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    margin-top: 8px;
}

.sop-item {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 9px 11px;
    line-height: 1.45;
}

.role-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 5px;
}

.role-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    margin: 0;
}

.role-chip input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.status-badge {
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
}

.status-badge.connected { background: #dcfce7; color: #166534; }
.status-badge.standby { background: #fef3c7; color: #92400e; }
.status-badge.banned { background: #fee2e2; color: #991b1b; }

.health-pill {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

.health-healthy { background: #dcfce7; color: #15803d; }
.health-warmup { background: #fef3c7; color: #b45309; }
.health-probation { background: #ede9fe; color: #6d28d9; }
.health-banned { background: #fee2e2; color: #b91c1c; }

.qr-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
}

.qr-code {
    width: 180px;
    height: 180px;
    border-radius: 8px;
}

.mascot-standby-box {
    margin-top: 12px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-align: center;
}

.mascot-standby-box img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    margin-bottom: 6px;
}

.dukun-alert-box {
    margin-top: 12px;
    padding: 11px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    font-size: 12px;
}

/* =====================================================================
   TABLES, PROGRESS & DATASET SUPERVISION
   ===================================================================== */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

th, td {
    padding: 9px 10px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
}

th {
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 2;
}

.supervision-table-viewport {
    max-height: 68vh;
    overflow: auto;
    margin-top: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.mining-banner {
    display: none;
    align-items: center;
    gap: 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 10px 14px;
    margin-top: 10px;
}

.mining-banner img {
    width: 44px;
    height: 44px;
    margin: 0;
}

.progress-container {
    width: 100%;
    height: 10px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 5px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00a884, #3b82f6);
    transition: width 0.3s ease;
}

.intent-tags-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.intent-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}

.intent-tag span {
    cursor: pointer;
    color: #dc2626;
    font-weight: 900;
}

.intent-add-row {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
}

.intent-add-row input {
    margin: 0;
    padding: 4px 7px;
    font-size: 11.5px;
}

.intent-add-row button {
    padding: 4px 8px;
}

.suggested-intent-box {
    background: #fffbeb;
    border: 1px dashed #f59e0b;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 11px;
    margin-bottom: 6px;
}

.pill-badge {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
}

.pill-vip { background: #fef3c7; color: #b45309; }
.pill-new { background: #f1f5f9; color: #475569; }
.pill-db { background: #dbeafe; color: #1d4ed8; }
.pill-retorika { background: #f3e8ff; color: #7e22ce; }

.lock-banner {
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 5px;
    margin-top: 5px;
}

.lock-other { background: #fee2e2; color: #991b1b; }
.lock-self { background: #dcfce7; color: #166534; }

.row-locked-other { background: #fef2f2; opacity: 0.78; }
.row-locked-self { background: #f0fdf4; }

.log-box {
    background: #0f172a;
    color: #e2e8f0;
    font-family: Consolas, monospace;
    font-size: 12px;
    padding: 12px;
    border-radius: 8px;
    max-height: 180px;
    overflow-y: auto;
    margin-top: 8px;
}

/* =====================================================================
   KARTU KHUSUS NGARONDA NOMOR WA & LENCANA KEDEKATAN FLUKTUATIF
   ===================================================================== */
.validator-card {
    border-top: 4px solid #0f766e;
    background: linear-gradient(180deg, #f0fdfa 0%, #ffffff 35%);
}

.validator-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.v-stat-box {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 12px;
    text-align: center;
}

.v-stat-label {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}

.v-stat-val {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
    margin-top: 2px;
}

.rel-pill {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
}

.rel-BELUM_KENALAN { background: #f1f5f9; color: #475569; }
.rel-SUDAH_KENALAN { background: #e0f2fe; color: #0369a1; }
.rel-BERTEMAN { background: #dcfce7; color: #15803d; }
.rel-AKRAB { background: #fef3c7; color: #b45309; border: 1px solid #f59e0b; }
.rel-SOBAT { background: #fce7f3; color: #be185d; border: 1px solid #f472b6; }

.sender-meta-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px 6px;
    margin-bottom: 6px;
    font-size: 10.5px;
    color: #334155;
}

/* =====================================================================
   RESPONSIVE MOBILE DRAWER
   ===================================================================== */
.mobile-drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 95;
}

@media (max-width: 768px) {
    .mobile-menu-btn { display: inline-block; }
    .sidebar {
        position: fixed;
        left: -270px;
        top: 0;
        bottom: 0;
        transition: left 0.25s ease;
    }
    .sidebar.mobile-open {
        left: 0;
    }
}