:root {
    --bg: #070707;
    --bg-elev: #121212;
    --bg-soft: #1b1b1b;
    --border: #2c2c2c;
    --border-strong: #3a3a3a;
    --text: #f1f1f1;
    --muted: #a8a8a8;
    --accent: #8f8f8f;
    --accent-strong: #a3a3a3;
    --danger: #9f4254;
    --danger-strong: #be4d63;
    --ok-bg: #153828;
    --ok-border: #2e8d57;
    --error-bg: #3a1a22;
    --error-border: #c2516c;
    --radius: 12px;
    --radius-sm: 9px;
    --shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
    --admin-sidebar-width: 220px;
    --admin-sidebar-offset: 16px;
    --admin-sidebar-gap: 18px;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(1200px 700px at -10% -10%, #1a1a1a 0%, transparent 52%),
        radial-gradient(900px 500px at 110% 0%, #151515 0%, transparent 46%),
        var(--bg);
    color: var(--text);
}

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

.login-card {
    width: min(420px, 100%);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin: 0 0 8px;
}

.login-card p {
    margin: 0 0 16px;
    color: var(--muted);
}

.remember-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    user-select: none;
}

.remember-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
    accent-color: var(--accent-strong);
}

.remember-row span {
    font-size: 14px;
    color: #d4d4d4;
    line-height: 1;
}

.password-input-wrap {
    position: relative;
}

.password-input-wrap input {
    padding-right: 48px;
}

.password-toggle-btn {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    margin: 0;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: #1f1f1f;
    color: #d7d7d7;
    line-height: 1;
    cursor: pointer;
}

.password-toggle-btn:hover {
    background: #2b2b2b;
    border-color: var(--accent);
    transform: translateY(-50%);
}

.bottom-tools-row {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0px;
}

.messages-modal-open-btn,
.download-leads-report-btn {
    width: auto;
    min-width: 122px;
    padding: 7px 11px;
    font-size: 12px;
    border-radius: 8px;
    cursor: pointer;
}

.messages-modal-open-btn {
    background: #232323;
    border: 1px solid var(--border-strong);
    color: var(--text);
    font-weight: 600;
}

.messages-modal-open-btn:hover {
    background: #2f2f2f;
    border-color: var(--accent);
}

.download-leads-report-btn {
    background: #1f9d52;
    border: 1px solid #2fbc67;
    color: #fff;
    font-weight: 700;
}

.download-leads-report-btn:hover {
    background: #25b35f;
    border-color: #38cf77;
}

.messages-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 13000;
    align-items: center;
    justify-content: center;
}

.messages-modal.is-open {
    display: flex;
}

.messages-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.messages-modal-dialog {
    position: relative;
    width: min(900px, calc(100vw - 30px));
    min-height: min(72vh, 700px);
    max-height: 86vh;
    background: #161616;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: auto;
}

.messages-modal-dialog h2 {
    margin: 0;
    font-size: 20px;
}

.messages-notes-layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 12px;
    min-height: min(62vh, 620px);
}

.messages-pages-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    padding-right: 10px;
}

.messages-pages-toolbar {
    display: flex;
    gap: 6px;
}

.messages-page-btn {
    width: auto;
    min-width: 0;
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 7px;
    border: 1px solid var(--border-strong);
    background: #232323;
    color: var(--text);
    cursor: pointer;
}

.messages-page-btn:hover {
    background: #2f2f2f;
    border-color: var(--accent);
}

.messages-pages-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 2px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.messages-pages-list::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.messages-pages-list:hover,
.messages-pages-list:focus-within {
    scrollbar-width: thin;
}

.messages-pages-list:hover::-webkit-scrollbar,
.messages-pages-list:focus-within::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.messages-page-item {
    width: 100%;
    text-align: left;
    padding: 7px 9px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: #171717;
    color: #d8d8d8;
    cursor: pointer;
    font-size: 12px;
}

.messages-page-item.is-active {
    border-color: var(--accent);
    background: #2a2a2a;
    color: #fff;
}

.messages-editor-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 8px;
}

.messages-page-title-input {
    width: 100%;
    min-height: 36px;
}

.messages-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    cursor: pointer;
}

