:root {
    --bg: #f5f1e8;
    --panel: #fffdf8;
    --ink: #1e1c17;
    --muted: #6a665d;
    --line: #d8d0c2;
    --accent: #2f6c5c;
    --accent-soft: #dcefe9;
    --warn: #e2a72b;
    --warn-soft: #f8edd0;
    --danger: #a53f2b;
    --danger-soft: #f6ddd8;
    --ok: #2a7b3f;
    --ok-soft: #dbf0e1;
    --shadow: 0 10px 30px rgba(34, 29, 20, 0.08);
    --radius: 18px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, #fff6db 0, transparent 35%),
        linear-gradient(180deg, #f4efe5 0%, #eee8dd 100%);
}
body.has-overlay-open {
    overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button,
input,
textarea,
select {
    font: inherit;
}
button {
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: white;
    padding: 0.8rem 1.2rem;
    cursor: pointer;
}
button:hover { opacity: 0.95; }
textarea,
input,
select {
    width: 100%;
    padding: 0.8rem 0.9rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: white;
}
.telegram-editor-source {
    display: none;
}
.telegram-editor {
    display: grid;
    gap: 0;
}
.telegram-editor-toolbar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.35rem;
    padding: 0.6rem;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    background: rgba(255, 253, 248, 0.98);
}
.telegram-editor-button {
    min-width: 0;
    width: 100%;
    background: rgba(255, 253, 248, 0.96);
    color: var(--ink);
    border: 1px solid var(--line);
    padding: clamp(0.46rem, 1.2vw, 0.58rem) clamp(0.12rem, 0.7vw, 0.3rem);
    font-size: clamp(0.66rem, 1.55vw, 0.8rem);
    font-weight: 700;
    white-space: nowrap;
}
.telegram-editor-button[data-telegram-action="bold"] {
    font-weight: 800;
}
.telegram-editor-button[data-telegram-action="italic"] {
    font-style: italic;
}
.telegram-editor-button[data-telegram-action="strike"] {
    text-decoration: line-through;
}
.telegram-editor-button[data-telegram-action="ul"],
.telegram-editor-button[data-telegram-action="ol"] {
    font-weight: 800;
}
.telegram-editor-button[data-telegram-action="pre"] {
    font-family: "Courier New", monospace;
}
.telegram-editor-button[data-telegram-action="link"] {
    text-decoration: underline;
}
.telegram-editor-surface {
    min-height: 10rem;
    padding: 0.9rem;
    border-radius: 16px;
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 16px 16px;
    background: white;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}
.telegram-editor-surface:focus {
    outline: 2px solid rgba(47, 108, 92, 0.22);
    border-color: rgba(47, 108, 92, 0.45);
}
.telegram-editor-surface:empty::before {
    content: attr(data-placeholder);
    color: #8b867d;
}
.telegram-editor-surface > :first-child {
    margin-top: 0;
}
.telegram-editor-surface > :last-child {
    margin-bottom: 0;
}
.telegram-editor-surface div,
.telegram-editor-surface p,
.telegram-editor-surface ul,
.telegram-editor-surface ol,
.telegram-editor-surface pre {
    margin: 0 0 0.8rem;
}
.telegram-editor-surface ul,
.telegram-editor-surface ol {
    padding-left: 1.35rem;
}
.telegram-editor-surface a {
    color: var(--accent);
    text-decoration: underline;
}
.telegram-editor-surface code {
    display: inline;
    padding: 0.1rem 0.32rem;
    border-radius: 7px;
    background: #f3eee4;
    font-size: 0.92em;
}
.telegram-editor-surface pre {
    padding: 0.8rem;
    border-radius: 14px;
    background: #f3eee4;
    overflow-x: auto;
}
.telegram-editor-surface pre code {
    display: block;
    padding: 0;
    background: transparent;
}
.telegram-editor-note,
.telegram-editor-error {
    margin: 0.55rem 0 0;
    font-size: 0.8rem;
    line-height: 1.35;
}
.telegram-editor-note {
    color: var(--muted);
}
.telegram-editor-error {
    color: var(--danger);
}
.telegram-editor.is-invalid .telegram-editor-surface {
    border-color: rgba(165, 63, 43, 0.55);
    outline: 2px solid rgba(165, 63, 43, 0.15);
}
label span {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.92rem;
    color: var(--muted);
}
.label-with-help {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.35rem;
}
.label-with-help label {
    margin: 0;
    font-size: 0.92rem;
    color: var(--muted);
}
.help-tip {
    width: 1.35rem;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.95);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
    cursor: help;
}
.tooltip-popup {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(24rem, calc(100vw - 2rem));
    max-width: calc(100vw - 2rem);
    padding: 0.75rem 0.85rem;
    border-radius: 12px;
    background: #221d14;
    color: #fffdf8;
    font-size: 0.8rem;
    line-height: 1.35;
    white-space: normal;
    letter-spacing: normal;
    text-transform: none;
    text-align: left;
    box-shadow: var(--shadow);
    z-index: 80;
    cursor: pointer;
}
.tooltip-popup[hidden] {
    display: none !important;
}
code {
    display: block;
    overflow-wrap: anywhere;
    padding: 0.8rem;
    background: #f3eee4;
    border-radius: 12px;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    backdrop-filter: blur(10px);
    background: rgba(245, 241, 232, 0.9);
    border-bottom: 1px solid rgba(216, 208, 194, 0.75);
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}
.brand a {
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.topbar.topbar-health-green {
    background: rgba(219, 240, 225, 0.96);
    border-bottom-color: rgba(42, 123, 63, 0.32);
    box-shadow: inset 0 -4px 0 rgba(42, 123, 63, 0.18);
}
.topbar.topbar-health-yellow {
    background: rgba(248, 237, 208, 0.97);
    border-bottom-color: rgba(135, 95, 16, 0.32);
    box-shadow: inset 0 -4px 0 rgba(226, 167, 43, 0.22);
}
.topbar.topbar-health-red {
    background: rgba(246, 221, 216, 0.97);
    border-bottom-color: rgba(165, 63, 43, 0.34);
    box-shadow: inset 0 -4px 0 rgba(165, 63, 43, 0.2);
}
.topbar.topbar-health-green .brand a,
.topbar.topbar-health-green .topbar-nav a,
.topbar.topbar-health-green .link-button {
    color: var(--ok);
}
.topbar.topbar-health-yellow .brand a,
.topbar.topbar-health-yellow .topbar-nav a,
.topbar.topbar-health-yellow .link-button {
    color: #875f10;
}
.topbar.topbar-health-red .brand a,
.topbar.topbar-health-red .topbar-nav a,
.topbar.topbar-health-red .link-button {
    color: var(--danger);
}
.topbar.topbar-health-green .user-chip {
    background: rgba(42, 123, 63, 0.14);
    color: var(--ok);
}
.topbar.topbar-health-yellow .user-chip {
    background: rgba(226, 167, 43, 0.18);
    color: #875f10;
}
.topbar.topbar-health-red .user-chip {
    background: rgba(165, 63, 43, 0.14);
    color: var(--danger);
}
.topbar-nav {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}
.topbar-sync-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 5.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.88);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}
.topbar-sync-badge.is-live {
    background: var(--ok-soft);
    color: var(--ok);
    border-color: rgba(42, 123, 63, 0.2);
}
.topbar-sync-badge.is-pending {
    background: rgba(47, 108, 92, 0.12);
    color: var(--accent);
    border-color: rgba(47, 108, 92, 0.22);
}
.topbar-sync-badge.is-warning {
    background: var(--warn-soft);
    color: #875f10;
    border-color: rgba(226, 167, 43, 0.28);
}
.topbar-sync-badge.is-offline {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(165, 63, 43, 0.28);
}
.page {
    max-width: 1240px;
    margin: 0 auto;
    padding: 1.5rem;
}
.landing-page {
    min-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}
