
/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
    --teal-50:  #f0fdfa;
    --teal-100: #ccfbf1;
    --teal-200: #99f6e4;
    --teal-300: #5eead4;
    --teal-400: #2dd4bf;
    --teal-500: #14b8a6;
    --teal-600: #0d9488;
    --teal-700: #0f766e;
    --teal-800: #115e59;
    --teal-900: #134e4a;

    --gray-50:  #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --accent:   var(--teal-600);
    --accent-h: var(--teal-700);
    --accent-l: var(--teal-50);

    --font-sans: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'DM Mono', monospace;

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
    --shadow:    0 2px 8px rgba(0,0,0,.10);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.12);

    --header-h:  60px;
    --sidebar-w: 280px;

    --step-h:    52px;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-800);
    background: var(--gray-50);
    overflow: hidden;
}
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: inherit; text-decoration: none; }

/* ── App shell ──────────────────────────────────────────────────────────── */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
#header {
    height: var(--header-h);
    background: var(--gray-900);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    flex-shrink: 0;
    z-index: 100;
}
.header-brand {
    display: flex;
    align-items: center;
}
.header-logo {
    height: 28px;
    width: auto;
    display: block;
}
.header-sep { flex: 1; }
.header-project {
    font-size: 13px;
    color: var(--gray-300);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.header-project span {
    color: #fff;
    font-weight: 500;
    margin-left: 4px;
}
.btn-lang {
    background: transparent;
    border: 1px solid var(--gray-600);
    color: var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    transition: all .15s;
}
.btn-lang:hover {
    border-color: var(--teal-400);
    color: var(--teal-300);
}

/* ── Step bar ───────────────────────────────────────────────────────────── */
#stepbar {
    height: var(--step-h);
    background: #222834;
    border-bottom: 1px solid #222834;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 4px;
    flex-shrink: 0;
    overflow-x: auto;
}
.step-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: rgba(255,255,255,0.45);
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    border: none;
    background: transparent;
}
.step-item:hover { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.08); }
.step-item.active { color: #fff; background: rgba(255,255,255,0.12); }
.step-item.done { color: rgba(255,255,255,0.55); }
.step-item.done:hover { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.08); }
.step-num {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.45);
    font-size: 11px;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.step-item.active .step-num {
    background: var(--accent);
    color: #fff;
}
.step-item.done .step-num {
    background: var(--teal-600);
    color: #fff;
}
.step-arrow {
    color: rgba(255,255,255,0.2);
    font-size: 12px;
    user-select: none;
}

/* ── Workspace ──────────────────────────────────────────────────────────── */
#workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-w);
    background: #fff;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}
.sidebar-section {
    padding: 16px;
    border-bottom: 1px solid var(--gray-100);
}
.sidebar-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--gray-400);
    margin-bottom: 10px;
}
.sidebar-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--gray-600);
    padding: 3px 0;
}
.sidebar-summary-row strong { color: var(--gray-800); }
.sidebar-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}
.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.stat-val {
    font-size: 20px;
    font-weight: 700;
    color: var(--teal-600);
}
.stat-label { font-size: 12px; color: var(--gray-500); }

/* ── Main panel ─────────────────────────────────────────────────────────── */
#panel {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Step nav ───────────────────────────────────────────────────────────── */
.step-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    margin-top: 24px;
    border-top: 1px solid var(--gray-200);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    border: none;
    transition: all .15s;
    cursor: pointer;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-200); }
.btn-ghost {
    background: transparent;
    color: var(--gray-600);
    border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--gray-100); border-color: var(--gray-200); }
.btn-danger {
    background: #fee2e2;
    color: #dc2626;
}
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
}
.btn-icon {
    background: transparent;
    border: none;
    color: var(--gray-400);
    padding: 4px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.btn-icon:hover { color: var(--gray-700); background: var(--gray-100); }
.btn-icon.danger:hover { color: #dc2626; background: #fee2e2; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}
.card.selected {
    border-color: var(--accent);
    background: var(--teal-50);
}

/* ── Chips ──────────────────────────────────────────────────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
    color: var(--gray-600);
    cursor: pointer;
    transition: all .15s;
    user-select: none;
}
.chip:hover { border-color: var(--teal-300); color: var(--teal-700); }
.chip.active {
    background: var(--teal-100);
    border-color: var(--teal-400);
    color: var(--teal-800);
}
.chip-remove {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    opacity: .6;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
.chip-remove:hover { opacity: 1; }

/* ── Inputs ─────────────────────────────────────────────────────────────── */
.input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--gray-800);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}
.input-sm { padding: 5px 9px; font-size: 12px; }
.input-inline {
    border: 1px solid var(--teal-400);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
    outline: none;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(13,148,136,.15);
}
select.input { appearance: auto; }
label.field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 5px;
}
.field { margin-bottom: 14px; }