.messages-modal-text {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    resize: vertical;
    font-size: 14px;
    line-height: 1.45;
    background: #0f0f0f;
    border: 1px solid var(--border);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.messages-modal-text::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.messages-modal-text:hover,
.messages-modal-text:focus {
    scrollbar-width: thin;
}

.messages-modal-text:hover::-webkit-scrollbar,
.messages-modal-text:focus::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

.messages-modal-save-btn {
    width: auto;
    min-width: 88px;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 7px;
    background: #232323;
    border: 1px solid var(--border-strong);
    color: var(--text);
    cursor: pointer;
}

.messages-modal-save-btn:hover {
    background: #2f2f2f;
    border-color: var(--accent);
}

label {
    display: block;
    font-size: 14px;
    margin: 12px 0 6px;
    color: #d4d4d4;
}

input,
select,
textarea,
button {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: #121212;
    color: #f1f1f1;
}

textarea {
    resize: vertical;
}

button {
    margin-top: 12px;
    font-weight: 600;
    background: var(--accent);
    border: 1px solid var(--accent);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
    background: var(--accent-strong);
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.hint {
    display: block;
    margin-top: 12px;
    color: var(--muted);
}

.dashboard-body {
    padding: 18px 166px 18px calc(var(--admin-sidebar-offset) + var(--admin-sidebar-width) + var(--admin-sidebar-gap));
}

.top-inline-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 6px;
    margin-right: -150px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(14, 14, 14, 0.84);
    backdrop-filter: blur(4px);
}

.dashboard-title {
    margin: 0;
    font-size: 24px;
    letter-spacing: 0.2px;
}

.top-inline-actions {
    position: static;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin: 0;
}

.top-inline-actions .btn-nuovo-sito,
.top-inline-actions .top-logout {
    min-height: 40px;
    padding: 10px 16px;
    font-size: 14px;
}

.right-rail {
    position: fixed;
    top: 52%;
    right: 16px;
    width: 128px;
    max-height: calc(100vh - 64px);
    overflow: auto;
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    transform: translateY(-50%);
}

.btn-nuovo-sito {
    width: auto;
    margin: 0;
    padding: 8px 16px;
    background: #2a2a2a;
    border: 1px solid var(--border-strong);
    color: var(--text);
}

.btn-nuovo-sito:hover {
    background: #333;
    border-color: var(--accent);
}

.site-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 20px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.site-modal.is-open {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}

.site-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(3px);
    cursor: pointer;
}

.site-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(440px, 100%);
    max-height: min(90vh, 640px);
    overflow-y: auto;
    padding: 22px 22px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: linear-gradient(180deg, rgba(24, 24, 24, 0.98), rgba(12, 12, 12, 0.98));
    box-shadow: var(--shadow);
}

.leads-modal-dialog {
    width: 100%;
    max-width: min(1680px, calc(100vw - 40px));
    max-height: calc(100vh - 44px);
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
}

.leads-table-wrap {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #111;
    overflow: auto;
    max-height: calc(100vh - 220px);
    width: 100%;
    box-sizing: border-box;
    padding-right: 4px;
    padding-bottom: 4px;
    scrollbar-gutter: stable;
}

.leads-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.leads-header-row .site-modal-lead {
    margin: 0;
    flex: 1 1 220px;
    min-width: 0;
}
.leads-header-search {
    flex: 1 1 200px;
    max-width: 320px;
    min-width: 160px;
}
.leads-table-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #111;
    color: #ededed;
}
.leads-table-search-input::placeholder {
    color: #666;
}
.leads-table-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(255, 138, 42, 0.2);
}
.leads-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.leads-header-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 5px;
    white-space: nowrap;
}
.leads-header-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

/* ── Popup aggiungi riga ── */
.leads-add-popup {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10100;
    align-items: center;
    justify-content: center;
}
.leads-add-popup.is-open {
    display: flex;
}
.leads-add-popup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}
.leads-add-popup-dialog {
    position: relative;
    width: min(720px, calc(100vw - 32px));
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px 28px 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.leads-add-popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: #aaa;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
.leads-add-popup-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}
.leads-add-popup-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
    color: #ededed;
}
.leads-add-popup-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 18px;
}
.leads-add-popup-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.leads-add-popup-label span {
    font-size: 12px;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.leads-add-popup-label input,
.leads-add-popup-label select {
    width: 100%;
    min-height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 7px;
    background: #111;
    color: #ededed;
    padding: 6px 10px;
    box-sizing: border-box;
    font-size: 13px;
}
.leads-add-popup-label select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%23b8b8b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px 14px;
}
.leads-add-popup-label input:focus,
.leads-add-popup-label select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(255, 138, 42, 0.25);
}
.leads-add-popup-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ── Popup conferma eliminazione ── */
.leads-confirm-popup {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10200;
    align-items: center;
    justify-content: center;
}
.leads-confirm-popup.is-open {
    display: flex;
}
.leads-confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}
.leads-confirm-dialog {
    position: relative;
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 22px 26px 18px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
}
.leads-confirm-text {
    margin: 0 0 18px;
    font-size: 14px;
    color: #ededed;
}
.leads-confirm-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}
.leads-confirm-btn {
    padding: 6px 18px;
    font-size: 13px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
}
.leads-confirm-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
}
.leads-confirm-cancel:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}
.leads-confirm-delete {
    background: #c0392b;
    color: #fff;
}
.leads-confirm-delete:hover {
    background: #e74c3c;
}

