/* Kliki.me V2 - Mobile-First Construction Tool */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@500&display=swap');

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-card-hover: #222633;
    --bg-input: #151821;
    --border: #2a2f3d;
    --border-focus: #f59e0b;
    --text: #e8eaed;
    --text-dim: #8b92a5;
    --text-muted: #565d73;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --accent-glow: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --success: #22c55e;
    --info: #3b82f6;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
}

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

body {
    font-family: 'IBM Plex Sans', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* ========= LAYOUT ========= */
#app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-logo {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    background: none;
    border: 0;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.header-logo:focus {
    outline: none;
}

.header-logo:focus-visible {
    border-radius: 6px;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.header-logo svg { width: 28px; height: 28px; }

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-dim);
    min-width: 0;
}

.language-switcher {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-input);
}

.login-language {
    justify-content: center;
    margin: 0 auto 20px;
    width: max-content;
}

.lang-btn {
    min-width: 34px;
    min-height: 26px;
    padding: 4px 8px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-dim);
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.lang-btn.active {
    background: var(--accent);
    color: #000;
}

.header-user > span:not(.role-badge) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.role-badge {
    background: var(--accent-glow);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.header-user .role-badge {
    flex: 0 0 auto;
}

.main-content {
    flex: 1;
    padding: 16px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* ========= LOGIN ========= */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 8px;
    color: var(--accent);
    font-size: 28px;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-dim);
    margin-bottom: 32px;
    font-size: 14px;
}

/* ========= FORMS ========= */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px; /* prevents zoom on iOS */
    font-family: inherit;
    transition: border-color var(--transition);
}

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

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238b92a5' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ========= BUTTONS ========= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--accent);
    color: #000;
    width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
}

/* ========= CAMERA BUTTON (hero) ========= */
.camera-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent);
    color: #000;
    border: none;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 90;
    transition: all var(--transition);
    touch-action: manipulation;
}

.camera-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(245, 158, 11, 0.5);
}

.camera-fab:active { transform: scale(0.95); }
.camera-fab svg { width: 28px; height: 28px; }

/* ========= NAVIGATION TABS ========= */
.nav-tabs {
    display: flex;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
    flex: 0 0 auto;
    min-width: max-content;
    padding: 14px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
    touch-action: manipulation;
}

.nav-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.mobile-nav {
    display: none;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
}

.mobile-nav-control {
    position: relative;
    width: 100%;
}

.mobile-nav-button::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-dim);
    border-bottom: 2px solid var(--text-dim);
    transform: translateY(-65%) rotate(45deg);
    pointer-events: none;
}

.mobile-nav-button {
    position: relative;
    width: 100%;
    min-height: 44px;
    padding: 11px 44px 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, var(--bg-card-hover), var(--bg-card));
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
}

.mobile-nav-button[aria-expanded="true"] {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.03);
}

.mobile-nav-button:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.mobile-nav-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 130;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 14px 28px rgba(0,0,0,0.35);
    overflow: hidden;
    padding: 4px;
}

.mobile-nav-option {
    width: 100%;
    min-height: 40px;
    padding: 10px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-dim);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.mobile-nav-option:hover,
.mobile-nav-option.active {
    background: var(--accent-glow);
    color: var(--accent);
}

/* ========= CARDS ========= */
.profile-hero {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.profile-eyebrow {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.profile-hero h2 {
    font-size: 22px;
    line-height: 1.2;
    margin-bottom: 8px;
}

.profile-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--text-dim);
    font-size: 13px;
}

.profile-language {
    margin-top: 12px;
}

.profile-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.profile-stats .stat-value {
    overflow-wrap: anywhere;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    transition: background var(--transition);
    cursor: pointer;
}

.card:hover { background: var(--bg-card-hover); }

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-dim);
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.card-meta .count {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--accent);
    font-weight: 600;
}

/* ========= USER LIST ========= */
.user-card {
    cursor: default;
}

.user-card-layout {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.user-card-info {
    flex: 1 1 auto;
    min-width: 0;
}

.user-card-info .card-title,
.user-card-info .card-subtitle {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.user-card-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    flex: 0 0 auto;
    max-width: 48%;
}

/* ========= ADDRESS LIST ========= */
.address-grid {
    display: grid;
    gap: 12px;
}

/* ========= ROOM GRID ========= */
.room-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.room-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    touch-action: manipulation;
}