/* ── Toggle ─────────────────────────────────────────────────────────────── */
.toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 20px;
    transition: .2s;
    cursor: pointer;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px; height: 14px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
}
.toggle-label { font-size: 13px; color: var(--gray-700); }

/* ── Badge ──────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.badge-teal { background: var(--teal-100); color: var(--teal-800); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-red  { background: #fee2e2; color: #dc2626; }

/* ── Step 1 — Start options ─────────────────────────────────────────────── */
.start-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 28px;
}
.start-card {
    display: flex;
    align-items: center;
    gap: 14px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 14px 18px;
    cursor: pointer;
    transition: all .15s;
    background: var(--white);
}
.start-card:hover  { border-color: var(--teal-300); background: var(--teal-50); }
.start-card.active { border-color: var(--accent);   background: var(--teal-50); }
.start-card-icon { font-size: 22px; flex-shrink: 0; }
.start-card-title { font-weight: 700; font-size: 13px; color: var(--gray-800); margin-bottom: 2px; }
.start-card-desc  { font-size: 11px; color: var(--gray-500); }

/* ── Step 1 — Structure ─────────────────────────────────────────────────── */
.structure-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.structure-card {
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all .15s;
}
.structure-card:hover { border-color: var(--teal-300); }
.structure-card.selected { border-color: var(--accent); background: var(--teal-50); }
.structure-card .sc-icon { font-size: 28px; margin-bottom: 10px; }
.structure-card .sc-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.structure-card .sc-desc { font-size: 12px; color: var(--gray-500); }

/* ── Step 2 — Systems ───────────────────────────────────────────────────── */
.systems-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.sys-card {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1.5px solid var(--gray-200);
    border-radius: 999px;
    padding: 5px 12px 5px 8px;
    cursor: pointer;
    transition: all .15s;
    background: var(--white);
}
.sys-card:hover { border-color: var(--teal-300); background: var(--teal-50); }
.sys-card.active { border-color: var(--accent); background: var(--teal-50); }
.sys-card .sys-icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--gray-500); }
.sys-card.active .sys-icon { color: var(--accent); }
.sys-card .sys-name { font-size: 12px; font-weight: 600; color: var(--gray-700); white-space: nowrap; }
.sys-card .sys-main { display: none; }
.sub-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ga-preview { font-family: var(--font-mono); font-size: 11px; color: var(--gray-600); }
.ga-preview-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    border-bottom: 1px solid var(--gray-100);
}
.ga-preview-row:last-child { border-bottom: none; }
.ga-addr { color: var(--teal-700); font-weight: 500; min-width: 40px; }
.ga-dpt { color: var(--gray-400); }
.ga-type-ctrl { color: #3b82f6; }
.ga-type-fb   { color: var(--gray-400); }

/* ── Step 3 — Floors (compact style block) ──────────────────────────────── */
.floor-grid { display: flex; flex-direction: column; gap: 10px; }
.room-chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Step 4 — Quantities ────────────────────────────────────────────────── */
.qty-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.qty-table th {
    text-align: left;
    padding: 8px 10px;
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 12px;
}
.qty-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
.qty-table tr:hover td { background: var(--gray-50); }
.qty-input {
    width: 60px;
    text-align: center;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 13px;
}
.qty-input:focus { border-color: var(--accent); outline: none; }

/* ── Step 5 — GA List ───────────────────────────────────────────────────── */
.stat-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.stat-card .val {
    font-size: 28px;
    font-weight: 700;
    color: var(--teal-600);
    line-height: 1;
}
.stat-card .lbl { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.ga-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.ga-tree { font-size: 13px; }
.ga-main-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--gray-800);
    color: #fff;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    cursor: pointer;
}
.ga-main-name { font-weight: 600; font-size: 13px; }
.ga-mid-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 24px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    cursor: pointer;
}
.ga-mid-name { font-weight: 600; color: var(--gray-700); }
.ga-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 40px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12px;
}
.ga-row:hover { background: var(--gray-50); }
.ga-row .addr { color: var(--teal-700); font-weight: 500; min-width: 50px; }
.ga-row .name { flex: 1; color: var(--gray-700); }
.ga-row .dpt  { color: var(--gray-400); font-size: 11px; }
.ga-row .type { font-size: 10px; }
.ga-row .actions { display: flex; gap: 4px; opacity: 0; transition: opacity .1s; }
.ga-row:hover .actions { opacity: 1; }
.ga-table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--gray-200); }
.ga-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-family: var(--font-sans);
}
.ga-table th {
    padding: 10px 14px;
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    font-weight: 600;
    text-align: left;
    font-size: 11px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .4px;
    position: sticky;
    top: 0;
    z-index: 1;
}
.ga-table td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
.ga-table tbody tr:last-child td { border-bottom: none; }
.ga-table tr:hover td { background: var(--gray-50); }
.ga-table .col-addr  { width: 96px;  font-family: var(--font-mono); font-weight: 600; color: var(--teal-700); font-size: 13px; }
.ga-table .col-sys   { width: 130px; }
.ga-table .col-dpt   { width: 136px; font-family: var(--font-mono); font-size: 12px; color: var(--gray-400); }
.ga-table .col-type  { width: 64px;  }
.ga-table .col-del   { width: 36px;  text-align: center; }
.add-manual-form {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 10px 8px 40px;
    background: var(--teal-50);
    border-radius: var(--radius-sm);
    margin-top: 4px;
}
.add-manual-form .input { padding: 4px 8px; font-size: 12px; }

