:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --secondary: #475569;
    --success: #15803d;
    --success-soft: #ecfdf3;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --warning: #b45309;
    --warning-soft: #fffbeb;
    --text: #172033;
    --muted: #667085;
    --border: #e4e7ec;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --background: #f3f6fb;
    --sidebar: #101828;
    --sidebar-muted: #98a2b3;
    --shadow: 0 12px 30px rgba(16, 24, 40, 0.08);
    --radius: 16px;
    --sidebar-width: 260px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--background);
    font-size: 14px;
    line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.admin-shell { min-height: 100vh; }
.admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    color: #fff;
    padding: 22px 16px;
    overflow-y: auto;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    padding: 0 8px 22px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: inline-grid;
    place-items: center;
    background: linear-gradient(135deg, #60a5fa, #2563eb);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: .04em;
    box-shadow: 0 8px 18px rgba(37, 99, 235, .28);
    flex: none;
}
.brand-mark.large { width: 58px; height: 58px; border-radius: 18px; font-size: 19px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 2px; color: var(--sidebar-muted); font-size: 12px; }
.sidebar-nav { display: grid; gap: 6px; padding-top: 22px; }
.nav-link {
    min-height: 45px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 11px;
    color: #d0d5dd;
    transition: .18s ease;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-link.active { color: #fff; background: var(--primary); box-shadow: 0 8px 20px rgba(37,99,235,.25); }
.nav-icon { width: 24px; text-align: center; font-size: 18px; }
.sidebar-footer { margin-top: auto; padding-top: 24px; }
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 8px;
    border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-user strong, .sidebar-user small { display: block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { font-size: 13px; }
.sidebar-user small { font-size: 11px; color: var(--sidebar-muted); }
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 800;
    flex: none;
}
.admin-main { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
    position: sticky;
    top: 0;
    z-index: 25;
    min-height: 86px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 30px;
    background: rgba(255,255,255,.93);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 23px; line-height: 1.25; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 9px; font-weight: 600; }
.mobile-menu-button {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
}
.content-wrap { padding: 28px 30px 44px; }
.sidebar-overlay { display: none; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}
.panel-header h2 { margin: 0; font-size: 17px; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.form-panel { max-width: 980px; padding: 24px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 700;
    font-size: 13px;
    line-height: 1;
    transition: .18s ease;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { color: #fff; background: var(--secondary); border-color: var(--secondary); }
.btn-outline { color: #344054; background: #fff; border-color: #d0d5dd; }
.btn-outline:hover { border-color: #98a2b3; background: #f9fafb; }
.btn-ghost { color: #475467; background: transparent; border-color: transparent; }
.btn-ghost:hover { background: #f2f4f7; }
.btn-danger-outline { color: var(--danger); background: #fff; border-color: #fecaca; }
.btn-danger-outline:hover { background: var(--danger-soft); }
.btn-sm { min-height: 33px; padding: 7px 10px; font-size: 12px; border-radius: 8px; }
.btn-lg { min-height: 48px; }
.btn-block { width: 100%; }

.alert {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 16px;
    margin-bottom: 20px;
    border: 1px solid;
    border-radius: 12px;
    transition: .25s ease;
}
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert button { border: 0; background: transparent; font-size: 20px; line-height: 1; color: inherit; }
.alert-success { color: #166534; background: var(--success-soft); border-color: #bbf7d0; }
.alert-danger { color: #991b1b; background: var(--danger-soft); border-color: #fecaca; }
.alert-warning { color: #92400e; background: var(--warning-soft); border-color: #fde68a; }
.fade-out { opacity: 0; transform: translateY(-6px); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 18px; margin-bottom: 22px; }
.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 126px;
    padding: 20px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.stat-icon { flex: 0 0 48px; width: 48px; height: 48px; border-radius: 14px; display: grid !important; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 22px; line-height: 1; }
.stat-card > div { min-width: 0; }
.stat-card small, .stat-card span, .stat-card strong { display: block; }
.stat-card small { color: var(--muted); }
.stat-card strong { margin-top: 3px; font-size: 26px; line-height: 1.1; }
.stat-card div > span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .8fr); gap: 20px; }
.quick-actions { padding-bottom: 10px; }
.quick-action { display: flex; align-items: center; gap: 12px; margin: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; transition: .18s ease; }
.quick-action:hover { border-color: #bfdbfe; background: var(--primary-soft); }
.quick-action > span { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: #eef2ff; color: #4f46e5; font-size: 20px; }
.quick-action strong, .quick-action small { display: block; }
.quick-action small { margin-top: 2px; color: var(--muted); }

.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: nowrap;
}

.page-actions .filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
}

.page-actions .filters input {
    flex: 1 1 280px;
    min-width: 180px;
    max-width: 380px;
}

.page-actions .filters select {
    width: 160px;
    flex: 0 0 160px;
}

.page-actions .filters .btn,
.page-actions > .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}
.form-grid { display: grid; gap: 18px; }
.form-grid.two-column { grid-template-columns: repeat(2, minmax(0,1fr)); align-items: start; }
.form-group { display: grid; align-content: start; gap: 7px; }
.form-group label { color: #344054; font-weight: 700; font-size: 12px; }
.form-group label span { color: var(--danger); }
.form-group small { color: var(--muted); font-size: 11px; }
input, select, textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid #d0d5dd;
    border-radius: 9px;
    outline: 0;
    transition: border-color .16s, box-shadow .16s;
}
.form-group > input,
.form-group > select { height: 42px; }
input:focus, select:focus, textarea:focus { border-color: #84adff; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
input[readonly] { background: #f8fafc; color: #667085; }
.switch-field { display: flex; align-items: center; gap: 11px; margin-top: 22px; cursor: pointer; }
.switch-field input[type=checkbox] { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui { width: 42px; height: 24px; padding: 3px; border-radius: 999px; background: #d0d5dd; transition: .18s; }
.switch-ui::after { content: ""; display: block; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: .18s; }
.switch-field input:checked + .switch-ui { background: var(--primary); }
.switch-field input:checked + .switch-ui::after { transform: translateX(18px); }
.switch-field strong, .switch-field small { display: block; }
.switch-field small { color: var(--muted); font-weight: 400; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--border); }

.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 14px 16px; border-bottom: 1px solid #eaecf0; text-align: left; vertical-align: middle; }
.data-table th { color: #667085; background: #f9fafb; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.data-table tbody tr:hover { background: #fcfcfd; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td > strong, .data-table td > small { display: block; }
.data-table td > small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.text-right { text-align: right !important; }
.entity-cell { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.entity-cell strong, .entity-cell small { display: block; }
.entity-cell small { color: var(--muted); font-size: 11px; }
.entity-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.table-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; white-space: nowrap; }
.table-actions form { margin: 0; }
.empty-cell { padding: 42px 20px !important; color: var(--muted); text-align: center !important; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge-active { color: #166534; background: #dcfce7; }
.badge-draft { color: #92400e; background: #fef3c7; }
.badge-inactive { color: #475467; background: #f2f4f7; }
.badge-neutral { color: #344054; background: #f2f4f7; }
.status-toggle { display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; color: #667085; font-weight: 700; }
.status-toggle span { width: 8px; height: 8px; border-radius: 50%; background: #98a2b3; }
.status-toggle.active { color: #15803d; }
.status-toggle.active span { background: #22c55e; }
.text-link { color: var(--primary); font-weight: 700; }
.muted { color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 16px; border-top: 1px solid var(--border); }
.pagination-link { min-height: 34px; display: inline-flex; align-items: center; padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-weight: 700; font-size: 12px; }
.pagination-link.disabled { opacity: .45; }
.pagination-info { color: var(--muted); font-size: 12px; }

.model-meta-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
.model-meta-bar h2 { margin: 2px 0 0; font-size: 20px; }
.model-meta-bar small { color: var(--muted); }
.eyebrow { color: var(--primary); font-weight: 800; font-size: 10px; letter-spacing: .1em; }
.builder-grid { display: grid; grid-template-columns: minmax(0,1.65fr) minmax(320px,.75fr); gap: 20px; align-items: start; }
.builder-panel { min-height: 460px; }
.sticky-builder-header { position: static; background: #fff; }
.builder-rows { display: grid; gap: 16px; padding: 18px; }
.empty-builder { min-height: 360px; display: grid; place-items: center; align-content: center; gap: 8px; padding: 28px; text-align: center; color: var(--muted); }
.empty-builder[hidden] { display: none; }
.empty-builder > span { font-size: 42px; color: #98a2b3; }
.empty-builder h3 { margin: 0; color: var(--text); }
.empty-builder p { margin: 0 0 8px; }
.row-card { border: 1px solid #dbe2ea; border-radius: 14px; background: #fbfcfe; overflow: hidden; }
.row-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; border-bottom: 1px solid #e4e7ec; background: #fff; }
.row-title { display: flex; align-items: center; gap: 9px; }
.row-title strong, .row-title small { display: block; }
.row-title small { color: var(--muted); font-size: 11px; }
.drag-handle { color: #98a2b3; letter-spacing: -3px; font-size: 18px; user-select: none; }
.row-toolbar { display: flex; align-items: center; gap: 7px; }
.row-toolbar label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.row-toolbar select { width: 105px; min-height: 34px; padding: 5px 8px; }
.row-toolbar > button, .icon-actions button { min-width: 34px; height: 34px; border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; color: #475467; font-weight: 800; }
.row-toolbar > button.danger, .icon-actions button.danger { color: var(--danger); border-color: #fecaca; }
.column-list { display: grid; gap: 10px; padding: 13px; }
.column-card { padding: 12px; background: #fff; border: 1px solid #e4e7ec; border-radius: 11px; }
.column-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.column-card-header > div:first-child { display: flex; align-items: center; gap: 8px; }
.icon-actions { display: flex; gap: 5px; }
.column-fields { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; align-items: start; }
.column-fields input, .column-fields select { height: 38px; min-height: 38px; padding: 7px 9px; }
.column-fields .form-group { gap: 5px; }
.add-column-button { width: calc(100% - 26px); min-height: 38px; margin: 0 13px 13px; color: var(--primary); background: #fff; border: 1px dashed #93c5fd; border-radius: 9px; font-weight: 800; }
.add-column-button:hover { background: var(--primary-soft); }
.no-columns { padding: 14px; border: 1px dashed #d0d5dd; border-radius: 9px; color: var(--muted); text-align: center; }
.preview-panel { position: sticky; top: 106px; }
.model-preview-frame { margin: 18px; padding: 16px; border: 1px solid #dbe2ea; border-radius: 16px; background: #f8fafc; }
.preview-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 13px; margin-bottom: 14px; border-bottom: 1px solid #e4e7ec; }
.preview-title strong, .preview-title small { display: block; }
.preview-title small { color: var(--muted); font-size: 10px; }
.live-preview { display: grid; gap: 12px; min-height: 180px; align-content: center; }
.preview-row { display: flex; align-items: center; gap: 8px; min-height: 68px; padding: 9px; border: 1px solid #d9e2ec; border-radius: 12px; background: #fff; overflow-x: auto; }
.preview-row {
    scrollbar-width: thin;
    scrollbar-color: #98a2b3 #eef2f7;
}
.preview-row::-webkit-scrollbar { height: 6px; }
.preview-row::-webkit-scrollbar-track {
    margin-inline: 9px;
    background: #eef2f7;
    border-radius: 999px;
}
.preview-row::-webkit-scrollbar-thumb {
    background: #98a2b3;
    border-radius: 999px;
}
.preview-row::-webkit-scrollbar-thumb:hover { background: var(--primary); }
.preview-align-left { justify-content: flex-start; }
.preview-align-center { justify-content: center; }
.preview-align-right { justify-content: flex-end; }
.preview-control { flex: 0 0 calc(44px + (var(--control-width, 1) - 1) * 13px); min-width: 44px; min-height: 48px; display: grid; place-items: center; align-content: center; gap: 2px; padding: 5px; border: 1px solid #cfd8e3; border-radius: 10px; background: linear-gradient(180deg,#fff,#f8fafc); box-shadow: 0 2px 7px rgba(16,24,40,.06); text-align: center; }
.preview-control span { color: #344054; font-size: 20px; line-height: 1; }
.preview-control small { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #667085; font-size: 8px; }
.preview-control.is-blank { border-style: dashed; background: transparent; box-shadow: none; }
.preview-stack { flex: 0 0 calc(44px + (var(--control-width, 1) - 1) * 13px); min-width: 44px; display: flex; flex-direction: column; gap: 4px; }
.preview-stack .preview-control { flex: 0 0 auto; width: 100%; min-width: 0; min-height: 34px; padding: 4px; }
.preview-stack .preview-control span { font-size: 16px; }
.preview-stack .preview-control small { font-size: 7px; }
.preview-empty, .preview-row-empty { color: var(--muted); text-align: center; font-size: 12px; }
.preview-row-empty { width: 100%; }
.preview-legend { display: grid; gap: 7px; padding: 0 18px 18px; color: var(--muted); font-size: 10px; }
.preview-legend span { display: flex; align-items: center; gap: 6px; }
.preview-legend i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.save-bar { position: sticky; bottom: 14px; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 20px; padding: 14px 16px; background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 14px 35px rgba(16,24,40,.13); backdrop-filter: blur(10px); }
.save-bar strong, .save-bar small { display: block; }
.save-bar small { color: var(--muted); }
.save-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.model-summary-inline { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.view-layout-grid { display: grid; grid-template-columns: minmax(260px,.7fr) minmax(420px,1.3fr); gap: 20px; margin-bottom: 20px; align-items: start; }
.detail-list { margin: 0; padding: 8px 22px 20px; }
.detail-list > div { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 13px 0; border-bottom: 1px solid #eaecf0; }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-weight: 700; }
.static-preview-panel { position: static; }
.model-configuration-panel { padding-bottom: 18px; }
.saved-row-card { margin: 14px 18px 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.saved-row-header { display: flex; justify-content: space-between; gap: 10px; padding: 11px 13px; background: #f8fafc; border-bottom: 1px solid var(--border); }
.saved-row-header span { color: var(--muted); font-size: 11px; }
.saved-columns { display: grid; grid-template-columns: repeat(auto-fill,minmax(180px,1fr)); gap: 10px; padding: 12px; }
.saved-columns > div { padding: 10px; border: 1px solid var(--border); border-radius: 9px; }
.saved-columns strong, .saved-columns small { display: block; }
.saved-columns small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.login-body { background: #eef3f9; }
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(430px,1.05fr) minmax(430px,.95fr); }
.login-visual { display: grid; place-items: center; padding: 60px; color: #fff; background: radial-gradient(circle at 25% 15%, rgba(96,165,250,.4), transparent 35%), linear-gradient(145deg,#0f172a,#172554 65%,#1d4ed8); }
.login-visual-content { max-width: 560px; }
.login-visual h1 { margin: 20px 0 10px; font-size: clamp(34px,4vw,54px); line-height: 1.05; }
.login-visual p { max-width: 520px; margin: 0; color: #dbeafe; font-size: 16px; }
.mini-layout-preview { display: grid; gap: 12px; margin-top: 42px; padding: 18px; border: 1px solid rgba(255,255,255,.2); border-radius: 18px; background: rgba(255,255,255,.08); backdrop-filter: blur(10px); }
.mini-layout-preview > div { display: flex; gap: 10px; padding: 10px; border-radius: 10px; background: rgba(255,255,255,.08); }
.mini-layout-preview > div.center { justify-content: center; }
.mini-layout-preview > div.right { justify-content: flex-end; }
.mini-layout-preview span { width: 52px; height: 42px; border: 1px solid rgba(255,255,255,.35); border-radius: 9px; background: rgba(255,255,255,.12); }
.login-panel { display: grid; place-items: center; padding: 34px; }
.login-card { width: min(430px,100%); padding: 34px; border: 1px solid var(--border); border-radius: 20px; background: #fff; box-shadow: 0 24px 60px rgba(15,23,42,.12); }
.login-heading { margin-bottom: 24px; }
.login-heading h2 { margin: 5px 0 4px; font-size: 28px; }
.login-heading p { margin: 0; color: var(--muted); }
.login-card .form-group { margin-bottom: 16px; }
.password-field { position: relative; }
.password-field input { padding-right: 60px; }
.password-field button { position: absolute; right: 7px; top: 7px; height: 28px; padding: 0 8px; border: 0; border-radius: 7px; color: var(--primary); background: var(--primary-soft); font-size: 11px; font-weight: 800; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 3px 0 20px; color: var(--muted); }
.checkbox-row input { width: 16px; min-height: 16px; }

@media (max-width: 1180px) {
    .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .builder-grid { grid-template-columns: 1fr; }
    .preview-panel { position: static; }
    .column-fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 980px) {
    .admin-sidebar { transform: translateX(-100%); transition: transform .22s ease; }
    .admin-main { margin-left: 0; }
    .mobile-menu-button { display: inline-grid; place-items: center; }
    .sidebar-overlay { position: fixed; inset: 0; z-index: 35; background: rgba(15,23,42,.45); }
    body.sidebar-open .admin-sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-overlay { display: block; }
    .topbar { padding: 16px 20px; }
    .content-wrap { padding: 22px 20px 36px; }
    .dashboard-grid, .view-layout-grid { grid-template-columns: 1fr; }
    .login-page { grid-template-columns: 1fr; }
    .login-visual { display: none; }
    .login-panel { min-height: 100vh; }
}

@media (max-width: 720px) {
    .topbar-user { display: none; }
    .topbar h1 { font-size: 19px; }
    .topbar p { display: none; }
    .content-wrap { padding: 16px 14px 30px; }
    .stats-grid { grid-template-columns: 1fr; gap: 12px; }
    .stat-card { min-height: 100px; }
    .page-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .page-actions .filters {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .page-actions .filters input,
    .page-actions .filters select,
    .page-actions .filters .btn,
    .page-actions > .btn {
        width: 100%;
        min-width: 0;
        max-width: none;
        flex: 1 1 100%;
    }
    .filters input, .filters select, .filters .btn { width: 100%; min-width: 0; }
    .form-grid.two-column, .column-fields { grid-template-columns: 1fr; }
    .form-panel { padding: 18px; }
    .row-card-header { align-items: flex-start; flex-direction: column; }
    .row-toolbar { width: 100%; flex-wrap: wrap; }
    .row-toolbar label { flex: 1; }
    .row-toolbar select { width: 100%; }
    .save-bar { position: static; align-items: stretch; flex-direction: column; }
    .save-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .save-actions .btn:first-child { grid-column: 1 / -1; }
    .model-meta-bar { align-items: flex-start; flex-direction: column; }
    .table-actions { justify-content: flex-start; }
    .pagination { justify-content: space-between; }
    .login-panel { padding: 16px; }
    .login-card { padding: 24px 20px; }
}
.drag-handle { cursor: grab; }
.drag-handle:active { cursor: grabbing; }
.row-card.is-dragging, .column-card.is-dragging { opacity: .45; border-style: dashed; }

/* Light/Fan grouped control helpers */
.row-add-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 0 13px 13px;
}
.row-add-actions .add-column-button {
    width: 100%;
    margin: 0;
}
.add-group-button {
    min-height: 38px;
    border: 1px dashed #93c5fd;
    border-radius: 9px;
    background: #fff;
    color: var(--primary);
    font-weight: 800;
}
.add-group-button:hover {
    background: var(--primary-soft);
}
.preview-indicator {
    min-height: 48px;
}
.preview-level-dots {
    width: 28px;
    min-height: 28px;
    display: grid;
    grid-template-columns: repeat(2, 5px);
    place-content: center;
    gap: 3px;
    border: 1px solid #e4e7ec;
    border-radius: 50%;
}
.preview-level-dots i {
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #d0d5dd;
}
.preview-level-dots i.is-active {
    background: var(--primary);
    box-shadow: 0 0 5px rgba(37, 99, 235, .45);
}

@media (max-width: 700px) {
    .row-add-actions {
        grid-template-columns: 1fr;
    }
}
