:root {
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --primary: #38bdf8;
    --accent: #818cf8;
    --text-main: #f1f5f9;
    --text-dim: #94a3b8;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --border: rgba(255, 255, 255, 0.1);
}

.lang-switcher { display: flex; gap: 0.5rem; }
.lang-switcher button { background: transparent; border: 1px solid var(--border); color: var(--text-dim); padding: 0.3rem 0.6rem; border-radius: 4px; cursor: pointer; font-size: 0.8rem; }
.lang-switcher button:hover { border-color: var(--primary); color: var(--text-main); }

/* Status Badges */
.status-pill-lg {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    font-size: 0.85rem;
}
.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.status-connected .status-indicator { background: var(--success); box-shadow: 0 0 10px var(--success); }
.status-error .status-indicator { background: var(--error); box-shadow: 0 0 10px var(--error); }
.status-testing .status-indicator { background: var(--primary); animation: blink 1s infinite; }
.status-unknown .status-indicator { background: var(--text-dim); }

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.dark-theme {
    background-image: radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
                      radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), 
                      radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
}

.hidden { display: none !important; }

/* Views */
.view {
    display: flex;
    min-height: 100vh;
}

#view-public {
    flex-direction: column;
}

/* Public Header */
.public-header {
    display: flex;
    justify-content: space-between;
    padding: 1.5rem 3rem;
    align-items: center;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(10px);
}

.public-header nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.nav-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 6rem 2rem;
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-dim);
    margin-bottom: 3rem;
}

.search-box-large {
    display: flex;
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-panel);
    padding: 0.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.search-box-large input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    padding: 1rem;
    font-size: 1.1rem;
    outline: none;
}

/* Features */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    padding: 2rem 6rem;
}
/* SEARCH V1 - Territorial */
.search-container-v1 {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem auto;
    max-width: 900px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.search-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.search-form-grid .span-2 {
    grid-column: span 2;
}

.row-double-line {
    grid-column: span 2;
    display: flex;
    gap: 1.5rem;
}

.form-field-half {
    flex: 1;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.search-actions-centered {
    text-align: center;
}

.btn-lg {
    padding: 1rem 3rem;
    font-size: 1.1rem;
    font-weight: 600;
}

#search-intent-result {
    max-width: 800px;
    margin: 2rem auto;
    animation: fadeIn 0.5s ease-out;
}

.intent-box {
    background: rgba(var(--accent-rgb), 0.1);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 2rem;
    text-align: left;
}

.intent-box h2 {
    color: var(--accent);
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.intent-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
}

.intent-item {
    display: flex;
    flex-direction: column;
}

.intent-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}

.intent-value {
    font-weight: 600;
}

.next-step-badge {
    background: var(--bg-main);
    border: 1px dashed var(--border);
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-main);
}

.public-entry-grid {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 1.5rem;
    max-width: 1240px;
    margin: 0 auto;
    align-items: start;
}

.public-entry-grid .search-container-v1 {
    margin: 0;
    max-width: none;
}

.public-panel {
    text-align: left;
}

.public-panel h2 {
    margin-bottom: 0.75rem;
    font-size: 1.65rem;
}

.public-panel p {
    color: var(--text-dim);
    margin-bottom: 1.25rem;
    line-height: 1.55;
}

.public-panel-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08rem;
    color: var(--primary);
    margin-bottom: 0.85rem;
    font-weight: 700;
}

.public-search-grid {
    margin-bottom: 1.25rem;
}

.public-search-mode-selector {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.public-search-mode-card {
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.78));
    color: var(--text-main);
    border-radius: 14px;
    padding: 1rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.public-search-mode-card:hover {
    transform: translateY(-1px);
    border-color: rgba(56, 189, 248, 0.55);
    box-shadow: 0 10px 26px rgba(8, 47, 73, 0.22);
}

.public-search-mode-card.is-active {
    border-color: rgba(56, 189, 248, 0.7);
    background: linear-gradient(180deg, rgba(8, 47, 73, 0.88), rgba(15, 118, 110, 0.55));
}

.public-search-mode-title {
    font-size: 1rem;
    font-weight: 700;
}

.public-search-mode-copy {
    font-size: 0.88rem;
    color: var(--text-dim);
    line-height: 1.45;
}