.room-card:hover, .room-card.selected {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.room-card .room-icon { font-size: 24px; margin-bottom: 6px; }
.room-card .room-name {
    font-size: 14px;
    font-weight: 500;
    overflow-wrap: anywhere;
}
.room-card .room-count { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.type-choice-grid,
.area-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.area-choice-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    cursor: pointer;
    transition: all var(--transition);
    touch-action: manipulation;
}

.area-choice-card:hover,
.area-choice-card.selected {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.area-choice-name {
    font-size: 14px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.area-choice-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

@media (max-width: 420px) {
    .type-choice-grid,
    .area-choice-grid {
        grid-template-columns: 1fr;
    }
}

/* ========= PHOTO GRID ========= */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.photo-grid-item {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
}

.photo-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition);
}

.photo-grid-item:hover img { transform: scale(1.05); }

.photo-grid-item .comment-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.photo-grid-item .marker-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(220,38,38,0.92);
    color: #fff;
    font-size: 11px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ========= PHOTO VIEWER (lightbox) ========= */
.photo-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.95);
    z-index: 200;
    display: flex;
    flex-direction: column;
    contain: layout paint;
}

.photo-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    color: #fff;
}

.photo-viewer-actions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    max-width: 100%;
}

.photo-viewer-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    touch-action: none;
    user-select: none;
}

.photo-image-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
    transform-origin: center center;
    will-change: transform;
}

.photo-viewer-body img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    touch-action: none;
    -webkit-user-drag: none;
    cursor: zoom-in;
    backface-visibility: hidden;
}

.photo-marker-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.photo-marker-mode .photo-marker-layer {
    pointer-events: auto;
    cursor: crosshair;
}

.photo-marker-pin {
    position: absolute;
    width: 28px;
    height: 28px;
    transform: translate(-50%, -50%);
    border: 2px solid #fff;
    border-radius: 50%;
    background: #dc2626;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 2px 10px rgba(0,0,0,0.45);
    pointer-events: auto;
    cursor: pointer;
}

.photo-marker-pin.is-active {
    background: #f59e0b;
    transform: translate(-50%, -50%) scale(1.18);
}

.photo-marker-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.photo-marker-hint {
    display: none;
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 1px solid rgba(245,158,11,0.35);
    border-radius: var(--radius-sm);
    background: rgba(245,158,11,0.12);
    color: #fbbf24;
    font-size: 12px;
    line-height: 1.35;
}

.photo-marker-hint.is-visible {
    display: block;
}

.photo-viewer-body img.is-zoomed {
    cursor: grab;
}

.photo-viewer-body img.is-zoomed:active {
    cursor: grabbing;
}

.photo-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 64px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.35);
    color: #fff;
    font-size: 42px;
    line-height: 1;
    border-radius: var(--radius-sm);
    cursor: pointer;
    z-index: 2;
}

.photo-viewer-prev { left: 12px; }
.photo-viewer-next { right: 12px; }

.photo-viewer:fullscreen {
    background: #000;
}

.photo-viewer:fullscreen .photo-viewer-info {
    display: none;
}

.photo-viewer.app-fullscreen {
    position: fixed;
    inset: 0;
    background: #000;
}

.photo-viewer.app-fullscreen .photo-viewer-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    background: linear-gradient(to bottom, rgba(0,0,0,0.72), rgba(0,0,0,0));
}

.photo-viewer.app-fullscreen .photo-viewer-info {
    display: none;
}

.photo-viewer.app-fullscreen .photo-viewer-body {
    min-height: 100dvh;
}

.photo-viewer-info {
    background: var(--bg-card);
    padding: 16px;
    max-height: 40vh;
    overflow-y: auto;
}

.photo-viewer-info .meta {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 12px;
}

