* { box-sizing: border-box; }
html {
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}
:root {
    --bg: #edf4fb;
    --panel: #ffffff;
    --panel-soft: #f7fbff;
    --line: #dbe7f2;
    --text: #111827;
    --muted: #667085;
    --primary: #1f6fe5;
    --primary-dark: #1559c4;
    --primary-soft: #e8f2ff;
    --accent: #10b981;
    --warm: #f59e0b;
    --danger: #d92d20;
    --shadow: 0 18px 44px rgba(26, 54, 93, 0.12);
    --radius: 8px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(circle at 14% 8%, rgba(31, 111, 229, 0.11), transparent 28%),
        radial-gradient(circle at 90% 12%, rgba(16, 185, 129, 0.10), transparent 24%),
        var(--bg);
}
button, input, textarea, select { font: inherit; }
button, .session-btn, .field, textarea, select {
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease;
}
button:disabled {
    cursor: not-allowed;
    opacity: 0.68;
}
.hidden { display: none !important; }
.auth-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(180deg, #f8fbff 0%, #eef2f6 100%);
}
.auth-panel {
    width: min(440px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.brand-row, .side-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.brand-logo {
    width: 84px;
    height: 84px;
    object-fit: contain;
    border-radius: var(--radius);
    background: #fff;
    flex: 0 0 auto;
}
.brand-logo.small {
    width: 42px;
    height: 42px;
}
.brand-row h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.brand-row p, .side-head span, .topbar span, .hint, .status-line {
    display: block;
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}
.mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), #25b7d3);
    color: #fff;
    font-weight: 800;
    font-size: 21px;
}
.mark.small { width: 34px; height: 34px; font-size: 15px; }
.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
}
.tab, .btn {
    min-height: 38px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: var(--radius);
    padding: 9px 13px;
    cursor: pointer;
}
.tab:hover, .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(31, 111, 229, 0.10);
}
.text-btn {
    border: 0;
    background: transparent;
    color: var(--primary);
    padding: 0;
    cursor: pointer;
    font-size: 13px;
}
.auth-actions {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-top: 12px;
}
.icp-link {
    display: block;
    color: #8a98ab;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
}
.icp-link:hover {
    color: var(--primary);
    text-decoration: underline;
}
.auth-icp {
    margin-top: 14px;
}
.sidebar-icp {
    margin-top: 2px;
    padding-bottom: 2px;
}
.captcha-panel, .sms-panel {
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
}
.captcha-widget {
    min-height: 80px;
}
.captcha-image {
    width: 100%;
    height: 72px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}