/* Popup duplicato nome ristorante (sopra modali tabelle contatti) */
.leads-duplicate-info-popup {
    z-index: 10350;
}
.leads-duplicate-popup-message {
    font-size: 15px;
    font-weight: 600;
}

.leads-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

.leads-table th,
.leads-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    padding: 4px 5px;
    vertical-align: middle;
    overflow: hidden;
    font-size: 11px;
}

.leads-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #1a1a1a;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
}

/* Larghezze colonne: # e azioni fissi minimi, il resto ~100% */
.leads-col-num {
    width: 22px;
}

.leads-col-nome {
    width: 15%;
}

.leads-col-citta {
    width: 8%;
}

.leads-col-ig,
.leads-col-fb {
    width: 11.5%;
}

.leads-col-link {
    width: 12.5%;
}

.leads-col-sito,
.leads-col-qual,
.leads-col-cont {
    width: 5.5%;
}

.leads-col-risp {
    width: 9.5%;
}

.leads-col-note {
    width: 16%;
}

.leads-col-actions {
    width: 32px;
}

.leads-table thead th.leads-col-num-head,
.leads-table .row-number-cell {
    width: 22px;
    max-width: 22px;
    min-width: 22px;
    padding: 1px 2px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
}

.leads-table td:last-child,
.leads-table th:last-child {
    border-right: 0;
}

.leads-table th.leads-col-actions {
    position: sticky;
    right: 0;
    z-index: 4;
    width: 32px;
    max-width: 32px;
    min-width: 32px;
    padding: 2px 6px 2px 2px;
    white-space: nowrap;
    text-align: center;
    overflow: visible;
    background: #1a1a1a;
    box-shadow: -8px 0 12px rgba(0, 0, 0, 0.45);
}

.leads-row-actions {
    position: sticky;
    right: 0;
    z-index: 1;
    width: 32px;
    max-width: 32px;
    min-width: 32px;
    padding: 2px 6px 2px 2px;
    text-align: center;
    vertical-align: middle;
    background: #161616;
    overflow: visible;
    box-shadow: -8px 0 12px rgba(0, 0, 0, 0.45);
}

.leads-table .leads-delete-row-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    min-width: 18px;
    max-width: 18px;
    height: 18px;
    margin: 0 auto;
    padding: 0;
    font-size: 13px;
    line-height: 1;
    font-weight: 700;
    color: #ff8a8a;
    background: transparent;
    border: 1px solid rgba(255, 138, 138, 0.35);
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    box-sizing: border-box;
    box-shadow: none;
    transform: none;
}

.leads-table .leads-delete-row-btn:hover {
    color: #ffb4b4;
    border-color: rgba(255, 180, 180, 0.55);
    background: rgba(255, 90, 90, 0.08);
    transform: none;
    box-shadow: none;
}

.row-number-cell {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    background: #161616;
}

.leads-table input {
    width: 100%;
    min-height: 26px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #ededed;
    padding: 3px 4px;
    box-shadow: none;
    font-size: 11px;
    line-height: 1.25;
    text-overflow: ellipsis;
}

.leads-add-popup-fields textarea {
    width: 100%;
    min-height: 72px;
    resize: vertical;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 7px;
    background-color: #111;
    color: #ededed;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.leads-table select {
    width: 100%;
    min-height: 26px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    background-color: #111;
    color: #ededed;
    padding: 3px 22px 3px 5px;
    box-sizing: border-box;
    font-size: 11px;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%23b8b8b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px 14px;
}

.leads-link-cell {
    display: flex;
    align-items: center;
    gap: 3px;
    width: 100%;
    min-width: 0;
}

.leads-link-cell input {
    flex: 1 1 auto;
    min-width: 0;
}

.leads-open-link {
    flex: 0 0 auto;
    color: #9dc7ff;
    font-size: 12px;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    padding: 0 2px;
}

.leads-open-link:hover {
    color: #c5deff;
}

.leads-table input:focus,
.leads-table select:focus {
    outline: none;
    border-color: var(--accent);
}

.site-modal-dialog h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.site-modal-lead {
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.site-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    line-height: 1;
    font-size: 22px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted);
}

.site-modal-close:hover {
    border-color: var(--border);
    color: var(--text);
}

.site-modal-form .site-modal-hint {
    display: block;
    margin: -4px 0 14px;
    font-size: 12px;
    color: var(--muted);
}

.site-modal-templates-label {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 600;
    color: #d4d4d4;
}

.site-modal-templates {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.site-modal-template-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #151515;
    cursor: pointer;
    margin: 0;
    font-size: 14px;
    color: var(--text);
}

.site-modal-template-option:hover {
    border-color: var(--border-strong);
}

.site-modal-template-option input {
    width: auto;
    margin: 0;
    flex-shrink: 0;
}

.site-modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.site-modal-actions button {
    width: auto;
    min-width: 120px;
    margin: 0;
}

.btn-modal-secondary {
    background: #1e1e1e;
    border-color: var(--border-strong);
}

