* {
    box-sizing: border-box;
}

:root {
    --bg: #eef2f7;
    --bg-soft: #f8fafc;
    --surface: #ffffff;
    --text: #172230;
    --muted: #5e7289;
    --line: #d8e0eb;
    --line-strong: #c4d0df;
    --primary: #0f4f8a;
    --primary-soft: #d9ebff;
    --danger: #b33a2f;
    --danger-soft: #ffe8e5;
    --success: #1f7a3d;
    --success-soft: #e8f8ee;
    --sidebar: #0f1d2d;
    --sidebar-soft: #21364d;
    --shadow: 0 8px 24px rgba(18, 37, 61, 0.08);
}

body {
    margin: 0;
    font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
    line-height: 1.4;
    color: var(--text);
    background: radial-gradient(circle at 20% 0%, #f4f7fd 0, #eef2f7 36%, #edf1f6 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

.app-body {
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 244px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, var(--sidebar) 0%, #182a3f 100%);
    color: #dce7f6;
    padding: 14px 11px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
}

.sidebar-toggle {
    display: none;
    margin-left: auto;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.08);
    color: #e6f1ff;
    border-radius: 8px;
    padding: 7px 11px;
    font-size: 13px;
    font-weight: 600;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(145deg, #3081c2, #12518b);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.brand-title {
    font-size: 14px;
    font-weight: 700;
}

.brand-sub {
    color: #99aec9;
    font-size: 11px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link {
    padding: 8px 10px;
    border-radius: 8px;
    color: #c9d8ec;
    transition: 0.18s ease;
    font-size: 13px;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
    background: #27496d;
    color: #fff;
}

.sidebar.advanced-nav-hidden [data-sidebar-advanced-item] {
    display: none;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.13);
    padding-top: 10px;
}

.sidebar-advanced-switch {
    width: 100%;
    margin-bottom: 8px;
    border: 1px solid rgba(197, 214, 234, 0.22);
    border-radius: 8px;
    background: rgba(173, 188, 204, 0.12);
    color: #d7e2f2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
}

.sidebar-advanced-switch-label {
    opacity: 0.92;
}

.sidebar-advanced-switch-track {
    width: 30px;
    height: 16px;
    border-radius: 999px;
    background: #2d7b4e;
    border: 1px solid rgba(255, 255, 255, 0.28);
    position: relative;
    transition: background 0.16s ease;
}

.sidebar-advanced-switch-thumb {
    position: absolute;
    top: 1px;
    left: 14px;
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #ffffff;
    transition: left 0.16s ease;
}

.sidebar-advanced-switch.is-off .sidebar-advanced-switch-track {
    background: #74859a;
}

.sidebar-advanced-switch.is-off .sidebar-advanced-switch-thumb {
    left: 1px;
}

.sidebar-advanced-switch:hover {
    background: rgba(186, 200, 214, 0.2);
    filter: none;
}

.locale-form {
    margin-bottom: 8px;
}

.locale-select-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(165, 178, 194, 0.2);
    border: 1px solid rgba(196, 210, 227, 0.24);
    border-radius: 8px;
    padding: 4px 6px;
}

.locale-flag {
    min-width: 16px;
    min-height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    opacity: 0.92;
}

.locale-flag::before {
    content: "\1F310";
    font-size: 13px;
}

.locale-flag[data-locale-country="fr"]::before { content: "\1F1EB\1F1F7"; }
.locale-flag[data-locale-country="gb"]::before { content: "\1F1EC\1F1E7"; }
.locale-flag[data-locale-country="de"]::before { content: "\1F1E9\1F1EA"; }
.locale-flag[data-locale-country="es"]::before { content: "\1F1EA\1F1F8"; }
.locale-flag[data-locale-country="it"]::before { content: "\1F1EE\1F1F9"; }
.locale-flag[data-locale-country="pt"]::before { content: "\1F1F5\1F1F9"; }
.locale-flag[data-locale-country="nl"]::before { content: "\1F1F3\1F1F1"; }
.locale-flag[data-locale-country="pl"]::before { content: "\1F1F5\1F1F1"; }
.locale-flag[data-locale-country="cz"]::before { content: "\1F1E8\1F1FF"; }
.locale-flag[data-locale-country="sk"]::before { content: "\1F1F8\1F1F0"; }
.locale-flag[data-locale-country="ro"]::before { content: "\1F1F7\1F1F4"; }
.locale-flag[data-locale-country="hu"]::before { content: "\1F1ED\1F1FA"; }
.locale-flag[data-locale-country="xx"]::before { content: "\1F310"; }
}

.locale-form select {
    width: 100%;
    border: 0;
    padding: 3px 2px;
    border-radius: 0;
    background: transparent;
    color: #d8e5f4;
    font-size: 11px;
    font-weight: 600;
    box-shadow: none;
}

.locale-form select:focus,
.locale-form select:focus-visible {
    border: 0;
    box-shadow: none;
    outline: none;
}

.locale-form select option {
    color: #152437;
    background: #ffffff;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.user-line {
    margin-bottom: 10px;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
}

.user-role {
    font-size: 11px;
    color: #9db4d2;
}

.main-content {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.group-page .app-shell {
    height: 100vh;
}

.group-page .main-content {
    height: 100vh;
    overflow: hidden;
    padding: 12px 16px;
    gap: 10px;
    min-height: 0;
}

.group-page .panel {
    padding: 12px;
}

.home-page .app-shell {
    height: 100vh;
    grid-template-columns: 204px 1fr;
}

.home-page .sidebar {
    padding: 12px 10px;
    gap: 10px;
}

.home-page .brand {
    padding: 4px 6px;
    gap: 8px;
}

.home-page .brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 14px;
}

.home-page .brand-title {
    font-size: 12px;
}

.home-page .brand-sub {
    font-size: 10px;
}

.home-page .nav-link {
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
}

.home-page .sidebar-footer {
    padding-top: 8px;
}

.home-page .user-name {
    font-size: 12px;
}

.home-page .user-role {
    font-size: 10px;
}

.home-page .main-content {
    height: 100vh;
    overflow: hidden;
    padding: 8px 10px;
    gap: 6px;
}

.home-page .home-workspace {
    flex: 1;
    min-height: 0;
}

.home-page .pane {
    min-height: 0;
}