.tab.active, .btn-primary {
    background: linear-gradient(135deg, var(--primary), #22a7d8);
    border-color: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), #168fbd); }
.btn-outline { background: transparent; }
.btn-sm { min-height: 30px; padding: 5px 9px; font-size: 13px; }
.full { width: 100%; }
.field {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 11px;
    margin-bottom: 10px;
    background: #fff;
    color: var(--text);
}
.form-field {
    display: block;
    margin-bottom: 10px;
}
.form-field > span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.form-field .field {
    margin-bottom: 0;
}
.field.invalid {
    border-color: #ff3b30;
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.08);
}
.field-error {
    display: block;
    min-height: 18px;
    margin-top: 6px;
    color: #ff3b30;
    font-size: 13px;
    line-height: 1.4;
}
.agreement-row {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 4px 0 2px;
    color: var(--muted);
    line-height: 1.6;
}
.agreement-row input {
    width: 18px;
    height: 18px;
    margin-top: 3px;
    accent-color: var(--primary);
    flex: 0 0 auto;
}
.policy-link {
    border: 0;
    padding: 0;
    background: transparent;
    color: #6557ff;
    cursor: pointer;
    font-weight: 700;
}
.agreement-error {
    margin-bottom: 10px;
}
.policy-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.72);
}
.policy-modal-card {
    width: min(720px, calc(100vw - 32px));
    height: min(70vh, 760px);
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}
.policy-modal-card header {
    min-height: 48px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.policy-modal-close {
    border: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}
.policy-modal-content {
    overflow-y: auto;
    padding: 22px 26px;
    color: #718096;
    font-size: 15px;
    line-height: 1.85;
    white-space: pre-line;
}
.policy-modal-content p {
    margin: 0 0 14px;
}
select.field {
    min-height: 44px;
    line-height: 1.35;
}
.style-mode-options {
    display: none;
}
.style-mode-options button {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
    min-height: 42px;
}
.style-mode-options button.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 111, 229, 0.08);
}
.field:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.app-shell, .admin-screen {
    height: 100vh;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    overflow: hidden;
}
.sidebar-backdrop {
    display: none;
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(14px);
    border-right: 1px solid var(--line);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 11px;
}
.side-head {
    margin-bottom: 10px;
}
.mobile-menu-btn,
.mobile-sidebar-close {
    display: none;
}
.side-head span {
    display: none;
}
.quota-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    background:
        linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(232, 242, 255, 0.72)),
        var(--panel-soft);
    box-shadow: 0 10px 26px rgba(26, 54, 93, 0.08);
}
.quota-card span, .label {
    color: var(--muted);
    font-size: 13px;
}
.quota-card strong {
    display: block;
    font-size: 17px;
    line-height: 1.45;
    margin: 2px 0 10px;
}
.quota-sub {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
    gap: 12px;
}
.quota-sub strong { margin: 0; font-size: 15px; }
.status-line {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-soft);
}
.sessions {
    flex: 1 1 auto;
    min-height: 90px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 2px;
}
.session-btn {
    min-height: 38px;
    text-align: left;
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--radius);
    padding: 9px 10px;
    cursor: pointer;
    color: var(--text);
}
.session-btn:hover, .session-btn.active {
    border-color: var(--line);
    background: var(--primary-soft);
    transform: translateX(2px);
}
.chat-main {
    height: 100vh;
    min-width: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 6;
    min-height: 66px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(14px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.topbar > div {
    min-width: 0;
}
.topbar strong { display: block; font-size: 16px; }
.topbar-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}
.support-entry-btn {
    white-space: nowrap;
    color: var(--primary);
    font-weight: 700;
}
.admin-link { display: none; }
.messages {
    padding: 24px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.message { display: flex; }
.message.user { justify-content: flex-end; }
.bubble {
    max-width: min(760px, 78%);
    padding: 12px 14px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--line);
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    animation: messageIn 0.24s ease both;
}
.message.user .bubble {
    background: linear-gradient(135deg, var(--primary), #24a3d5);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 12px 28px rgba(31, 111, 229, 0.18);
}
.announcement-bar {
    position: sticky;
    top: 66px;
    z-index: 5;
    padding: 0;
    background: linear-gradient(90deg, #fff4bf, #e9f8ff);
    color: #805000;
    border-bottom: 1px solid #f3d985;
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    white-space: nowrap;
}
.announcement-track {
    display: inline-flex;
    align-items: center;
    gap: 40px;
    min-width: 100%;
    padding: 10px 16px;
    animation: announcementScroll 26s linear infinite;
    will-change: transform;
}
.announcement-bar:hover .announcement-track {
    animation-play-state: paused;
}
.announcement-item {
    flex: 0 0 auto;
}
.announcement-dialog h3 {
    margin: 0 0 14px;
}
.announcement-content {
    max-height: min(52vh, 420px);
    overflow-y: auto;
    color: var(--text);
    line-height: 1.75;
    white-space: pre-line;
    overflow-wrap: anywhere;
    word-break: break-word;
    padding-right: 4px;
}
.announcement-content p {
    margin: 0 0 10px;
}
.announcement-overlay, .profile-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(17, 24, 39, 0.55);
    display: grid;
    place-items: center;
    padding: 18px;
}
.announcement-dialog, .profile-panel {
    width: min(620px, 100%);
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.user-avatar {
    border: 0;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 0;
}
.user-avatar img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    background: #fff;
    box-shadow: 0 0 0 1px var(--line), 0 8px 18px rgba(26, 54, 93, 0.10);
}
.user-avatar span {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-weight: 700;
    color: var(--text);
}
.profile-panel label {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 13px;
}
.profile-panel .field {
    margin-top: 6px;
    margin-bottom: 0;
}
.profile-panel .btn { margin-top: 10px; }
.composer {
    padding: 14px 18px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(14px);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.composer textarea {
    flex: 1;
    min-height: 46px;
    max-height: 150px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 11px 12px;
    background: rgba(255, 255, 255, 0.96);
}
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: grid;
    place-items: center;
    padding: 20px;
}
.modal-card {
    width: min(480px, 100%);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    background: #fff;
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.support-modal {
    position: fixed;
    inset: 0;
    z-index: 42;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.42);
}
.support-card {
    width: min(520px, 100%);
    height: min(680px, calc(100dvh - 40px));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border: 1px solid rgba(219, 231, 242, 0.9);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
}
.support-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}
.support-header h2 {
    margin: 0 0 6px;
    font-size: 20px;
}
.support-presence {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.support-presence i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #98a2b3;
    box-shadow: 0 0 0 3px rgba(152, 162, 179, 0.14);
}
.support-presence.online {
    color: #047857;
}
.support-presence.online i {
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}
.support-messages,
.support-admin-messages {
    min-height: 0;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background:
        radial-gradient(circle at 16% 0%, rgba(31, 111, 229, 0.08), transparent 28%),
        var(--panel-soft);
}
.support-message {
    max-width: 82%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.support-message.mine {
    align-self: flex-end;
    color: #fff;
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary), #24a3d5);
}
.support-message .support-message-meta {
    display: block;
    margin-bottom: 4px;
    color: inherit;
    opacity: 0.72;
    font-size: 12px;
}
.support-composer,
.support-admin-reply {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--line);
    background: #fff;
}
.support-composer textarea,
.support-admin-reply textarea {
    flex: 1;
    resize: vertical;
    min-height: 44px;
    max-height: 120px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
}
.panel-title-row.compact {
    margin-bottom: 8px;
    align-items: center;
}
.recent-orders-panel {
    margin: 12px 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel-soft);
}
.recent-orders-list {
    display: grid;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
}
.recent-order-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid rgba(219, 231, 242, 0.95);
    border-radius: var(--radius);
    background: #fff;
}
.recent-order-row strong,
.recent-order-row span {
    display: block;
    word-break: break-word;
}
.recent-order-row span {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}
.recent-order-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}
.empty-state.compact {
    min-height: auto;
    padding: 8px;
    color: var(--muted);
    font-size: 13px;
}
pre {
    padding: 12px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    white-space: pre-wrap;
}
.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: #111827;
    color: #fff;
    padding: 10px 14px;
    border-radius: var(--radius);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.24);
}
.admin-main {
    padding: 20px;
    overflow: auto;
}
.admin-dashboard-mode {
    grid-template-columns: 1fr;
}
.admin-dashboard {
    position: relative;
    min-height: 100vh;
    padding: 18px;
    background:
        radial-gradient(circle at 8% 6%, rgba(31, 111, 229, 0.16), transparent 24%),
        radial-gradient(circle at 88% 8%, rgba(245, 158, 11, 0.15), transparent 22%),
        radial-gradient(circle at 74% 82%, rgba(16, 185, 129, 0.13), transparent 26%),
        linear-gradient(135deg, #eef6ff, #f7fbff 45%, #eefbf6);
}
.dashboard-hero {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 22px;
    margin-bottom: 14px;
    border: 1px solid rgba(219, 231, 242, 0.86);
    border-radius: 14px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(232, 242, 255, 0.76)),
        rgba(255, 255, 255, 0.86);
    box-shadow: 0 18px 46px rgba(26, 54, 93, 0.12);
}
.dashboard-hero::after {
    content: "";
    position: absolute;
    inset: auto -12% -70% 42%;
    height: 180px;
    background: linear-gradient(90deg, rgba(31, 111, 229, 0.12), rgba(16, 185, 129, 0.16), rgba(245, 158, 11, 0.13));
    filter: blur(22px);
    animation: dashboardGlow 6s ease-in-out infinite alternate;
}
.dashboard-hero h1 {
    margin: 4px 0 6px;
    font-size: 28px;
    line-height: 1.2;
}
.dashboard-hero p {
    margin: 0;
    color: var(--muted);
}
.dashboard-kicker {
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
}
.dashboard-status {
    position: relative;
    z-index: 1;
    min-width: 210px;
    padding: 14px 16px;
    border: 1px solid rgba(31, 111, 229, 0.18);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: inset 0 0 24px rgba(31, 111, 229, 0.08);
}
.dashboard-status span {
    display: block;
    color: var(--accent);
    font-weight: 800;
}
.dashboard-status strong {
    display: block;
    margin-top: 4px;
    color: var(--text);
}
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: start;
    gap: 14px;
}
.dashboard-panel {
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.84);
    backdrop-filter: blur(14px);
    box-shadow: 0 16px 42px rgba(26, 54, 93, 0.10);
    animation: panelIn 0.34s ease both;
}
.dashboard-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--warm));
}
.api-panel,
.host-panel,
.dashboard-panel:nth-of-type(4),
.dashboard-panel:nth-of-type(8),
.dashboard-panel:nth-of-type(9) {
    grid-column: 1 / -1;
}
.dashboard-panel:nth-of-type(2),
.dashboard-panel:nth-of-type(3),
.dashboard-panel:nth-of-type(5),
.dashboard-panel:nth-of-type(6) {
    grid-column: span 6;
}
.dashboard-panel:nth-of-type(7) {
    grid-column: span 12;
}
.support-admin-panel {
    grid-column: 1 / -1;
}
.panel-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.panel-title-row h2 {
    margin: 4px 0 0;
}
.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    color: #915200;
    background: #fff3cc;
    border: 1px solid #f7d780;
    font-weight: 700;
    font-size: 13px;
}
.status-pill.success {
    color: #047857;
    background: #dcfce7;
    border-color: #86efac;
}
.support-admin-layout {
    display: grid;
    grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
    gap: 14px;
    min-height: 420px;
}
.support-conversation-list {
    min-height: 0;
    max-height: 520px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}