.btn-modal-primary {
    background: var(--accent);
    border-color: var(--accent);
}

.template-base-hint {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.4;
}

.template-base-hint-extra {
    display: block;
    margin-top: 8px;
    color: var(--muted);
}

.quick-fields-fieldset,
.file-editor-fieldset {
    border: none;
    padding: 0;
    margin: 0 0 12px;
    min-width: 0;
}

.quick-fields-fieldset:disabled .field-wrap,
.quick-fields-fieldset:disabled .menu-builder,
.quick-fields-fieldset:disabled .section-group summary {
    opacity: 0.55;
}

.page-switch-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    width: 100%;
}

.page-switch-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.floating-actions {
    position: static;
    width: 100%;
    z-index: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-top: 0;
    padding-top: 50px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.page-switch-links {
    padding-bottom: 50px;
}

.page-switch-actions .top-action-btn {
    width: 100%;
    margin: 0;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 600;
    white-space: normal;
    text-align: left;
    line-height: 1.2;
    background: #222;
    border: 1px solid var(--border-strong);
    color: var(--text);
}

.icon-only-btn {
    width: 100% !important;
    height: 36px !important;
    min-height: 36px;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.action-icon {
    width: 21px;
    height: 21px;
    display: block;
}

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

.page-switch-actions .top-action-btn:hover {
    background: #2c2c2c;
    border-color: var(--accent);
}

.page-switch-links a {
    display: block;
    text-decoration: none;
    padding: 7px 10px;
    border-radius: 7px;
    border: 1px solid var(--border);
    color: #ececec;
    background: #141414;
    transition: border-color 0.2s ease, background 0.2s ease;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.page-switch-links a.active {
    border-color: var(--accent);
    background: #232323;
}

.preview-open-btn {
    width: 100%;
    margin: 0;
    padding: 8px 10px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    background: #222;
    font-weight: 600;
    font-size: 12px;
    white-space: normal;
    text-align: left;
    line-height: 1.2;
    position: static;
    left: auto;
}

.preview-open-btn:hover {
    background: #2c2c2c;
    border-color: var(--accent);
}

.logout {
    color: #d2d2d2;
    text-decoration: none;
    font-weight: 600;
}

.alert {
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 12px;
}

.success {
    background: var(--ok-bg);
    border: 1px solid var(--ok-border);
}

.error {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
}

.dashboard-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr;
    align-items: start;
}

.main-column {
    display: grid;
    gap: 16px;
}

.admin-autosave-status {
    margin: 0;
    min-height: 1.35em;
    font-size: 13px;
    color: var(--muted);
    transition: color 0.2s ease;
}

.admin-autosave-status.is-ok {
    color: #7eb88c;
}

.admin-autosave-status.is-error {
    color: var(--danger-strong);
}

.editor-section,
.template-sidebar {
    background: linear-gradient(180deg, rgba(20, 20, 20, 0.97), rgba(14, 14, 14, 0.97));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.editor-section h2 {
    margin-top: 0;
}

.template-sidebar h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 15px;
}

.template-sidebar {
    order: 0;
    position: fixed;
    top: 18px;
    left: var(--admin-sidebar-offset);
    width: var(--admin-sidebar-width);
    height: calc(100vh - 36px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 12px;
}

.sidebar-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 2px;
}

.template-sidebar nav {
    display: grid;
    gap: 6px;
    margin-bottom: 10px;
}

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

.sidebar-bottom-actions {
    flex-shrink: 0;
    display: grid;
    gap: 0px;
    margin-top: 0;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(180deg, rgba(14, 14, 14, 0.92), rgba(14, 14, 14, 0.97));
    box-shadow: 0 -10px 18px rgba(0, 0, 0, 0.28);
}

.sidebar-table-btn {
    width: 100%;
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: #232323;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.sidebar-table-btn:hover {
    background: #2f2f2f;
    border-color: var(--accent);
}

.sidebar-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #1f1f1f;
    color: #dcdcdc;
    text-decoration: none;
    font-weight: 600;
}

.sidebar-logout:hover {
    background: #2b2b2b;
    border-color: var(--accent);
}

.top-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #1f1f1f;
    color: #dcdcdc;
    text-decoration: none;
    font-weight: 600;
}

.top-logout:hover {
    background: #2b2b2b;
    border-color: var(--accent);
}

.template-sidebar a {
    display: block;
    text-decoration: none;
    color: #ececec;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 8px;
    font-size: 13px;
    line-height: 1.35;
    background: #151515;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.template-sidebar a.active {
    border-color: var(--accent);
    background: #242424;
}

.template-sidebar a:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
}

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

.modified-folders details {
    border: 0;
    border-radius: var(--radius-sm);
    padding: 6px 0;
    background: transparent;
}

.modified-folders details + details {
    margin-top: 8px;
}