.home-page .tree-sidebar-pane {
    max-height: none;
    min-height: 0;
}

.home-page .panel {
    padding: 8px 10px;
}

.home-page .panel-title {
    font-size: 15px;
}

.home-page .panel-sub {
    font-size: 11px;
}

.home-page .panel-title-small {
    margin-bottom: 4px;
    font-size: 13px;
}

.home-page .panel-subtitle {
    margin: 8px 0 5px;
    font-size: 12px;
}

.home-page .stats-grid {
    gap: 6px;
    margin-top: 6px;
}

.home-page .stat-box {
    padding: 6px 8px;
}

.home-page .stat-box span {
    font-size: 10px;
}

.home-page .stat-box strong {
    margin-top: 2px;
    font-size: 20px;
    line-height: 1;
}

.home-page .toolbar {
    padding: 6px;
    gap: 6px;
}

.home-page .field {
    gap: 3px;
    min-width: 136px;
}

.home-page .field label {
    font-size: 11px;
}

.home-page input,
.home-page select,
.home-page textarea {
    padding: 6px 7px;
    border-radius: 7px;
}

.home-page .btn,
.home-page button {
    padding: 6px 9px;
    font-size: 12px;
    border-radius: 7px;
}

.home-page .btn-link {
    padding: 3px 6px;
    font-size: 11px;
}

.home-page .tree-pane-add {
    width: 24px;
    height: 24px;
}

.home-page .tree-link {
    padding: 4px 5px;
}

.home-page .tree-label {
    font-size: 12px;
}

.home-page .tree-count {
    font-size: 10px;
}

.home-page .object-list {
    gap: 3px;
}

.home-page .object-row {
    padding: 5px;
}

.home-page .obj-key,
.home-page .obj-meta {
    font-size: 10px;
}

.home-page th,
.home-page td {
    padding: 5px 4px;
    font-size: 11px;
}

.home-page th {
    font-size: 10px;
}

.home-page .table-scroll table {
    min-width: 560px;
}

.home-page .home-list-pane,
.home-page .home-detail-pane {
    overflow: auto;
}

.home-page .home-list-pane.is-panel-hidden {
    display: none;
}

.home-page .home-detail-pane.is-wide {
    grid-column: 2 / 4;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.home-page .home-detail-pane.is-wide .attributes-table-scroll {
    flex: 1;
}

.home-page .home-detail-pane .pane-head {
    position: sticky;
    top: -1px;
    z-index: 2;
    background: #fff;
    padding-bottom: 6px;
}

.home-page .detail-grid {
    gap: 6px;
}

@media (min-width: 981px) {
    .compact-ui .app-shell {
        grid-template-columns: 204px 1fr;
    }

    .compact-ui .sidebar {
        padding: 12px 10px;
        gap: 10px;
    }

    .compact-ui .brand {
        padding: 4px 6px;
        gap: 8px;
    }

    .compact-ui .brand-logo {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        font-size: 14px;
    }

    .compact-ui .brand-title {
        font-size: 12px;
    }

    .compact-ui .brand-sub {
        font-size: 10px;
    }

    .compact-ui .nav-link {
        padding: 8px 10px;
        border-radius: 8px;
        font-size: 12px;
    }

    .compact-ui .sidebar-footer {
        padding-top: 8px;
    }

    .compact-ui .user-name {
        font-size: 12px;
    }

    .compact-ui .user-role {
        font-size: 10px;
    }

    .compact-ui .main-content {
        padding: 8px 10px;
        gap: 6px;
    }

    .compact-ui .panel {
        padding: 8px 10px;
    }

    .compact-ui .panel-title {
        font-size: 15px;
    }

    .compact-ui .panel-sub {
        font-size: 11px;
    }

    .compact-ui .panel-title-small {
        margin-bottom: 4px;
        font-size: 13px;
    }

    .compact-ui .panel-subtitle {
        margin: 8px 0 5px;
        font-size: 12px;
    }

    .compact-ui .stats-grid {
        gap: 6px;
        margin-top: 6px;
    }

    .compact-ui .stat-box {
        padding: 6px 8px;
    }

    .compact-ui .stat-box span {
        font-size: 10px;
    }

    .compact-ui .stat-box strong {
        margin-top: 2px;
        font-size: 20px;
        line-height: 1;
    }

    .compact-ui .toolbar {
        padding: 6px;
        gap: 6px;
    }

    .compact-ui .field {
        gap: 3px;
        min-width: 136px;
    }

    .compact-ui .field label {
        font-size: 11px;
    }

    .compact-ui input,
    .compact-ui select,
    .compact-ui textarea {
        padding: 6px 7px;
        border-radius: 7px;
    }

    .compact-ui .btn,
    .compact-ui button {
        padding: 6px 9px;
        font-size: 12px;
        border-radius: 7px;
    }

    .compact-ui .btn-link {
        padding: 3px 6px;
        font-size: 11px;
    }

    .compact-ui th,
    .compact-ui td {
        padding: 5px 4px;
        font-size: 11px;
    }

    .compact-ui th {
        font-size: 10px;
    }

    .compact-ui .object-list {
        gap: 3px;
    }

    .compact-ui .object-row {
        padding: 5px;
    }

    .compact-ui .obj-key,
    .compact-ui .obj-meta {
        font-size: 10px;
    }

    .compact-ui .card {
        padding: 14px;
    }

    .compact-ui .title {
        margin: 0 0 6px;
        font-size: 18px;
    }

    .compact-ui .subtitle {
        margin: 0 0 8px;
        font-size: 12px;
    }

    .compact-ui .login-shell {
        max-width: 380px;
    }

    .compact-ui .setup-shell {
        max-width: 920px;
    }
}

.detail-grid-single {
    grid-template-columns: 1fr 1fr;
}

.row-selected {
    background: #e9f3ff !important;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 18px;
}

.title {
    margin: 0 0 8px;
    font-size: 21px;
}

.subtitle {
    margin: 0 0 10px;
    color: var(--muted);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 12px 12px 10px;
    overflow: hidden;
}

.panel-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.panel-title {
    margin: 0;
    font-size: 21px;
    font-weight: 700;
}

.panel-sub {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.panel-title-small {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 700;
}

.panel-subtitle {
    margin: 10px 0 6px;
    font-size: 14px;
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.stat-box {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg-soft);
    padding: 9px;
}

.stat-box span {
    display: block;
    font-size: 11px;
    color: var(--muted);
}

.stat-box strong {
    display: block;
    margin-top: 2px;
    font-size: 18px;
}

.workspace-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 1fr 1fr;
}

.home-workspace {
    grid-template-columns: minmax(260px, 0.95fr) minmax(250px, 0.88fr) minmax(520px, 1.62fr);
}

.pane-head-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.quick-inline-form {
    margin: 8px 0 12px;
    padding: 10px;
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
    background: #f8fbff;
}

.tree-sidebar-pane {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 360px;
    max-height: 72vh;
    overflow: hidden;
}

.tree-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.tree-sidebar-title {
    margin: 0;
}

.tree-sidebar-head-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tree-sidebar-toggle {
    min-width: 34px;
    height: 32px;
    padding: 0 6px;
    font-weight: 700;
}

.tree-sidebar-content {
    min-height: 0;
    height: 100%;
    overflow: auto;
    padding-right: 4px;
}

.tree-entity-overview {
    margin-bottom: 10px;
    border: 1px solid #d4e1ef;
    border-radius: 10px;
    background: linear-gradient(180deg, #f9fcff 0%, #f2f7fd 100%);
    padding: 8px;
}

.tree-entity-overview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.tree-entity-overview-title {
    font-size: 12px;
    color: #173755;
}

.tree-entity-overview-open {
    display: inline-flex;
    margin-bottom: 6px;
}

.tree-entity-overview-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 180px;
    overflow: auto;
    padding-right: 2px;
}

.tree-entity-overview-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid #cfdded;
    border-radius: 8px;
    background: #fff;
    padding: 5px 6px;
    font-size: 12px;
    color: #1b334c;
}

