:root {
    --bg: #f4f1ea;
    --panel: #fffdf8;
    --panel-border: #dfd6c8;
    --ink: #22201c;
    --muted: #6e665c;
    --accent: #0b6e4f;
    --accent-dark: #074c37;
    --danger: #8f1d21;
    --shadow: 0 18px 40px rgba(34, 32, 28, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(11, 110, 79, 0.15), transparent 28%),
        linear-gradient(180deg, #f0ebe1 0%, var(--bg) 100%);
    color: var(--ink);
}

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

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

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

.sidebar-toggle,
.sidebar-backdrop {
    display: none;
}

.sidebar {
    padding: 28px 22px;
    background: rgba(34, 32, 28, 0.96);
    color: #f7f2e9;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

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

.brand-kicker,
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.75rem;
    color: var(--muted);
}

.sidebar .brand-kicker {
    color: rgba(247, 242, 233, 0.6);
}

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

.nav-link {
    padding: 12px 14px;
    border-radius: 14px;
    color: rgba(247, 242, 233, 0.88);
}

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

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 10px;
}

.sidebar-footer p,
.sidebar-footer small {
    margin: 0;
}

.content {
    padding: 34px;
}

.content-auth {
    display: grid;
    place-items: center;
}

.auth-card,
.panel,
.stat-card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-card {
    width: min(520px, 100%);
    padding: 34px;
    display: grid;
    gap: 24px;
}

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

.page-head h1,
.auth-card h1 {
    margin: 4px 0 0;
    font-size: 2rem;
}

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

.stats-grid,
.panel-grid {
    display: grid;
    gap: 18px;
    margin-bottom: 22px;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

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

.stat-card {
    padding: 22px;
}

.stat-card strong {
    display: block;
    font-size: 2rem;
    margin-bottom: 10px;
}

.panel {
    padding: 22px;
    overflow-x: auto;
}

.panel-head {
    margin-bottom: 16px;
}

.panel h2 {
    margin: 0;
    font-size: 1.1rem;
}

.form-grid {
    display: grid;
    gap: 16px;
}

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

.form-grid label {
    display: grid;
    gap: 8px;
    color: var(--muted);
}

.form-grid .full {
    grid-column: 1 / -1;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cfc4b4;
    border-radius: 12px;
    padding: 12px 14px;
    background: #fff;
    color: var(--ink);
}

textarea {
    resize: vertical;
}

.checkbox-row {
    display: flex !important;
    align-items: center;
    gap: 10px !important;
    color: var(--ink) !important;
}

.checkbox-row input {
    width: auto;
}

.button,
.button-secondary,
.button-full,
.link-button {
    border: none;
    border-radius: 999px;
    padding: 12px 18px;
    cursor: pointer;
    transition: 0.2s ease;
}

.button {
    background: var(--accent);
    color: #fff;
}

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

.button-secondary {
    background: #ece4d6;
    color: var(--ink);
}

.button-full {
    width: 100%;
}

.link-button {
    background: transparent;
    padding: 0;
    color: inherit;
}

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

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

th,
td {
    text-align: left;
    padding: 14px 8px;
    border-bottom: 1px solid #eadfce;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 600;
}

.actions {
    display: flex;
    gap: 14px;
    align-items: center;
}

.flash {
    padding: 14px 18px;
    border-radius: 14px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}

.flash-success {
    background: rgba(11, 110, 79, 0.12);
    border-color: rgba(11, 110, 79, 0.2);
}

.flash-error {
    background: rgba(143, 29, 33, 0.12);
    border-color: rgba(143, 29, 33, 0.2);
}

.inline-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.field-inline {
    display: flex;
    gap: 10px;
    align-items: center;
}

.field-inline .button {
    white-space: nowrap;
}

.qr-layout {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(280px, 420px) minmax(280px, 1fr);
}

.qr-box {
    display: grid;
    gap: 12px;
}

.qr-video,
.qr-inline-video {
    width: 100%;
    max-width: 420px;
    min-height: 220px;
    background: #111;
    border-radius: 16px;
    object-fit: cover;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-pill-success {
    background: rgba(11, 110, 79, 0.14);
    color: var(--accent-dark);
}

.status-pill-danger {
    background: rgba(143, 29, 33, 0.14);
    color: var(--danger);
}

.status-pill-neutral {
    background: #efe6d8;
    color: var(--ink);
}

.ticket-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.timeline {
    display: grid;
    gap: 14px;
}

.timeline-item {
    border-left: 3px solid #d9cbb6;
    padding-left: 14px;
}

.timeline-item p {
    margin: 6px 0 0;
}

.attachment-list {
    display: grid;
    gap: 10px;
}

.attachment-list a {
    color: var(--accent-dark);
    text-decoration: underline;
}

.asset-photo {
    width: min(100%, 320px);
    border-radius: 18px;
    border: 1px solid var(--panel-border);
}

.map-canvas {
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    overflow: hidden;
    background: #f8f4ec;
    padding: 12px;
}

.map-canvas.is-editor {
    cursor: crosshair;
}

.map-canvas.is-compact {
    max-width: 760px;
    display: inline-block;
}

.map-canvas.is-full {
    max-width: 1180px;
    margin-bottom: 22px;
}

.map-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
    background: #fff;
}

.map-image {
    display: block;
    max-width: min(100%, 736px);
    max-height: 520px;
    width: auto;
    height: auto;
}

.map-pin {
    position: absolute;
    transform: translate(-50%, -100%);
    display: block;
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    text-decoration: none;
    overflow: visible;
    z-index: 2;
}

.map-pin-editor {
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.map-pin-marker {
    position: absolute;
    inset: 0;
    display: block;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: #d4442e;
    border: 2px solid #fff;
    box-shadow: 0 8px 12px rgba(34, 32, 28, 0.22);
}

.map-pin-marker::after {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 999px;
    background: #fff;
}

.map-pin-badge {
    position: absolute;
    top: -4px;
    right: -12px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(34, 32, 28, 0.9);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.map-assets-list h2 {
    margin: 0 0 12px;
    font-size: 1.05rem;
}

.map-list-pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(34, 32, 28, 0.9);
    color: #fff;
    font-weight: 700;
}

.map-placeholder {
    min-width: 320px;
    min-height: 220px;
}

.map-placeholder {
    display: grid;
    place-items: center;
    min-height: 280px;
    padding: 24px;
    text-align: center;
}

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

    .sidebar-toggle {
        display: inline-flex;
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 30;
        border: none;
        background: var(--accent);
        color: #fff;
        border-radius: 999px;
        padding: 10px 14px;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 18;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(84vw, 320px);
        z-index: 20;
        gap: 18px;
        transform: translateX(-104%);
        transition: transform 0.22s ease;
    }

    .content {
        padding: 22px;
        padding-top: 72px;
    }

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

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

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

    .field-inline,
    .inline-actions,
    .qr-layout {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

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

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

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }
}