.landing-title-link,
.landing-image-link {
    display: block;
    width: 100%;
    text-align: center;
}
.landing-title {
    margin: 0;
    font-size: clamp(2rem, 7vw, 5rem);
    line-height: 1;
    white-space: nowrap;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.landing-image {
    display: block;
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 220px);
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.landing-subtitle-link {
    display: inline-block;
    margin: 0;
    font-size: clamp(1rem, 2.6vw, 1.7rem);
    line-height: 1.05;
    white-space: nowrap;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: center;
}
.landing-footer {
    margin-top: auto;
    width: 100%;
    display: flex;
    justify-content: center;
    padding-top: 1rem;
}
.landing-attribution-button {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 0.45rem 0.8rem;
    font-size: 0.74rem;
}
.hero {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 1.5rem;
    min-height: calc(100vh - 120px);
    align-items: center;
}
.hero-copy h1,
.section-heading h1 {
    margin: 0.2rem 0 0.5rem;
    font-size: clamp(2rem, 6vw, 4rem);
    line-height: 0.95;
}
.eyebrow {
    margin: 0;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.82rem;
    font-weight: 700;
}
.panel,
.card {
    background: var(--panel);
    border: 1px solid rgba(216, 208, 194, 0.95);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.stack { display: grid; gap: 1.25rem; }
.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.section-heading.compact h2 {
    margin: 0.2rem 0 0;
}
.subtle-copy {
    margin: 0 0 1rem;
    color: var(--muted);
}
.grid-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}
.full-span { grid-column: 1 / -1; }
.card-grid,
.two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}
.card {
    display: grid;
    gap: 0.7rem;
}
.card h2 { margin: 0; }
.card-meta,
.button-row,
.inline-form,
.mini-table-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.pill,
.user-chip {
    display: inline-flex;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: #ece6d8;
    font-size: 0.82rem;
}
.pill-green { background: var(--ok-soft); color: var(--ok); }
.pill-yellow { background: var(--warn-soft); color: #875f10; }
.pill-red { background: var(--danger-soft); color: var(--danger); }
.button-secondary,
.link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}
.tab-strip {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    padding: 0;
}
.tab-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1rem;
    border: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.9);
    border-radius: 999px;
    color: var(--muted);
    font-weight: 700;
    transition: background 0.15s ease, color 0.15s ease;
}
.tab-link.is-active {
    background: var(--accent);
    color: white;
}
.tab-link.tab-alert-yellow,
.tab-link.tab-alert-yellow.is-active {
    animation: tab-flash-yellow 1s steps(2, start) infinite;
}
.tab-link.tab-alert-red,
.tab-link.tab-alert-red.is-active {
    animation: tab-flash-red 1s steps(2, start) infinite;
}
.tab-panel[hidden] {
    display: none !important;
}
.danger-button { background: var(--danger); }
.danger-panel { border-color: rgba(165, 63, 43, 0.2); }
.callout { background: linear-gradient(135deg, #f9f2df, #fffdf8); }
.event-list,
.mini-table,
.queue-list {
    display: grid;
    gap: 0.65rem;
}
.event-row {
    display: grid;
    grid-template-columns: 2fr repeat(3, 1fr);
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: #f4f0e7;
}
.event-future { background: var(--warn-soft); }
.event-live { background: var(--ok-soft); }
.event-past { background: var(--danger-soft); }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}
.stat {
    padding: 1rem;
    background: #f4f0e7;
    border-radius: 14px;
}
.stat span {
    display: block;
    color: var(--muted);
    margin-bottom: 0.4rem;
}
.stat strong {
    font-size: 1.5rem;
}
.feedback {
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: #f4f0e7;
}
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.error { background: var(--danger-soft); color: var(--danger); }
.feedback.warn { background: var(--warn-soft); color: #875f10; }
.overlay-panel {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(30, 28, 23, 0.58);
}
.overlay-panel.is-open {
    display: flex;
}
.overlay-card {
    width: min(100%, 520px);
    background: var(--panel);
    border: 1px solid rgba(216, 208, 194, 0.95);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.camera-card {
    width: min(100%, 720px);
}
.camera-video {
    width: 100%;
    min-height: 260px;
    border-radius: 18px;
    background: #16140f;
    object-fit: cover;
}
.guest-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}
.guest-grid-button {
    min-height: 4rem;
    font-size: 1.25rem;
}
.guest-grid-button:disabled {
    background: #d9d2c5;
    color: #8c8375;
    cursor: not-allowed;
}
.bulk-command-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}
.bulk-command-grid > button {
    width: 100%;
}
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}
.checkbox-help-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}
.checkbox-help-row .checkbox-row {
    margin: 0;
}
.checkbox-row input {
    width: auto;
}
.table-wrap {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th,
td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
}
.empty-state {
    color: var(--muted);
}
.help-list {
    margin: 0;
    padding-left: 1.2rem;
    display: grid;
    gap: 0.8rem;
}
.help-page .panel h2,
.help-page .panel h3 {
    margin-top: 0;
}
.help-content {
    min-width: 0;
}
.help-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.25rem;
}
.help-jump-links {
    margin-top: 1rem;
    justify-content: flex-start;
}
.help-section-list {
    display: grid;
    gap: 0.9rem;
}
.help-section-item {
    padding: 0.95rem 1rem;
    border-radius: 14px;
    background: #f4f0e7;
    border: 1px solid rgba(216, 208, 194, 0.9);
}
.help-section-item p {
    margin-bottom: 0;
}
.faq-jump-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.7rem;
}
.faq-jump-link {
    display: block;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    border: 1px solid rgba(216, 208, 194, 0.9);
    background: #f4f0e7;
    font-weight: 700;
    line-height: 1.25;
    white-space: normal;
    text-wrap: balance;
}
.faq-jump-link:hover {
    background: #eee7d9;
}
.help-tab-panel[hidden] {
    display: none !important;
}
.privacy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}
.privacy-card h3 {
    margin: 0.2rem 0 0;
}
.privacy-field {
    gap: 0.5rem;
}
.privacy-field p,
.privacy-field ul {
    margin: 0;
}
.help-overlay {
    align-items: stretch;
    justify-content: center;
    padding: 1rem;
    overflow: hidden;
}
.help-overlay-card {
    width: min(1100px, 100%);
    height: calc(100vh - 2rem);
    max-height: calc(100vh - 2rem);
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}
.help-overlay-card h2 {
    margin: 0.2rem 0 0;
}
.help-overlay-body {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 0.35rem;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}
@keyframes tab-flash-yellow {
    0%, 49.99% {
        background: var(--warn-soft);
        color: #875f10;
        border-color: rgba(226, 167, 43, 0.45);
        box-shadow: 0 0 0 2px rgba(226, 167, 43, 0.14);
    }
    50%, 100% {
        background: rgba(255, 253, 248, 0.9);
        color: var(--muted);
        border-color: var(--line);
        box-shadow: none;
    }
}
@keyframes tab-flash-red {
    0%, 49.99% {
        background: var(--danger-soft);
        color: var(--danger);
        border-color: rgba(165, 63, 43, 0.48);
        box-shadow: 0 0 0 2px rgba(165, 63, 43, 0.16);
    }
    50%, 100% {
        background: rgba(255, 253, 248, 0.9);
        color: var(--muted);
        border-color: var(--line);
        box-shadow: none;
    }
}
@media (max-width: 880px) {
    .hero,
    .two-column,
    .card-grid,
    .grid-form,
    .stats-grid,
    .help-grid {
        grid-template-columns: 1fr;
    }
    .event-row {
        grid-template-columns: 1fr;
    }
    .guest-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .bulk-command-grid {
        grid-template-columns: 1fr;
    }
    .page {
        padding: 1rem;
    }
    .landing-page {
        min-height: calc(100vh - 96px);
    }
    .landing-image {
        max-height: calc(100vh - 180px);
    }
    .telegram-editor-button {
        padding: 0.5rem 0.08rem;
        font-size: clamp(0.62rem, 2.6vw, 0.74rem);
    }
}
