/* ─── WIDOS Online — Styles ─────────────────────────────────────────── */

:root {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --primary: #005fa3;
    --primary-dark: #00447a;
    --accent: #e85d2c;
    --text: #1a1a1a;
    --text-secondary: #666;
    --border: #d0d5dd;
    --border-light: #e5e7eb;
    --hover: #f5f7fa;
    --selected: #e8f0fe;
    --success: #10b981;
    --warning: #f59e0b;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --radius: 6px;
    --header-height: 48px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── App Layout ──────────────────────────────────────────────────── */

.app { display: flex; flex-direction: column; height: 100vh; }

/* ─── Header ───────────────────────────────────────────────────────── */

.header {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--header-height); padding: 0 16px;
    background: var(--primary); color: white;
    box-shadow: var(--shadow);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.logo { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
a.logo { color: white !important; text-decoration: none; }
a.logo:hover { text-decoration: none; opacity: 0.9; }
.nav-icons { display: flex; gap: 4px; }
.nav-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: var(--radius);
    color: rgba(255,255,255,0.8); font-size: 16px;
    transition: background 0.15s;
}
.nav-icon:hover { background: rgba(255,255,255,0.15); text-decoration: none; }
.nav-icon.active { background: rgba(255,255,255,0.2); color: white; }
.header-right { display: flex; align-items: center; gap: 8px; }
.brand-text { font-size: 12px; opacity: 0.8; }
.user-badge {
    font-size: 12px; padding: 2px 8px; background: rgba(255,255,255,0.15);
    border-radius: 4px; color: rgba(255,255,255,0.9);
}
.logout-link {
    font-size: 12px; color: rgba(255,255,255,0.7) !important;
    text-decoration: none; padding: 2px 6px; border-radius: 4px;
    transition: background 0.15s;
}
.logout-link:hover { background: rgba(255,255,255,0.15); text-decoration: none; }

/* ─── Tabs ──────────────────────────────────────────────────────────── */

.tabs {
    display: flex; gap: 0; padding: 0 16px;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.tab {
    padding: 10px 20px; font-size: 13px; font-weight: 500;
    color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active {
    color: var(--primary); border-bottom-color: var(--primary);
    font-weight: 600;
}
a.tab { display: inline-block; }

/* ─── Main Content ─────────────────────────────────────────────────── */

.main-content {
    display: flex; flex: 1; flex-direction: column; gap: 16px; padding: 16px;
    max-width: 1400px; margin: 0 auto; width: 100%;
    min-height: 0;
}

/* ─── Hierarchy Panel (25vh, aligned to bottom) ───────────────────── */

.hierarchy-panel {
    height: 35vh; background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); display: flex; flex-direction: column;
    min-height: 0; overflow: hidden;
}
.hierarchy-grid { display: grid; grid-template-columns: repeat(4, 1fr); flex: 1; min-height: 0; overflow: hidden; }
.hierarchy-column {
    border-right: 1px solid var(--border-light); min-height: 0;
    display: flex; flex-direction: column;
}
.hierarchy-column:last-child { border-right: none; }
.h-col-header {
    padding: 10px 12px; font-weight: 600; font-size: 12px;
    text-transform: uppercase; color: var(--text-secondary);
    background: var(--hover); border-bottom: 1px solid var(--border-light);
}
.h-col-list {
    flex: 1; overflow-y: auto; padding: 4px 0;
}
.h-col-list .h-item {
    padding: 8px 12px; cursor: pointer; font-size: 13px;
    border-left: 3px solid transparent; transition: all 0.1s;
}
.h-col-list .h-item:hover { background: var(--hover); }
.h-col-list .h-item.selected {
    background: var(--selected); border-left-color: var(--primary);
    font-weight: 500;
}
.h-loading { padding: 16px; color: var(--text-secondary); text-align: center; }
.h-hint { padding: 16px; color: var(--text-secondary); font-size: 12px; text-align: center; }
.h-count { font-size: 11px; color: var(--text-secondary); font-weight: normal; }
.hierarchy-footer {
    padding: 12px 16px; border-top: 1px solid var(--border-light);
    display: flex; justify-content: flex-end;
}

/* ─── Preview Panel (now above hierarchy) ──────────────────────────── */

.preview-panel {
    width: 100%; background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); display: flex; flex-direction: column;
    flex: 1;
}
.preview-image {
    display: flex; align-items: center; justify-content: center;
    padding: 12px; min-height: 80px; max-height: 300px;
}
.preview-image img { max-width: 100%; max-height: 280px; object-fit: contain; }
.preview-placeholder { color: var(--text-secondary); font-size: 13px; }

/* ─── Buttons ───────────────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 20px; border: none; border-radius: var(--radius);
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.4; cursor: default; }
.btn-small { padding: 5px 12px; font-size: 12px; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--hover); }

/* ─── Catalog search in tabs ────────────────────────────────────────── */

.catalog-search-bar {
    display: flex; gap: 6px; align-items: center; flex-shrink: 0;
    margin-left: auto; padding: 6px 0;
}
.catalog-search-bar input {
    width: 220px; padding: 4px 10px;
    border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px;
}

/* ─── Catalog Layout ────────────────────────────────────────────────── */

.catalog-layout {
    display: flex; flex: 1; gap: 0; width: 100%;
    min-height: 0;
}
.catalog-tree {
    width: 300px; min-width: 180px; background: var(--surface);
    border-right: 1px solid var(--border); display: flex; flex-direction: column;
    overflow: hidden;
}
.tree-header {
    padding: 12px; border-bottom: 1px solid var(--border-light);
}
.tree-search input {
    width: 100%; padding: 6px 10px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 12px;
}
.tree-list { flex: 1; overflow: auto; min-height: 0; }

/* ─── Tree navigation ────────────────────────────────── */
.tree-model {
    padding: 6px 10px;
    font-weight: 700;
    font-size: 12px;
    color: #1a1a2e;
    cursor: default;
    border-bottom: 1px solid #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sub-section header inside virtual tree */
.tree-header-sub {
    padding: 4px 8px 4px 24px;
    font-size: 12px;
    color: #666;
    background: #f5f6f8;
    border-bottom: 1px solid #e0e3e8;
}
.tree-section { margin-left: 0; }

.tree-section-header {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; cursor: pointer;
    background: var(--hover);
    font-weight: 600; font-size: 12px; color: var(--primary-dark);
    user-select: none;
}
.tree-section-header:hover { background: #e5e8ec; }
.tree-toggle { font-size: 9px; width: 12px; text-align: center; color: var(--text-secondary); flex-shrink: 0; }
.tree-toggle.mini { font-size: 7px; width: 10px; }

.tree-group {
    display: flex; align-items: center; gap: 4px;
    padding: 5px 10px; cursor: pointer;
    transition: all 0.1s;
}
.tree-group:hover { background: var(--hover); }
.tree-group.active { background: var(--selected); border-left: 3px solid var(--primary); }
.tree-group.level-1 { padding-left: 24px; }
.tree-group.level-2 { padding-left: 42px; font-size: 12px; }

.tree-code { font-weight: 600; font-size: 11px; color: var(--primary); flex-shrink: 0; }
.tree-title { font-size: 11px; color: var(--text-secondary); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-partno { font-size: 10px; color: var(--accent); font-family: monospace; flex-shrink: 0; }

/* ─── Tree resizer (draggable splitter) ──────────────── */
.tree-resizer {
    width: 4px; cursor: col-resize; background: transparent;
    flex-shrink: 0; position: relative; z-index: 10;
    transition: background 0.15s;
}
.tree-resizer::before {
    content: '';
    position: absolute;
    left: -4px; right: -4px; top: 0; bottom: 0;
}
.tree-resizer:hover,
.tree-resizer.resizing { background: var(--primary); }

/* Search results */
.sr-section-title {
    padding: 10px 12px; font-weight: 700; font-size: 14px;
    background: var(--primary); color: white; border-radius: 4px 4px 0 0;
}
.sr-path { padding: 4px 12px 8px; font-size: 12px; color: var(--text-secondary); }
.sr-path-item { color: var(--primary); }
.sr-path-sep { color: var(--text-secondary); margin: 0 2px; }

/* ─── Catalog Content ──────────────────────────────────────────────── */

.catalog-content {
    flex: 1; padding: 2px; overflow: hidden;
    display: flex; flex-direction: column; min-height: 0; height: 100%;
}

.group-header {
    margin-bottom: 12px; flex-shrink: 0;
}
.group-header h2 { font-size: 16px; font-weight: 600; }

/* ─── Diagram ────────────────────────────────────────────────────────── */

.diagram-container {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 0;
    flex: 3; min-height: 80px; overflow: hidden; position: relative;
    display: flex; flex-direction: column;
    border-radius: var(--radius) var(--radius) 0 0;
}
.diagram-scroll-wrap {
    overflow: auto; flex: 1; position: relative;
    display: flex; align-items: flex-start; justify-content: center;
    width: 100%; min-height: 0;
}
.diagram-resizer {
    height: 5px; cursor: row-resize; background: transparent;
    flex-shrink: 0; position: relative; z-index: 10;
    transition: background 0.15s;
}
.diagram-resizer:hover,
.diagram-resizer.resizing { background: var(--primary); }
.diagram-toolbar {
    position: absolute; top: 8px; left: 8px; z-index: 20;
    display: flex; flex-direction: column; gap: 2px;
    background: rgba(255,255,255,0.92);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    box-shadow: var(--shadow);
}
.zoom-btn {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: transparent;
    border-radius: 4px; cursor: pointer;
    font-size: 16px; line-height: 1; color: var(--text);
    transition: background 0.1s;
}
.zoom-btn:hover { background: var(--hover); }
.zoom-btn.active { background: var(--selected); color: var(--primary); }
.diagram-image-wrapper {
    position: relative; display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
    transform-origin: 0 0;
}
.diagram-image {
    max-width: 100%; max-height: 100%;
    object-fit: contain; border-radius: 4px; display: block;
}
.diagram-temp, .diagram-pin, .diagram-areas {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; overflow: visible;
}
.diagram-area {
    position: absolute; pointer-events: auto; cursor: pointer;
    background: transparent; border: none; border-radius: 2px;
}
.diagram-crossref-areas {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; overflow: visible;
}
.diagram-crossref-area {
    position: absolute; pointer-events: auto; cursor: pointer;
    background: rgba(66, 133, 244, 0.08);
    border: 1px solid rgba(66, 133, 244, 0.35);
    border-radius: 2px;
    transition: all 0.15s;
}
.diagram-crossref-area:hover {
    background: rgba(66, 133, 244, 0.18);
    border-color: rgba(66, 133, 244, 0.7);
}
.diagram-highlight {
    display: none; position: absolute; pointer-events: none;
    border-radius: 2px; box-sizing: border-box;
}
.diagram-highlight.temp {
    border: 1px solid #e53e3e; background: rgba(229, 62, 62, 0.15);
}
.diagram-highlight.pin {
    border: 1px solid #d97706; background: rgba(245, 158, 11, 0.15);
    pointer-events: auto; cursor: pointer;
}
.diagram-highlights { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.diagram-label {
    font-size: 11px; font-weight: 600; color: var(--text-secondary);
    text-align: left; padding-bottom: 4px;
}
.diagram-image {
    max-width: 100%; height: auto;
    border-radius: 4px;
}
.diagram-nav {
    display: flex; justify-content: center; align-items: center; gap: 12px;
    padding: 8px; margin-top: 8px;
}
.diagram-nav button { padding: 4px 12px; font-size: 12px; }

/* ─── Parts Table ───────────────────────────────────────────────────── */

.table-container {
    background: var(--surface); border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
    flex: 2; min-height: 80px; display: flex; flex-direction: column;
}
.table-header {
    padding: 8px 12px; font-weight: 600; font-size: 12px;
    display: flex; justify-content: space-between;
    background: var(--hover); border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.items-count { color: var(--text-secondary); font-weight: normal; }
.table-wrapper { overflow-y: auto; flex: 1; min-height: 0; }
.parts-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.parts-table th {
    padding: 8px 10px; text-align: left; font-weight: 600;
    font-size: 11px; text-transform: uppercase; color: var(--text-secondary);
    background: var(--hover); border-bottom: 1px solid var(--border);
    white-space: nowrap; position: sticky; top: 0;
}
.parts-table td { padding: 6px 10px; border-bottom: 1px solid var(--border-light); cursor: default; }
.parts-table tr:hover, .parts-table tr.hovered { background: #eef4ff; }
.parts-table tr.selected { background: #fff3cd; box-shadow: inset 3px 0 0 #f59e0b; }
.parts-table tr.selected td:first-child { font-weight: 700; color: #d97706; }
.pos { width: 40px; text-align: center; font-weight: 600; color: var(--primary); }
.part-no { font-family: 'Courier New', monospace; font-weight: 500; white-space: nowrap; }
.qty { text-align: center; }
.valid-for { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

/* ─── Search Results Overlay (within catalog) ──────────────────────── */

.search-results-overlay {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 12px;
}
.sr-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; font-weight: 600; font-size: 13px;
    background: var(--hover); border-bottom: 1px solid var(--border-light);
}
.sr-list { padding: 8px; }
.sr-group { margin-bottom: 12px; }
.sr-group-title {
    padding: 6px 10px; font-weight: 500; font-size: 13px;
    color: var(--primary); cursor: pointer;
    background: var(--selected); border-radius: 4px; margin-bottom: 4px;
}
.sr-group-title:hover { text-decoration: underline; }
.sr-table { font-size: 12px; }
.sr-empty { padding: 16px; color: var(--text-secondary); text-align: center; }

/* ─── Search Page ─────────────────────────────────────────────────── */

.search-page { padding: 16px; max-width: 1000px; margin: 0 auto; width: 100%; }
.search-form {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.search-form-row { display: flex; gap: 12px; align-items: flex-end; }
.search-field { flex: 1; }
.search-field label {
    display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px;
    color: var(--text-secondary);
}
.search-field input {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 14px;
}
.search-field input:focus { border-color: var(--primary); outline: none; }
.search-hint { margin-top: 8px; font-size: 12px; color: var(--text-secondary); }

/* ─── Search Results (page) ────────────────────────────────────────── */

.search-results-page { }
.sr-status {
    padding: 8px 12px; background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 12px; font-size: 13px;
}
.sr-brand-block { margin-bottom: 20px; }
.sr-brand-title {
    padding: 8px 12px; font-size: 15px; font-weight: 700;
    background: var(--primary); color: white; border-radius: var(--radius);
    margin-bottom: 8px;
}
.sr-series-block { margin: 8px 0 8px 16px; }
.sr-series-title {
    padding: 6px 12px; font-weight: 600; font-size: 14px; cursor: pointer;
    color: var(--primary); border-left: 3px solid var(--primary);
    background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 4px;
}
.sr-series-title:hover { background: var(--selected); text-decoration: none; }
.sr-group-block { margin: 4px 0 4px 24px; }
.sr-group-link {
    padding: 4px 10px; font-size: 13px; cursor: pointer; color: var(--text);
}
.sr-group-link:hover { color: var(--primary); text-decoration: underline; }
.sr-group-block .parts-table { font-size: 12px; margin-top: 4px; }

/* ─── Source Selector (SN range tabs) ─────────────────────────────── */

.source-selector {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 16px; background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.source-tabs {
    display: flex; gap: 4px;
}
.source-tab {
    display: inline-block; padding: 4px 14px;
    font-size: 13px; font-weight: 500;
    border-radius: 4px; background: var(--bg);
    color: var(--text); cursor: pointer; border: 1px solid var(--border);
    text-decoration: none !important;
}
.source-tab:hover {
    background: var(--hover); border-color: var(--primary);
}
.source-tab.active {
    background: var(--primary); color: white; border-color: var(--primary);
}

/* ─── Login Page ─────────────────────────────────────────────────── */

.login-page {
    display: flex; align-items: center; justify-content: center;
    height: 100vh; background: var(--bg);
}
.login-card {
    background: var(--surface); border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12); padding: 40px;
    width: 360px; text-align: center;
}
.login-logo {
    font-size: 28px; font-weight: 700; color: var(--primary);
    margin-bottom: 4px;
}
.login-subtitle {
    font-size: 14px; color: var(--text-secondary); margin-bottom: 24px;
}
.login-field { margin-bottom: 16px; }
.login-input {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 16px; text-align: center;
    outline: none; transition: border-color 0.15s;
}
.login-input:focus { border-color: var(--primary); }
.login-btn { width: 100%; justify-content: center; font-size: 15px; padding: 10px; }
.login-error {
    margin-top: 12px; font-size: 13px; color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════════════
   ─── MOBILE RESPONSIVE ───────────────────────────────────────────────
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── Breadcrumbs ──────────────────────────────────────────────────── */
.breadcrumbs {
    display: flex; align-items: center; gap: 4px;
    margin-top: 4px; font-size: 12px; color: var(--text-secondary);
    flex-wrap: wrap;
}
.bc-item { color: var(--primary); }
.bc-item.bc-current { color: var(--text-secondary); font-weight: 500; }
.bc-sep { color: var(--text-secondary); margin: 0 2px; }

/* ─── Desktop: hide mobile-only elements ──────────────────────────── */
.tree-toggle-btn { display: none; }
.tree-drawer-overlay { display: none !important; }
.tree-drawer-close { display: none; }

/* ─── Planchette / Tablet ────────────────────────────────────────── */
@media (max-width: 768px) {
    :root { --header-height: 44px; }

    .main-content { padding: 10px; gap: 10px; }

    /* Hierarchy: 2x2 grid, compact items */
    .hierarchy-grid { grid-template-columns: repeat(2, 1fr); }
    .hierarchy-panel { height: auto; max-height: 55vh; }
    .preview-panel { display: none; }
    .h-col-header { padding: 6px 8px; font-size: 11px; }
    .h-col-list .h-item { padding: 6px 8px; font-size: 12px; min-height: 36px; }

    /* Catalog: tree as overlay drawer */
    .catalog-tree {
        position: fixed; top: 0; left: -85vw; width: 85vw; max-width: 360px;
        height: 100vh; z-index: 100; border-right: none;
        box-shadow: 4px 0 16px rgba(0,0,0,0.2);
        transition: left 0.25s ease;
    }
    .catalog-tree.open { left: 0; }
    .tree-resizer { display: none; }
    .tree-toggle-btn { display: inline-flex; align-items: center; justify-content: center;
        width: 36px; height: 36px; border: none; background: transparent;
        color: white; font-size: 18px; cursor: pointer; border-radius: var(--radius);
        margin-right: 4px; }
    .tree-toggle-btn:hover { background: rgba(255,255,255,0.15); }
    .tree-drawer-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.4); z-index: 99; }
    .tree-drawer-overlay.visible { display: block; }
    .tree-drawer-close { display: inline-flex; align-items: center; justify-content: center;
        background: none; border: none; color: var(--text); font-size: 18px;
        cursor: pointer; padding: 4px 10px; min-width: 44px; min-height: 44px; }

    /* Tabs: hide links, keep search bar full width */
    .tabs .tab { display: none; }
    .catalog-search-bar { width: 100%; margin-left: 0; }

    /* Stack: schema on top, table below — no tabs */
    .diagram-resizer { display: none !important; }
    .diagram-container { flex: none !important; max-height: 45vh; }
    .table-container { flex: 1 !important; min-height: 100px; }

    /* Hide overlays on mobile — hard to tap */
    .diagram-areas, .diagram-crossref-areas, .diagram-temp, .diagram-pin {
        display: none !important;
    }

    /* Table mobile tweaks */
    .parts-table thead th:first-child { font-size: 0; }
    .parts-table thead th:first-child::before {
        content: 'ПОЗ.';
        font-size: 12px;
        font-weight: 600;
    }
    .parts-table .part-no { font-family: inherit; }

    /* Source selector — scrollable */
    .source-selector { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Search */
    .search-page { padding: 12px; }
    .search-form-row { flex-direction: column; gap: 8px; }
}

/* ─── Phone ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    :root { --header-height: 40px; --radius: 4px; }

    .main-content { padding: 6px; gap: 6px; }

    .header { padding: 0 8px; }
    .logo { font-size: 15px; }
    .brand-text { display: none; }
    .nav-icons { gap: 2px; }
    .nav-icon { width: 28px; height: 28px; font-size: 14px; }
    .user-badge { font-size: 10px; padding: 1px 5px; }

    .tabs { padding: 0 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab { padding: 8px 12px; font-size: 12px; white-space: nowrap; }
    .catalog-search-bar { margin-left: 0; width: 100%; padding: 4px 0; }
    .catalog-search-bar input { width: 100%; }

    /* Hierarchy: 2 columns on phone too */
    .hierarchy-grid { grid-template-columns: repeat(2, 1fr); }
    .hierarchy-panel { height: auto; max-height: 60vh; }
    .h-col-header { padding: 8px 10px; font-size: 11px; }
    .h-col-list .h-item { padding: 10px 10px; font-size: 13px; min-height: 44px; }
    .hierarchy-footer { padding: 8px 12px; }
    .hierarchy-footer .btn { width: 100%; justify-content: center; }

    /* Catalog tree drawer — full width */
    .catalog-tree { width: 100vw; max-width: 100vw; left: -100vw; }
    .tree-model { font-size: 11px; padding: 5px 8px; }
    .tree-section-header { padding: 8px 8px; font-size: 11px; min-height: 44px; }
    .tree-group { padding: 8px 8px; min-height: 44px; }
    .tree-group.level-1 { padding-left: 20px; }

    /* Catalog content — stack layout */
    .catalog-content { padding: 0; }
    .group-header { margin-bottom: 6px; }
    .group-header h2 { font-size: 14px; }
    .breadcrumbs { font-size: 11px; }

    .diagram-toolbar { top: 4px; left: 4px; flex-direction: row; gap: 1px; padding: 3px; }
    .zoom-btn { width: 36px; height: 36px; font-size: 18px; }

    .parts-table { font-size: 12px; }
    .parts-table th { padding: 6px 6px; font-size: 10px; }
    .parts-table td { padding: 6px 6px; }
    .pos { width: 30px; }
    .part-no { font-size: 11px; }
    .valid-for { font-size: 10px; }
    .table-wrapper { overflow-x: auto; }

    /* Source selector */
    .source-selector { padding: 4px 8px; gap: 4px; }
    .source-tab { padding: 3px 10px; font-size: 11px; white-space: nowrap; }

    /* Search */
    .search-page { padding: 8px; }
    .search-form { padding: 12px; }
    .search-form-row { flex-direction: column; gap: 8px; }
    .search-field input { font-size: 16px; }
    .sr-series-title { font-size: 13px; padding: 8px 10px; min-height: 44px; display: flex; align-items: center; }
    .sr-group-title { font-size: 12px; padding: 8px 10px; min-height: 44px; }
    .sr-series-block { margin-left: 8px; }
    .sr-group-block { margin-left: 12px; }

    /* Login */
    .login-card { width: 90%; margin: 0 16px; padding: 24px; }
    .login-logo { font-size: 22px; }
    .login-input { font-size: 16px; }
}
