:root {
    --bg: #F7F8FA;
    --surface: #ffffff;
    --border: rgba(15, 23, 42, 0.08);
    --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
    --text: #0F172A;
    --text-muted: #64748B;
    --text-faint: #94A3B8;

    --accent: #2563EB;
    --accent-dark: #1D4ED8;
    --accent-soft-bg: #EFF6FF;
    --accent-soft-text: #1D4ED8;
    --accent-helper: #6366F1;
    --hero-gradient: linear-gradient(135deg, #2563EB 0%, #6366F1 100%);

    --success-bg: #DCFCE7;
    --success-text: #15803D;
    --success-dot: #22C55E;

    --pending-bg: #FEF3C7;
    --pending-text: #92400E;
    --pending-dot: #F59E0B;

    --failed-bg: #FEE2E2;
    --failed-text: #B91C1C;
    --failed-dot: #EF4444;

    --neutral-bg: #F1F5F9;
    --neutral-text: #64748B;
    --neutral-dot: #CBD5E1;

    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 500px at 85% -10%, rgba(99,102,241,.08), transparent 60%),
        radial-gradient(900px 500px at -10% 0%, rgba(99,102,241,.05), transparent 60%),
        var(--bg);
    min-height: 100vh;
}

.topnav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 32px;
}
.topnav .brand { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 14px 6px 6px;
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow);
}
.user-chip:hover { border-color: var(--accent); }
.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-soft-bg);
    color: var(--accent-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}
.user-chip .chevron { color: var(--text-faint); font-size: 10px; }

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 8px 32px 64px;
}
.container-narrow { max-width: 440px; }

.page-header { margin-bottom: 24px; }


.hero-welcome {
    background: var(--hero-gradient);
    border-radius: var(--radius-lg);
    color: #fff;
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.hero-welcome h1 { color: #fff; font-size: 26px; }
.hero-welcome .subtitle { color: rgba(255,255,255,0.85); margin-bottom: 0; }
.hero-icon {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 10px;
}
.hero-icon svg { width: 100%; height: 100%; }
@media (max-width: 640px) { .hero-icon { display: none; } }

h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 700; margin-top: 40px; }
.subtitle { color: var(--text-muted); font-size: 14px; margin: 0 0 24px; line-height: 1.5; }

/* Connection status summary bar */
.status-summary {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
}
.status-summary-count {
    min-width: 180px;
}
.status-summary-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.status-summary-value {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.status-summary-list {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    flex: 1;
}
.status-summary-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.status-summary-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-summary-item .name { font-weight: 600; }
.status-summary-item .state { color: var(--text-muted); display: block; font-size: 11.5px; }

/* Service cards */
.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.service-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.3s ease;
}
.service-card:not(.is-disabled):hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.1);
    border-color: rgba(37, 99, 235, 0.25);
}
.service-card.is-disabled { opacity: 0.6; }
.service-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.service-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}
.service-icon svg { width: 22px; height: 22px; }
.service-name { font-weight: 700; font-size: 15px; margin: 2px 0 0; }
.service-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin: 0; }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    width: fit-content;
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.status-success { background: var(--success-bg); color: var(--success-text); }
.status-success .dot { background: var(--success-dot); }
.status-pending { background: var(--pending-bg); color: var(--pending-text); }
.status-pending .dot { background: var(--pending-dot); }
.status-failed { background: var(--failed-bg); color: var(--failed-text); }
.status-failed .dot { background: var(--failed-dot); }
.status-neutral { background: var(--neutral-bg); color: var(--neutral-text); }
.status-neutral .dot { background: var(--neutral-dot); }

.btn, button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    margin-top: auto;
    transition: background 0.2s ease, transform 0.15s ease;
}
.btn:active, button:active { transform: scale(0.98); }
.btn-soft { background: var(--accent-soft-bg); color: var(--accent-soft-text); }
.btn-soft:hover { background: #E0E7FF; }
.btn-solid, button[type="submit"] { background: var(--accent); color: #fff; }
.btn-solid:hover, button[type="submit"]:hover { background: var(--accent-dark); }
.btn-disabled { background: var(--neutral-bg); color: var(--text-faint); cursor: not-allowed; }

/* Auth & form cards -- pakai animasi hover yang sama kayak service card */
.auth-box, .form-card {
    max-width: 400px;
    margin: 90px auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 36px;
    transition: all 0.3s ease;
}
.auth-box:hover, .form-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.1);
    border-color: rgba(37, 99, 235, 0.2);
}
.form-card { margin: 24px 0; max-width: none; }
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text-muted);
}
.req { color: var(--failed-dot); }

input[type="text"], input[type="email"], input[type="password"], select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: #FBFCFD;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input:hover, select:hover {
    border-color: rgba(37, 99, 235, 0.4);
    background: #fff;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft-bg);
    background: #fff;
}
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    padding-right: 36px;
    cursor: pointer;
}

.switch-link { font-size: 13px; text-align: center; margin-top: 18px; color: var(--text-muted); }
.switch-link a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }

.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 18px;
    font-weight: 500;
}
.alert-error { background: var(--failed-bg); color: var(--failed-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    text-decoration: none;
    padding: 8px 16px 8px 12px;
    border-radius: 999px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}
.back-link:hover {
    color: var(--accent-dark);
    border-color: var(--accent);
    transform: translateX(-2px);
}
.back-link .arrow { font-size: 15px; line-height: 1; }

code {
    background: var(--neutral-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    font-size: 13px;
    margin-top: 12px;
    box-shadow: var(--shadow);
}
.history-table th, .history-table td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.history-table th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.history-table tr:last-child td { border-bottom: none; }
.empty { color: var(--text-faint); text-align: center; padding: 32px; }

.checkbox-input {
    width: 20px;
    height: 20px;
    margin-top: 8px;
    accent-color: var(--accent);
    cursor: pointer;
}
.conditional-field {
    padding-left: 4px;
    border-left: 2px solid var(--accent-soft-bg);
    margin-bottom: 4px;
}