.modified-folders summary {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    padding: 6px 0;
    list-style: none;
}

.modified-folders summary::-webkit-details-marker {
    display: none;
}

.modified-folders summary::marker {
    content: '';
}

.modified-folders summary::before {
    content: '';
    flex: 0 0 auto;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 6px solid #9a9a9a;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.modified-folders details[open] > summary::before {
    transform: rotate(90deg);
}

.modified-folders summary:hover::before {
    border-left-color: #d0d0d0;
}

.modified-folders ul {
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
}

.modified-folders li {
    margin: 4px 0;
    color: #d7d7d7;
    word-break: break-word;
}

.modified-folders .version-link {
    display: block;
    color: #ececec;
    text-decoration: none;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 7px 8px;
    font-size: 13px;
    line-height: 1.35;
    background: #151515;
    transition: background 0.2s ease, transform 0.2s ease;
}

.modified-folders .version-link:hover {
    transform: translateY(-1px);
    background: #1e1e1e;
}

.modified-folders .version-link.active {
    color: #ffffff;
    font-weight: 700;
    background: #242424;
}

.version-link {
    color: #d7d7d7;
    text-decoration: none;
}

.version-link.active {
    color: #ffffff;
    font-weight: 700;
}

.delete-version-form {
    margin: 0;
}

.delete-btn {
    width: auto;
    margin: 0;
    padding: 5px 9px;
    font-size: 12px;
    background: var(--danger);
    border-color: var(--danger-strong);
}

.delete-btn:hover {
    background: var(--danger-strong);
}

.delete-current-template-form {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #2c2c2c;
}

.page-switch-delete-form {
    margin: 0;
}

.page-switch-delete-form .delete-btn {
    margin: 0;
    padding: 8px 12px;
    font-size: 13px;
}

.empty-folder {
    margin: 8px 0 0;
    color: #9f9f9f;
    font-size: 13px;
}

.field-wrap + .field-wrap {
    margin-top: 8px;
}

.quick-global-theme-section {
    margin-bottom: 14px;
}

.quick-global-theme-section + .editor-section {
    margin-top: 14px;
}

.quick-global-theme-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #111;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.quick-global-theme-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.quick-global-theme-item .quick-section-bg-palette {
    top: calc(100% + 8px);
    right: auto;
    left: 0;
}

.quick-global-theme-label {
    font-size: 12px;
    color: #c6c6c6;
    font-weight: 600;
}

.field-label-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

.field-label-row > label {
    margin: 12px 0 6px;
}

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

.field-text-color-control {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.field-color-mini-label {
    font-size: 10px;
    letter-spacing: 0.04em;
    color: #b8b8b8;
    font-weight: 700;
    line-height: 1;
}

.field-text-color-btn {
    width: auto;
    margin: 0;
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: #1f1f1f;
    cursor: pointer;
}

.field-text-color-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.field-text-color-preview {
    width: 16px;
    height: 16px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    display: inline-block;
}

.field-text-color-palette {
    position: absolute;
    top: 0;
    right: calc(100% + 8px);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: #141414;
    box-shadow: 0 18px 34px rgba(0, 0, 0, 0.45);
    z-index: 50;
    min-width: min(220px, 70vw);
    max-width: min(320px, 70vw);
    box-sizing: border-box;
}

.field-text-color-swatches {
    display: grid;
    grid-template-columns: repeat(8, 18px);
    gap: 7px;
}

.field-text-color-swatch {
    width: 18px;
    height: 18px;
    padding: 0;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
}

.quick-editor-palette-hex-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    width: 100%;
    box-sizing: border-box;
}

.quick-editor-palette-hex-label {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 600;
    color: #b8b8b8;
}

.quick-section-bg-palette .quick-editor-palette-hex-input,
.field-text-color-palette .quick-editor-palette-hex-input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    max-width: none;
    margin-top: 0;
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
    background: #1f1f1f;
    color: #eee;
    font-size: 12px;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    line-height: 1.2;
}

.quick-editor-palette-hex-input.is-invalid {
    border-color: #c2516c;
    box-shadow: 0 0 0 1px rgba(194, 81, 108, 0.35);
}

.quick-section-bg-palette .quick-editor-palette-hex-apply,
.field-text-color-palette .quick-editor-palette-hex-apply {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    margin-top: 0;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
    background: #2a2a2a;
    color: #eee;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    transform: none;
    box-shadow: none;
}

.quick-section-bg-palette .quick-editor-palette-hex-apply:hover,
.field-text-color-palette .quick-editor-palette-hex-apply:hover {
    background: #353535;
    transform: none;
    box-shadow: none;
}

.section-group {
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #131313;
    padding: 10px;
}

.section-group > summary {
    display: flex;
    align-items: center;
    font-weight: 700;
    color: #e0e0e0;
    cursor: pointer;
    user-select: none;
    list-style: none;
}

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

