@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* Simplified Professional Design System - JMA3 Hosting */
:root {
    --color-black: #020202;
    --color-forest: #0d2818;
    --color-emerald: #04471c;
    --color-brand: #058c42;
    --color-neon: #16db65;
    
    --bg-main: #f4f7f5;
    --bg-surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --sidebar-bg: #0d2818;
    --sidebar-text: #ffffff;
    --sidebar-text-muted: #94a3b8;
    --sidebar-active: #058c42;
    
    --font-primary: 'Plus Jakarta Sans', sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 20px rgba(13, 40, 24, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-primary); background: var(--bg-main); color: var(--text-main); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.02em; color: var(--color-forest); }
a { color: var(--color-brand); text-decoration: none; font-weight: 500; }
.hidden { display: none !important; }

/* Dashboard layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; box-shadow: 4px 0 15px rgba(0,0,0,0.05); }
.sidebar-header { padding: 1.75rem 1.5rem; font-size: 1.35rem; font-weight: 700; color: #ffffff; letter-spacing: -0.03em; border-bottom: 1px solid rgba(255,255,255,0.06); }
.sidebar-header span { color: var(--color-neon); }
.sidebar-nav { display: flex; flex-direction: column; gap: 0.35rem; padding: 1.5rem 1.25rem; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; color: var(--sidebar-text-muted); border-radius: 8px; font-weight: 600; font-size: 0.9rem; transition: all 0.2s ease; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #ffffff; }
.nav-item.active { background: var(--sidebar-active); color: #ffffff; box-shadow: 0 2px 8px rgba(5, 140, 66, 0.3); }
.sidebar-footer { padding: 1.25rem; border-top: 1px solid rgba(255,255,255,0.06); font-size: 0.85rem; }

/* Main layout plane */
.main-content { flex: 1; margin-left: 260px; padding: 3rem 4rem; max-width: 1300px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2.5rem; }
.topbar h2 { font-size: 1.8rem; color: var(--color-black); }
.status-pill { background: rgba(5, 140, 66, 0.08); color: var(--color-brand); padding: 0.35rem 0.85rem; border-radius: 20px; font-weight: 700; font-size: 0.75rem; border: 1px solid rgba(5, 140, 66, 0.2); text-transform: uppercase; letter-spacing: 0.05em; }