/* ── Step 6 — Export ────────────────────────────────────────────────────── */
.export-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
}
.export-panel .card { height: 100%; }
.format-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.format-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--gray-50);
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-500);
    cursor: pointer;
    text-align: center;
    transition: all .15s;
}
.format-btn.active {
    border-color: var(--accent);
    background: var(--teal-50);
    color: var(--accent);
}
.xml-preview {
    background: var(--gray-900);
    color: #e2e8f0;
    font-family: var(--font-mono);
    font-size: 11px;
    border-radius: var(--radius);
    padding: 16px;
    overflow: auto;
    max-height: 420px;
    white-space: pre;
    tab-size: 2;
}
.xml-preview .tag   { color: #7dd3fc; }
.xml-preview .attr  { color: #86efac; }
.xml-preview .val   { color: #fde68a; }
.xml-preview .cmt   { color: #94a3b8; font-style: italic; }
.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.preview-title { font-weight: 600; font-size: 13px; color: var(--gray-700); }

/* ── Import modal ───────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}
.modal-overlay.hidden { display: none; }
.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 480px;
    max-width: calc(100vw - 40px);
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}
.modal-close:hover { color: var(--gray-700); background: var(--gray-100); }
.drop-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    color: var(--gray-400);
    cursor: pointer;
    transition: all .15s;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--teal-400);
    background: var(--teal-50);
    color: var(--teal-600);
}
.drop-zone-icon { font-size: 32px; margin-bottom: 10px; }
.drop-zone-text { font-size: 13px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* ── Loading overlay ────────────────────────────────────────────────────── */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 900;
}
#loading-overlay.hidden { display: none; }
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg { font-size: 14px; color: var(--gray-500); }

/* ── Toast ──────────────────────────────────────────────────────────────── */
#toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--gray-900);
    color: #fff;
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 800;
    opacity: 0;
    transition: all .25s;
    pointer-events: none;
    white-space: nowrap;
}
#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
#toast.toast-error { background: #dc2626; }

/* ── Misc utils ─────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-xs   { font-size: 11px; }
.text-sm   { font-size: 12px; }
.text-muted { color: var(--gray-400); }
.fw-bold   { font-weight: 700; }
.text-teal  { color: var(--teal-600); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-auto { margin-top: auto; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.ml-auto { margin-left: auto; }
.w-full  { width: 100%; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-end { justify-content: flex-end; }
.truncate-flex { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Reusable component classes ─────────────────────────────────────────── */
.empty-state {
  padding: 40px 24px;
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
}
.empty-state.bordered {
  border: 1px dashed var(--gray-200);
  border-radius: var(--radius);
}

/* Sidebar GA total count */
.sb-ga-total { font-size: 24px; font-weight: 700; color: var(--teal-600); }

/* ── Sidebar feedback widget ────────────────────────────────────────────── */
.sb-feedback {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.sb-feedback-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}
.sb-feedback-icon {
  width: 14px; height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}
.sb-feedback-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
}
.sb-feedback-desc {
  font-size: 11px;
  color: var(--gray-400);
  margin: 0 0 8px;
  line-height: 1.5;
}
.sb-feedback-input {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.5;
  padding: 7px 9px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--gray-700);
  min-height: 68px;
  margin-bottom: 8px;
  transition: border-color .15s;
}
.sb-feedback-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Sidebar brand footer ────────────────────────────────────────────────── */
.sb-brand {
  margin-top: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--gray-100);
  text-align: center;
}
.sb-brand-logo {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  color: #15527f;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.sb-brand-logo:hover {
  text-decoration: underline;
}
.sb-brand-tagline {
  font-size: 10px;
  color: var(--gray-400);
  margin-top: 3px;
  line-height: 1.4;
}