.support-conversation-item {
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
    background: rgba(255, 255, 255, 0.86);
    cursor: pointer;
}
.support-conversation-item.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 10px 24px rgba(31, 111, 229, 0.12);
}
.support-conversation-item strong {
    display: block;
    margin-bottom: 4px;
}
.support-conversation-item span,
.support-conversation-item em {
    display: block;
    color: var(--muted);
    font-style: normal;
    font-size: 12px;
    line-height: 1.5;
}
.support-conversation-item .unread-badge {
    display: inline-flex;
    margin-top: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    color: #fff;
    background: var(--danger);
    font-weight: 800;
}
.support-admin-chat {
    min-width: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
}
.support-admin-messages {
    min-height: 320px;
}
.btn-danger {
    border-color: rgba(217, 45, 32, 0.24);
    background: #fff5f4;
    color: var(--danger);
}
.btn-danger:hover {
    box-shadow: 0 8px 20px rgba(217, 45, 32, 0.10);
}
.toolbar-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) repeat(3, auto);
    gap: 10px;
    align-items: start;
    margin-bottom: 12px;
}
.toolbar-row .field {
    margin-bottom: 0;
}
.action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.config-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.compact-config {
    margin: 10px 0 12px;
}
.config-item {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid rgba(219, 231, 242, 0.92);
    border-radius: 10px;
    background: rgba(247, 251, 255, 0.86);
}
.config-item span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 12px;
}
.config-item strong {
    display: block;
    color: var(--text);
    font-size: 13px;
    line-height: 1.55;
    word-break: break-all;
}
.host-panel {
    grid-column: 1 / -1;
}
.metric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}
.metric-card {
    position: relative;
    min-height: 92px;
    overflow: hidden;
    padding: 12px;
    border: 1px solid rgba(219, 231, 242, 0.86);
    border-radius: 12px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(232, 242, 255, 0.72)),
        #fff;
}
.metric-card::after {
    content: "";
    position: absolute;
    right: -18px;
    bottom: -24px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(31, 111, 229, 0.10);
}
.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}
.metric-card strong {
    position: relative;
    z-index: 1;
    display: block;
    margin-top: 8px;
    color: var(--text);
    font-size: 22px;
    line-height: 1.2;
    word-break: break-word;
}
.metric-card em {
    position: relative;
    z-index: 1;
    display: block;
    margin-top: 7px;
    color: #8a97aa;
    font-size: 12px;
    font-style: normal;
}
.admin-login-mode {
    grid-template-columns: 1fr;
    place-items: center;
    padding: 24px;
}
.admin-login-mode .admin-login-panel {
    position: static;
    width: min(420px, 100%);
    height: auto;
    min-height: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    background: rgba(255, 255, 255, 0.94);
}
.admin-login-mode .side-head {
    justify-content: flex-start;
    margin-bottom: 22px;
}
.admin-login-mode .side-head span {
    display: block;
}
.admin-auth-sidebar .field,
.admin-auth-sidebar .btn,
.admin-auth-sidebar #adminLoginHint {
    display: none;
}
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}
.stat-card, .table-panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 0;
}
.dashboard-stats .stat-card {
    position: relative;
    overflow: hidden;
    min-height: 96px;
    padding: 16px;
    border-color: rgba(255, 255, 255, 0.72);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(232, 242, 255, 0.70));
    box-shadow: 0 14px 34px rgba(26, 54, 93, 0.10);
    animation: panelIn 0.28s ease both;
}
.dashboard-stats .stat-card::after {
    content: "";
    position: absolute;
    width: 90px;
    height: 90px;
    right: -22px;
    bottom: -30px;
    border-radius: 50%;
    background: rgba(31, 111, 229, 0.12);
}
.dashboard-stats .stat-card-2::after { background: rgba(16, 185, 129, 0.14); }
.dashboard-stats .stat-card-3::after { background: rgba(245, 158, 11, 0.16); }
.dashboard-stats .stat-card-4::after { background: rgba(34, 167, 216, 0.15); }
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; font-size: 28px; margin-top: 6px; }
.dashboard-stats .stat-card strong {
    font-size: 30px;
}
.stat-card em {
    display: block;
    margin-top: 6px;
    color: #8a97aa;
    font-size: 12px;
    font-style: normal;
}
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.settings-grid label {
    color: var(--muted);
    font-size: 13px;
}
.toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
th, td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}
th { color: var(--muted); font-weight: 600; }
@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes panelIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes dashboardGlow {
    from { transform: translateX(-8px); opacity: 0.55; }
    to { transform: translateX(18px); opacity: 0.95; }
}
@keyframes announcementScroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}
@media (max-width: 820px) {
    .app-shell {
        height: var(--app-vh, 100dvh);
        min-height: var(--app-vh, 100dvh);
        max-height: var(--app-vh, 100dvh);
        grid-template-columns: 1fr;
        overflow: hidden;
    }
    .admin-screen {
        height: auto;
        min-height: 100vh;
        grid-template-columns: 1fr;
        overflow: visible;
    }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        width: min(86vw, 320px);
        height: var(--app-vh, 100dvh);
        max-height: var(--app-vh, 100dvh);
        min-height: 0;
        overflow-y: auto;
        border-right: 1px solid var(--line);
        border-bottom: none;
        transform: translateX(-102%);
        transition: transform 0.22s ease;
        box-shadow: 18px 0 48px rgba(15, 23, 42, 0.16);
        padding-top: max(16px, env(safe-area-inset-top));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }
    .app-shell.sidebar-open .sidebar {
        transform: translateX(0);
    }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 35;
        display: block;
        background: rgba(15, 23, 42, 0.38);
        backdrop-filter: blur(2px);
    }
    .sidebar-backdrop.hidden {
        display: none;
    }
    .mobile-menu-btn,
    .mobile-sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: #fff;
        color: var(--primary);
        cursor: pointer;
        font-weight: 700;
    }
    .mobile-menu-btn {
        flex: 0 0 auto;
        min-height: 36px;
        padding: 7px 10px;
    }
    .mobile-sidebar-close {
        margin-left: auto;
    }
    .chat-main {
        height: var(--app-vh, 100dvh);
        max-height: var(--app-vh, 100dvh);
        min-height: 0;
    }
    .topbar {
        min-height: 56px;
        padding: 9px 10px;
        align-items: flex-start;
    }
    .topbar-actions {
        align-self: flex-start;
    }
    .support-entry-btn {
        min-height: 36px;
        padding: 7px 9px;
        font-size: 13px;
    }
    .topbar strong {
        font-size: 15px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .topbar span {
        display: -webkit-box;
        overflow: hidden;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        font-size: 12px;
        line-height: 1.35;
    }
    .announcement-bar { top: 0; }
    .messages {
        min-height: 0;
        padding: 12px;
    }
    .bubble { max-width: 92%; }
    .support-modal {
        padding: 12px;
    }
    .support-card {
        width: 100%;
        height: min(680px, calc(var(--app-vh, 100dvh) - 24px));
    }
    .support-composer {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    .support-message {
        max-width: 90%;
    }
    .composer {
        position: sticky;
        bottom: 0;
        z-index: 7;
        padding: 8px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        gap: 8px;
    }
    .composer textarea {
        min-height: calc(var(--mobile-control-height, 48px) - 6px);
        max-height: min(112px, calc(var(--app-vh, 100dvh) * 0.22));
        resize: none;
    }
    .field,
    select.field {
        min-height: var(--mobile-control-height, 48px);
        padding-top: 11px;
        padding-bottom: 11px;
        font-size: 16px;
        line-height: 1.4;
    }
    select.field {
        height: var(--mobile-control-height, 48px);
        appearance: auto;
        -webkit-appearance: menulist;
    }
    #styleModeInput {
        display: none;
    }
    .style-mode-options {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        margin-bottom: 10px;
    }
    .style-mode-options button {
        min-height: var(--mobile-control-height, 48px);
        font-size: 16px;
    }
    .policy-modal {
        padding: 16px;
    }
    .policy-modal-card {
        width: calc(100vw - 32px);
        height: 70vh;
    }
    .policy-modal-content {
        padding: 18px;
        font-size: 14px;
    }
    .stat-grid, .settings-grid { grid-template-columns: 1fr; }
    .dashboard-hero {
        align-items: stretch;
        flex-direction: column;
    }
    .dashboard-grid,
    .config-grid,
    .metric-grid,
    .toolbar-row,
    .support-admin-layout {
        grid-template-columns: 1fr;
    }
    .support-conversation-list {
        max-height: 300px;
    }
    .api-panel,
    .dashboard-panel:nth-of-type(4),
    .dashboard-panel:nth-of-type(8) {
        grid-column: auto;
    }
}
