* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: linear-gradient(160deg, #f2f8f4 0%, #eef5ef 45%, #e8f3ed 100%);
    color: #183325;
}

.chat-body {
    height: 100vh;
    overflow: hidden;
}

.chat-page {
    height: 100vh;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.chat-card {
    width: 100%;
    max-width: 560px;
    height: min(92vh, 760px);
    min-height: 0;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 14px 42px rgba(26, 62, 41, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--secondary-border, #d8e8dd);
    background: var(--secondary-color, #f8fcf9);
}

.chat-logo {
    width: 180px;
    max-width: 42%;
    height: auto;
}

.chat-header h1 {
    margin: 0 0 2px;
    font-size: 18px;
    color: var(--primary-color, #2f7b50);
}

.chat-header p {
    margin: 0;
    font-size: 12px;
    color: var(--chat-header-text, #466a56);
}

.chat-messages {
    padding: 14px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: #fafdfb;
}

.msg {
    margin: 10px 0;
    display: flex;
}

.msg p {
    margin: 0;
    line-height: 1.45;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 14px;
    max-width: 88%;
    white-space: normal;
    position: relative;
}

.msg-bot p {
    background: var(--secondary-color, #e9f6ee);
    color: var(--secondary-text-color, #204b34);
    border: 1px solid var(--secondary-border, #c8e7d4);
}

.msg-bot p::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid var(--secondary-color, #e9f6ee);
}

.msg-user {
    justify-content: flex-end;
}

.msg-user p {
    background: var(--primary-color, #2f7b50);
    color: #ffffff;
}

.msg-user p::after {
    content: "";
    position: absolute;
    right: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 8px solid var(--primary-color, #2f7b50);
}

.msg-card p {
    display: flow-root;
    max-width: 96%;
    line-height: 1.5;
}

.msg-card-image {
    float: left;
    width: 82px;
    min-width: 82px;
    margin: 0 4px 2px 0;
    border-radius: 9px;
    border: 1px solid var(--secondary-border, #bfd7c8);
    box-shadow: 0 4px 12px rgba(24, 60, 39, 0.18);
}

.msg-card-text {
    display: inline;
    line-height: 1.5;
}

.msg-card-theme-inline {
    font-weight: 600;
    color: var(--secondary-text-color, #204b34);
}

.msg-temp p {
    opacity: 0.95;
}

.msg-closing-actions p.msg-action-row {
    background: transparent;
    border: 0;
    padding: 0;
    max-width: 100%;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.msg-closing-actions p.msg-action-row::before {
    display: none;
}

.msg-action-btn {
    border: 1px solid transparent;
    border-radius: 14px;
    padding: 10px 16px;
    min-width: 128px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(21, 58, 39, 0.16);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.msg-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(21, 58, 39, 0.22);
}

.msg-action-btn:active {
    transform: translateY(0);
    box-shadow: 0 3px 8px rgba(21, 58, 39, 0.18);
}

.msg-action-restart {
    background: var(--primary-color, #2f7b50);
    border-color: var(--primary-color, #2f7b50);
    color: #ffffff;
}

.msg-action-restart:hover {
    background: #256441;
    border-color: #256441;
    color: #ffffff;
}

.msg-action-close {
    background: var(--secondary-color, #e9f6ee);
    color: var(--secondary-text-color, #204b34);
    border-color: var(--secondary-border, #c8e7d4);
}

.msg-action-close:hover {
    background: var(--primary-color, #2f7b50);
    border-color: var(--primary-color, #2f7b50);
    color: #ffffff;
}

.msg-typing p {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.typing-dots {
    display: inline-flex;
    gap: 3px;
}

.typing-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--secondary-text-color, #4e7a61);
    opacity: 0.35;
    animation: atTypingDot 1s infinite ease-in-out;
}

.typing-dots i:nth-child(2) {
    animation-delay: 0.18s;
}

.typing-dots i:nth-child(3) {
    animation-delay: 0.36s;
}

@keyframes atTypingDot {
    0% {
        opacity: 0.25;
        transform: translateY(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-2px);
    }
    100% {
        opacity: 0.25;
        transform: translateY(0);
    }
}

.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 14px 0;
}

.quick-btn {
    border: 1px solid var(--secondary-border, #c8e7d4);
    color: var(--secondary-text-color, #204b34);
    background: var(--secondary-color, #e9f6ee);
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 13px;
    cursor: pointer;
}

.quick-btn:hover {
    background: var(--primary-color, #2f7b50);
    border-color: var(--primary-color, #2f7b50);
    color: #ffffff;
}

.quick-btn-card {
    width: 84px;
    height: 96px;
    border-radius: 10px;
    border: 1px solid var(--secondary-border, #c8e7d4);
    background: var(--secondary-color, #e9f6ee);
    color: var(--secondary-text-color, #204b34);
    padding: 6px 4px;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.quick-btn-card:hover {
    filter: brightness(0.97);
}

.quick-card-number {
    display: block;
    font-size: 30px;
    line-height: 1;
    font-weight: 700;
    margin-top: -2px;
}

.quick-card-label {
    display: block;
    font-size: 12px;
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chat-form {
    display: flex;
    gap: 8px;
    padding: 12px 14px 14px;
    border-top: 1px solid #d8e8dd;
    background: #ffffff;
}

.chat-form input {
    flex: 1;
    border: 1px solid #b9d4c2;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
}

.chat-form input:focus {
    border-color: var(--primary-color, #2f7b50);
}

.chat-form button {
    border: 1px solid var(--secondary-border, #c8e7d4);
    border-radius: 10px;
    background: var(--secondary-color, #e9f6ee);
    color: var(--secondary-text-color, #204b34);
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
}

.chat-form button:hover:not(:disabled) {
    background: var(--primary-color, #2f7b50);
    border-color: var(--primary-color, #2f7b50);
    color: #ffffff;
}

.chat-form button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-ad-slot {
    border-bottom: 1px solid #d8e8dd;
    background: #ffffff;
    padding: 6px 8px;
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-ad-fixed {
    width: 320px;
    height: 50px;
    max-width: 100%;
}

@media (min-width: 641px) {
    .chat-ad-slot {
        min-height: 66px;
    }
}

.admin-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 22px;
}

.admin-page-textos {
    max-width: 1460px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.admin-header h1 {
    margin: 0;
    color: var(--primary-color, #2f7b50);
    font-size: 20px !important;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.admin-nav a,
.btn-link,
.btn {
    text-decoration: none;
    border: 1px solid #b7d4c1;
    background: #fff;
    color: #20573b;
    border-radius: 8px;
    padding: 8px 12px;
    margin-right: 6px;
    display: inline-block;
    cursor: pointer;
}

.admin-nav a {
    margin-right: 0;
}

.btn-primary {
    background: var(--primary-color, #2f7b50);
    color: #fff;
    border-color: var(--primary-color, #2f7b50);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.card {
    background: #fff;
    border: 1px solid #d8e8dd;
    border-radius: 12px;
    padding: 14px;
}

.card h3 {
    margin: 0 0 8px;
    font-size: 14px;
}

.card strong {
    font-size: 24px;
    color: var(--primary-color, #2f7b50);
}

.dashboard-card {
    margin-top: 14px;
}

.summary-theme-card p {
    margin: 6px 0 0;
}

.online-now-card {
    padding: 8px 12px;
}

.online-now-card p {
    margin: 0;
    font-size: 13px;
    color: #2f5d47;
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.online-now-card strong {
    font-size: 18px;
    line-height: 1;
}

.online-now-card span {
    color: #5c7b6b;
}

.admin-footer-note {
    margin: 14px 2px 4px;
    font-size: 12px;
    color: #5d7f6d;
    opacity: 0.9;
}

.admin-footer-link {
    color: #2f7b50;
    text-decoration: underline;
}

.admin-footer-link:hover {
    color: #225d3d;
}

.faq-mobile-only {
    display: none;
}

.faq-help-card {
    margin-bottom: 10px;
    padding: 0;
    overflow: hidden;
    border-radius: 10px;
}

.faq-help-card summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 12px;
    color: #1f5a3d;
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.faq-help-card summary::-webkit-details-marker {
    display: none;
}

.faq-help-card summary::after {
    content: '▾';
    font-size: 11px;
    transition: transform 0.2s ease;
}

.faq-help-card[open] summary::after {
    transform: rotate(180deg);
}

.faq-mobile-body {
    border-top: 1px solid #d7e5db;
    padding: 10px 12px 12px;
    line-height: 1.4;
    font-size: 14px;
}

.faq-mobile-body strong {
    font-size: inherit;
    color: inherit;
    font-weight: 700;
}

.faq-copy-btn {
    border: 0;
    background: transparent;
    color: #1b66c9;
    font: inherit;
    font-size: 13px;
    padding: 0;
    margin: 0;
    cursor: pointer;
    text-decoration: underline;
}

.faq-copy-btn:hover {
    color: #144f9c;
}

.faq-copy-btn.is-copied {
    color: #c92222;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    border: 1px solid #d7e5db;
    padding: 8px;
    font-size: 13px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #f2f8f4;
}

.th-sort-btn {
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    margin: 0;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.th-sort-btn:hover {
    color: var(--primary-color, #2f7b50);
}

.th-sort-arrow {
    font-size: 11px;
    line-height: 1;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #d7e5db;
    border-radius: 10px;
    background: #fff;
}

.table-scroll table {
    min-width: 760px;
    border: 0;
    margin: 0;
}

.table-compact {
    width: 100%;
    table-layout: fixed;
}

.table-compact th,
.table-compact td {
    white-space: normal;
    word-break: break-word;
}

.table-compact th:first-child,
.table-compact td:first-child {
    width: 58%;
}

.table-compact th:last-child,
.table-compact td:last-child {
    width: 42%;
    text-align: center;
}

.city-stats-scroll {
    height: 170px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid #d7e5db;
    border-radius: 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #9bbfaf #edf6f1;
}

.city-stats-scroll table {
    width: 100%;
    border: 0;
}

.city-stats-scroll::-webkit-scrollbar {
    width: 8px;
}

.city-stats-scroll::-webkit-scrollbar-track {
    background: #edf6f1;
    border-radius: 8px;
}

.city-stats-scroll::-webkit-scrollbar-thumb {
    background: #9bbfaf;
    border-radius: 8px;
}

.city-stats-hint {
    display: none;
    margin: 6px 2px 0;
    font-size: 12px;
    color: #3f6d56;
}

.table-textos table {
    min-width: 1180px;
}

.table-textos th:nth-child(1),
.table-textos td:nth-child(1) {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
}

.table-textos th:nth-child(2),
.table-textos td:nth-child(2) {
    width: 120px;
    min-width: 120px;
    max-width: 120px;
}

.table-textos textarea {
    min-height: 96px;
    padding: 10px;
    line-height: 1.35;
}

.keywords-form textarea {
    min-height: 96px;
    padding: 10px;
    line-height: 1.35;
}

textarea,
input[type="text"],
input[type="number"],
input[type="password"],
select {
    width: 100%;
    border: 1px solid #b9d4c2;
    border-radius: 8px;
    padding: 8px;
    font-size: 14px;
}

.admin-page textarea,
.admin-page input[type="text"],
.admin-page input[type="number"],
.admin-page input[type="password"],
.admin-page select {
    background: #f3faf6;
    color: #173727;
}

.admin-page textarea:focus,
.admin-page input[type="text"]:focus,
.admin-page input[type="number"]:focus,
.admin-page input[type="password"]:focus,
.admin-page select:focus {
    background: #ffffff;
    border-color: var(--primary-color, #2f7b50);
    box-shadow: 0 0 0 2px rgba(47, 123, 80, 0.12);
    outline: none;
}

textarea {
    min-height: 74px;
    resize: vertical;
}

.flash {
    border: 1px solid #b7ddc5;
    background: #effbf3;
    color: #20573b;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border: 1px solid #d8e8dd;
    border-radius: 14px;
    padding: 22px;
}

.login-card h1 {
    margin: 0 0 14px;
    font-size: 20px;
    color: var(--primary-color, #2f7b50);
}

.row-gap {
    margin-bottom: 10px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.color-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-input-wrap input[type="color"] {
    width: 44px;
    height: 38px;
    border: 1px solid #b9d4c2;
    border-radius: 8px;
    padding: 2px;
    background: #fff;
    cursor: pointer;
}

.color-input-wrap input[type="text"] {
    max-width: 150px;
}

.logo-url-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.logo-url-wrap input[type="text"] {
    flex: 1;
    min-width: 220px;
}

#openLogoCropModal {
    background: #dff4e6;
    border-color: #9fcdad;
    color: #1f5a3d;
}

#openLogoCropModal:hover {
    background: #cbead6;
    border-color: #87b996;
    color: #184b33;
}

.admin-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    z-index: 99999;
    padding: 16px;
}

.admin-modal.on {
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-modal-box {
    width: 100%;
    max-width: 640px;
    height: min(92vh, 860px);
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.admin-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    border: 1px solid #b9d4c2;
    background: #fff;
    color: #1e5137;
    border-radius: 8px;
    padding: 5px 9px;
    cursor: pointer;
}

.admin-modal-box iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.admin-modal-logo {
    max-width: 760px;
    height: auto;
    max-height: 92vh;
    overflow: auto;
}

.logo-crop-content {
    padding: 18px;
}

.logo-crop-content h3 {
    margin: 0 0 6px;
    color: var(--primary-color, #2f7b50);
}

.logo-crop-content p {
    margin: 0 0 10px;
}

.logo-crop-stage {
    width: 100%;
    max-width: 480px;
    height: 96px;
    border: 2px dashed #b7d4c1;
    border-radius: 10px;
    background: #f6fcf8;
    position: relative;
    overflow: hidden;
    margin-top: 10px;
    user-select: none;
    touch-action: none;
    cursor: grab;
}

.logo-crop-stage:active {
    cursor: grabbing;
}

.logo-crop-stage img {
    position: absolute;
    left: 0;
    top: 0;
    max-width: none;
    display: block;
    -webkit-user-drag: none;
    user-select: none;
}

.logo-crop-controls {
    margin-top: 10px;
    max-width: 480px;
}

.logo-crop-controls input[type="range"] {
    width: 100%;
}

.logo-crop-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.logo-crop-message {
    margin-top: 10px;
    color: #1f5c3d;
    min-height: 18px;
}

.logo-crop-message.error {
    color: #b42318;
}

@media (max-width: 640px) {
    .chat-page {
        padding: 0;
    }

    .chat-card {
        height: 100vh;
        min-height: 100vh;
        border-radius: 0;
        max-width: none;
    }

    .chat-logo {
        width: 130px;
    }

    .chat-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .chat-header h1,
    .chat-header p {
        margin-left: 0;
    }

    .msg-card-image {
        width: 74px;
        min-width: 74px;
        margin-right: 4px;
    }

    .quick-btn-card {
        width: 76px;
        height: 88px;
    }

    .quick-card-number {
        font-size: 26px;
    }

    .chat-ad-slot {
        min-height: 58px;
        padding: 6px;
    }

    .city-stats-hint {
        display: block;
    }

    .faq-desktop-only {
        display: none;
    }

    .faq-mobile-only {
        display: block;
        padding: 0;
        overflow: hidden;
        margin: 0 0 8px;
        border-radius: 10px;
    }

    .faq-mobile-only summary {
        list-style: none;
        cursor: pointer;
        padding: 8px 10px;
        color: #1f5a3d;
        font-weight: 700;
        font-size: 13px;
        line-height: 1.2;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .faq-mobile-only summary::-webkit-details-marker {
        display: none;
    }

    .faq-mobile-only summary::after {
        content: '▾';
        font-size: 11px;
        transition: transform 0.2s ease;
    }

    .faq-mobile-only[open] summary::after {
        transform: rotate(180deg);
    }

    .faq-mobile-body {
        border-top: 1px solid #d7e5db;
        padding: 8px 10px 10px;
        line-height: 1.35;
        font-size: 13px;
    }

    .faq-help-card summary {
        padding: 8px 10px;
        font-size: 13px;
    }

    .faq-help-card summary::after {
        font-size: 11px;
    }

    .summary-theme-card {
        padding: 10px 12px;
    }

    .summary-theme-card p {
        margin-top: 4px;
        line-height: 1.3;
    }

    .admin-page {
        padding: 12px;
        font-size: 15px;
    }

    .admin-header h1 {
        font-size: 19px !important;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .admin-nav {
        width: 100%;
        justify-content: flex-start;
    }

    .admin-nav a,
    .btn-link,
    .btn {
        margin-right: 0;
        font-size: 14px;
        padding: 9px 12px;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 2px;
    }

    .table-scroll table {
        min-width: 640px;
    }

    .table-compact th,
    .table-compact td {
        padding: 6px;
        font-size: 13px;
    }

    .table-textos table {
        min-width: 1100px;
    }

    .table-textos th:nth-child(1),
    .table-textos td:nth-child(1) {
        width: 34px;
        min-width: 34px;
        max-width: 34px;
        text-align: center;
        padding-left: 4px;
        padding-right: 4px;
    }

    .table-textos th:nth-child(2),
    .table-textos td:nth-child(2) {
        width: 128px;
        min-width: 128px;
        max-width: 128px;
    }

    .table-textos textarea {
        min-height: 116px;
    }

    .keywords-form textarea {
        min-height: 116px;
    }

    .color-input-wrap input[type="text"] {
        max-width: none;
    }

    .card h3 {
        font-size: 16px;
    }

    table th,
    table td {
        font-size: 13px;
    }

    .admin-page input[type="text"],
    .admin-page input[type="number"],
    .admin-page input[type="password"],
    .admin-page select,
    .admin-page textarea {
        font-size: 16px;
    }

    .logo-url-wrap input[type="text"] {
        min-width: 0;
    }

    .admin-modal {
        padding: 8px;
    }

    .admin-modal-box {
        max-width: none;
        height: 95vh;
        border-radius: 10px;
    }

    .admin-modal-logo {
        height: auto;
        max-height: 95vh;
    }

    .logo-crop-content {
        padding: 14px;
    }

    .logo-crop-stage {
        height: 78px;
    }
}

@media (max-width: 900px) {
    .admin-page {
        padding: 14px;
    }

    .admin-header h1 {
        font-size: 18px !important;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .admin-nav {
        justify-content: flex-start;
    }

    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
