:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --ink: #1f2937;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #2d2a5c;
    --brand-dark: #1c1a3d;
    --blue: #2563eb;
    --green: #19a463;
    --amber: #e0a800;
    --red: #dc3545;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    line-height: 1.5;
}

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

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

.app-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    gap: 20px;
    border-right: 1px solid var(--line);
    background: #111827;
    color: #e5e7eb;
    padding: 22px 16px;
    position: sticky;
    top: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    line-height: 1.1;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
}

.nav {
    display: grid;
    gap: 6px;
}

.nav-section-label {
    margin: 14px 12px 2px;
    color: #7890b2;
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    line-height: 1.2;
    text-transform: uppercase;
}

.nav-section-label:first-child {
    margin-top: 2px;
}

.nav a,
.nav-group summary,
.logout-form button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #cbd5e1;
    cursor: pointer;
    padding: 10px 12px;
    text-align: left;
}

.nav-icon {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    color: #94a3b8;
}

.nav a.active .nav-icon,
.nav a:hover .nav-icon,
.nav-group summary.active .nav-icon,
.nav-group summary:hover .nav-icon {
    color: currentColor;
}

.nav a.active,
.nav a:hover,
.nav-group summary.active,
.nav-group summary:hover,
.logout-form button:hover {
    background: #243044;
    color: #fff;
}

