:root {
    --bg: #0f0f14;
    --bg-panel: #16161e;
    --bg-card: #1c1c27;
    --bg-hover: #22222e;
    --text: #e4e4e7;
    --text-muted: #71717a;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --green: #22c55e;
    --red: #ef4444;
    --orange: #f59e0b;
    --border: #27272a;
    --radius: 10px;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
header {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    height: 56px;
    flex-shrink: 0;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: 100%;
}

h1 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-c {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--accent);
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
}

.tag {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.12);
    padding: 2px 8px;
    border-radius: 4px;
}

.api-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.api-info label {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.api-info input {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    width: 280px;
    font-family: 'SF Mono', monospace;
}

.btn-sm {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: border-color 0.2s;
}

.btn-sm:hover { border-color: var(--accent); }

#connStatus {
    font-size: 0.8rem;
    min-width: 20px;
}

/* Main layout */
main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 420px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.map-wrap {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* Search */
.search-box {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.search-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.tab {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 7px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.search-input {
    display: flex;
    gap: 8px;
}

.search-input input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
}

.search-input input:focus { border-color: var(--accent); }

.btn-primary {
    background: var(--accent);
    color: white;
    border: none;
    padding: 9px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-primary:hover { background: var(--accent-light); }

/* Results list */
.results {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.result-item {
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}

.result-item:hover { background: var(--bg-hover); }
.result-item.active { background: var(--bg-card); border-color: var(--accent); }

.result-ico {
    font-family: 'SF Mono', monospace;
    font-size: 0.8rem;
    color: var(--accent-light);
}

.result-name {
    font-weight: 500;
    font-size: 0.95rem;
    margin: 2px 0;
}

.result-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Detail */
.detail {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.detail-header {
    margin-bottom: 20px;
}

.detail-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.detail-ico {
    font-family: 'SF Mono', monospace;
    color: var(--accent-light);
    font-size: 0.85rem;
}

.detail-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    margin-bottom: 12px;
    background: none;
    border: none;
}

.detail-back:hover { color: var(--text); }

.detail-section {
    margin-bottom: 16px;
}

.detail-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.detail-field {
    background: var(--bg);
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.detail-field.full { grid-column: 1 / -1; }

.detail-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.detail-value {
    font-size: 0.9rem;
    word-break: break-word;
}

.badge-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-active { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-insolvent { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-ok { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-unknown { background: rgba(245,158,11,0.15); color: var(--orange); }
.badge-error { background: rgba(239,68,68,0.15); color: var(--red); }

.nace-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.nace-tag {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: 'SF Mono', monospace;
}

/* Stats bar */
.stats-bar {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: rgba(22, 22, 30, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
    z-index: 1000;
    display: none;
}

/* Loading / empty states */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.pending-msg {
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.3);
    padding: 14px;
    border-radius: 8px;
    text-align: center;
    color: var(--accent-light);
    font-size: 0.9rem;
}

.error-msg {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    padding: 14px;
    border-radius: 8px;
    text-align: center;
    color: var(--red);
    font-size: 0.9rem;
}

/* Leaflet */
.leaflet-container { background: #e8e8e8; }

/* Login screen */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg);
}

.login-box {
    text-align: center;
    padding: 48px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    max-width: 400px;
}

.login-box h2 {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.user-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