.tree-entity-overview-item:hover {
    background: #eef5ff;
    border-color: #adc5e1;
}

.tree-entity-overview-item-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-entity-overview-item-meta {
    flex: 0 0 auto;
    color: #4d6380;
    font-size: 11px;
}

.tree-sidebar-pane.is-collapsed {
    width: 56px;
    min-width: 56px;
    max-width: 56px;
    padding-left: 8px;
    padding-right: 8px;
    align-items: center;
}

.tree-sidebar-pane.is-collapsed .tree-sidebar-title,
.tree-sidebar-pane.is-collapsed .tree-sidebar-content,
.tree-sidebar-pane.is-collapsed .tree-sidebar-head-actions .tree-pane-add {
    display: none;
}

.tree-sidebar-pane.is-collapsed .tree-sidebar-head {
    width: 100%;
    justify-content: center;
}

.group-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.group-entity-shell {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

.group-current-banner {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 2fr;
    padding: 0;
    overflow: hidden;
}

.group-current-label {
    background: #1fa75c;
    color: #fff;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
    padding: 10px 14px;
}

.group-current-value {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 12px;
    font-size: 16px;
    color: #22435f;
    background: #fff;
}

.group-workspace {
    display: grid;
    grid-template-columns: minmax(760px, 2fr) minmax(300px, 1fr);
    gap: 10px;
    align-items: stretch;
    min-height: 0;
}

.group-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.group-main-entity {
    gap: 10px;
}

.group-main-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.group-main-head .panel-title-small {
    margin-bottom: 0;
}

.group-main-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    flex-wrap: wrap;
}

.group-zoom-tools {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.group-canvas {
    position: relative;
    height: 680px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    overflow: hidden;
    background: #f6f9fd;
}

.group-page .group-workspace {
    flex: 1;
    min-height: 0;
}

.group-page .group-main,
.group-page .group-workspace > aside {
    min-height: 0;
}

.group-page .group-canvas {
    height: 100%;
    min-height: 320px;
}

.group-org-list-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.group-org-list {
    flex: 1;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: auto;
    background: #fff;
}

.group-org-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid #e7edf5;
    transition: background-color 0.15s ease;
}

.group-org-item:last-child {
    border-bottom: 0;
}

.group-org-item:hover {
    background: #f3f8ff;
}

.group-org-item.is-selected {
    background: #e7f0ff;
    box-shadow: inset 3px 0 0 #2b5b8f;
}

.group-org-item.is-active {
    background: #1fa75c;
    color: #fff;
}

.group-org-item.is-active:hover {
    background: #1b9351;
}

.group-org-item.is-active.is-selected {
    box-shadow: none;
}

.group-org-item.is-active .badge-success {
    background: #fff;
    color: #1f7a3d;
}

.group-org-item.is-active .badge-warning {
    background: #f8f1d8;
    color: #825f00;
}

.group-org-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

.group-org-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.group-tree-title {
    margin-top: 12px;
}

.group-tree-panel {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f9fbff;
    padding: 8px;
    min-height: 120px;
    max-height: 220px;
    overflow: auto;
}

.group-tree-line {
    padding: 4px 4px 4px calc(8px + (var(--depth, 0) * 18px));
    white-space: nowrap;
    font-size: 12px;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 6px;
}

.group-tree-arrow {
    color: #56779c;
    display: inline-block;
    width: 14px;
}

.group-tree-kind {
    color: #214f7d;
    font-weight: 700;
    margin-right: 8px;
}

.group-tree-name {
    color: #1a2d42;
}

.group-tree-logo {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid #cad8e5;
    background: #f1f5fa;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    overflow: hidden;
    color: #214f7d;
    flex: 0 0 16px;
}

.group-tree-logo .icon-svg {
    width: 12px;
    height: 12px;
}

.group-tree-cycle {
    color: #b33a2f;
    margin-left: 6px;
}

.group-viewport {
    position: absolute;
    inset: 0;
    overflow: auto;
    cursor: grab;
}

.group-viewport.is-panning {
    cursor: grabbing;
}

.group-scene-wrap {
    position: relative;
    min-width: 100%;
    min-height: 100%;
}