.section-group > summary::marker {
    content: "";
}

.section-summary-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
    vertical-align: middle;
}

.section-summary-left {
    min-width: 0;
    display: flex;
    align-items: center;
}

.section-summary-left::before {
    content: "▸";
    display: inline-block;
    margin-right: 10px;
    color: #bdbdbd;
    transform: rotate(0deg);
    transition: transform 0.18s ease;
}

.section-group[open] .section-summary-left::before {
    transform: rotate(90deg);
}

.section-summary-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.section-summary-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.section-summary-title {
    min-width: 0;
}

.quick-section-toggle-btn {
    width: auto;
    margin: 0;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: #1f1f1f;
    color: #d7d7d7;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.quick-section-toggle-btn:hover {
    background: #2b2b2b;
    border-color: var(--accent);
}

.quick-section-toggle-btn.is-hidden {
    background: #3a1a22;
    border-color: var(--danger-strong);
    color: #f5c8d0;
}

.quick-section-nested-styles {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.quick-section-nested-style-block + .quick-section-nested-style-block {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.quick-section-nested-style-title {
    margin: 0 0 0.35rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: #e8e8e8;
}

.quick-section-nested-style-block .field-hint {
    margin-top: 0;
    margin-bottom: 0.65rem;
}

.quick-section-nested-styles-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

.quick-section-bg-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    position: relative;
}

.quick-section-bg-label {
    font-size: 12px;
    color: #bdbdbd;
    font-weight: 600;
}

.quick-section-bg-btn {
    width: auto;
    margin: 0;
    padding: 4px 6px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: #1f1f1f;
    color: #d7d7d7;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0;
}

.quick-section-bg-btn:hover {
    background: #2b2b2b;
    border-color: var(--accent);
}

.quick-section-bg-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.quick-section-bg-preview {
    width: 70px;
    height: 16px;
    border-radius: 6px;
    border: 0;
    background: #000;
    display: inline-block;
}

.quick-section-bg-palette {
    position: absolute;
    top: 0;
    right: calc(100% + 10px);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: #141414;
    box-shadow: 0 18px 34px rgba(0, 0, 0, 0.45);
    z-index: 50;
    max-width: min(320px, 70vw);
    min-width: min(248px, 70vw);
    box-sizing: border-box;
}

.quick-section-bg-swatches {
    display: grid;
    grid-template-columns: repeat(10, 20px);
    gap: 8px;
}

.quick-section-bg-swatch.is-transparent-swatch,
.field-text-color-swatch.is-transparent-swatch {
    background: repeating-conic-gradient(#8a8a8a 0% 25%, #5c5c5c 0% 50%) 50% / 10px 10px !important;
    border: 1px solid rgba(255, 255, 255, 0.35);
    position: relative;
}

.quick-section-bg-swatch.is-transparent-swatch::after,
.field-text-color-swatch.is-transparent-swatch::after {
    content: "T";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: #f0f0f0;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.quick-section-bg-swatch {
    width: 20px;
    height: 20px;
    padding: 0;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: #000;
    cursor: pointer;
}

.quick-section-bg-swatch:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.28);
}

.panel-popup-trigger > summary {
    cursor: pointer;
    list-style: none;
}

.panel-popup-dialog {
    width: min(1100px, 96vw);
    max-height: min(92vh, 860px);
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(46, 46, 46, 0.98), rgba(34, 34, 34, 0.98));
    border-color: #4a4a4a;
}

.panel-popup-trigger > summary::-webkit-details-marker {
    display: none;
}

.panel-popup-trigger > summary::marker {
    content: "";
}

.panel-popup-content {
    overflow: auto;
    padding-right: 2px;
}

.panel-popup-content .backend-collapsible-body {
    display: block;
}

#file-editor-modal .panel-popup-dialog {
    width: min(1320px, 98vw);
    height: 96vh;
    max-height: 96vh;
}

#file-editor-modal .panel-popup-content {
    flex: 1 1 auto;
    overflow: hidden;
    padding-right: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#file-editor-modal .panel-popup-content .backend-collapsible-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow: hidden;
}

#file-editor-modal .project-tree {
    flex: 0 0 20%;
    min-height: 0;
    max-height: 20%;
    margin: 0;
    overflow: auto;
}

#file-editor-modal .editor-form {
    flex: 1 1 80%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#file-editor-modal .file-editor-fieldset {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

#file-editor-modal .file-editor-fieldset label {
    flex-shrink: 0;
}

#file-editor-modal .code-area,
#file-editor-modal .CodeMirror {
    flex: 1 1 auto;
    min-height: 160px;
    max-height: none;
}

#file-editor-modal .actions-toolbar {
    flex-shrink: 0;
}

.section-group-body {
    margin-top: 10px;
}

.menu-builder-actions button,
.menu-col-head button,
.menu-col-editor > button,
.menu-row-editor button {
    width: auto;
    margin-top: 0;
    padding: 8px 10px;
}