.nav-group summary {
    position: relative;
    list-style: none;
    user-select: none;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-group summary::after {
    position: absolute;
    top: 50%;
    right: 14px;
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    content: '';
    transform: translateY(-65%) rotate(45deg);
    transition: transform 150ms ease;
}

.nav-group[open] summary::after {
    transform: translateY(-35%) rotate(225deg);
}

.nav-submenu {
    display: grid;
    gap: 4px;
    margin-top: 4px;
    padding-left: 16px;
}

.nav-submenu a {
    padding-block: 8px;
    font-size: 0.92rem;
}

.nav-submenu .nav-icon {
    width: 17px;
    height: 17px;
    flex-basis: 17px;
}

.logout-form {
    margin-top: auto;
}

.main {
    min-width: 0;
    padding: 28px;
}

.topbar,
.panel-header,
.summary-card,
.header-actions,
.map-legend,
.row-actions,
.form-actions,
.inline-form {
    display: flex;
    align-items: center;
}

.topbar {
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar-title {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
}

.mobile-menu-button {
    display: none;
    width: 40px;
    min-width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.mobile-menu-button__bars {
    display: grid;
    width: 18px;
    gap: 4px;
}

.mobile-menu-button__bars span {
    display: block;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
}

.sidebar-backdrop {
    display: none;
}

.eyebrow,
.section-label {
    margin: 0 0 4px;
    color: var(--brand);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(1.7rem, 2.5vw, 2.25rem);
    line-height: 1.15;
}

h2 {
    margin: 0;
    font-size: 1.08rem;
}

.user-chip,
.record-count {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    padding: 7px 11px;
    font-size: 0.82rem;
    font-weight: 700;
}

.notice {
    margin-bottom: 14px;
    border: 1px solid #b7e2ce;
    border-radius: 8px;
    background: #eaf8f1;
    color: #0f6d45;
    padding: 10px 12px;
}

.notice.error,
.form-error {
    border-color: #f3bac3;
    background: #fff0f3;
    color: #9f1d35;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.summary-card {
    min-height: 108px;
    gap: 15px;
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.85);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 22px;
    position: relative;
}

.summary-card p {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.summary-card strong {
    display: block;
    font-size: 1.9rem;
    line-height: 1.15;
}

.summary-icon,
.dot {
    display: inline-block;
    border-radius: 50%;
}

.summary-icon {
    display: grid;
    width: 50px;
    height: 50px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 14px;
}

.summary-icon.total {
    background: var(--blue);
}

.summary-icon.online,
.dot.online {
    background: var(--green);
}

.summary-icon.idle,
.dot.idle {
    background: var(--amber);
}

.summary-icon.offline,
.dot.offline {
    background: var(--red);
}

.panel {
    margin-bottom: 22px;
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel-header {
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--line);
    padding: 20px 24px;
}

.header-actions,
.map-legend {
    flex-wrap: wrap;
    gap: 10px;
}

.live-indicator {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    gap: 6px;
    border: 1px solid #cce7d8;
    border-radius: 999px;
    background: #f1faf5;
    color: #087443;
    padding: 4px 9px;
    font-size: 0.72rem;
    font-weight: 800;
}

.live-indicator i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
}

.live-indicator.is-live i {
    animation: live-indicator-pulse 1.8s ease-in-out infinite;
}

.live-indicator.is-refreshing {
    border-color: #f1dfa2;
    background: #fffaf0;
    color: #8a6500;
}

.live-indicator.is-refreshing i {
    background: var(--amber);
}

.live-indicator.is-error {
    border-color: #f1c4ca;
    background: #fff5f6;
    color: #a31f2d;
}

.live-indicator.is-error i {
    background: var(--red);
}

.live-indicator.is-demo {
    border-color: #c7d8f5;
    background: #f2f6fd;
    color: #1d4ed8;
}

.live-indicator.is-demo i {
    background: #2563eb;
}

.demo-button {
    gap: 7px;
    min-height: 34px;
}

.demo-button__icon {
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 8px solid currentColor;
}

.demo-button.is-active {
    border-color: #bfccde;
    background: #edf2f8;
    color: #334155;
}

.demo-button.is-active .demo-button__icon {
    width: 9px;
    height: 9px;
    border: 0;
    background: currentColor;
}

.demo-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.muted {
    color: var(--muted);
    font-size: 0.82rem;
}

.floor-map-shell,
.editor-canvas-wrap {
    margin: 20px;
    overflow: hidden;
    border: 1px solid #d8dee8;
    border-radius: 13px;
    background-color: #eef2f7;
    background-image:
        linear-gradient(#dfe6ef 1px, transparent 1px),
        linear-gradient(90deg, #dfe6ef 1px, transparent 1px);
    background-size: 24px 24px;
}

.floor-map-shell {
    background-color: #ffffff;
    background-image: none;
    position: relative;
}

.editor-canvas-wrap {
    background-color: #ffffff;
    background-image: none;
}

.floor-map-svg,
.floor-editor-canvas {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 360px;
}

.floor-editor-canvas {
    cursor: crosshair;
    touch-action: none;
    user-select: none;
}

.floor-editor-canvas .floor-object,
.floor-editor-canvas .floor-object-label {
    cursor: grab;
}

.floor-editor-canvas .floor-object.is-selected {
    stroke: var(--brand);
    stroke-width: 0.42;
}

.floor-editor-canvas .floor-object-label.is-selected {
    fill: var(--brand-dark);
}

.floor-editor-canvas .editor-beacon-marker__background {
    fill: #ffffff;
    stroke: #9aa9bc;
    stroke-width: 0.18;
    filter: drop-shadow(0 1px 4px rgba(15, 23, 42, 0.22));
}

.floor-editor-canvas .editor-beacon-marker__dot {
    fill: var(--brand);
}

.floor-editor-canvas .editor-beacon-marker__label {
    fill: #153052;
    font-weight: 850;
}

.floor-editor-canvas .resize-frame {
    pointer-events: none;
    stroke: var(--brand);
    stroke-dasharray: 1 1;
    stroke-width: 0.2;
}

.floor-editor-canvas .resize-handle {
    cursor: pointer;
    fill: #ffffff;
    stroke: var(--brand);
    stroke-width: 0.24;
}

.floor-editor-canvas .resize-handle--n,
.floor-editor-canvas .resize-handle--s {
    cursor: ns-resize;
}

.floor-editor-canvas .resize-handle--e,
.floor-editor-canvas .resize-handle--w {
    cursor: ew-resize;
}

.floor-editor-canvas .resize-handle--nw,
.floor-editor-canvas .resize-handle--se {
    cursor: nwse-resize;
}

.floor-editor-canvas .resize-handle--ne,
.floor-editor-canvas .resize-handle--sw {
    cursor: nesw-resize;
}

.area-count-marker {
    cursor: pointer;
    outline: none;
}

.area-count-marker__background {
    fill: #ffffff;
    stroke: #b9c6d8;
    stroke-width: 0.18;
    filter: drop-shadow(0 2px 6px rgba(15, 23, 42, 0.24));
    transition: fill 140ms ease, stroke 140ms ease, filter 140ms ease;
}

.area-count-marker__focus-ring {
    fill: none;
    opacity: 0;
    stroke: #2563eb;
    stroke-width: 0.32;
}

.area-count-marker__icon-background {
    fill: #1d4ed8;
    transition: fill 140ms ease;
}

.area-count-marker__icon {
    fill: none;
    pointer-events: none;
    stroke: #ffffff;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.area-count-marker:hover .area-count-marker__background,
.area-count-marker:focus .area-count-marker__background,
.area-count-marker.is-selected .area-count-marker__background {
    fill: #f8fbff;
    stroke: #2563eb;
    filter: drop-shadow(0 3px 8px rgba(37, 99, 235, 0.28));
}

.area-count-marker.is-selected .area-count-marker__background {
    stroke-width: 0.32;
}

.area-count-marker:focus-visible .area-count-marker__focus-ring,
.area-count-marker.is-selected .area-count-marker__focus-ring {
    opacity: 1;
}

.area-count-marker:hover .area-count-marker__icon-background,
.area-count-marker:focus .area-count-marker__icon-background,
.area-count-marker.is-selected .area-count-marker__icon-background {
    fill: #1e40af;
}

.area-count-marker__count {
    fill: #17233a;
    font-size: 2px;
    font-weight: 850;
    pointer-events: none;
}

.area-count-marker.is-live-increased .area-count-marker__background,
.area-count-marker.is-live-decreased .area-count-marker__background {
    animation: area-marker-change 1.8s ease-out;
}

.area-count-marker.is-live-new .area-count-marker__background {
    animation-name: area-marker-arrive;
}

.area-count-marker__delta {
    pointer-events: none;
    animation: area-delta-show 2.2s ease-out forwards;
}

.area-count-marker__delta rect {
    stroke: #ffffff;
    stroke-width: 0.12;
}

.area-count-marker__delta.is-positive rect {
    fill: var(--green);
}

.area-count-marker__delta.is-negative rect {
    fill: var(--red);
}

.area-count-marker__delta text {
    fill: #ffffff;
    font-size: 1px;
    font-weight: 850;
}

.floor-area-shape.is-live-increased {
    animation: floor-area-increase 1.8s ease-out;
}

.floor-area-shape.is-live-decreased {
    animation: floor-area-decrease 1.8s ease-out;
}

.map-marker-tooltip {
    position: absolute;
    z-index: 5;
    width: max-content;
    max-width: min(260px, calc(100% - 20px));
    border: 1px solid #d8e0eb;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
    padding: 10px 12px;
    pointer-events: none;
}

.map-marker-tooltip::after {
    position: absolute;
    left: var(--tooltip-arrow-left, 50%);
    bottom: -5px;
    width: 9px;
    height: 9px;
    border-right: 1px solid #d8e0eb;
    border-bottom: 1px solid #d8e0eb;
    background: #ffffff;
    content: "";
    transform: translateX(-50%) rotate(45deg);
}

.map-marker-tooltip.is-below::after {
    top: -5px;
    bottom: auto;
    border: 0;
    border-top: 1px solid #d8e0eb;
    border-left: 1px solid #d8e0eb;
}

.map-marker-tooltip__area {
    margin: 0 0 2px;
    color: var(--muted);
    font-size: 0.69rem;
    font-weight: 800;
    text-transform: uppercase;
}

.map-marker-tooltip__total {
    display: flex;
    align-items: baseline;
    gap: 5px;
    color: #17233a;
}

.map-marker-tooltip__total strong {
    font-size: 1.25rem;
    line-height: 1.2;
}

.map-marker-tooltip__total span {
    font-size: 0.78rem;
    font-weight: 700;
}

.map-marker-tooltip__statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 7px;
    padding-top: 7px;
    border-top: 1px solid #edf1f6;
}

.map-marker-tooltip__status {
    display: inline-flex;
    align-items: center;
    color: #475569;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

.map-marker-tooltip__status .dot {
    width: 7px;
    height: 7px;
    margin-right: 4px;
}

@keyframes live-indicator-pulse {
    50% {
        opacity: 0.45;
    }
}

@keyframes area-marker-change {
    0% {
        stroke: #2563eb;
        stroke-width: 0.65;
        filter: drop-shadow(0 3px 9px rgba(37, 99, 235, 0.34));
    }
}

@keyframes area-marker-arrive {
    0% {
        fill: #eaf2ff;
        stroke: #2563eb;
        stroke-width: 0.8;
        filter: drop-shadow(0 3px 10px rgba(37, 99, 235, 0.4));
    }
}

@keyframes area-delta-show {
    0%, 100% {
        opacity: 0;
    }
    12%, 72% {
        opacity: 1;
    }
}

@keyframes floor-area-increase {
    0% {
        stroke: var(--green);
        stroke-width: 0.85;
    }
}

@keyframes floor-area-decrease {
    0% {
        stroke: var(--red);
        stroke-width: 0.85;
    }
}

@media (prefers-reduced-motion: reduce) {
    .live-indicator.is-live i,
    .area-count-marker__background,
    .area-count-marker__delta,
    .floor-area-shape {
        animation: none !important;
    }
}

.modal-backdrop {
    display: grid;
    place-items: center;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(15, 23, 42, 0.42);
    padding: 20px;
}

.modal-backdrop[hidden] {
    display: none;
}

.area-detail-modal {
    width: min(620px, 100%);
    max-height: min(760px, calc(100vh - 40px));
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.area-detail-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid var(--line);
    padding: 16px 18px;
}

.area-detail-modal h3 {
    margin: 0;
    font-size: 1.1rem;
}

.area-detail-modal__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-button {
    width: 34px;
    min-height: 34px;
    padding: 0;
}

.area-detail-list {
    display: grid;
    gap: 10px;
    max-height: min(590px, calc(100vh - 165px));
    overflow: auto;
    padding: 16px;
}

.area-detail-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    align-items: center;
    border: 1px solid #edf0f4;
    border-radius: 10px;
    background: #fafbfc;
    padding: 10px 12px;
}

.area-detail-meta {
    display: flex;
    flex-wrap: wrap;
    grid-column: 1 / -1;
    gap: 10px;
    color: var(--muted);
    font-size: 0.74rem;
}

.map-legend {
    padding: 0 18px 18px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.dot {
    width: 9px;
    height: 9px;
    margin-right: 6px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid #edf1f7;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

td strong,
td small {
    display: block;
}

td small {
    color: var(--muted);
    font-size: 0.75rem;
}

.battery-meter {
    display: inline-flex;
    min-width: 68px;
    align-items: center;
    gap: 7px;
    color: #475569;
    font-size: 0.76rem;
    font-weight: 750;
    line-height: 1;
    white-space: nowrap;
}

.battery-meter__icon {
    display: inline-flex;
    width: 25px;
    height: 13px;
    flex: 0 0 auto;
    align-items: stretch;
    position: relative;
    overflow: visible;
    border: 1.5px solid currentColor;
    border-radius: 3px;
    padding: 2px;
}

.battery-meter__icon::after {
    width: 3px;
    height: 6px;
    position: absolute;
    top: 2px;
    right: -5px;
    border-radius: 0 2px 2px 0;
    background: currentColor;
    content: "";
}

.battery-meter__fill {
    display: block;
    height: 100%;
    border-radius: 1px;
    background: currentColor;
}

.battery-meter__value {
    min-width: 30px;
    font-variant-numeric: tabular-nums;
}

.battery-meter--good {
    color: #0f8a52;
}

.battery-meter--medium {
    color: #b27a00;
}

.battery-meter--low {
    color: #c62f3e;
}

.battery-meter--unknown {
    color: #94a3b8;
}

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

.row-actions {
    justify-content: flex-end;
    gap: 8px;
}

.row-actions form {
    margin: 0;
}

.pending-beacon-actions,
.pending-beacon-confirm {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pending-beacon-actions {
    justify-content: flex-end;
}

.pending-beacon-actions form {
    margin: 0;
}

.pending-beacon-confirm input {
    width: 180px;
    min-width: 150px;
}

.button,
.primary-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font-weight: 750;
    padding: 7px 12px;
}

.primary-button {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
}

.button:hover,
.button.active {
    border-color: #b7c3d4;
    background: #f1f5f9;
}

.primary-button:hover {
    background: var(--brand-dark);
}

.danger-button {
    border-color: #dc3545;
    background: #dc3545;
    color: #fff;
}

.danger-button:hover {
    border-color: #b4232f;
    background: #b4232f;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 24px;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 0.7rem;
    font-weight: 800;
}

.status-badge::before {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    content: "";
}

.status-badge.online {
    background: #e8f7ef;
    color: #087443;
}

.status-badge.online::before {
    background: var(--green);
}

.status-badge.idle,
.status-badge.unknown {
    background: #fff7d6;
    color: #8a6500;
}

.status-badge.idle::before,
.status-badge.unknown::before {
    background: var(--amber);
}

.status-badge.offline {
    background: #fdecef;
    color: #a31f2d;
}

.status-badge.offline::before {
    background: var(--red);
}

.page-actions {
    margin-bottom: 14px;
}

.empty-state {
    padding: 30px;
    color: var(--muted);
    text-align: center;
}

.form-panel {
    padding: 18px;
}

.form-stack {
    display: grid;
    gap: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.span-2 {
    grid-column: span 2;
}

label {
    display: grid;
    gap: 6px;
    color: #334155;
    font-size: 0.83rem;
    font-weight: 750;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 9px 10px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check-row input {
    width: auto;
}

.form-actions {
    gap: 10px;
    margin-top: 16px;
}

.inline-form {
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px;
}

.history-filter-header h2,
.history-results-header h2 {
    margin: 0;
    font-size: 1rem;
}

.history-filters {
    display: grid;
    grid-template-columns: minmax(240px, 1.4fr) repeat(2, minmax(150px, 0.7fr)) auto;
    align-items: end;
    gap: 14px;
    padding: 18px 24px 22px;
}

.history-filters label {
    display: grid;
    gap: 6px;
    color: #334155;
    font-size: 0.8rem;
    font-weight: 750;
}

.history-filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
}

.history-result-count {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--muted);
    padding: 5px 9px;
    font-size: 0.76rem;
    font-weight: 750;
}

.auth-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: min(420px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 26px;
}

.login-brand {
    margin-bottom: 22px;
}

.editor-shell {
    display: grid;
    gap: 12px;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.editor-tool-group,
.editor-selection-actions,
.editor-draft-actions,
.editor-save-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.editor-tool-group {
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.editor-tool-group .button {
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
}

.editor-tool-group .button:last-child {
    border-right: 0;
}

.editor-selection-actions,
.editor-draft-actions {
    margin-left: 4px;
    border-left: 1px solid var(--line);
    padding-left: 12px;
}

.editor-selection-actions[hidden],
.editor-draft-actions[hidden] {
    display: none;
}

.editor-draft-actions .button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.editor-save-group {
    margin-left: auto;
}

.editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
}

.editor-canvas-wrap {
    margin: 0;
}

.editor-panel {
    min-height: 520px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 14px;
}

.editor-panel h2 {
    margin: 0 0 10px;
}

.editor-list {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.editor-item {
    display: grid;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    padding: 10px;
}

.editor-item--selected-area {
    border-color: #b9cbed;
    background: #f7faff;
}

.editor-selection-empty {
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    color: var(--muted);
    padding: 18px 12px;
    font-size: 0.8rem;
    text-align: center;
}

.editor-item-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.color-chip {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 8px;
    border-radius: 3px;
    vertical-align: middle;
}

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

    body.sidebar-open {
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 50;
        width: min(290px, calc(100vw - 48px));
        min-height: 100vh;
        transform: translateX(-100%);
        transition: transform 180ms ease;
        box-shadow: 18px 0 44px rgba(15, 23, 42, 0.24);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 45;
        border: 0;
        background: rgba(15, 23, 42, 0.46);
        cursor: pointer;
    }

    .sidebar-backdrop[hidden] {
        display: none;
    }

    .mobile-menu-button {
        display: inline-flex;
    }

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

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

@media (max-width: 760px) {
    .main {
        padding: 18px;
    }

    .summary-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .history-filters {
        grid-template-columns: 1fr;
        padding-inline: 18px;
    }

    .history-filter-actions .primary-button,
    .history-filter-actions .button {
        flex: 1;
    }

    .span-2 {
        grid-column: auto;
    }

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

    .topbar-title {
        width: 100%;
    }

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