.public-search-mode-card.is-active .public-search-mode-copy {
    color: #d7f7ff;
}

.public-search-toolbar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.public-inline-feedback {
    border-radius: 10px;
    border: 1px solid var(--border);
    padding: 0.9rem 1rem;
    margin-top: 0.75rem;
    font-size: 0.92rem;
}

.public-inline-feedback.tone-info {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.35);
    color: #bae6fd;
}

.public-inline-feedback.tone-success {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.35);
    color: #a7f3d0;
}

.public-inline-feedback.tone-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fecaca;
}

.public-geo-note {
    margin-bottom: 0.85rem;
}

.form-hint {
    margin-top: 0.55rem;
    font-size: 0.82rem;
    color: var(--text-dim);
    line-height: 1.45;
}

.public-selection-bar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin: 1.2rem 0 0.8rem;
}

.public-selection-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.public-results-shell {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.4);
}

.public-results-table-wrap {
    overflow-x: auto;
}

.public-results-table {
    margin-top: 0;
}

.public-results-table thead th {
    background: rgba(255, 255, 255, 0.04);
}

.public-result-row {
    cursor: pointer;
    transition: background 0.2s ease;
}

.public-result-row:hover {
    background: rgba(56, 189, 248, 0.06);
}

.link-button {
    background: transparent;
    border: none;
    color: var(--primary);
    font: inherit;
    cursor: pointer;
    padding: 0;
    text-align: left;
}

.link-button:hover {
    color: #7dd3fc;
}

.external-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.2s ease;
}

.external-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

.public-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.public-pagination-status {
    color: var(--text-dim);
    font-size: 0.9rem;
}

.card {
    background: var(--bg-panel);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: 0.3s;
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

/* Auth */
#view-auth {
    justify-content: center;
    align-items: center;
}

.auth-card {
    background: var(--bg-panel);
    padding: 3rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 450px;
}

.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; color: var(--text-dim); }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 0.8rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: white;
}

.form-group select:disabled {
    opacity: 0.72;
    cursor: default;
    border-color: rgba(148, 163, 184, 0.35);
    color: var(--text-dim);
}

.form-group input:disabled {
    opacity: 0.72;
    cursor: default;
    border-color: rgba(148, 163, 184, 0.35);
    color: var(--text-dim);
}

.sector-hierarchy-field select {
    transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.sector-hierarchy-field select:disabled {
    opacity: 0.82;
    cursor: default;
}

.sector-level-status {
    margin-top: 0.6rem;
    padding: 0.85rem 0.95rem;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(15, 23, 42, 0.42);
    color: #dbe4f0;
    font-size: 0.9rem;
    line-height: 1.45;
}

.sector-hierarchy-field.field-waiting .sector-level-status {
    background: rgba(8, 47, 73, 0.28);
    border-color: rgba(56, 189, 248, 0.36);
    color: #bae6fd;
}

.sector-hierarchy-field.field-empty .sector-level-status {
    background: rgba(120, 53, 15, 0.16);
    border-color: rgba(245, 158, 11, 0.28);
    color: #fde68a;
}

.sector-hierarchy-field.field-muted label,
.sector-hierarchy-field.field-waiting label,
.sector-hierarchy-field.field-empty label {
    color: #cbd5e1;
}

.sector-hierarchy-field.field-muted select {
    background: rgba(15, 23, 42, 0.34);
    border-color: rgba(148, 163, 184, 0.24);
    color: var(--text-dim);
}

.sector-hierarchy-field.field-waiting select {
    background: rgba(8, 47, 73, 0.28);
    border-color: rgba(56, 189, 248, 0.38);
    color: #dbeafe;
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.08);
}

.sector-hierarchy-field.field-ready select {
    border-color: rgba(56, 189, 248, 0.3);
}

.sector-hierarchy-field.field-ready select:not(:disabled) {
    cursor: pointer;
    background: rgba(8, 47, 73, 0.16);
}

.sector-hierarchy-field.field-empty select {
    background: rgba(51, 65, 85, 0.22);
    border-style: dashed;
    border-color: rgba(148, 163, 184, 0.3);
    color: var(--text-dim);
}

.sector-hierarchy-field.field-hidden select,
.sector-hierarchy-field.field-hidden .sector-level-status {
    display: none;
}

