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

:root {
    --bg:         #f5f5f5;
    --surface:    #ffffff;
    --surface2:   #f8f8f8;
    --border:     #e8e8e8;
    --border2:    #f0f0f0;
    --text:       #111;
    --text-mid:   #555;
    --text-muted: #aaa;
    --accent:     #111;
    --canvas-bg:  #000;

    --logo-h:     52px;
    --viewer-h:   45vh;
    --tabs-h:     42px;
    --bottom-h:   56px;

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html, body {
    width: 100%; height: 100%;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    overflow-x: hidden;
}

/* ── LOADING ── */
.loading {
    position: fixed; inset: 0; z-index: 999;
    background: #fff;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 14px;
}
.loading.hidden { display: none; }
.loading-spinner {
    width: 32px; height: 32px;
    border: 2px solid #e8e8e8;
    border-top-color: #111;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-muted); font-size: 13px; }

/* ── 0. LOGO HEADER ── */
.logo-header {
    height: var(--logo-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 16px;
    position: sticky; top: 0; z-index: 100;
}
.logo-img { height: 26px; }

/* ── 1. VIEWER ── */
.viewer-section {
    position: relative;
    width: 100%;
    height: var(--viewer-h);
    background: var(--canvas-bg);
    overflow: hidden;
    flex-shrink: 0;
}
.main-canvas {
    display: block;
    width: 100%; height: 100%;
    touch-action: none;
}

/* Przyciski obrotu */
.rot-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff; font-size: 24px; line-height: 1;
    border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(4px);
}
.rot-left  { left: 10px; }
.rot-right { right: 10px; }
.rot-btn:active { background: rgba(255,255,255,0.3); }

/* Spinner sekwencji */
.seq-loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.4);
}
.seq-loading.hidden { display: none; }
.seq-spinner {
    width: 28px; height: 28px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

/* ── 2. LEVEL TABS ── */
.level-tabs {
    display: flex;
    height: var(--tabs-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: var(--logo-h); z-index: 90;
}
.ltab {
    flex: 1;
    border: none; background: none;
    color: var(--text-muted);
    font-size: 13px; font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.ltab.active {
    color: var(--text);
    border-bottom-color: var(--text);
    font-weight: 600;
}
.ltab:active { background: var(--surface2); }

/* ── 3. KARTA MIESZKANIA ── */
.apt-card {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: calc(var(--logo-h) + var(--tabs-h));
    z-index: 85;
    box-shadow: 0 2px 6px rgba(0,0,0,0.07);
}
.apt-card.hidden { display: none; }

/* 3a header */
.apt-card-header {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border2);
}
.apt-card-dot {
    width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0;
    background: #ccc;
}
.apt-card-name {
    font-size: 15px; font-weight: 700; color: var(--text); flex: 1;
}
.apt-card-status {
    font-size: 11px; color: var(--text-muted);
}
.apt-card-close {
    background: none; border: none;
    color: var(--text-muted); font-size: 16px;
    cursor: pointer; padding: 4px 6px;
    -webkit-tap-highlight-color: transparent;
}

/* 3b siatka danych */
.apt-card-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    border-bottom: 1px solid var(--border2);
}
.apt-card-cell {
    padding: 10px 8px;
    text-align: center;
    border-right: 1px solid var(--border2);
}
.apt-card-cell:last-child { border-right: none; }
.apt-cell-label {
    font-size: 10px; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.apt-cell-value {
    font-size: 13px; font-weight: 600; color: var(--text);
}

/* 3c przyciski */
.apt-card-actions {
    display: flex;
    border-top: 1px solid var(--border);
}
.apt-action-btn {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; gap: 4px;
    padding: 10px 4px;
    background: var(--surface);
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px; font-weight: 500;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s, border-bottom-color 0.15s;
}
.apt-action-btn.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.apt-action-btn:active { background: var(--surface2); }
.apt-action-btn svg { width: 18px; height: 18px; }

/* ── 4. LISTA MIESZKAŃ ── */
.apt-list-section {
    background: var(--surface);
    margin-top: 8px;
    padding-bottom: var(--bottom-h);
}
.apt-list-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: calc(var(--logo-h) + var(--tabs-h));
    z-index: 80;
    background: var(--surface);
}
.apt-list-title {
    font-size: 10px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.1em;
}
.apt-list-count { font-size: 12px; color: var(--text-muted); }

/* Sort bar — nagłówki kolumn listy */
.apt-sort-bar {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.sort-btn {
    padding: 8px 4px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--text-muted);
    font-size: 11px; font-weight: 500;
    text-align: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s, border-bottom-color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sort-btn:first-child  { flex: 2; text-align: left; padding-left: 16px; }
.sort-btn:not(:first-child) { flex: 1; }
.sort-btn.active {
    color: var(--text);
    border-bottom-color: var(--text);
    font-weight: 600;
}

/* Lista jako tabela — kolumny odpowiadają sort barowi */
.apt-list-item {
    display: flex; align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border2);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s;
}
.apt-list-item:active { background: var(--surface2); }
.apt-list-item.selected { background: #f0f0f0; }
.ali-name {
    flex: 2; display: flex; align-items: center; gap: 8px;
    padding-left: 16px; min-width: 0;
}
.ali-name span { font-weight: 600; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ali-floor, .ali-rooms {
    flex: 1; text-align: center;
    font-size: 13px; color: var(--text-mid);
}
.ali-status {
    flex: 1; text-align: right; padding-right: 16px;
    font-size: 11px; line-height: 1.5;
}
.ali-status-val { font-weight: 600; }
.ali-area { color: var(--text-muted); }

.apt-list-dot {
    width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
}

/* ── 5. BOTTOM BAR ── */
.bottom-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bottom-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
}
.bb-btn {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px;
    background: none; border: none;
    color: var(--text-muted);
    font-size: 11px; font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
}
.bb-btn svg { width: 20px; height: 20px; }
.bb-btn.active { color: var(--text); }

/* ── VR OVERLAY ── */
.vr-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: #000;
    display: flex; flex-direction: column;
}
.vr-overlay.hidden { display: none; }
.vr-close {
    position: absolute; top: 12px; right: 12px; z-index: 210;
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--border);
    color: var(--text); padding: 8px 14px;
    border-radius: 20px; font-size: 13px; cursor: pointer;
}
.vr-frame {
    flex: 1; border: none; width: 100%; height: 100%;
}

/* ── CONTACT OVERLAY ── */
.contact-overlay {
    position: absolute; inset: 0; z-index: 50;
    background: #fff;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 10px; padding: 28px 24px;
}
.contact-overlay.hidden { display: none; }
.contact-tagline {
    font-size: 14px; color: var(--text);
    text-align: center; line-height: 1.55;
    max-width: 200px;
    margin-bottom: 6px;
}
.contact-divider {
    width: 36px; height: 1px;
    background: var(--border); margin: 6px 0;
}
.contact-name {
    font-size: 15px; font-weight: 700; color: var(--text);
}
.contact-row {
    display: flex; align-items: center; gap: 9px;
    color: var(--text); text-decoration: none;
    font-size: 13px;
    -webkit-tap-highlight-color: transparent;
}
.contact-row svg {
    width: 15px; height: 15px;
    color: var(--text-muted); flex-shrink: 0;
}

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