/* Agent Panel — Design System */
:root {
    --bg: #07090d;
    --bg-elevated: #0d1117;
    --surface: #12171f;
    --surface-hover: #181f2a;
    --surface-glass: rgba(18, 23, 31, 0.85);
    --border: rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.1);
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.35);
    --accent-subtle: rgba(99, 102, 241, 0.12);
    --success: #10b981;
    --success-subtle: rgba(16, 185, 129, 0.15);
    --danger: #f43f5e;
    --danger-subtle: rgba(244, 63, 94, 0.15);
    --warning: #f59e0b;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.5);
    --sidebar-w: 272px;
    --font: 'Plus Jakarta Sans', system-ui, sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% -10%, rgba(99, 102, 241, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 100% 0%, rgba(16, 185, 129, 0.06), transparent);
    pointer-events: none;
    z-index: 0;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 1.75rem;
    text-decoration: none;
    color: inherit;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent), #a855f7);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.sidebar-logo svg { width: 22px; height: 22px; color: #fff; }

.sidebar-brand-text {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.sidebar-brand-text span {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0;
    margin-top: 1px;
}

.nav-section {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.nav { flex: 1; }

.nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 0.2rem;
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
}

.nav a svg {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav a:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.nav a:hover svg { opacity: 1; }

.nav a.active {
    background: var(--accent-subtle);
    color: var(--accent-light);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.25);
}

.nav a.active svg { opacity: 1; color: var(--accent-light); }

.sidebar-user {
    margin-top: auto;
    padding: 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.sidebar-user-role {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent-light);
    margin-bottom: 0.35rem;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: var(--transition);
}

.sidebar-logout:hover {
    color: var(--danger);
    border-color: rgba(244, 63, 94, 0.3);
    background: var(--danger-subtle);
}

.main-wrap {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border);
    background: rgba(7, 9, 13, 0.6);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 40;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.page-header > div:first-child {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem 1rem;
}

.page-header > div:first-child h1 {
    flex: 1;
    min-width: 200px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.page-header .page-sub {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.main-content {
    padding: 1.75rem 2rem 2.5rem;
    flex: 1;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.panel-tabs {
    display: flex;
    gap: 0.35rem;
    padding: 0.25rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.panel-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.panel-tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.panel-tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.panel-tab svg {
    width: 16px;
    height: 16px;
}

.panel-tab-count {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: var(--accent-subtle);
    color: #a5b4fc;
}

.panel-tab.active .panel-tab-count {
    background: var(--accent);
    color: #fff;
}

.panel-pane {
    display: none;
}

.panel-pane.active {
    display: block;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.35rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 22px; height: 22px; }

.stat-icon.indigo { background: var(--accent-subtle); color: var(--accent-light); }
.stat-icon.emerald { background: var(--success-subtle); color: #34d399; }
.stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

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

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-top: 0.15rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 1.15rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: var(--transition);
    white-space: nowrap;
}

.btn svg { width: 18px; height: 18px; }

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
    filter: brightness(1.08);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-ghost {
    background: var(--surface-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
}

.btn-success {
    background: linear-gradient(135deg, #059669, var(--success));
    color: #fff;
    box-shadow: 0 2px 12px rgba(16, 185, 129, 0.25);
}

.btn-success:hover { filter: brightness(1.06); }

.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.8rem; }
.btn-sm svg { width: 16px; height: 16px; }

/* Alerts */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.15rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    animation: slideDown 0.35s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success {
    background: var(--success-subtle);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

.alert-error {
    background: var(--danger-subtle);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fda4af;
}

.alert-info {
    background: var(--accent-subtle);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
}

/* Table */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 0.9rem 1.15rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

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

.data-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

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

.site-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.site-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent-subtle), rgba(168, 85, 247, 0.2));
    border: 1px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--accent-light);
    text-transform: uppercase;
}

.site-name strong {
    display: block;
    font-weight: 600;
    color: var(--text);
}

.site-name span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-balance {
    background: var(--success-subtle);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-muted {
    background: var(--surface-hover);
    color: var(--text-muted);
}

.badge-count {
    background: var(--accent-subtle);
    color: var(--accent-light);
}

/* Forms */
.form-grid { max-width: 520px; }

.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.45rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.form-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.form-divider::before,
.form-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.mono {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.82rem;
}

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

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

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    opacity: 0.4;
    margin-bottom: 1rem;
}

/* Modals */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    animation: fadeIn 0.2s ease;
}

.modal-backdrop.open { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: modalUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.modal-wide { max-width: 480px; }

@keyframes modalUp {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    margin-bottom: 1.25rem;
}

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.modal-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

.rate-banner {
    padding: 0.65rem 0.85rem;
    background: var(--accent-subtle);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--accent-light);
    margin-bottom: 1rem;
}

.usd-preview {
    padding: 0.65rem 0.85rem;
    background: rgba(59, 130, 246, 0.1);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: #93c5fd;
    margin: -0.25rem 0 1rem;
    display: none;
}

.info-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.5rem 1rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.info-row:last-child { border-bottom: none; }
.info-row dt { color: var(--text-muted); font-weight: 500; }
.info-row dd { font-weight: 500; }

/* Login */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
    position: relative;
    z-index: 1;
}

.login-brand {
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: linear-gradient(160deg, #12171f 0%, #0d1117 50%, #07090d 100%);
    border-right: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.login-brand::before {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--accent-glow), transparent 70%);
    top: -100px;
    right: -100px;
    pointer-events: none;
}

.login-brand h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    margin-bottom: 0.75rem;
    position: relative;
}

.login-brand p {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 360px;
    line-height: 1.7;
    position: relative;
}

.login-features {
    margin-top: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
}

.login-feature {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.login-feature-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--accent-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-light);
}

.login-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-box {
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.35rem;
}

.login-box .sub {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .login-page { grid-template-columns: 1fr; }
    .login-brand { display: none; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition);
    }
    .sidebar.open { transform: translateX(0); }
    .main-wrap { margin-left: 0; }
    .topbar, .main-content { padding-left: 1.25rem; padding-right: 1.25rem; }
    .mobile-menu-btn { display: flex !important; }
}

.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