.group-scene {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: 0 0;
    background-color: #f6f9fd;
    background-image:
        linear-gradient(#e4ebf4 1px, transparent 1px),
        linear-gradient(90deg, #e4ebf4 1px, transparent 1px);
    background-size: 24px 24px;
}

.group-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.group-line {
    stroke: #3b6fa3;
    stroke-width: 2;
    fill: none;
    opacity: 0.85;
}

#group_nodes {
    position: absolute;
    inset: 0;
}

.group-node {
    position: absolute;
    width: 220px;
    min-height: 112px;
    border: 1px solid #b7c9db;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(25, 44, 69, 0.12);
    cursor: move;
    user-select: none;
}

.group-node.is-group {
    border-color: #1f7a3d;
}

.group-node.link-from {
    box-shadow: 0 0 0 2px #2e6ea5, 0 8px 24px rgba(25, 44, 69, 0.14);
}

.group-node.is-selected {
    box-shadow: 0 0 0 2px #215c94, 0 10px 28px rgba(25, 44, 69, 0.2);
}

.group-node-head {
    display: flex;
    gap: 10px;
    padding: 14px;
}

.group-logo {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    border: 1px solid #cad8e5;
    background: #f1f5fa;
    color: #214f7d;
}

.group-logo.fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.group-logo .icon-svg {
    width: 22px;
    height: 22px;
}

.group-title-wrap {
    min-width: 0;
}

.group-title {
    font-weight: 700;
    color: #16324f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-sub {
    margin-top: 4px;
    font-size: 12px;
    color: #587392;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-handle {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 2px solid #2e6ea5;
    background: #fff;
    cursor: pointer;
    z-index: 2;
}

.group-handle.top {
    top: -8px;
}

.group-handle.bottom {
    bottom: -8px;
}

.group-context-menu {
    position: fixed;
    z-index: 70;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(24, 41, 66, 0.18);
    padding: 10px;
    width: min(320px, calc(100vw - 16px));
}

.group-context-title {
    margin: 0 0 8px;
    font-weight: 700;
    color: #16324f;
}

.group-context-form {
    display: grid;
    gap: 8px;
}

.group-context-menu button {
    border: 1px solid #d3e2f3;
    background: #f6fbff;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    color: #123f6b;
    text-align: left;
    font-weight: 600;
}

.group-context-menu button:hover {
    background: #e8f3ff;
}

.group-context-menu button.danger {
    border-color: #f2c2b9;
    background: #fff0ed;
    color: #8b2e23;
}

.group-context-menu button.danger:hover {
    background: #ffe2dc;
}

.table-scroll textarea {
    width: 100%;
    min-height: 56px;
    resize: vertical;
}

.table-scroll td .muted {
    white-space: pre-wrap;
}

.group-text-panel {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: #f9fbff;
    max-height: 700px;
    overflow: auto;
}

.group-selection-tip {
    position: absolute;
    right: 10px;
    top: 10px;
    width: min(340px, calc(100% - 20px));
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #c9d9ea;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 24px rgba(18, 37, 61, 0.12);
    z-index: 3;
    pointer-events: auto !important;
}

.group-selection-title {
    font-weight: 700;
    color: #173755;
    margin-bottom: 6px;
}

.group-selection-row {
    font-size: 12px;
    color: #2c4a67;
    margin-bottom: 4px;
}

.group-selection-row:last-child {
    margin-bottom: 0;
}

.group-selection-links {
    margin-top: 4px;
    display: grid;
    gap: 4px;
}

.group-selection-link-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.group-selection-link-name {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-selection-link-remove {
    padding: 2px 6px;
    font-size: 11px;
}

.group-selection-empty {
    color: #587392;
}

.workspace-grid.two {
    grid-template-columns: 1fr 1fr;
}

.pane {
    min-height: 260px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toolbar {
    display: flex;
    align-items: end;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: linear-gradient(180deg, #fcfdff 0%, #f6f9fe 100%);
}

.toolbar.inline {
    margin-bottom: 12px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 180px;
}

[hidden] {
    display: none !important;
}

.field.compact {
    min-width: 170px;
}

.schema-switcher {
    position: relative;
    display: flex;
    align-items: center;
}

.schema-switcher-current {
    min-width: 150px;
    text-align: left;
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    padding: 7px 28px 7px 9px;
    position: relative;
}

.schema-switcher-current::after {
    content: 'v';
    position: absolute;
    right: 9px;
    top: 50%;
    transform: translateY(-50%);
    color: #6d7f97;
    font-size: 11px;
}

.schema-switcher-current:hover {
    background: #f8fbff;
    color: var(--ink);
}

.schema-switcher select[data-schema-switcher-select] {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 220px;
    z-index: 8;
    box-shadow: 0 10px 24px rgba(8, 28, 57, 0.14);
}

.field label {
    color: #4f6279;
    font-size: 12px;
    font-weight: 600;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    padding: 7px 8px;
    background: #fff;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

textarea {
    resize: vertical;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
.btn:focus-visible,
.btn-link:focus-visible,
.nav-link:focus-visible {
    outline: 2px solid #6aa8e8;
    outline-offset: 2px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #82afe2;
    box-shadow: 0 0 0 3px rgba(64, 132, 201, 0.14);
}

button,
.btn {
    border: 0;
    border-radius: 7px;
    background: var(--primary);
    color: #fff;
    padding: 8px 11px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    line-height: 1.2;
}

button:hover,
.btn:hover {
    filter: brightness(0.96);
}

.btn-secondary {
    background: #4f647d;
}

.btn-full {
    width: 100%;
}

.sidebar-toggle {
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.08);
    color: #e6f1ff;
    padding: 7px 11px;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.16);
    filter: none;
}

.actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.actions-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.actions-inline form {
    margin: 0;
}

.ocr-tools {
    margin-top: 4px;
}

.ocr-result-panel {
    margin-top: 10px;
    padding: 12px;
    background: #f9fcff;
    border-style: dashed;
}

.ocr-output {
    max-height: 320px;
}

.btn-link {
    border: 1px solid #bfd5ef;
    background: #edf5ff;
    color: #145189;
    cursor: pointer;
    padding: 3px 7px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
    line-height: 1.25;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-link.danger {
    background: #fff0ed;
    border-color: #f2c2b9;
    color: var(--danger);
}

.inline-icon-btn {
    min-width: 30px;
    justify-content: center;
    padding: 4px 7px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.alert {
    border-radius: 9px;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid transparent;
}

.alert-error {
    background: var(--danger-soft);
    color: #7a2820;
    border-color: #efb6ae;
}

.alert-success {
    background: var(--success-soft);
    color: #1f6e39;
    border-color: #badfca;
}

.muted {
    color: var(--muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-success {
    background: var(--success-soft);
    color: #1f6e39;
    border: 1px solid #badfca;
}

.badge-muted {
    background: #eef2f7;
    color: #5f7188;
    border: 1px solid #d7e0ec;
}

.badge-info {
    background: #e7f3ff;
    color: #275b8e;
    border: 1px solid #bfdcf7;
}

.badge-warning {
    background: #fff5df;
    color: #946000;
    border: 1px solid #f1d79f;
}

.badge-danger {
    background: var(--danger-soft);
    color: #7a2820;
    border: 1px solid #efb6ae;
}

.setup-stepper {
    display: flex;
    align-items: center;
    margin: 14px 0 18px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: linear-gradient(180deg, #f8fbff 0%, #f1f6fc 100%);
    gap: 8px;
}

.setup-step {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-weight: 600;
}

.setup-step-dot {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    background: #fff;
}

.setup-step-line {
    flex: 1;
    min-width: 14px;
    border-top: 1px solid var(--line-strong);
}

.setup-step.is-active {
    color: var(--text);
}

.setup-step.is-active .setup-step-dot {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.setup-step.is-done {
    color: #2f5e3f;
}

.setup-step.is-done .setup-step-dot {
    background: #2f8f55;
    color: #fff;
    border-color: #2f8f55;
}

.setup-panel {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
    margin-bottom: 10px;
}

.setup-process {
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
    padding: 10px;
    margin-top: 8px;
    background: var(--bg-soft);
    max-height: 260px;
    overflow: auto;
}

.setup-process-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.setup-process-row:last-child {
    margin-bottom: 0;
}

.setup-process-text {
    font-size: 13px;
    line-height: 1.35;
}

.mono {
    font-family: Consolas, "Courier New", monospace;
}

.json-cell {
    margin: 0;
    max-width: 520px;
    max-height: 220px;
    overflow: auto;
    white-space: pre;
    font-size: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    text-align: left;
    padding: 6px 6px;
    vertical-align: top;
}

th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #5f748b;
}

.table-scroll {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: auto;
    background: #fff;
}

.table-scroll table {
    min-width: 620px;
}

.table-scroll th {
    background: #f5f9ff;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table-scroll tbody tr:nth-child(even) {
    background: #fbfdff;
}

.table-scroll tbody tr:hover {
    background: #f2f8ff;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    padding: 8px 10px;
}

.history-item-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.history-item-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    font-size: 13px;
}

.history-item-badges {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.history-item-meta {
    margin-top: 4px;
    font-size: 12px;
    color: #4d627b;
}

.history-item-summary {
    margin-top: 4px;
    font-size: 13px;
}

.history-item-block {
    margin-top: 8px;
}

.history-change-list {
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
    border: 1px solid #dbe5f1;
    border-radius: 8px;
    background: #f9fbfe;
}

.history-change-row {
    padding: 6px 8px;
    border-top: 1px solid #e4edf8;
}

.history-change-row:first-child {
    border-top: 0;
}

.history-change-name {
    font-weight: 700;
    font-size: 12px;
    margin-bottom: 3px;
}

.history-change-values {
    display: grid;
    gap: 3px;
    font-size: 12px;
}

.history-technical {
    margin-top: 8px;
}

.history-technical > summary {
    cursor: pointer;
    font-weight: 600;
    color: #355a7f;
}

.history-list-compact .history-item {
    padding: 7px 8px;
}

.history-change-list-compact {
    margin-top: 5px;
}

.history-compact-table {
    border: 1px solid #dbe5f1;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.history-compact-head,
.history-compact-row {
    display: grid;
    grid-template-columns: 148px 130px 86px 120px minmax(110px, 1fr) minmax(110px, 1fr);
    gap: 6px;
    align-items: center;
    padding: 6px 8px;
}

.history-compact-head {
    background: #f5f9ff;
    font-size: 11px;
    letter-spacing: 0.04em;
    color: #5f748b;
    text-transform: uppercase;
    font-weight: 700;
}

.history-compact-row {
    border-top: 1px solid #e4edf8;
    font-size: 12px;
}

.history-compact-row:nth-child(even) {
    background: #fbfdff;
}

.history-compact-row > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-deleted {
    opacity: 0.75;
}

.tree-list {
    list-style: none;
    margin: 0;
    padding: 0 0 0 12px;
    border-left: 1px dashed #d3deeb;
}

.tree-list > li {
    margin: 4px 0;
}

.tree-row {
    position: relative;
}

.tree-row-draggable {
    cursor: grab;
}

.tree-row-dragging {
    opacity: 0.55;
}

.tree-row-drop-before::before,
.tree-row-drop-after::after {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    height: 2px;
    border-radius: 999px;
    background: #1f5f9b;
    pointer-events: none;
}

.tree-row-drop-before::before {
    top: -2px;
}

.tree-row-drop-after::after {
    bottom: -2px;
}

.tree-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 8px;
    border: 1px solid transparent;
}

.tree-node-actions {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    gap: 6px;
}

.tree-node:hover .tree-node-actions {
    display: inline-flex;
}

.tree-action-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 6px;
    border: 1px solid #c2d3e7;
    background: #f2f7ff;
    color: #294d73;
    font-size: 13px;
    line-height: 1;
}

.tree-action-btn:hover {
    background: #dfedff;
}

.tree-node-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 220px;
    z-index: 6;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--shadow);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tree-node-menu[hidden] {
    display: none !important;
}

.tree-menu-item {
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    color: var(--text);
    text-align: left;
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
}

.tree-menu-item:hover {
    background: #f2f7ff;
    border-color: #d7e7ff;
}

.tree-link:hover {
    background: #f2f7ff;
    border-color: #d7e7ff;
}

.tree-link.active {
    background: var(--primary-soft);
    border-color: #aacdff;
}

.tree-link.tree-link-entity-hub {
    background: #edf9f1;
    border-color: #c3e7d0;
}

.tree-link.tree-link-entity-hub:hover {
    background: #e4f5eb;
    border-color: #9fd5b4;
}

.tree-link.tree-link-entity-hub.active {
    background: #dcf1e5;
    border-color: #87c8a2;
}

.entity-row.active {
    border-color: #87c8a2;
    background: #edf9f1;
}

.entity-readonly-note {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.row-context-menu {
    position: fixed;
    z-index: 56;
    min-width: 220px;
    max-width: min(300px, calc(100vw - 16px));
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(14, 33, 58, 0.2);
    padding: 6px;
}

.row-context-menu[hidden] {
    display: none !important;
}

.row-context-title {
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 700;
    color: #365577;
    border-bottom: 1px solid #e7eef7;
    margin-bottom: 4px;
}

.row-context-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.row-context-action {
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    color: var(--text);
    text-align: left;
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
}

.row-context-action:hover:not(:disabled) {
    background: #f2f7ff;
    border-color: #d7e7ff;
}

.row-context-action:disabled {
    opacity: 0.45;
    cursor: default;
}

.row-context-action.danger {
    color: #9a2b24;
}

.attributes-table-scroll {
    height: 100%;
    min-height: 0;
}

.object-attributes-table-scroll {
    overflow: visible;
}

.object-attributes-table-scroll table {
    min-width: 0;
    width: 100%;
}

.attributes-layout-table .attribute-order-col {
    width: 56px;
    text-align: center;
}

.attributes-layout-table td {
    vertical-align: middle;
}

.attribute-drag-handle {
    width: 24px;
    height: 24px;
    border: 1px solid #c3d3e5;
    border-radius: 6px;
    background: #f3f8ff;
    color: #2e5379;
    padding: 0;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1;
    cursor: grab;
}

.attribute-drag-handle:active {
    cursor: grabbing;
}

.attribute-row-dragging {
    opacity: 0.55;
}

.attribute-row-drop-before td {
    box-shadow: inset 0 2px 0 #1f5f9b;
}

.attribute-row-drop-after td {
    box-shadow: inset 0 -2px 0 #1f5f9b;
}

.compact-note {
    margin-top: 6px;
    font-size: 11px;
}

.tree-link.passive {
    background: #f9fbff;
    border-color: #e6edf7;
}

.tree-label {
    flex: 1;
    min-width: 0;
}

.tree-count {
    font-size: 12px;
    color: #6c8198;
}

.icon-wrap {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #355578;
}

.icon-svg {
    width: 18px;
    height: 18px;
}

.icon-img {
    width: 18px;
    height: 18px;
    display: inline-block;
    object-fit: contain;
    vertical-align: middle;
}

.object-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.object-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    display: grid;
    gap: 2px;
}

.object-row:hover {
    border-color: #bdd3f0;
    background: #f8fbff;
}

.object-row.active {
    border-color: #9ec0ea;
    background: #eef5ff;
}

.obj-key {
    font-size: 12px;
    color: #5f748b;
    font-family: Consolas, "Courier New", monospace;
}

.obj-label {
    font-weight: 600;
}

.obj-meta {
    font-size: 12px;
    color: #6b7f95;
}

.detail-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr;
}

.editable-value {
    min-height: 22px;
    padding: 2px 4px;
    border-radius: 6px;
}

.editable-value.is-editable {
    cursor: text;
    border: 1px dashed transparent;
}

.editable-value.is-editable:hover {
    border-color: #bfd2ea;
    background: #f5f9ff;
}

.inline-edit-input {
    width: 100%;
    border: 1px solid #8bb4df;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 14px;
}

.inline-attr-editor {
    display: flex;
    align-items: center;
    gap: 6px;
}

.inline-attr-editor-input {
    flex: 1;
    min-width: 0;
}

.inline-attr-editor-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.inline-attr-editor-btn {
    padding: 4px 8px;
    font-size: 12px;
}

.attr-editable-value.is-editable {
    min-width: 120px;
}

.attr-editable-value.is-editable::after {
    content: " modifier";
    color: #6f8fb2;
    font-size: 11px;
    margin-left: 6px;
}

.attr-editable-value[data-editing="1"]::after {
    content: "";
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #eaf3ff;
    color: #174d80;
    border: 1px solid #c4daef;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
}

.enum-display-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid #9eb6cf;
    background: #eef4fb;
    color: #234868;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 12px;
    line-height: 1.35;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.tag-chip-remove {
    width: 18px;
    height: 18px;
    line-height: 1;
    border-radius: 999px;
    border: 1px solid #adc9e5;
    background: #f7fbff;
    color: #174d80;
    padding: 0;
}

.search-results {
    margin-top: 8px;
    max-height: 170px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.search-item {
    width: 100%;
    text-align: left;
    border: 0;
    border-bottom: 1px solid #eef3f8;
    background: #fff;
    color: #1b334c;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.search-item:hover {
    background: #f5f9ff;
}

.search-item:last-child {
    border-bottom: 0;
}

.pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.panel-segmented {
    display: inline-flex;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    overflow: hidden;
    background: #f4f8ff;
}

.segment-link {
    padding: 6px 10px;
    font-size: 13px;
    color: #43658a;
    border-right: 1px solid var(--line-strong);
}

.segment-link:last-child {
    border-right: 0;
}

.segment-link.active {
    background: #dcecff;
    color: #123f6b;
    font-weight: 700;
}

.tree-pane-add {
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
}

.type-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(16, 32, 53, 0.45);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.type-modal-overlay[hidden] {
    display: none !important;
}

.type-modal {
    width: min(500px, 100%);
    border-radius: 14px;
    border: 1px solid var(--line-strong);
    background: #fff;
    box-shadow: 0 16px 48px rgba(10, 23, 41, 0.24);
    padding: 12px;
}

.object-create-modal {
    width: min(760px, 100%);
    max-height: calc(100vh - 24px);
    overflow: auto;
}

.document-import-modal {
    width: min(1320px, 100%);
    max-height: calc(100vh - 24px);
    overflow: auto;
}

.document-import-form {
    margin-top: 4px;
}

.document-import-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    align-items: start;
}

.document-import-layout.is-preview-visible {
    grid-template-columns: minmax(0, 1fr) 360px;
}

.document-import-main {
    min-width: 0;
}

.document-import-form .field {
    gap: 3px;
}

.document-import-form .field label {
    font-size: 11px;
}

.document-import-form input,
.document-import-form select,
.document-import-form textarea {
    padding: 6px 7px;
    font-size: 12px;
}

.document-import-form .actions {
    margin-top: 8px;
}

.document-import-upload-actions .muted {
    margin-left: auto;
}

.document-import-upload-actions .muted.is-error {
    color: #a1312b;
    font-weight: 600;
}

.field-grid {
    display: grid;
    gap: 8px;
}

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

.field-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.type-inherited-options {
    margin-top: 8px;
    border: 1px solid #d4e0ee;
    border-radius: 10px;
    background: #f8fbff;
    padding: 8px;
}

.type-inherited-options-head {
    margin-bottom: 8px;
}

.type-inherited-options-head .panel-subtitle {
    margin: 0 0 3px;
}

.type-inherited-options-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
    padding-right: 4px;
}

.type-inherited-option {
    border: 1px solid #dbe6f3;
    border-radius: 8px;
    background: #fff;
    padding: 7px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.type-inherited-option-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.type-inherited-option-title {
    font-weight: 600;
}

.type-inherited-option-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.type-inherited-option-serial {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: end;
}

.type-inherited-option-empty {
    font-size: 12px;
    color: #577090;
}

.document-lines {
    margin-top: 8px;
    border: 1px solid #d6e2f0;
    border-radius: 10px;
    padding: 7px;
    background: #f8fbff;
}

.document-lines-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.document-lines-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.document-line-item {
    border: 1px solid #dbe6f3;
    border-radius: 8px;
    padding: 7px;
    background: #fff;
}

.document-line-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.document-line-target {
    margin: 0;
    font-size: 12px;
}

.document-import-preview {
    border: 1px solid #d7e3f2;
    border-radius: 10px;
    background: #f6f9fe;
    padding: 8px;
    position: sticky;
    top: 0;
}

.document-preview-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.document-preview-tabs {
    display: inline-flex;
    align-items: center;
    border: 1px solid #bfd3eb;
    border-radius: 8px;
    overflow: hidden;
    background: #edf4fc;
}

.document-preview-tabs .segment-link {
    border-radius: 0;
    margin: 0;
    border: 0;
    border-right: 1px solid #c6d8ee;
    background: transparent;
    min-width: 92px;
    justify-content: center;
}

.document-preview-tabs .segment-link:last-child {
    border-right: 0;
}

.document-preview-meta {
    margin-bottom: 8px;
    padding: 6px 8px;
    border: 1px solid #d7e4f3;
    border-radius: 8px;
    background: #fff;
}

.document-preview-view {
    border: 1px solid #d7e4f3;
    border-radius: 8px;
    background: #fff;
    padding: 8px;
    min-height: 250px;
}

.document-preview-empty {
    color: #5a6f88;
    font-size: 12px;
}

.document-preview-view iframe {
    width: 100%;
    min-height: 420px;
    border: 0;
    border-radius: 6px;
    background: #f2f6fc;
}

.document-ocr-scroll {
    max-height: 200px;
}

.object-create-attributes {
    margin-top: 8px;
    border: 1px solid #d4e0ee;
    border-radius: 10px;
    background: #f8fbff;
    padding: 8px;
}

.object-create-attributes .panel-subtitle {
    margin: 0 0 8px;
}

.object-create-attributes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow: auto;
    padding-right: 4px;
}

.object-create-attr-field {
    min-width: 0;
}

.object-create-attr-input {
    width: 100%;
}

.object-create-reference-picker {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.object-create-reference-actions {
    margin: 0;
}

.object-create-reference-picker .search-results {
    margin-top: 0;
}

.icons-page .icons-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.icon-preview {
    display: inline-block;
    object-fit: contain;
    border-radius: 4px;
}

.icon-preview-16 {
    width: 16px;
    height: 16px;
}

.icon-preview-48 {
    width: 48px;
    height: 48px;
}

.icon-preview-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: #f1f5fb;
    border: 1px solid #dbe5f2;
}

.icon-preview-wrap.icon-preview-16 {
    width: 20px;
    height: 20px;
}

.icon-preview-wrap.icon-preview-48 {
    width: 52px;
    height: 52px;
}

.icon-preview-wrap.icon-preview-16 .icon-svg,
.icon-preview-wrap.icon-preview-16 .icon-img {
    width: 14px;
    height: 14px;
}

.icon-preview-wrap.icon-preview-48 .icon-svg,
.icon-preview-wrap.icon-preview-48 .icon-img {
    width: 38px;
    height: 38px;
}

.icon-create-modal {
    width: min(680px, 100%);
}

.icon-dropzone {
    border: 2px dashed #ced9ea;
    border-radius: 12px;
    padding: 16px 12px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #f8fbff;
    transition: border-color .16s ease, background .16s ease;
}

.icon-dropzone.is-over {
    border-color: #2c6cb0;
    background: #edf5ff;
}

.icon-dropzone-circle {
    width: 178px;
    height: 178px;
    border: 2px dashed #c2d2e8;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #4e6584;
}

.icon-editor {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

.icon-editor-preview-wrap {
    width: 260px;
    height: 260px;
    margin: 0 auto;
    border-radius: 10px;
    border: 1px solid #d0dced;
    overflow: hidden;
    background-image:
        linear-gradient(45deg, #e9edf5 25%, transparent 25%),
        linear-gradient(-45deg, #e9edf5 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e9edf5 75%),
        linear-gradient(-45deg, transparent 75%, #e9edf5 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.icon-editor-preview-wrap canvas {
    width: 260px;
    height: 260px;
    display: block;
}

.icon-editor-zoom {
    display: grid;
    gap: 6px;
}

.icon-editor-mini {
    display: flex;
    align-items: center;
    gap: 18px;
}

.group-entity-modal {
    width: min(560px, 100%);
}

.group-delete-modal {
    width: min(560px, 100%);
}

.group-delete-deps {
    display: grid;
    gap: 8px;
    margin: 10px 0;
}

.group-delete-dep-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid #d8e4f2;
    border-radius: 8px;
    background: #f8fbff;
    padding: 8px 10px;
    color: #274869;
}

.type-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.group-entity-modal-head-left {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.type-modal-head h3 {
    margin: 0;
}

.type-modal-close {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 8px;
    background: #edf3fb;
    color: #294b70;
}

.type-modal-close[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.group-entity-tabs {
    display: inline-flex;
    gap: 4px;
    margin: 12px 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 3px;
    background: #f5f9ff;
}

.group-entity-tab {
    border: 0;
    background: transparent;
    border-radius: 8px;
    padding: 6px 10px;
    color: #496788;
    font-weight: 600;
}

.group-entity-tab.active {
    background: #dcecff;
    color: #123f6b;
}

.group-entity-tab-panel {
    display: grid;
    gap: 10px;
}

.group-entity-tab-panel[hidden] {
    display: none !important;
}

.group-icon-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid #bfd0e3;
    border-radius: 10px;
    background: #fff;
    padding: 8px 10px;
    color: #16324f;
}

.group-icon-current {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.group-icon-picker {
    border: 1px solid #bfd0e3;
    border-radius: 10px;
    background: #fff;
    max-height: 230px;
    overflow: auto;
    display: grid;
    gap: 1px;
}

.group-icon-option {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: 0;
    background: #fff;
    padding: 8px 10px;
    color: #123f6b;
    text-align: left;
}

.group-icon-option:hover {
    background: #f3f8ff;
}

.group-icon-option.active {
    background: #dcecff;
}

.group-icon-option-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.group-icon-option-icon .icon-svg {
    width: 20px;
    height: 20px;
}

.icon-select {
    position: relative;
}

.icon-select-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1px solid #bfd0e3;
    border-radius: 10px;
    background: #fff;
    padding: 8px 10px;
    color: #16324f;
}

.icon-select-current {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.icon-select-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    border: 1px solid #bfd0e3;
    border-radius: 10px;
    background: #fff;
    max-height: 230px;
    overflow: auto;
    z-index: 30;
    display: grid;
    gap: 1px;
}

.icon-select-menu[hidden] {
    display: none !important;
}

.icon-select-option {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    background: #fff;
    padding: 8px 10px;
    color: #123f6b;
    text-align: left;
    width: 100%;
}

.icon-select-option:hover {
    background: #f3f8ff;
}

.icon-select-option.active {
    background: #dcecff;
}

.icon-select-option-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #214f7d;
    flex: 0 0 18px;
}

.icon-select-option-icon .icon-svg {
    width: 18px;
    height: 18px;
}

.icon-select-option-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-select-caret {
    color: #5a7695;
    font-size: 12px;
}

.group-logo-preview-wrap {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f9fbff;
    padding: 10px;
}

.group-logo-preview-label {
    font-size: 12px;
    color: #56779c;
    margin-bottom: 8px;
}

.group-logo-preview {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    border: 1px solid #bfd0e3;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.group-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.group-logo-placeholder {
    width: 100%;
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #2c5c89;
    font-weight: 700;
}

.group-logo-placeholder .icon-svg {
    width: 36px;
    height: 36px;
}

.upload-status-success {
    color: #1f6e39;
}

.upload-status-error {
    color: #7a2820;
}

.separator {
    margin: 16px 0;
    border: 0;
    border-top: 1px solid var(--line);
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.switch input[type="checkbox"] {
    accent-color: var(--primary);
}

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.login-shell {
    width: 100%;
    max-width: 420px;
}

.setup-shell {
    width: 100%;
    max-width: 980px;
}

.login-card {
    width: 100%;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

@media (max-width: 1200px) {
    .workspace-grid {
        grid-template-columns: 1fr 1fr;
    }

    .group-workspace {
        grid-template-columns: 1fr;
    }

    .group-current-banner {
        grid-template-columns: 1fr;
    }

    .group-current-label {
        font-size: 26px;
    }

    .group-current-value {
        justify-content: flex-start;
        padding: 10px 16px 14px;
    }

    .home-workspace {
        grid-template-columns: 1fr;
    }

    .home-page .home-detail-pane.is-wide {
        grid-column: auto;
    }

    .tree-sidebar-pane {
        min-height: auto;
        max-height: none;
    }

    .tree-sidebar-pane.is-collapsed {
        width: auto;
        min-width: 0;
        max-width: none;
        padding-left: 12px;
        padding-right: 12px;
        align-items: stretch;
    }

    .tree-sidebar-pane.is-collapsed .tree-sidebar-title,
    .tree-sidebar-pane.is-collapsed .tree-sidebar-content,
    .tree-sidebar-pane.is-collapsed .tree-sidebar-head-actions .tree-pane-add {
        display: initial;
    }

    .tree-sidebar-pane.is-collapsed .tree-sidebar-head {
        justify-content: space-between;
    }

    .home-page .app-shell {
        height: auto;
        min-height: 100vh;
    }

    .home-page .main-content {
        height: auto;
        overflow: auto;
    }

    .home-page .home-workspace {
        flex: initial;
    }

    .group-page .app-shell {
        height: auto;
        min-height: 100vh;
    }

    .group-page .main-content {
        height: auto;
        overflow: auto;
    }

    .group-page .group-entity-shell {
        flex: initial;
    }
}

@media (max-width: 980px) {
    .field-grid.two,
    .field-grid.three {
        grid-template-columns: 1fr;
    }

    .document-import-layout,
    .document-import-layout.is-preview-visible {
        grid-template-columns: 1fr;
    }

    .document-import-preview {
        position: static;
    }

    .document-preview-view iframe {
        min-height: 280px;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 10;
        display: block;
        padding: 10px 12px;
        gap: 10px;
    }

    .brand {
        padding: 0;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .sidebar-content {
        display: none;
        margin-top: 8px;
    }

    .sidebar.is-open .sidebar-content {
        display: flex;
    }

    .nav {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 4px;
    }

    .sidebar-footer {
        display: block;
    }

    .workspace-grid,
    .workspace-grid.two {
        grid-template-columns: 1fr;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

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

    .field,
    .field.compact {
        min-width: 100%;
    }

    .table-scroll table {
        min-width: 560px;
    }

    .setup-stepper {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .setup-step-line {
        display: none;
    }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: min(500px, calc(100% - 24px));
    padding: 16px;
    border: 1px solid var(--line);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.modal-head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    border: 1px solid var(--line);
    background: var(--bg-soft);
    border-radius: 999px;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 14px;
    color: var(--muted);
}

.modal-body {
    margin-bottom: 16px;
    font-size: 14px;
}

.modal .actions {
    justify-content: flex-end;
}