/* Step 5 toolbar right-side action group */
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; flex-wrap: wrap; }

/* GA set preview icon */
.ga-set-icon { font-size: 28px; margin-bottom: 8px; }

/* GA tree toggle arrow */
.tree-arrow { margin-left: 8px; opacity: 0.5; font-size: 12px; user-select: none; }

/* Step 1 address-format preview box */
.addr-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--teal-700);
  background: var(--teal-50);
  padding: 8px;
  border-radius: 4px;
  line-height: 1.8;
}

/* Manual-GA form: remove default field margin */
.manual-ga-form .field { margin: 0; }

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 4px;
}
.section-desc { font-size: 13px; color: var(--gray-500); margin-bottom: 18px; }
.divider { height: 1px; background: var(--gray-100); margin: 12px 0; }

/* ── Step 2 — Two col layout ─────────────────────────────────────────────── */
.two-col {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}
.ga-set-preview {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    position: sticky;
    top: 0;
}
.ga-set-empty {
    text-align: center;
    color: var(--gray-400);
    font-size: 13px;
    padding: 24px 0;
}
.ga-set-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 12px;
}
.ga-set-row:last-child { border-bottom: none; }
.ga-offset { font-family: var(--font-mono); color: var(--gray-400); min-width: 30px; font-size: 11px; }
.ga-set-name { flex: 1; color: var(--gray-700); }
.ga-type-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 600;
}
.ga-type-badge.ctrl { background: #dbeafe; color: #1d4ed8; }
.ga-type-badge.fb   { background: var(--gray-100); color: var(--gray-500); }
.sel-count { font-size: 12px; color: var(--gray-500); }

/* ── View toggle (Step 2/3) ──────────────────────────────────────────────── */
.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    padding: 3px;
}
.vt-btn {
    padding: 4px 12px;
    border-radius: 4px;
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    transition: all .15s;
}
.vt-btn.active { background: #fff; color: var(--gray-800); box-shadow: var(--shadow-sm); }

/* ── Step 3 — Floor builder ─────────────────────────────────────────────── */
.floors-list { display: flex; flex-direction: column; gap: 10px; }

.floor-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow .15s, border-color .15s;
}
.floor-card:focus-within { box-shadow: 0 0 0 2px rgba(13,148,136,.12); border-color: var(--teal-300); }

.floor-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px 11px 0;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
    border-left: 3px solid var(--teal-400);
    padding-left: 12px;
}
.mid-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 22px;
    font-size: 10px;
    font-weight: 700;
    padding: 0 7px;
    border-radius: 10px;
    background: var(--teal-100);
    color: var(--teal-800);
    flex-shrink: 0;
}
.floor-name-field {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    outline: none;
    min-width: 0;
    transition: color .12s;
}
.floor-name-field:focus { color: var(--teal-700); }

.floor-room-count {
    font-size: 11px;
    font-weight: 600;
    background: var(--teal-50);
    color: var(--teal-600);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}
.floor-room-count.zero { background: var(--gray-100); color: var(--gray-400); }

