:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
    --bg: #fbfbfa;
    --bg-sidebar: #f6f5f3;
    --surface: #ffffff;
    --surface-soft: #f7f7f6;
    --surface-hover: rgba(32, 33, 36, 0.035);
    --surface-active: rgba(35, 131, 226, 0.09);
    --surface-drop: rgba(35, 131, 226, 0.12);
    --text-primary: #2b2b2a;
    --text-secondary: #8a8a84;
    --text-muted: #a8a8a1;
    --border-soft: rgba(15, 23, 42, 0.06);
    --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.04);
    --shadow-card: 0 8px 22px rgba(15, 23, 42, 0.05);
    --blue: #2383e2;
    --danger: #cf4f4f;
    --radius-ui: 8px;
    --radius-pill: 999px;
}

* {
    box-sizing: border-box;
}

[x-cloak] {
    display: none !important;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text-primary);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.page {
    min-height: 100vh;
    padding: 24px;
}

.page.page-workspace {
    padding: 0;
}

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

.card {
    padding: 24px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.auth-card {
    display: grid;
    gap: 16px;
    max-width: 420px;
}

.muted,
.meta {
    color: var(--text-secondary);
}

.notice {
    margin: 0 0 16px;
    padding: 14px 16px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.notice.success {
    color: #166534;
}

.notice.error {
    color: #b42318;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1,
h2 {
    font-weight: 650;
    letter-spacing: -0.03em;
}

label {
    display: grid;
    gap: 8px;
}

label > span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

input,
textarea,
button {
    font: inherit;
}

input,
textarea {
    width: 100%;
    padding: 11px 13px;
    border: 0;
    background: #f4f4f2;
    color: var(--text-primary);
    border-radius: var(--radius-ui);
    outline: none;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus {
    background: #efefec;
    box-shadow: inset 0 0 0 1px rgba(35, 131, 226, 0.24);
}

textarea {
    resize: vertical;
    min-height: 92px;
}

button {
    border: 0;
    padding: 10px 14px;
    background: var(--blue);
    color: #ffffff;
    border-radius: var(--radius-ui);
    cursor: pointer;
    transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

button.ghost {
    background: rgba(32, 33, 36, 0.06);
    color: var(--text-primary);
}

.workspace {
    display: grid;
    grid-template-columns: var(--sidebar-width, 308px) 8px minmax(0, 1fr);
    min-height: 100vh;
    background: linear-gradient(
        to right,
        var(--bg-sidebar) 0,
        var(--bg-sidebar) calc(var(--sidebar-width, 308px) + 8px),
        var(--bg) calc(var(--sidebar-width, 308px) + 8px),
        var(--bg) 100%
    );
}

.sidebar {
    align-self: stretch;
    min-height: 100%;
    background: var(--bg-sidebar);
}

.sidebar-inner {
    position: sticky;
    top: 0;
    padding: 14px 16px 40px 18px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding: 4px 4px 10px;
}

.sidebar-brand-mark {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    background: #ebe9e5;
    color: #6d6d66;
    font-size: 15px;
    font-weight: 700;
}

.sidebar-brand-copy {
    display: grid;
    gap: 1px;
}

.sidebar-brand-copy strong {
    font-size: 14px;
    font-weight: 650;
}

.sidebar-brand-copy span {
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-logout {
    margin-left: auto;
}

.sidebar-logout button {
    padding: 8px 12px;
}

.sidebar-resizer {
    position: relative;
    cursor: col-resize;
    background: var(--bg-sidebar);
}

.sidebar-resizer::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 3px;
    width: 2px;
    background: transparent;
    transition: background 0.15s ease;
}

.sidebar-resizer:hover::before {
    background: rgba(31, 31, 28, 0.12);
}

body.is-resizing-sidebar {
    cursor: col-resize;
    user-select: none;
}

.sidebar-upload {
    display: grid;
    gap: 8px;
    margin-bottom: 26px;
}

.upload-dropzone {
    position: relative;
    display: grid;
    gap: 6px;
    min-height: 120px;
    padding: 18px 16px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-ui);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04), 0 8px 18px rgba(15, 23, 42, 0.04);
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.upload-dropzone:hover {
    transform: translateY(-1px);
}

.upload-dropzone.is-dragging {
    background: rgba(35, 131, 226, 0.08);
    box-shadow: inset 0 0 0 2px rgba(35, 131, 226, 0.22);
}

.upload-dropzone.is-uploading {
    opacity: 0.76;
    pointer-events: none;
}

.upload-dropzone strong {
    font-size: 16px;
    font-weight: 650;
}

.upload-dropzone span {
    max-width: 220px;
    line-height: 1.4;
}

.upload-dropzone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.sidebar-section {
    display: grid;
    gap: 14px;
}

.section-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.section-title h2 {
    font-size: 15px;
    font-weight: 650;
}

.group-create-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.group-create-form button {
    padding-inline: 12px;
}

.group-panel,
.group-sortable {
    display: grid;
    gap: 4px;
}

.group-panel {
    padding-bottom: 18px;
}

.group-nav-item {
    width: 100%;
    min-height: 34px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 8px 7px 8px;
    position: relative;
    background: transparent;
    color: var(--text-primary);
    box-shadow: none;
    justify-content: flex-start;
    text-align: left;
    border-radius: var(--radius-ui);
}

.group-nav-item:hover {
    background: var(--surface-hover);
    transform: none;
}

.group-nav-item.is-active {
    background: rgba(255, 255, 255, 0.88);
}

.group-nav-item.is-drop-target {
    background: var(--surface-drop);
}

.group-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 10px;
    border-radius: 999px;
    background: var(--group-color, #9b9a97);
}

.group-name {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-count {
    flex: 0 0 auto;
    min-width: 28px;
    padding: 2px 6px;
    margin-left: auto;
    margin-right: 1px;
    background: rgba(32, 33, 36, 0.04);
    color: var(--text-secondary);
    font-size: 12px;
    text-align: center;
    border-radius: var(--radius-pill);
}

.group-drag {
    flex: 0 0 18px;
    width: 18px;
    margin-left: -2px;
    margin-right: 1px;
    color: var(--text-muted);
    cursor: grab;
    user-select: none;
    text-align: center;
}

.group-drag-placeholder {
    visibility: hidden;
}

.group-name-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 3px 6px;
    background: rgba(255, 255, 255, 0.88);
}

.group-menu-button {
    width: 24px;
    min-width: 24px;
    height: 24px;
    padding: 0;
    margin-left: 0;
    background: transparent;
    color: var(--text-muted);
    box-shadow: none;
    font-size: 16px;
    line-height: 1;
}

.group-menu-button:hover {
    background: rgba(32, 33, 36, 0.06);
    color: var(--text-primary);
    transform: none;
}

.group-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 8px;
    z-index: 20;
    min-width: 160px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: var(--radius-ui);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.group-menu-item {
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    color: var(--text-primary);
    box-shadow: none;
    text-align: left;
}

.group-menu-item:hover {
    background: rgba(32, 33, 36, 0.05);
    transform: none;
}

.group-menu-item.is-danger {
    color: var(--danger);
}

.main-content {
    padding: 26px 40px 40px;
}

.objects-shell {
    display: grid;
    gap: 24px;
}

.objects-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}

.objects-header h2 {
    font-size: 31px;
    line-height: 1.02;
    font-weight: 400;
    letter-spacing: -0.02em;
}

.objects-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 28px;
    align-items: start;
}

.objects-layout.is-panel-collapsed {
    grid-template-columns: minmax(0, 1fr) 56px;
}

.objects-list-panel,
.point-panel {
    min-height: 640px;
    background: rgba(255, 255, 255, 0.86);
    border-radius: var(--radius-ui);
    box-shadow: var(--shadow-card);
}

.objects-list-panel {
    padding: 16px;
}

.point-panel {
    display: grid;
    gap: 18px;
    padding: 22px;
    position: relative;
    overflow: hidden;
}

.point-panel.is-collapsed {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 14px 8px;
}

.point-panel-toggle {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 36px;
}

.point-panel.is-collapsed .point-panel-toggle {
    position: sticky;
    top: 14px;
}

.point-panel-content {
    display: grid;
    gap: 18px;
}

.point-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.point-panel-head h3 {
    font-size: 16px;
    font-weight: 650;
}

.point-panel-head-compact {
    align-items: center;
}

.points-tree,
.points-group,
.points-group-sortable,
.address-list,
.point-form,
.custom-fields {
    display: grid;
    gap: 10px;
}

.sidebar-address {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: start;
    padding: 12px 14px;
    background: transparent;
    border-radius: var(--radius-ui);
    box-shadow: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.sidebar-address:hover {
    background: rgba(32, 33, 36, 0.035);
    transform: none;
}

.sidebar-address.is-selected {
    background: rgba(35, 131, 226, 0.08);
    box-shadow: inset 0 0 0 1px rgba(35, 131, 226, 0.14);
}

.address-body {
    min-width: 0;
    display: grid;
    gap: 5px;
}

.address-title {
    font-size: 15px;
    font-weight: 650;
    color: var(--text-primary);
    word-break: break-word;
}

.address-text {
    color: var(--text-secondary);
    word-break: break-word;
}

.address-delete {
    align-self: center;
    padding: 7px 10px;
    background: rgba(32, 33, 36, 0.045);
    color: #7b7b74;
    border-radius: var(--radius-ui);
}

.address-delete:hover {
    background: rgba(207, 79, 79, 0.12);
    color: var(--danger);
}

.empty-dropzone,
.empty-state,
.empty-inline {
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--text-secondary);
    background: rgba(32, 33, 36, 0.025);
    border-radius: var(--radius-ui);
}

.empty-dropzone {
    min-height: 72px;
    padding: 14px;
}

.empty-state {
    min-height: 240px;
    gap: 8px;
    padding: 28px;
}

.empty-state-compact {
    min-height: 180px;
}

.empty-inline {
    min-height: 56px;
    padding: 10px 12px;
}

.custom-field-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 8px;
}

.custom-field-row button,
.point-form-actions button {
    width: auto;
}

.point-form-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

.sortable-ghost {
    opacity: 0.45;
}

.sortable-chosen {
    opacity: 0.92;
}

@media (max-width: 1100px) {
    .objects-layout {
        grid-template-columns: 1fr;
    }

    .objects-header h2 {
        font-size: 24px;
    }

    .point-panel,
    .objects-list-panel {
        min-height: 0;
    }
}

@media (max-width: 960px) {
    .workspace {
        grid-template-columns: 1fr;
        background: var(--bg);
    }

    .sidebar,
    .sidebar-resizer,
    .main-content {
        grid-column: 1;
    }

    .sidebar {
        min-height: 0;
    }

    .sidebar-inner {
        position: static;
    }

    .sidebar-inner {
        position: static;
        padding: 0 18px 20px;
    }

    .sidebar-resizer {
        display: none;
    }

    .main-content {
        padding: 8px 18px 24px;
    }
}

@media (max-height: 820px) {
    .sidebar {
        max-height: 100vh;
    }

    .sidebar-inner {
        max-height: 100vh;
        overflow-y: auto;
        scrollbar-gutter: stable;
    }
}

@media (max-width: 640px) {
    .page {
        padding: 16px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .group-create-form,
    .custom-field-row {
        grid-template-columns: 1fr;
    }

    .sidebar-address {
        grid-template-columns: 1fr;
    }

    .address-delete {
        justify-self: start;
    }
}