/* ========= UPLOAD QUEUE ========= */
.upload-queue {
    position: fixed;
    bottom: 100px;
    right: 16px;
    left: 16px;
    z-index: 95;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.upload-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.upload-item .thumb-preview {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
}

.upload-item .upload-info { flex: 1; }
.upload-item .upload-name { font-weight: 500; }

.upload-progress {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.upload-item.done .upload-progress-bar { background: var(--success); }
.upload-item.error .upload-progress-bar { background: var(--danger); }

/* ========= CAMERA MODAL ========= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 300;
    display: flex;
    align-items: flex-end;
}

.modal-sheet {
    background: var(--bg-card);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-height: 85dvh;
    overflow-y: auto;
    padding: 20px 16px 32px;
    animation: slideUp 0.25s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-sheet h2 {
    font-size: 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
}

/* ========= SECTION HEADERS ========= */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
}

.photo-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
    max-width: 220px;
}

.photo-upload-link {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 2px 4px;
    text-align: center;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.photo-upload-link:hover {
    color: var(--accent-light);
}

/* ========= BREADCRUMB ========= */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.breadcrumb a, .breadcrumb span.link {
    color: var(--text-dim);
    cursor: pointer;
    text-decoration: none;
}

.breadcrumb a:hover, .breadcrumb span.link:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--text-muted); }

/* ========= FILTER BAR ========= */
.gallery-filters {
    display: grid;
    gap: 14px;
    margin-bottom: 16px;
}

.filter-step label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 7px;
}

.filter-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    white-space: nowrap;
    max-width: 100%;
    cursor: pointer;
    color: var(--text-dim);
    transition: all var(--transition);
}

.filter-chip.active {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent);
}

/* ========= COMMENTS ========= */
.comment-list { margin-top: 12px; }

.comment-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.comment-item:last-child { border-bottom: none; }

.photo-marker-row {
    cursor: pointer;
}

.photo-marker-row.is-active {
    background: rgba(245,158,11,0.12);
}

.comment-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.comment-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 8px;
}

.comment-text {
    font-size: 14px;
    margin-top: 4px;
    line-height: 1.5;
}

.comment-form {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.comment-form input {
    flex: 1;
}

/* ========= STATS ========= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}

.stat-label {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========= FIRESTOP CATALOG ========= */
.firestop-catalog {
    display: grid;
    gap: 12px;
}

.firestop-brand-card {
    display: grid;
    gap: 14px;
}

.firestop-brand-head,
.firestop-product-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.firestop-products {
    display: grid;
    gap: 8px;
}

.firestop-product-row {
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
}

.firestop-product-row strong {
    display: block;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.firestop-product-row span {
    display: block;
    margin-top: 2px;
    color: var(--text-dim);
    font-size: 12px;
}

.firestop-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.firestop-manager-card {
    display: grid;
    gap: 16px;
}

.firestop-manager-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.firestop-brand-select {
    margin-bottom: 0;
}

.firestop-toolbar-actions {
    padding-bottom: 1px;
}

/* ========= EMPTY STATE ========= */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-dim);
}

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

.empty-state h3 { margin-bottom: 4px; color: var(--text); }
.empty-state p { font-size: 14px; }

/* ========= TOAST ========= */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 14px;
    z-index: 300;
    animation: fadeInUp 0.3s ease;
    box-shadow: var(--shadow);
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ========= LOADING ========= */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 24px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========= AREA SECTIONS ========= */
.area-section { margin-bottom: 20px; }

.area-section-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