.menu-builder-actions {
    margin-bottom: 10px;
}

.footer-default-popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1400;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.footer-default-popup-backdrop.is-open {
    display: flex;
}

.footer-default-popup {
    width: min(560px, 96vw);
    max-height: 84vh;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid var(--border-strong);
    background: #171717;
    box-shadow: 0 24px 54px rgba(0, 0, 0, 0.4);
    padding: 12px;
}

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

.footer-default-popup-head button {
    width: auto;
    margin: 0;
    padding: 6px 10px;
}

.footer-default-popup-body {
    display: grid;
    gap: 8px;
}

.footer-default-popup-option {
    width: 100%;
    text-align: left;
    margin: 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #202020;
}

.footer-default-popup-option:hover {
    border-color: var(--accent);
    background: #292929;
}

.footer-default-popup-option-label {
    display: block;
    font-weight: 700;
    color: #f1f1f1;
    margin-bottom: 4px;
}

.footer-default-popup-option-value {
    display: block;
    color: #b9b9b9;
    font-size: 13px;
    word-break: break-word;
}

.menu-col-editor {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    margin-bottom: 10px;
    background: #161616;
}

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

.menu-row-list {
    display: grid;
    gap: 8px;
    margin: 8px 0 10px;
}

.menu-row-editor {
    display: grid;
    grid-template-columns: 1fr 140px auto;
    gap: 8px;
}

.image-field small {
    color: #9f9f9f;
    display: block;
    margin-top: 6px;
    word-break: break-word;
}

.quick-image-preview {
    display: block;
    max-width: 220px;
    max-height: 140px;
    width: auto;
    height: auto;
    margin-top: 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    object-fit: cover;
}

.actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 14px;
}

.actions button {
    margin-top: 0;
}

.actions.actions-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

.actions.actions-toolbar button {
    width: auto;
    margin: 0;
    padding: 6px 11px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.inline-form {
    display: grid;
    grid-template-columns: 220px 1fr auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 12px;
}

.inline-form label {
    margin: 0;
}

.inline-form button {
    margin: 0;
}

.code-area {
    font-family: "Cascadia Code", "Fira Code", Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.5;
    min-height: 280px;
    background: #0e0e0e;
    color: #ededed;
    border: 1px solid #333333;
    border-radius: 10px;
    padding: 12px 14px;
    tab-size: 4;
    caret-color: #ffffff;
}

.code-area:focus {
    outline: none;
    border-color: #565656;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.CodeMirror {
    border: 1px solid #333333;
    border-radius: 10px;
    font-family: "Cascadia Code", "Fira Code", Consolas, "Courier New", monospace;
    font-size: 13px;
}

.CodeMirror-gutters {
    border-right: 1px solid #333333;
}

.project-tree {
    margin: 12px 0 14px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #141414;
    min-height: 180px;
    max-height: 320px;
    overflow: auto;
}

.project-tree h3 {
    margin: 0 0 8px;
    font-size: 14px;
}

.project-tree ul {
    margin: 0;
    padding-left: 18px;
}

.project-tree li {
    margin: 3px 0;
}

.tree-node > details > summary {
    cursor: pointer;
    color: #c7c7c7;
    user-select: none;
}

.tree-folder > ul {
    margin-top: 4px;
}

.tree-file-item {
    list-style: disc;
}

.tree-file-link {
    color: #d9d9d9;
    text-decoration: none;
}

.tree-file-link.active {
    color: #ffffff;
    font-weight: 700;
}

.image-preview-wrap {
    margin: 8px 0 12px;
}

.asset-preview {
    max-width: 100%;
    max-height: 240px;
    border: 1px solid #2f2f2f;
    border-radius: 8px;
    background: #101010;
}

.upload-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #2c2c2c;
}

.webp-tools-form {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #2c2c2c;
}

.scroll-activation-box {
    position: relative;
}

[data-scroll-zone="full-editor"]:not(.scroll-zone-active) .project-tree,
[data-scroll-zone="full-editor"]:not(.scroll-zone-active) .code-area,
[data-scroll-zone="full-editor"]:not(.scroll-zone-active) .CodeMirror-scroll {
    overflow: hidden !important;
}

.mode-badge {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 13px;
}

.tracking-panel {
    margin-top: 16px;
}

.tracking-hint {
    margin: -4px 0 12px;
    color: var(--muted);
    font-size: 13px;
}

/* Neutralize CodeMirror's default blue accents. */
.CodeMirror,
.CodeMirror.cm-s-material-darker {
    background: #0e0e0e !important;
    color: #f1f1f1 !important;
}

.cm-s-material-darker .CodeMirror-gutters {
    background: #111111 !important;
}

.cm-s-material-darker .CodeMirror-linenumber {
    color: #8e8e8e !important;
}