/* Premium Grid Cards */
.grid-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.75rem; margin-top: 1.75rem; }
@media (max-width: 1024px) { .grid-cards { grid-template-columns: 1fr; } }
.card { background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 14px; padding: 1.75rem; box-shadow: var(--shadow-md); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.card:hover { box-shadow: 0 8px 30px rgba(13, 40, 24, 0.08); }
.card-header { font-weight: 600; color: var(--text-muted); margin-bottom: 0.5rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.card-val { font-size: 2.2rem; font-weight: 700; color: var(--color-black); letter-spacing: -0.03em; }

/* Professional Buttons & Forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.65rem 1.35rem; border-radius: 8px; font-weight: 600; cursor: pointer; border: none; font-size: 0.85rem; line-height: 1.2; transition: all 0.2s ease; outline: none; }
.btn-primary { background: var(--color-forest); color: #ffffff; box-shadow: 0 2px 6px rgba(13, 40, 24, 0.2); }
.btn-primary:hover { background: var(--color-black); transform: translateY(-1px); }
.btn-success { background: var(--color-brand); color: #ffffff; box-shadow: 0 2px 6px rgba(5, 140, 66, 0.2); }
.btn-success:hover { background: #047637; transform: translateY(-1px); }
.btn-danger { background: #ef4444; color: #ffffff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { border: 1px solid var(--border-color); background: var(--bg-surface); color: var(--text-main); font-weight: 600; }
.btn-outline:hover { background: #f8fafc; border-color: #cbd5e1; }

.form-group { margin-bottom: 1.35rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.45rem; color: var(--text-main); }
.input-group { display: flex; align-items: center; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; background: var(--bg-surface); transition: border-color 0.2s ease; }
.input-group:focus-within { border-color: var(--color-brand); box-shadow: 0 0 0 3px rgba(5, 140, 66, 0.1); }
.input-group input { flex: 1; border: none; padding: 0.65rem 1rem; font-family: inherit; font-size: 0.9rem; color: var(--text-main); outline: none; background: transparent; }
.input-group span { background: #f8fafc; padding: 0.65rem 1rem; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); border-left: 1px solid var(--border-color); }
.form-control { width: 100%; padding: 0.65rem 1rem; border: 1px solid var(--border-color); border-radius: 8px; font-family: inherit; font-size: 0.9rem; outline: none; transition: all 0.2s ease; }
.form-control:focus { border-color: var(--color-brand); box-shadow: 0 0 0 3px rgba(5, 140, 66, 0.1); }

/* Modals & Friendly Toasts */
.toast-container { position: fixed; top: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.75rem; }
.toast { background: var(--color-black); color: #ffffff; padding: 1rem 1.35rem; border-radius: 10px; border-left: 4px solid var(--color-neon); font-size: 0.85rem; font-weight: 600; box-shadow: 0 10px 25px rgba(0,0,0,0.15); animation: slideIn 0.2s ease; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-card { background: var(--bg-surface); padding: 2.5rem; border-radius: 16px; width: 100%; max-width: 520px; box-shadow: 0 20px 40px rgba(0,0,0,0.2); border: 1px solid var(--border-color); }

/* Landing Auth Shell */
.auth-wrapper { max-width: 440px; margin: 5rem auto; padding: 3rem; background: var(--bg-surface); border-radius: 20px; border: 1px solid var(--border-color); box-shadow: 0 10px 30px rgba(13, 40, 24, 0.05); }

/* --- Utility & Refactored Component Classes --- */
.d-flex { display: flex; }
.d-block { display: block; }
.d-inline-flex { display: inline-flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }

.m-auto { margin: auto; }
.mt-0 { margin-top: 0; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mt-5 { margin-top: 2.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 0.75rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2rem; }
.mb-6 { margin-bottom: 2.5rem; }
.mr-2 { margin-right: 0.5rem; }
.p-0 { padding: 0; }

.w-100 { width: 100%; }
.text-center { text-align: center; }

.text-inherit { color: inherit; }
.text-none { text-decoration: none; }
.text-muted { color: var(--text-muted); }
.text-sidebar-muted { color: var(--sidebar-text-muted); }
.text-neon { color: var(--color-neon); }
.text-brand { color: var(--color-brand); }
.text-black { color: var(--color-black); }
.text-danger { color: #ef4444; }

.font-bold { font-weight: 700; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.85rem; }
.text-lg { font-size: 1.1rem; }
.text-xl { font-size: 1.6rem; }
.text-uppercase { text-transform: uppercase; }
.tracking-sm { letter-spacing: 0.05em; }
.tracking-md { letter-spacing: 0.08em; }
.cursor-pointer { cursor: pointer; }

/* Custom Components */
.sidebar-link { color: inherit; text-decoration: none; }
.sidebar-logout-btn { width: 100%; padding: 0.45rem; background: rgba(255,255,255,0.06); color: #fff; border-color: rgba(255,255,255,0.1); }
.sidebar-logout-btn:hover { background: rgba(255,255,255,0.1); }

.add-website-panel { margin-top: 2.5rem; border-left: 4px solid var(--color-brand); display: flex; justify-content: space-between; align-items: center; }
.modal-dialog { border: none; border-radius: 12px; padding: 2rem; box-shadow: 0 10px 40px rgba(0,0,0,0.2); max-width: 400px; width: 100%; margin: auto; }

.site-stats-panel { display: flex; gap: 1.5rem; margin-bottom: 2.5rem; background: #f8fafc; padding: 1.25rem 2rem; border-radius: 12px; border: 1px solid var(--border-color); flex-wrap: wrap; }
.stat-divider { border-left: 1px solid var(--border-color); padding-left: 1.5rem; }

.grafana-container { background: var(--color-black); border: 1px solid rgba(5,140,66,0.3); border-radius: 16px; overflow: hidden; box-shadow: 0 20px 40px rgba(0,0,0,0.1); }
.grafana-header { background: rgba(255,255,255,0.03); padding: 1.25rem 2rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.06); }
.grafana-canvas-wrap { height: 450px; background: rgba(0,0,0,0.2); overflow: hidden; }
.grafana-canvas-wrap iframe { width: 100%; height: 100%; border: none; display: block; }
.grafana-loading { display: flex; align-items: center; justify-content: center; height: 100%; }
.grafana-logs-wrap { padding: 1.5rem 2rem; background: rgba(255,255,255,0.01); border-top: 1px solid rgba(255,255,255,0.05); }

.logs-table { width: 100%; text-align: left; font-family: monospace; font-size: 0.85rem; color: #cbd5e1; border-collapse: collapse; }
.logs-th { padding-bottom: 0.4rem; }
.logs-tr { color: var(--sidebar-text-muted); border-bottom: 1px solid rgba(255,255,255,0.1); }

.btn-metric { padding: 0.4rem 0.8rem; color: #fff; border-color: rgba(255,255,255,0.1); }
.btn-metric-active { background: var(--color-brand) !important; }

.secret-code-display { font-size: 0.85rem; color: var(--color-black); font-weight: bold; cursor: pointer; }
.copy-btn-mini { padding: 0.2rem 0.4rem; font-size: 0.7rem; min-width: auto; display: none; }

.text-forest { color: var(--color-forest); }
.text-white { color: #fff; }
.mt-1 { margin-top: 0.5rem; }
.w-200 { width: 200px; }

.auth-tabs-panel { display: flex; gap: 0.5rem; margin-bottom: 1.75rem; background: #f8fafc; padding: 4px; border-radius: 8px; border: 1px solid var(--border-color); }
.auth-tab-btn { flex: 1; border: none; background: transparent; }

.hero-card { background: linear-gradient(135deg, var(--color-forest), var(--color-brand)); padding: 2.5rem; border-radius: 16px; color: #ffffff; box-shadow: 0 10px 30px rgba(5,140,66,0.15); }
.hero-label { color: rgba(255,255,255,0.9); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.hero-val { font-size: 1.6rem; font-weight: 700; color: var(--color-neon); margin-bottom: 0.5rem; letter-spacing: -0.02em; }
.hero-desc { font-size: 0.9rem; color: rgba(255,255,255,0.8); }

/* Mobile First Adjustments */
@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    .sidebar { position: relative; width: 100%; height: auto; box-shadow: none; z-index: 10; border-bottom: 2px solid var(--color-brand); }
    .sidebar-header { padding: 1.25rem 1rem; text-align: center; }
    .sidebar-nav { padding: 0.5rem 1rem; flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.06); }
    .sidebar-footer { padding: 1rem; display: flex; justify-content: space-between; align-items: center; flex-direction: row; }
    .sidebar-footer p { margin-bottom: 0 !important; font-size: 0.75rem; text-align: left; }
    .sidebar-footer button { width: auto !important; padding: 0.4rem 1rem !important; }
    .main-content { margin-left: 0; padding: 1.5rem 1rem; }
    .topbar { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .auth-wrapper { margin: 2rem auto; padding: 2rem 1.5rem; }
    
    /* Site page specific tweaks */
    #site-ws > div[style*="display:flex"] { flex-direction: column; gap: 1rem !important; padding: 1rem !important; }
    #site-ws > div[style*="display:flex"] > div { border-left: none !important; padding-left: 0 !important; border-top: 1px solid var(--border-color); padding-top: 0.5rem; }
    #site-ws > div[style*="display:flex"] > div:first-child { border-top: none; padding-top: 0; }
}

.site-card { border-left: 4px solid var(--color-brand); }
.site-card-btn { flex: 1; justify-content: center; padding: 0.4rem; font-size: 0.8rem; }
.secret-code-panel { background: #f8fafc; border: 1px solid var(--border-color); border-radius: 6px; padding: 0.6rem 0.8rem; margin-bottom: 1rem; display: flex; justify-content: space-between; align-items: center; }
.copy-btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    transition: all 0.2s ease;
    min-width: auto;
    cursor: pointer;
}
.copy-btn-sm:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--color-brand);
}
.text-2xs { font-size: 0.7rem; }

.site-title-link { color: var(--color-black); text-decoration: none; display: inline-flex; align-items: center; gap: 0.35rem; transition: color 0.2s; }
.site-title-link:hover { color: var(--color-brand); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; border-radius: 6px; }
.logs-td { padding: 0.4rem 0; }
.receipt-card { padding: 0.6rem 0.8rem; background: rgba(5,140,66,0.04); border-left: 3px solid var(--color-brand); margin-bottom: 8px; border-radius: 4px; font-size: 0.85rem; }
.pull-right { float: right; }
.btn-danger-outline { color: #ef4444; border: 1px solid #ef4444; background: transparent; }
.btn-danger-outline:hover { background: #fef2f2; color: #dc2626; border-color: #dc2626; }
.font-mono { font-family: monospace; }
.code-highlight {
    background: #f8fafc;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-family: var(--font-mono, monospace);
    font-size: 0.8rem;
    color: #334155;
}
.secret-code-display {
    cursor: pointer;
    transition: all 0.2s ease;
}
.secret-code-display:hover {
    background: #e2e8f0;
    color: var(--color-forest);
    border-color: #cbd5e1;
}

/* Premium Custom Select Dropdown */
.premium-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.65rem center;
    background-repeat: no-repeat;
    background-size: 1.1rem;
    padding-right: 2rem !important;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-surface);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    outline: none;
    transition: all 0.2s ease;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.premium-select:hover {
    border-color: #cbd5e1;
    background-color: #f8fafc;
}
.premium-select:focus {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(5, 140, 66, 0.1);
}

.back-link { font-size: 0.85rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 0.25rem; margin-bottom: 0.5rem; text-decoration: none; transition: color 0.2s; }
.back-link:hover { color: var(--color-brand); }
.settings-panel { max-width: 600px; }

/* Premium Admin Layout Enhancements */
.admin-tab { display: none; }
.admin-tab.active { display: block; }

.admin-tabs {
    display: inline-flex;
    background: rgba(15, 23, 42, 0.05);
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 2rem;
    gap: 2px;
}
.tab-btn {
    background: transparent;
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.tab-btn:hover {
    color: var(--color-forest);
    background: rgba(255, 255, 255, 0.4);
}
.tab-btn.active {
    color: var(--color-forest);
    background: var(--bg-surface);
    box-shadow: 0 4px 12px rgba(13, 40, 24, 0.06);
}

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(13, 40, 24, 0.04);
    border: 1px solid var(--border-color);
}
.admin-table th {
    background: #f8fafc;
    padding: 1rem 1.25rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}
.admin-table td {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
    color: var(--text-main);
    vertical-align: middle;
    transition: background-color 0.2s ease;
}
.admin-table tr:last-child td {
    border-bottom: none;
}
.admin-table tr:hover td {
    background-color: #f8fafc;
}

/* User Avatars & Badges */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-forest), var(--color-brand));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 2px 6px rgba(13, 40, 24, 0.15);
    flex-shrink: 0;
}

.badge-admin { background: rgba(5, 140, 66, 0.1); color: var(--color-brand); padding: 0.3rem 0.75rem; border-radius: 20px; font-size: 0.75rem; font-weight: 700; border: 1px solid rgba(5, 140, 66, 0.2); }
.badge-root { background: rgba(239,68,68,0.1); color: #ef4444; padding: 0.3rem 0.75rem; border-radius: 20px; font-size: 0.75rem; font-weight: 700; border: 1px solid rgba(239,68,68,0.2); }
.badge-client { background: #f1f5f9; color: var(--text-muted); padding: 0.3rem 0.75rem; border-radius: 20px; font-size: 0.75rem; font-weight: 700; border: 1px solid var(--border-color); }
.badge-disabled { background: #e2e8f0; color: #475569; padding: 0.3rem 0.75rem; border-radius: 20px; font-size: 0.75rem; font-weight: 700; border: 1px solid #cbd5e1; }

/* Inactive and active status pills */
.status-pill-active {
    background: rgba(22, 219, 101, 0.1);
    color: #047637;
    border: 1px solid rgba(22, 219, 101, 0.25);
}
.status-pill-inactive {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.35rem;
}
.pulse-dot-active {
    background-color: var(--color-neon);
    box-shadow: 0 0 0 0 rgba(22, 219, 101, 0.7);
    animation: pulseActive 1.8s infinite;
}
.pulse-dot-inactive {
    background-color: #ef4444;
}
@keyframes pulseActive {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(22, 219, 101, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 5px rgba(22, 219, 101, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(22, 219, 101, 0);
    }
}

.hover-brand:hover { color: var(--color-brand) !important; }

.pb-3 { padding-bottom: 1rem; }
.pt-3 { padding-top: 1rem; }
.border-bottom { border-bottom: 1px solid var(--border-color); }
.border-top { border-top: 1px solid var(--border-color); }
.danger-panel { border: 1px solid #fca5a5; background: #fef2f2; padding: 1.5rem; border-radius: 8px; }

.billing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 2.5rem; margin-bottom: 2.5rem; }
.scroll-list { max-height: 260px; overflow-y: auto; }
.border-danger-left { border-left: 4px solid #ef4444; }
.status-pill-admin { background: #fef2f2; color: #b91c1c; border-color: rgba(239, 68, 68, 0.2); }
.overflow-x-auto { overflow-x: auto; }
.d-grid { display: grid; }