.floor-del {
    width: 26px; height: 26px;
    border: none; background: transparent;
    color: var(--gray-300); font-size: 13px;
    cursor: pointer; border-radius: 5px;
    display: flex; align-items: center; justify-content: center;
    transition: all .12s; flex-shrink: 0;
}
.floor-del:hover { background: #fee2e2; color: #ef4444; }

.floor-card-body { padding: 14px 16px 12px; }

/* Room tags */
.room-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; min-height: 2px; }
.room-tag {
    display: inline-flex;
    align-items: center;
    padding: 5px 6px 5px 11px;
    border-radius: 6px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    font-size: 12.5px;
    color: var(--gray-700);
    cursor: default;
    transition: background .1s, border-color .1s;
    gap: 0;
}
.room-tag:hover { background: var(--gray-100); border-color: var(--gray-300); }
.room-tag.fixed-room { background: var(--teal-50); border-color: var(--teal-200); color: var(--teal-700); }
.room-tag-text { margin-right: 5px; }
.room-tag-del {
    width: 18px; height: 18px;
    border: none; background: transparent;
    color: var(--gray-300); font-size: 11px;
    cursor: pointer; border-radius: 3px;
    display: flex; align-items: center; justify-content: center;
    transition: all .1s; flex-shrink: 0;
}
.room-tag-del:hover { background: #fee2e2; color: #ef4444; }

/* Add room row */
.room-add-row {
    display: flex;
    align-items: center;
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: all .15s;
}
.room-add-row:focus-within {
    border-style: solid;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(13,148,136,.1);
}
.room-add-input {
    flex: 1;
    border: none; background: transparent;
    font-size: 12.5px; padding: 8px 10px;
    color: var(--gray-800); outline: none;
}
.room-add-input::placeholder { color: var(--gray-400); }
.room-add-btn {
    background: var(--accent); color: #fff;
    border: none; padding: 8px 14px;
    font-size: 12px; font-weight: 500;
    cursor: pointer; opacity: 0;
    transition: opacity .15s; white-space: nowrap;
}
.room-add-row:focus-within .room-add-btn { opacity: 1; }

/* Add floor button */
.add-floor-btn {
    margin-top: 8px;
    background: transparent;
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius);
    padding: 14px;
    width: 100%;
    font-size: 13px; font-weight: 500;
    color: var(--gray-400);
    cursor: pointer;
    transition: all .15s;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.add-floor-btn:hover { border-color: var(--teal-400); color: var(--teal-600); background: var(--teal-50); }
.add-floor-btn span { font-size: 18px; line-height: 1; }

/* ── Step 3 — Room inline rename ────────────────────────────────────────── */
.room-tag-rename {
    border: none; background: transparent; outline: none;
    font-size: 12.5px; color: var(--gray-800);
    min-width: 40px; max-width: 160px;
}
.room-tag.editing {
    background: #fff; border-color: var(--teal-400);
    box-shadow: 0 0 0 2px rgba(13,148,136,.15);
}

/* ── Step 3 — Tree view ──────────────────────────────────────────────────── */
.tree-list { display: flex; flex-direction: column; gap: 6px; }
.tree-floor-node {
    border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--gray-200); background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.tree-floor-node:focus-within { border-color: var(--teal-300); box-shadow: 0 0 0 2px rgba(13,148,136,.1); }
.tree-floor-hd {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 12px 11px 0;
    background: var(--gray-50);
    border-bottom: 1px solid transparent;
    border-left: 3px solid transparent;
    cursor: pointer; user-select: none;
    padding-left: 12px;
    transition: border-color .12s;
}
.tree-floor-hd.open { border-bottom-color: var(--gray-100); border-left-color: var(--teal-400); }
.tree-caret {
    font-size: 9px; color: var(--gray-400);
    transition: transform .15s; flex-shrink: 0;
}
.tree-caret.open { transform: rotate(90deg); }
.tree-floor-body { padding: 8px 14px 12px 40px; }

.tree-room-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border-radius: var(--radius-sm);
    color: var(--gray-700);
    transition: background .1s;
}
.tree-room-row:hover { background: var(--gray-50); }
.tree-room-idx {
    font-size: 10px; font-family: var(--font-mono);
    color: var(--gray-300); width: 16px;
    text-align: right; flex-shrink: 0;
}
.tree-room-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.tree-room-rename-inp {
    flex: 1; border: 1px solid var(--teal-400); border-radius: 4px;
    padding: 2px 8px; font-size: 13px; outline: none;
    background: #fff; color: var(--gray-800);
}
.tree-room-actions { display: none; gap: 2px; flex-shrink: 0; }
.tree-room-row:hover .tree-room-actions { display: flex; }
.tree-icon-btn {
    background: none; border: none; padding: 3px 5px; border-radius: 4px;
    cursor: pointer; font-size: 12px; color: var(--gray-400);
    line-height: 1; transition: all .1s;
}
.tree-icon-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.tree-icon-btn.danger:hover { background: #fee2e2; color: #dc2626; }

.tree-add-room {
    display: flex; align-items: center;
    margin-top: 6px; border-radius: var(--radius-sm);
    border: 1px dashed var(--gray-300);
    overflow: hidden; transition: all .15s;
}
.tree-add-room:focus-within {
    border-color: var(--accent); border-style: solid;
    box-shadow: 0 0 0 2px rgba(13,148,136,.1);
}
.tree-add-room-inp {
    flex: 1; border: none; background: transparent;
    font-size: 12px; outline: none; color: var(--gray-800);
    padding: 7px 10px;
}
.tree-add-room-inp::placeholder { color: var(--gray-400); }
.tree-add-room .room-add-btn { opacity: 0; padding: 7px 12px; font-size: 11px; }
.tree-add-room:focus-within .room-add-btn { opacity: 1; }

.tree-connector { position: relative; }
.tree-connector::before {
    content: ''; position: absolute;
    left: -20px; top: 0; bottom: 0;
    width: 1px; background: var(--gray-200);
}

/* Step 3 empty state */
.floors-empty {
    text-align: center; padding: 48px 24px;
    border: 2px dashed var(--gray-200); border-radius: var(--radius);
    color: var(--gray-400);
}
.floors-empty-icon { font-size: 28px; color: var(--gray-300); margin-bottom: 12px; }
.no-rooms-msg { font-size: 13px; color: var(--gray-400); padding: 12px 4px; display: inline-block; }
.floors-empty p { font-size: 13px; margin: 0 0 16px; }

/* ── Step 4 — Assign layout ─────────────────────────────────────────────── */
.assign-layout {
    display: grid;
    grid-template-columns: 210px 1fr;
    gap: 16px;
    align-items: start;
}

/* Floor list panel */
.assign-left {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}
.assign-left-header {
    padding: 10px 12px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--gray-400);
    border-bottom: 1px solid var(--gray-100);
}
.assign-floor-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 11px 12px;
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--gray-600);
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    text-align: left;
    transition: background .12s, color .12s;
}
.assign-floor-btn:hover { background: var(--gray-50); color: var(--gray-900); }
.assign-floor-btn.active {
    background: var(--teal-600);
    color: #fff;
    font-weight: 600;
    border-bottom-color: transparent;
}
.assign-floor-btn.active .mid-badge {
    background: rgba(255,255,255,0.2);
    color: #fff;
}
.assign-floor-btn:last-child { border-bottom: none; }
.assign-floor-count {
    font-size: 11px;
    font-weight: 700;
    color: var(--teal-500);
    margin-left: auto;
    flex-shrink: 0;
}
.assign-floor-btn.active .assign-floor-count { color: rgba(255,255,255,0.75); }