/* ========= RESPONSIVE ========= */
@media (max-width: 480px) {
    .header {
        padding: 10px 12px;
        gap: 10px;
    }

    .header-logo {
        font-size: 19px;
        flex: 0 0 auto;
    }

    .header-logo svg {
        width: 26px;
        height: 26px;
    }

    .header-user {
        flex: 1 1 auto;
        justify-content: flex-end;
        gap: 8px;
        font-size: 12px;
    }

    .header-language {
        display: none;
    }

    .header-user .role-badge {
        padding: 2px 7px;
        font-size: 10px;
    }

    .header-user .btn-icon {
        flex: 0 0 32px;
        width: 32px !important;
        height: 32px !important;
    }

    .nav-tabs {
        display: none;
    }

    .mobile-nav {
        display: block;
    }

    .main-content {
        padding: 16px 14px 96px;
    }

    .section-title {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .filter-bar {
        overflow-x: visible;
        flex-wrap: wrap;
        gap: 7px;
        padding-bottom: 0;
    }

    .filter-chip {
        padding: 6px 12px;
        font-size: 12.5px;
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: center;
    }

    .gallery-filters {
        gap: 12px;
    }

    .section-header {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .profile-hero {
        flex-direction: column;
    }

    .profile-hero .btn {
        width: auto;
    }

    .section-header .btn,
    .section-header .btn-sm {
        flex: 0 0 auto;
    }

    .section-header .photo-actions {
        max-width: none;
    }

    .room-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .comment-form,
    .photo-viewer-header,
    .firestop-manager-toolbar,
    .firestop-brand-head,
    .firestop-product-row {
        flex-wrap: wrap;
    }

    .firestop-manager-toolbar {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 15px;
    }

    .user-card-layout {
        gap: 10px;
    }

    .user-card-actions {
        max-width: 34%;
    }

    .user-card-actions .btn-sm {
        width: 100%;
        min-width: 64px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .camera-fab {
        right: max(18px, env(safe-area-inset-right));
        bottom: calc(92px + env(safe-area-inset-bottom));
        width: 68px;
        height: 68px;
        box-shadow: 0 6px 28px rgba(245, 158, 11, 0.55);
    }
}

@media (max-width: 360px) {
    .header-user > span:not(.role-badge) {
        display: none;
    }

    .user-card-layout {
        flex-direction: column;
    }

    .user-card-actions {
        justify-content: flex-start;
        max-width: none;
        width: 100%;
    }

    .user-card-actions .btn-sm {
        width: auto;
    }

    .mobile-nav {
        padding-left: 12px;
        padding-right: 12px;
    }
}

@media (min-width: 600px) {
    .room-grid { grid-template-columns: repeat(3, 1fr); }
    .photo-grid { grid-template-columns: repeat(4, 1fr); }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 900px) {
    .photo-grid { grid-template-columns: repeat(6, 1fr); }
    .room-grid { grid-template-columns: repeat(4, 1fr); }
    .upload-queue { left: auto; width: 360px; }
    .modal-overlay { align-items: center; justify-content: center; }
    .modal-sheet { max-width: 500px; border-radius: var(--radius); }
}

/* ========= HIDDEN HELPER ========= */
.hidden { display: none !important; }


/* ========= PLANS MODULE ========= */
.main-content.plan-workspace {
    max-width: none;
    padding: 10px;
}

.plans-filter { margin-bottom: 16px; }
.plan-card { cursor: pointer; transition: transform var(--transition), border-color var(--transition); }
.plan-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.plan-card-icon { font-size: 38px; margin-bottom: 12px; }
.plan-card-delete { margin-top: 12px; }
.plan-workspace .page-header {
    margin-bottom: 10px;
}

.plan-workspace .page-header h1 {
    font-size: 22px;
}

.plan-workspace .page-header p {
    margin-top: 2px;
}

.plans-layout { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 16px; align-items: start; }
.plan-workspace .plans-layout {
    height: calc(100dvh - 160px);
    min-height: 560px;
}

.plan-tools { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.plan-workspace .plan-tools {
    width: 100%;
}

#plan-zoom-label {
    min-width: 56px;
    text-align: center;
    font-weight: 700;
}

.plan-viewer-card { overflow:hidden; }
.plan-workspace .plan-viewer-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 12px;
}

.plan-help { color: var(--text-dim); font-size: 13px; margin-bottom: 10px; }
.plan-scroll { overflow:auto; height: min(78dvh, 900px); max-height: calc(100dvh - 230px); border:1px solid var(--border); border-radius: var(--radius-sm); background:#0b0d12; touch-action:none; overscroll-behavior:contain; overflow-anchor:none; }
.plan-workspace .plan-scroll {
    flex: 1;
    height: auto;
    max-height: none;
}

.plan-canvas { position:relative; width:100%; min-width:1080px; min-height:1080px; }
.plan-file { display:block; width:100%; min-height:inherit; border:0; background:white; object-fit:contain; user-select:none; -webkit-user-drag:none; }
.plan-marker-layer { position:absolute; inset:0; pointer-events:none; }
.plan-pin-origin { position:absolute; width:4px; height:4px; transform:translate(-50%,-50%); border-radius:50%; background:#ff1d1d; z-index:2; pointer-events:none; }
.plan-pin-line { position:absolute; height:2px; transform-origin:0 50%; background:rgba(15,23,42,.55); pointer-events:none; z-index:1; }
.plan-pin { pointer-events:auto; position:absolute; width:34px; height:34px; transform:translate(-50%,-50%); border-radius:999px; border:3px solid white; background:var(--accent); color:#000; font-weight:800; box-shadow:0 6px 18px rgba(0,0,0,.45); cursor:pointer; }
.plan-pin.dragging { transform:translate(-50%,-50%) scale(1.08); box-shadow:0 0 0 5px rgba(255,29,29,.22), 0 8px 24px rgba(0,0,0,.5); z-index:5; }
.plan-pin.status-done,.plan-pin.status-checked { background:var(--success); color:#001b08; }
.plan-pin.status-in_progress { background:var(--info); color:white; }
.plan-loupe { position:fixed; width:132px; height:132px; border:3px solid #fff; border-radius:50%; overflow:hidden; z-index:2000; background:#f8fafc; box-shadow:0 14px 36px rgba(0,0,0,.42); pointer-events:none; }
.plan-loupe.hidden { display:none; }
.plan-loupe-view { position:absolute; inset:0; background-repeat:no-repeat; background-color:#fff; }
.plan-loupe-frame { position:absolute; border:0; transform-origin:0 0; pointer-events:none; }
.plan-loupe-crosshair { position:absolute; inset:0; }
.plan-loupe-crosshair::before,
.plan-loupe-crosshair::after { content:""; position:absolute; left:50%; top:50%; background:#e00000; transform:translate(-50%,-50%); }
.plan-loupe-crosshair::before { width:38px; height:2px; }
.plan-loupe-crosshair::after { width:2px; height:38px; }
.plan-loupe-crosshair { box-shadow:inset 0 0 0 1px rgba(224,0,0,.25); border-radius:50%; }
.marker-add-here { width:100%; margin:0 0 14px; justify-content:center; }
.marker-list { position:sticky; top:86px; max-height:calc(100dvh - 110px); overflow:auto; }
.plan-workspace .marker-list {
    max-height: calc(100dvh - 160px);
}

.marker-row { padding:12px; border:1px solid var(--border); border-radius:var(--radius-sm); margin:8px 0; cursor:pointer; background:var(--bg-input); display:grid; gap:4px; }
.marker-row span,.marker-row small,.muted { color:var(--text-dim); }
.marker-photos { display:grid; gap:8px; }
.marker-photos img { width:72px; height:72px; object-fit:cover; border-radius:8px; border:1px solid var(--border); margin-right:6px; }
.marker-product-select {
    min-height: 132px;
}

@media (max-width: 900px) {
    .main-content.plan-workspace {
        padding: 8px;
    }

    .plan-workspace .page-header {
        display: grid;
        gap: 8px;
    }

    .plan-workspace .plan-tools {
        display: grid;
        grid-template-columns: 48px minmax(64px, auto) 48px;
        gap: 8px;
        align-items: center;
    }

    .plan-workspace .plan-tools > button:nth-of-type(1),
    .plan-workspace .plan-tools > button:nth-of-type(2) {
        grid-column: 1 / -1;
        width: 100%;
    }

    .plan-workspace .plan-tools > button:nth-of-type(3) {
        grid-column: 1;
    }

    .plan-workspace .plan-tools > #plan-zoom-label {
        grid-column: 2;
        justify-self: center;
    }

    .plan-workspace .plan-tools > button:nth-of-type(4) {
        grid-column: 3;
    }

    .plan-workspace .page-header h1 {
        font-size: 18px;
    }

    .plans-layout { grid-template-columns:1fr; }
    .plan-workspace .plans-layout {
        height: auto;
        min-height: 0;
    }

    .plan-workspace .plan-viewer-card {
        height: calc(100dvh - 205px);
        min-height: 520px;
    }

    .marker-list { position:static; max-height:none; }
    .plan-canvas { min-width:760px; min-height:760px; }
}
.plan-file { pointer-events: none; }