.sector-hierarchy-field.field-muted .form-hint {
    color: #cbd5e1;
}

.sector-hierarchy-field.field-waiting .form-hint {
    color: #bae6fd;
}

.sector-hierarchy-field.field-ready .form-hint {
    color: #cbd5e1;
}

.sector-hierarchy-field.field-empty .form-hint {
    color: #fde68a;
}

#public-search-city-fallback {
    margin-top: 0.75rem;
}

#public-locality-feedback {
    margin-top: 0.75rem;
}

#public-sector-feedback {
    margin-top: 0.75rem;
}

/* Multi-Country Selection Panel */
.multi-country-panel {
    border: 1px solid rgba(56, 189, 248, 0.18);
    border-radius: 12px;
    padding: 1rem;
    background: rgba(8, 47, 73, 0.12);
}

.multi-country-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.multi-country-filter {
    margin-bottom: 0.75rem;
}

.multi-country-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.25rem 0.75rem;
    max-height: 180px;
    overflow-y: auto;
    padding: 0.5rem;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.15);
    scrollbar-width: thin;
    scrollbar-color: rgba(56, 189, 248, 0.3) transparent;
}

.multi-country-list:empty {
    display: none;
}

.multi-country-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    padding: 0.2rem 0;
    cursor: pointer;
    color: var(--text-main);
    transition: background 0.15s ease;
    border-radius: 4px;
}

.multi-country-item:hover {
    background: rgba(56, 189, 248, 0.08);
}

.multi-country-item input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.multi-country-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.multi-country-badges:empty {
    display: none;
}

.multi-country-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: #bae6fd;
    border-radius: 16px;
    padding: 0.25rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.multi-country-badge:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.45);
    color: #fecaca;
}

.multi-country-badge .badge-remove {
    font-size: 0.7rem;
    opacity: 0.7;
}

.multi-country-count-badge {
    background: var(--primary);
    color: #000;
    border-radius: 10px;
    padding: 0.1rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    margin-left: 0.4rem;
}

.multi-country-count-badge:empty {
    display: none;
}

.btn-full { width: 100%; margin-top: 1rem; }

/* Sidebar */
.sidebar {
    width: 260px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

.logo { font-weight: 800; font-size: 1.2rem; margin-bottom: 3rem; letter-spacing: 2px; }
.highlight { color: var(--primary); }
.sidebar nav ul { list-style: none; }
.sidebar nav li {
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.3s;
    color: var(--text-dim);
}
.sidebar nav li:hover, .sidebar nav li.active { background: var(--bg-panel); color: var(--text-main); }

/* Content */
.content { flex: 1; padding: 2rem 3rem; overflow-y: auto; }
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }

.credit-badge {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
}