/* Room tabs — underline style */
.room-tab-bar {
    display: flex;
    gap: 0;
    flex-wrap: wrap;
    padding: 0 16px;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid var(--gray-200);
    border-bottom: none;
}
.room-tab {
    padding: 11px 14px 10px;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    font-size: 13px;
    color: var(--gray-500);
    cursor: pointer;
    transition: all .15s;
    margin-bottom: -1px;
    white-space: nowrap;
}
.room-tab:hover { color: var(--gray-800); }
.room-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}
.room-tab-count {
    display: inline-block;
    margin-left: 5px;
    font-size: 10px;
    font-weight: 700;
    color: var(--teal-500);
    background: var(--teal-50);
    padding: 1px 5px;
    border-radius: 8px;
    vertical-align: middle;
}
.room-tab.active .room-tab-count { background: var(--teal-100); }

/* Circuit content area */
.room-qty-area {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 4px 0 8px;
}

/* System section */
.sys-section {
    padding: 14px 20px 6px;
    border-top: 1px solid var(--gray-100);
}
.sys-section:first-child { border-top: none; padding-top: 16px; }

.sys-section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.sys-section-icon {
    width: 30px; height: 30px;
    background: var(--teal-50);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}
.sys-section-icon svg { width: 15px; height: 15px; }
.sys-section-label {
    font-weight: 600;
    font-size: 13.5px;
    color: var(--gray-800);
    flex: 1;
}
.qty-sum-badge {
    font-size: 11px;
    padding: 2px 9px;
    border-radius: 10px;
    background: var(--teal-100);
    color: var(--teal-800);
    font-weight: 600;
}
.qty-sum-badge.zero { background: var(--gray-100); color: var(--gray-400); }