.cm-s-material-darker .CodeMirror-cursor {
    border-left: 1px solid #f1f1f1 !important;
}

.cm-s-material-darker .CodeMirror-selected {
    background: rgba(255, 255, 255, 0.12) !important;
}

.cm-s-material-darker .CodeMirror-activeline-background {
    background: rgba(255, 255, 255, 0.04) !important;
}

.tracking-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 12px;
    align-items: end;
}

.tracking-field label {
    margin-top: 0;
}

.tracking-actions {
    grid-column: 1 / -1;
}

.tracking-actions button {
    width: auto;
    min-width: 220px;
}

.smtp-panel {
    margin-top: 16px;
}

.smtp-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.smtp-field-span2 {
    grid-column: 1 / -1;
}

.smtp-field label {
    margin-top: 0;
}

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

.smtp-actions button {
    min-width: 180px;
}

.smtp-test-btn:disabled {
    opacity: 0.65;
    cursor: wait;
}

.smtp-test-badge {
    display: inline-block;
    margin: 8px 0 0;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
}

.smtp-status-pending {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    color: var(--muted);
}

.smtp-status-ok {
    background: var(--ok-bg);
    border: 1px solid var(--ok-border);
    color: #c8f5d9;
}

.smtp-status-fail {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    color: #f5c8d0;
}

.smtp-zip-warning {
    margin: 8px 0 0;
    color: var(--danger-strong);
    font-size: 14px;
}

.smtp-test-result {
    margin-top: 12px;
    font-size: 14px;
    min-height: 1.2em;
}

.smtp-test-result.is-ok {
    color: #8fd4a8;
}

.smtp-test-result.is-err {
    color: var(--danger-strong);
}

.senders-panel-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.senders-subpanel {
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-soft);
}

.senders-subpanel > summary.senders-subpanel-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    list-style: none;
}

.senders-subpanel > summary.senders-subpanel-summary::-webkit-details-marker {
    display: none;
}

.senders-subpanel-title {
    font-weight: 600;
}

.senders-subpanel-body {
    padding: 0 14px 14px;
}

.senders-subpanel.is-sender-off .senders-subpanel-body {
    opacity: 0.55;
    pointer-events: none;
}

#mailgun-email-texts-panel.is-email-texts-locked .backend-collapsible-body form {
    opacity: 0.72;
}

.sender-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex-shrink: 0;
    pointer-events: auto;
}

.senders-subpanel.is-sender-off .sender-toggle {
    pointer-events: auto;
}

.sender-toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.sender-toggle-slider {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: var(--border);
    transition: background 0.2s ease;
}

.sender-toggle-slider::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s ease;
}

.sender-toggle-input:checked + .sender-toggle-slider {
    background: var(--ok-border);
}

.sender-toggle-input:checked + .sender-toggle-slider::after {
    transform: translateX(18px);
}

.sender-toggle-input:focus-visible + .sender-toggle-slider {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.sender-toggle-label {
    font-size: 12px;
    font-weight: 600;
    min-width: 36px;
    color: var(--muted);
}

.sender-toggle-input:checked ~ .sender-toggle-label {
    color: #c8f5d9;
}

.ugo-pixel-textarea {
    width: 100%;
    min-height: 160px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.45;
}

@media (max-width: 980px) {
    .dashboard-body {
        padding: 16px;
    }

    .top-inline-row {
        flex-wrap: wrap;
        margin-right: 0;
    }

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

    .template-sidebar {
        order: 0;
        position: static;
        width: auto;
        height: auto;
        overflow: visible;
    }

    .sidebar-scroll {
        flex: none;
        min-height: 0;
        overflow: visible;
        padding-right: 0;
    }

    .actions:not(.actions-toolbar) {
        grid-template-columns: 1fr;
    }

    .inline-form {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .right-rail {
        position: static;
        width: auto;
        max-height: none;
        overflow: visible;
        gap: 8px;
        transform: none;
    }

    .top-inline-actions {
        position: static;
        margin: 0;
    }

    .page-switch-links {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .page-switch-actions {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
    }

    .floating-actions {
        position: static;
        width: auto;
        padding-top: 0;
        border-top: 0;
    }

    .preview-open-btn {
        width: auto;
    }

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

    .tracking-actions button {
        width: 100%;
        min-width: 0;
    }

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

    .smtp-field-span2 {
        grid-column: auto;
    }

    .smtp-actions button {
        width: 100%;
        min-width: 0;
    }
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #101010;
}

::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 999px;
    border: 2px solid #101010;
}

::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

.field-hint {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #b8b8b8;
    font-size: 0.9rem;
    line-height: 1.45;
}

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

.opacity-percent-field input[type="range"] {
    width: 100%;
    max-width: 320px;
}

.opacity-percent-field output {
    font-weight: 600;
    color: #e8e8e8;
}

.opacity-percent-field small {
    color: #9f9f9f;
}