/* Status Pills */
.status-pill { padding: 0.3rem 0.8rem; border-radius: 20px; font-size: 0.8rem; font-weight: 600; }
.status-ok { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-error { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.status-warning { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }

/* Buttons */
.btn { padding: 0.6rem 1.2rem; border-radius: 8px; border: none; cursor: pointer; font-weight: 600; transition: 0.2s; }
.btn-primary { background: var(--primary); color: #000; }
.btn-secondary { background: rgba(255, 255, 255, 0.1); color: var(--text-main); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-warning { background: var(--warning); color: #000; }
.btn:disabled {
    opacity: 0.55;
    cursor: default;
}

/* Footer Info */
.footer-info { color: var(--text-dim); font-size: 0.8rem; }

/* Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card { background: var(--bg-panel); padding: 1.5rem; border-radius: 12px; border: 1px solid var(--border); }
.stat-label { font-size: 0.9rem; color: var(--text-dim); }
.stat-value { font-size: 1.8rem; font-weight: 700; margin-top: 0.5rem; }

/* Modal */
.modal { display: none; position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); }
.modal-content { background: #1e293b; margin: 5% auto; padding: 2rem; border: 1px solid var(--border); width: 80%; border-radius: 12px; }
.close-modal { float: right; cursor: pointer; font-size: 1.5rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { text-align: left; padding: 1rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; }
/* Role Badges */
.role-badge { padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.role-admin { background: #fca5a5; color: #7f1d1d; }
.role-customer { background: #93c5fd; color: #1e3a8a; }
.role-agent_operator { background: #d8b4fe; color: #581c87; }
.role-viewer { background: #d1d5db; color: #374151; }

/* Tags */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.tag { background: rgba(255,255,255,0.05); padding: 0.4rem 0.8rem; border-radius: 6px; font-size: 0.85rem; border: 1px solid var(--border); }
.tag-active { border-color: var(--primary); background: rgba(56, 189, 248, 0.1); color: var(--primary); }

.btn-error { background: var(--error); color: white; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.85rem; }

/* ===== ADMIN MONITORING SYSTEM ===== */

/* Admin layout adjusts for the bottom status bar */
#view-admin { flex-wrap: wrap; position: relative; }
.admin-content-area { padding-bottom: 40px !important; }

/* --- Sidebar Monitoring Widget --- */
.sidebar-monitor {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
.sidebar-monitor-title {
    font-size: 0.65rem;
    letter-spacing: 3px;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
    font-weight: 700;
}
.monitor-gauge-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.mini-gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.gauge-svg {
    width: 42px;
    height: 42px;
    transform: rotate(-90deg);
}
.gauge-bg {
    fill: none;
    stroke: rgba(255,255,255,0.06);
    stroke-width: 3;
}
.gauge-fill {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray 0.6s ease, stroke 0.3s ease;
}
.gauge-cpu { stroke: var(--primary); }
.gauge-ram { stroke: var(--accent); }
.gauge-swap { stroke: var(--warning); }
.gauge-disk { stroke: var(--success); }
.gauge-label {
    font-size: 0.6rem;
    color: var(--text-dim);
    letter-spacing: 1px;
    font-weight: 600;
}
.gauge-val {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-main);
}
.gauge-alert { stroke: var(--error) !important; }

/* --- Persistent Bottom Status Bar --- */
.admin-status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 32px;
    background: rgba(10, 15, 30, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255,255,255,0.06);
    display: none; /* shown only in admin view */
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0 1.5rem;
    z-index: 90;
    font-size: 0.72rem;
    font-family: 'Inter', monospace;
}
#view-admin:not(.hidden) ~ .admin-status-bar,
#view-admin:not(.hidden) .admin-status-bar { display: flex; }
.status-bar-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.sb-label {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.65rem;
    letter-spacing: 0.5px;
}
.sb-value {
    color: var(--text-main);
    font-weight: 700;
    min-width: 32px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.sb-value.sb-warn { color: var(--warning); }
.sb-value.sb-crit { color: var(--error); }
.status-bar-sep {
    width: 1px;
    height: 14px;
    background: rgba(255,255,255,0.1);
}
.sb-dot {
    font-size: 0.85rem;
    line-height: 1;
}
.sb-ok { color: var(--success); }
.sb-error { color: var(--error); }
.sb-degraded { color: var(--warning); }
.sb-unknown { color: var(--text-dim); }

/* --- Monitoring Detail Page --- */
.monitor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.monitor-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}
.monitor-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0.5;
}
.monitor-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.monitor-card-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
}
.monitor-card-value {
    font-size: 2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.monitor-card-sub {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.3rem;
}
.monitor-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    margin-top: 0.75rem;
    overflow: hidden;
}
.monitor-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease, background 0.3s ease;
}
.bar-cpu { background: linear-gradient(90deg, var(--primary), #60a5fa); }
.bar-ram { background: linear-gradient(90deg, var(--accent), #a78bfa); }
.bar-swap { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.bar-disk { background: linear-gradient(90deg, var(--success), #34d399); }
.bar-alert { background: linear-gradient(90deg, var(--error), #f87171) !important; }

/* Per-core CPU bars */
.core-bars {
    display: flex;
    gap: 3px;
    align-items: flex-end;
    height: 40px;
    margin-top: 0.75rem;
}
.core-bar {
    flex: 1;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
    min-width: 6px;
    transition: height 0.6s ease, background 0.3s ease;
    position: relative;
}
.core-bar:hover {
    opacity: 0.85;
}
.core-bar::after {
    content: attr(data-val);
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.55rem;
    color: var(--text-dim);
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
}
.core-bar:hover::after { opacity: 1; }

/* Services grid */
.services-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.service-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    transition: border-color 0.3s;
}
.service-card.svc-ok { border-color: rgba(16,185,129,0.3); }
.service-card.svc-error { border-color: rgba(239,68,68,0.3); }
.service-card.svc-degraded { border-color: rgba(245,158,11,0.3); }
.service-name {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}
.service-status {
    font-size: 1.5rem;
}

/* Activity Log */
.activity-log {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    max-height: 220px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.6;
    color: var(--text-dim);
}
.activity-log .log-line {
    white-space: pre-wrap;
    word-break: break-all;
}
.activity-log .log-line:last-child { color: var(--text-main); }
.activity-log-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}
/* ===== AI COMMAND CENTER (MACGYVER) ===== */

.ai-orchestrator-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    height: calc(100vh - 180px);
}

.ai-main-column, .ai-task-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.ai-command-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ai-chat-history {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1.5rem;
    overflow-y: auto;
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border: 1px solid var(--border);
}

.ai-message {
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    max-width: 85%;
    line-height: 1.5;
}

.ai-bot {
    align-self: flex-start;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-main);
}

.ai-user {
    align-self: flex-end;
    background: var(--primary);
    color: #000;
    font-weight: 500;
}

.ai-loading {
    font-style: italic;
    opacity: 0.7;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 0.9; }
    100% { opacity: 0.5; }
}

.ai-input-area {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ai-input-area textarea {
    width: 100%;
    padding: 1rem;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: white;
    font-family: inherit;
    resize: none;
}

.ai-plan-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-main);
}

.ai-task-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    padding-right: 0.5rem;
}

.ai-task-feedback {
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.ai-task-feedback-success {
    color: #86efac;
}

.ai-task-feedback-error {
    color: #fca5a5;
}

.ai-task-feedback-empty {
    color: var(--text-dim);
}

.btn.is-loading {
    opacity: 0.7;
    cursor: wait;
}

.task-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    transition: 0.3s;
}

.task-card:hover {
    background: rgba(255, 255, 255, 0.05);
}

.task-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.task-type {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 1px;
}

.task-agent {
    font-size: 0.7rem;
    color: var(--text-dim);
}

.task-title {
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.task-status-pill {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.task-diff-preview {
    background: #000;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.75rem;
    overflow-x: auto;
    border: 1px solid rgba(255,255,255,0.05);
}

.task-diff-preview code {
    font-family: 'Courier New', monospace;
    color: #34d399;
}

.task-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ai-empty-state {
    color: var(--text-dim);
    text-align: center;
    padding: 2rem;
    font-style: italic;
    font-size: 0.9rem;
}

.task-logs-view {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.log-entry {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.task-exec-result {
    margin-top: 1rem;
    padding: 1rem;
    background: #000;
    border-radius: 8px;
}

.task-exec-result h4 {
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.task-exec-result pre {
    font-size: 0.8rem;
    color: var(--text-main);
    white-space: pre-wrap;
}

/* ===== AI COMMAND CENTER (MACGYVER) REBORN ===== */

.ai-orchestrator-layout {
    display: grid;
    grid-template-columns: 280px 1fr 350px;
    gap: 1.5rem;
    height: calc(100vh - 200px);
    margin-top: 1rem;
}

.ai-side-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-main-column {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.ai-task-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

.ai-chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-history {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-input-area {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.1);
}

.ai-message {
    padding: 1rem 1.5rem;
    border-radius: 16px;
    max-width: 80%;
    line-height: 1.6;
    position: relative;
    font-size: 0.95rem;
}

.ai-bot {
    align-self: flex-start;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.ai-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #000;
    font-weight: 600;
    border-bottom-right-radius: 4px;
}

.markdown-output {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    white-space: normal;
    word-break: break-word;
}

.markdown-output h1, .markdown-output h2, .markdown-output h3, .markdown-output h4 {
    margin: 0.5rem 0 0.2rem 0;
    line-height: 1.35;
}

.markdown-output h2 { font-size: 1.1rem; color: var(--accent); }
.markdown-output h3 { font-size: 1rem; color: var(--primary); }

.markdown-output strong { font-weight: 700; color: #fff; }

.markdown-output ul, .markdown-output ol {
    margin: 0;
    padding-left: 1.5rem;
}

.markdown-output li { margin-bottom: 0.2rem; }

.markdown-output p { margin: 0; }

.markdown-output pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.markdown-output code {
    font-family: 'Courier New', monospace;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.85em;
    color: #34d399;
}

.markdown-output pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.markdown-output hr {
    border: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0.5rem 0;
}

.markdown-output table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.85rem;
}

.markdown-output th, .markdown-output td {
    padding: 0.4rem 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.markdown-output th {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
}

/* User Message Overrides */
.ai-user .markdown-output h1,
.ai-user .markdown-output h2,
.ai-user .markdown-output h3,
.ai-user .markdown-output h4,
.ai-user .markdown-output strong {
    color: #000;
}

.ai-user .markdown-output code {
    background: rgba(255, 255, 255, 0.3);
    color: #000;
}

.ai-user .markdown-output pre {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(0, 0, 0, 0.1);
}

.ai-user .markdown-output hr {
    background: rgba(0, 0, 0, 0.1);
}

.ai-user .markdown-output th, .ai-user .markdown-output td {
    border-color: rgba(0, 0, 0, 0.1);
}

.ai-user .markdown-output th {
    background: rgba(0, 0, 0, 0.05);
    color: #000;
}

/* Legacy fallback support */
.markdown-output .md-bullet {
    position: relative;
    padding-left: 1rem;
}

.markdown-output .md-bullet::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* Diagnostic Page Styles */
.diag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.diag-card {
    background: var(--bg-panel);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1.5rem;
}

.diag-label { color: var(--text-dim); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 0.25rem; }
.diag-value { font-size: 1.1rem; font-weight: 600; word-break: break-all; }
.diag-raw {
    background: #000;
    color: #34d399;
    font-family: monospace;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 1rem;
}

/* Error States */
.error-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: #fca5a5;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-family: monospace;
    font-size: 0.85rem;
}
.error-box-title { font-weight: 800; margin-bottom: 0.5rem; text-transform: uppercase; }

.public-json-preview {
    margin-top: 0.75rem;
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(2, 6, 23, 0.72);
    color: #dbeafe;
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.45;
    overflow: auto;
    white-space: pre-wrap;
}

.public-modal-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

@media (max-width: 1080px) {
    .public-entry-grid {
        grid-template-columns: 1fr;
    }

    .public-search-mode-selector {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .hero {
        padding: 4rem 1rem 2rem;
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .search-form-grid,
    .form-grid-3,
    .features {
        grid-template-columns: 1fr;
    }

    .search-form-grid .span-2 {
        grid-column: span 1;
    }

    .public-search-toolbar .btn,
    .public-selection-actions .btn {
        width: 100%;
    }

    .public-selection-bar {
        align-items: stretch;
    }

    .public-selection-actions {
        width: 100%;
    }

    .public-header {
        padding: 1rem;
    }
}

/* Company Search Enhancements */
.company-name-cell {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.score-pill {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    min-width: 3rem;
}

.score-success { background: rgba(16, 185, 129, 0.2); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.score-warning { background: rgba(245, 158, 11, 0.2); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.score-danger { background: rgba(239, 68, 68, 0.2); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }

.tag-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    width: fit-content;
}

/* Search Modes Ordering */
.mode-company #group-public-keyword { order: 1; }
.mode-company #group-public-continent { order: 2; }
.mode-company #public-search-multi-country-panel { order: 3; }

.mode-territory #group-public-continent { order: 1; }
.mode-territory #group-public-country { order: 2; }
.mode-territory [data-public-filter-group="region"] { order: 3; }
.mode-territory #group-public-postal-code { order: 4; }
.mode-territory #group-public-city { order: 5; }
.mode-territory [data-public-filter-group="locality-fallback"] { order: 6; }
.mode-territory #group-public-keyword { order: 7; }
.mode-territory #group-public-taxonomy { order: 8; }
.mode-territory .sector-hierarchy-field { order: 9; }
.mode-territory #group-public-sector-free { order: 10; }

.mode-sector #group-public-taxonomy { order: 1; }
.mode-sector .sector-hierarchy-field { order: 2; }
.mode-sector #group-public-sector-free { order: 3; }
.mode-sector #group-public-continent { order: 4; }
.mode-sector #public-search-multi-country-panel { order: 5; }

.public-search-grid > * {
    order: 50;
}

#group-public-page-size { order: 100; }