/* Circuit type group */
.circuit-type-group { margin-bottom: 14px; }
.circuit-type-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--teal-600);
    text-transform: uppercase;
    letter-spacing: .7px;
    margin-bottom: 8px;
}
.circuit-type-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-100);
}

/* Circuit name rows */
.circuit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.circuit-num {
    font-size: 11px;
    color: var(--gray-300);
    font-family: var(--font-mono);
    width: 18px;
    text-align: right;
    flex-shrink: 0;
    user-select: none;
}
.circuit-name-input {
    flex: 1;
    max-width: 300px;
}
.circuit-del {
    width: 24px; height: 24px;
    border: none;
    background: transparent;
    color: var(--gray-300);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    transition: all .12s;
    flex-shrink: 0;
}
.circuit-del:hover { background: #fee2e2; color: #ef4444; }

/* Add circuit button */
.circuit-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--gray-400);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    margin-top: 2px;
}
.circuit-add-btn span { font-size: 15px; line-height: 1; margin-top: -1px; }
.circuit-add-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--teal-50);
}

/* ── Sidebar styles ──────────────────────────────────────────────────────── */
.sb-section { padding: 14px 16px; border-bottom: 1px solid var(--gray-100); }
.sb-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--gray-400); margin-bottom: 8px; }
.sb-step-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 8px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--gray-500);
    cursor: pointer;
    text-align: left;
    transition: all .1s;
}
.sb-step-btn:hover { background: var(--gray-100); color: var(--gray-800); }
.sb-step-btn.active { background: var(--teal-50); color: var(--teal-800); font-weight: 600; }
.sb-step-btn.done { color: var(--gray-600); }
.sb-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--gray-300);
    flex-shrink: 0;
}
.sb-step-btn.active .sb-dot { background: var(--accent); }
.sb-step-btn.done .sb-dot { background: var(--teal-300); }
.sb-info-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--gray-600);
    padding: 3px 0;
}
.sb-info-row strong { color: var(--gray-800); }
.sb-sys-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.sb-sys-chip {
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 10px;
    background: var(--teal-100);
    color: var(--teal-800);
    font-weight: 600;
}

/* ── Save indicator ─────────────────────────────────────────────────────── */
#save-indicator {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-600);
    opacity: 0;
    transition: opacity .3s;
    white-space: nowrap;
}
#save-indicator.saved { opacity: 1; color: var(--teal-400); }

/* ── Drag handle & drag-to-reorder ──────────────────────────────────────── */
.drag-handle {
  cursor: grab;
  color: var(--gray-300);
  font-size: 14px;
  padding: 0 4px;
  user-select: none;
  flex-shrink: 0;
  line-height: 1;
}
.drag-handle:hover { color: var(--gray-500); }
.drag-handle:active { cursor: grabbing; }

.floor-card.drag-over,
.tree-floor-node.drag-over {
  box-shadow: 0 0 0 2px var(--teal-400);
  opacity: 0.75;
}
.floor-card.dragging,
.tree-floor-node.dragging { opacity: 0.4; }

/* ── Preview line numbers ────────────────────────────────────────────────── */
.xml-preview .ln {
  display: block;
  counter-increment: ln;
}
.xml-preview .ln::before {
  content: counter(ln);
  display: inline-block;
  width: 3ch;
  margin-right: 12px;
  color: #475569;
  text-align: right;
  user-select: none;
  font-size: 10px;
}
.xml-preview { counter-reset: ln; }
.xml-preview .csv-header { color: #86efac; font-weight: 600; }

/* ── Toast undo button ───────────────────────────────────────────────────── */
.toast-undo {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-left: 8px;
  vertical-align: middle;
  transition: background .15s;
}
.toast-undo:hover { background: rgba(255,255,255,0.25); }

/* ── GA name editing ─────────────────────────────────────────────────────── */
.ga-name-text { cursor: text; flex: 1; }
.ga-name-input { display: none; flex: 1; }
.ga-name-input.visible { display: block; }

/* ── Sprint 2 base styles ────────────────────────────────────────────────── */
.floor-select-mobile { display: none; }

.manual-ga-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}

/* Input width helpers — used in manual GA form */
.input-w-lg  { width: 140px; }
.input-w-md  { width: 130px; }
.input-w-sm  { width: 80px; }
.input-w-xs  { width: 100px; }
.input-w-dpt { width: 220px; }

/* DPT search field */
.field-hint { font-size: 11px; font-weight: 400; color: var(--gray-400); }
.dpt-search-wrap { position: relative; display: inline-flex; align-items: center; }
.dpt-search-icon { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--gray-400); pointer-events: none; }
.dpt-search-input { width: 260px; padding-left: 26px !important; }
.field-dpt { flex: 1 1 260px; }

/* Custom DPT dropdown list */
.dpt-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  min-width: 320px;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  z-index: 200;
}
.dpt-dropdown.open { display: block; }
.dpt-option {
  padding: 7px 12px;
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  border-bottom: 1px solid var(--gray-50);
  white-space: nowrap;
}
.dpt-option:hover, .dpt-option.focused { background: var(--teal-50); color: var(--teal-700); }
.dpt-option-more { padding: 6px 12px; font-size: 11px; color: var(--gray-400); text-align: center; }

/* Address x/y/z inline group */
.addr-inputs { display: flex; align-items: center; gap: 4px; }
.addr-inputs .addr-part { width: 80px; text-align: center; }
.addr-sep { font-size: 14px; font-weight: 600; color: var(--gray-400); line-height: 1; }

/* ── Hamburger button (hidden on desktop) ────────────────────────────────── */
.btn-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--gray-600);
  color: var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.btn-hamburger:hover { border-color: var(--teal-400); color: var(--teal-300); }

/* ── Sidebar backdrop (mobile only) ─────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
}
.sidebar-backdrop.open { display: block; }

/* ══ Responsive breakpoints ══════════════════════════════════════════════ */

/* ── Tablet ≤ 768px ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 220px; }

  #panel { padding: 16px; gap: 16px; }

  /* Step 2: stacked */
  .two-col { grid-template-columns: 1fr; }
  .ga-set-preview { position: static; }

  /* Step 6: stacked */
  .export-layout { grid-template-columns: 1fr; }

  /* Step 4: show dropdown, hide sidebar floor list */
  .floor-select-mobile { display: block; margin-bottom: 12px; }
  .assign-layout { grid-template-columns: 1fr; }
  .assign-left   { display: none; }

  /* Step 5 toolbar: wrap buttons below filter chips */
  .ga-toolbar { flex-direction: column; align-items: stretch; }
  .ga-toolbar .filter-chips { flex-wrap: wrap; }
  .ga-toolbar > div:last-child { margin-left: 0; flex-wrap: wrap; }
}

/* ── Mobile ≤ 480px ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  :root { --sidebar-w: 280px; }

  /* Show hamburger */
  .btn-hamburger { display: inline-flex; }

  /* Sidebar: fixed drawer sliding in from left */
  #sidebar {
    position: fixed;
    top: calc(var(--header-h) + var(--step-h));
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
    box-shadow: var(--shadow-lg);
    border-right: 1px solid var(--gray-200);
  }
  #sidebar.open { transform: translateX(0); }

  /* Panel takes full width */
  #panel { padding: 12px; gap: 12px; }

  /* Step bar: hide labels, keep numbers only */
  .step-label { display: none; }
  .step-arrow { display: none; }
  .step-item  { padding: 6px 8px; }

  /* Step 1 */
  .start-options  { grid-template-columns: 1fr; }
  .structure-grid { grid-template-columns: 1fr; }

  /* Step 5: smaller stat values */
  .stat-card .val { font-size: 22px; }

  /* Step 5 GA tree: reduce deep indent, hide secondary columns */
  .ga-row     { padding-left: 16px; }
  .ga-mid-row { padding-left: 12px; }
  .ga-row .dpt  { display: none; }
  .ga-row .type { display: none; }

  /* Step 5 manual GA form: 2-column grid */
  .manual-ga-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
  .manual-ga-form .field-name { grid-column: 1 / -1; }
  .manual-ga-form > .btn      { grid-column: 1 / -1; width: 100%; justify-content: center; }
  .input-w-lg, .input-w-md, .input-w-sm, .input-w-xs { width: 100%; }

  /* Header: shorten project name */
  .header-project { max-width: 110px; }
}
