/* ─── Design system: Dark OLED · Fira Sans + Fira Code · admin panel ─── */
:root {
    --app-header-height: 56px;
    --app-header-sticky-offset: var(--app-header-height);
    --page-max-width: 1180px;
    --page-wide-max-width: 1400px;
    --page-narrow-max-width: 980px;
    --space-page-y: 1.25rem;
    --space-page-x: 1.25rem;
    --space-section: 1rem;
    --space-row: 0.65rem;
    --table-cell-y: 0.5rem;
    --table-cell-x: 0.7rem;
    --bg-color: #0c0e12;
    --panel-bg: #161920;
    --panel-hover: #1e2230;
    --text-main: #e2e8f0;
    --text-muted: #7c8ba1;
    --text-subtle: #4a5568;
    --border-color: #252b3a;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.15);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.12);
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.12);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.12);
    --info: #38bdf8;
    --green: var(--success);
    --red: var(--danger);
    --bg-secondary: var(--panel-hover);
    --radius: 8px;
    --radius-sm: 5px;
    --transition: 0.18s ease;
    /* shorthand aliases used in inline styles across templates */
    --panel: var(--panel-bg);
    --border: var(--border-color);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.9rem;
    line-height: 1.5;
    min-width: 0;
    overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-subtle);
}

/* ── Header ── */
.app-header {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    height: var(--app-header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
    text-decoration: none;
    color: inherit;
}

.logo-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.logo h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    min-width: 0;
}

.nav-group {
    display: flex;
    gap: 0.1rem;
    align-items: center;
}

.nav-group--secondary {
    margin-left: 1.25rem;
    padding-left: 1.25rem;
    border-left: 1px solid var(--border-color);
}

.nav-link {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--text-muted);
    text-decoration: none;
    font-family: inherit;
    font-weight: 500;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    font-size: 0.88rem;
    transition: color var(--transition), background var(--transition);
    cursor: pointer;
}

.nav-link:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}

.nav-link:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.nav-link.active {
    color: var(--primary);
    background: var(--primary-glow);
    font-weight: 600;
}

.nav-link-muted {
    color: var(--text-muted);
}

.nav-search {
    display: flex;
    align-items: center;
    margin-right: 0.5rem;
    margin-bottom: 0;
    flex: 0 0 auto;
}

.nav-search-input {
    width: 140px;
    height: 28px;
    padding: 0 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    font-size: 0.8rem;
}

.nav-dropdown {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
}

.nav-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.nav-dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 0.2rem);
    left: 0;
    z-index: 100;
    min-width: 180px;
    padding: 0.4rem 0;
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.nav-dropdown-content::before {
    content: "";
    position: absolute;
    top: -0.5rem;
    left: 0;
    right: 0;
    height: 0.7rem;
}

.nav-dropdown:hover .nav-dropdown-content,
.nav-dropdown:focus-within .nav-dropdown-content {
    display: block;
}

.nav-dropdown-content .nav-link {
    display: block;
    width: calc(100% - 0.8rem);
    margin: 0 0.4rem;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    text-align: left;
}

/* ── Main layout ── */
.app-main {
    max-width: var(--page-max-width);
    margin: 0 auto;
    padding: var(--space-page-y) var(--space-page-x);
    min-width: 0;
}

.app-main.layout-wide {
    max-width: var(--page-wide-max-width);
}

.app-main.layout-narrow {
    max-width: var(--page-narrow-max-width);
}

/* ── Typography ── */
.page-header {
    margin-bottom: 1rem;
}

.page-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
    margin-bottom: 0.3rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-subtle {
    color: var(--text-subtle);
}

.text-sm {
    font-size: 0.82rem;
}

.text-xs {
    font-size: 0.75rem;
}

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

.text-center {
    text-align: center;
}

.mt-1 {
    margin-top: 0.3rem;
}

.mono {
    font-family: 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 0.85em;
}

.font-mono {
    font-family: 'Fira Code', 'JetBrains Mono', monospace;
}

/* ── Table ── */
.table-container {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.86rem;
}

.data-table th {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.48rem var(--table-cell-x);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.01);
}

.data-table td {
    padding: var(--table-cell-y) var(--table-cell-x);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    transition: background var(--transition);
    cursor: default;
}

.data-table tbody tr:hover {
    background: var(--panel-hover);
}

.data-table td.actions {
    white-space: nowrap;
    text-align: right;
    padding-right: var(--table-cell-x);
    vertical-align: middle;
}

.data-table a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.data-table a:hover {
    text-decoration: underline;
}

.inactive-row td {
    opacity: 0.4;
}

/* ── Location ── */
.location-code {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.flag {
    font-size: 1.2rem;
    line-height: 1;
    flex-shrink: 0;
}

.label {
    color: var(--text-muted);
    width: 38px;
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Badges ── */
.count-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--border-color);
    padding: 0.1rem 0.45rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    font-family: 'Fira Code', monospace;
}

.status-badge {
    display: inline-block;
    padding: 0.14rem 0.48rem;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid transparent;
}

.status-badge.active,
.status-badge.success {
    background: var(--success-glow);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.25);
}

.status-badge.inactive {
    background: var(--danger-glow);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.status-badge.info {
    background: rgba(56, 189, 248, 0.1);
    color: var(--info);
    border-color: rgba(56, 189, 248, 0.2);
}

.status-badge.warn {
    background: var(--warning-glow);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.2);
}

.status-badge.neutral {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border-color: var(--border-color);
}

/* ── Forms ── */
.form-container {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.form-section {
    background: var(--panel-bg);
    padding: var(--space-section);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.form-section h3 {
    margin: 0 0 0.75rem 0;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.45rem;
}

.section-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: -0.35rem 0 0.75rem 0;
}

.form-row {
    display: flex;
    gap: var(--space-row);
    flex-wrap: wrap;
    align-items: flex-start;
}

.form-group {
    flex: 1;
    min-width: 180px;
    margin-bottom: 0.55rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
}

.checkbox-label input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
    cursor: pointer;
}

input[type="text"]:not(.form-control),
input[type="date"]:not(.form-control),
input[type="number"]:not(.form-control),
select:not(.form-control) {
    padding: 0.36rem 0.58rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 6px;
    font-family: 'Inter', inherit;
    font-size: 0.9rem;
    transition: border-color var(--transition);
    appearance: none;
    height: 32px;
    box-sizing: border-box;
}

input[type="text"]:not(.form-control):focus,
input[type="date"]:not(.form-control):focus,
input[type="number"]:not(.form-control):focus,
select:not(.form-control):focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control {
    width: 100%;
    max-width: 100%;
    padding: 0.42rem 0.62rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 6px;
    font-family: 'Inter', inherit;
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder {
    color: var(--text-subtle);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    line-height: 1.5;
}

.form-control.mono {
    font-family: 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 0.83rem;
}

.input-with-select {
    display: flex;
    gap: 0.5rem;
}

.help-text {
    display: block;
    margin-top: 0.22rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Short IDs */
.short-ids-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.short-id-chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    font-family: 'Fira Code', monospace;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ── Alerts ── */
.alert {
    padding: 0.65rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    border: 1px solid transparent;
    line-height: 1.5;
}

.alert-warning {
    background: var(--warning-glow);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.25);
}

.alert-info {
    background: rgba(56, 189, 248, 0.08);
    color: var(--info);
    border-color: rgba(56, 189, 248, 0.2);
}

.alert-success {
    background: var(--success-glow);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.25);
}

.warning-section {
    border-color: rgba(245, 158, 11, 0.3) !important;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.38rem 0.78rem;
    border-radius: 6px;
    border: none;
    font-family: 'Inter', inherit;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), opacity var(--transition), box-shadow var(--transition), border-color var(--transition);
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--text-subtle);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-glow);
    box-shadow: 0 0 0 1px var(--primary);
}

.btn-sm {
    padding: 0.18rem 0.48rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 0.55rem 1.25rem;
    font-size: 0.95rem;
}

.border-danger {
    border: 1px solid rgba(239, 68, 68, 0.35) !important;
    color: var(--danger) !important;
    background: transparent !important;
}

.border-danger:hover:not(:disabled) {
    background: var(--danger-glow) !important;
    border-color: var(--danger) !important;
}

.action-bar {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    padding-top: 0.5rem;
}

.save-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.sticky-bottom {
    position: sticky;
    bottom: 0;
    background: var(--panel-bg);
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius) var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
}

/* ── Drag handle ── */
.drag-handle {
    cursor: grab;
    color: var(--text-subtle);
    font-size: 1.1rem;
    user-select: none;
    padding: 0 0.25rem;
}

.drag-handle:active {
    cursor: grabbing;
}

/* ── Toggle buttons (hosts) ── */
.toggle-btn {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem 0.45rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
    line-height: 1;
}

.toggle-on {
    color: var(--success);
}

.toggle-off {
    color: var(--text-subtle);
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.07);
}

/* Inline form in hosts table */
.inline-name-form .form-control--inline {
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
    width: 160px;
}

/* ── Routing sub-nav ── */
.subnav {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0;
}

.subnav-link {
    padding: 0.36rem 0.72rem;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 6px 6px 0 0;
    border-bottom: 2px solid transparent;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
    margin-bottom: -1px;
}

.subnav-link:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
}

.subnav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
    background: transparent;
}

/* ── Support section ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.65rem;
}

.stat-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.75rem 0.85rem;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.stat-value {
    font-size: 1.55rem;
    font-weight: 700;
}

.stat-value.bad {
    color: var(--danger);
}

.stat-value.warn {
    color: var(--warning);
}

.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

.dialog-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.support-dialog-page {
    max-width: 820px;
    margin: 0 auto;
    padding-bottom: 7.5rem;
}

.support-dialog-header {
    position: sticky;
    top: var(--app-header-sticky-offset);
    z-index: 40;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin: -0.9rem -0.25rem 1rem;
    padding: 0.9rem 0.25rem 0.85rem;
    background: var(--bg-color);
    background: color-mix(in srgb, var(--bg-color) 92%, transparent);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
}

.support-dialog-title {
    min-width: 0;
}

.support-dialog-title h2 {
    font-size: 1.35rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.back-link {
    display: inline-block;
    margin-bottom: 0.45rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.86rem;
}

.back-link:hover {
    color: var(--text-main);
}

.dialog-quick-actions,
.dialog-control-buttons,
.dialog-status-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dialog-quick-actions {
    margin-top: 0.55rem;
}

.dialog-quick-actions .btn-outline {
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    text-decoration: none;
}

.dialog-quick-actions .btn-outline:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.support-dialog-controls {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.45rem;
    padding-top: 0.25rem;
}

.dialog-status-row {
    align-items: center;
    justify-content: flex-end;
}

.dialog-sub-count {
    font-size: 0.78rem;
    opacity: 0.75;
    white-space: nowrap;
}

.dialog-sub-count.muted {
    opacity: 0.45;
}

.support-dialog-timeline {
    padding-bottom: 0;
}

.support-send-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    background: var(--bg-color);
    background: color-mix(in srgb, var(--bg-color) 94%, transparent);
    border-top: 1px solid var(--border-color);
    padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.26);
    backdrop-filter: blur(10px);
}

.support-send-form {
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.support-send-form textarea {
    flex: 1;
    min-width: 0;
}

.msg {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-left-width: 3px;
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
}

.msg-user {
    border-left-color: #22c55e;
    background: hsla(142, 62%, 38%, 0.178);
}

.msg-assistant {
    border-left-color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
}

.msg-admin {
    border-left-color: #b33e6f;
    background: lab(42.26% 59.32 -40.72 / 0.209);
}

.msg-tool {
    border-left-color: var(--text-subtle);
    background: rgba(255, 255, 255, 0.02);
    font-size: 0.88rem;
}

.msg-bad {
    border-left-color: var(--danger);
    background: var(--danger-glow);
}

.msg-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-bottom: 0.4rem;
}

.role-label {
    font-weight: 700;
    color: var(--text-main);
}

.model-tag {
    font-family: 'Fira Code', monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: 0.4rem;
}

.msg-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.55;
}

.msg-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.bad-tag {
    background: var(--danger-glow);
    color: var(--danger);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
}

.tool-calls summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.tool-calls pre {
    background: var(--bg-color);
    padding: 0.5rem;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.78rem;
}

@media (max-width: 760px) {
    .support-dialog-page {
        padding-bottom: 9.5rem;
    }

    .support-dialog-header {
        position: static;
        flex-direction: column;
        margin-top: -0.75rem;
    }

    .support-dialog-controls,
    .dialog-control-buttons,
    .dialog-status-row {
        width: 100%;
        align-items: stretch;
        justify-content: flex-start;
    }

    .dialog-control-buttons form,
    .dialog-control-buttons .btn {
        flex: 1 1 auto;
    }

    .dialog-control-buttons form .btn {
        width: 100%;
    }

    .support-send-form {
        display: grid;
        grid-template-columns: auto 1fr auto;
        gap: 0.45rem;
    }

    .support-send-form textarea {
        grid-column: 1 / -1;
        order: -1;
    }
}

.knowledge-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1.5rem;
}

.file-list {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
}

.file-list h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.file-list ul {
    list-style: none;
}

.file-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.88rem;
    transition: background var(--transition);
}

.file-list a:hover {
    background: rgba(255, 255, 255, 0.05);
}

.file-list a.active {
    background: var(--primary);
    color: white;
}

.file-size {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.file-list a.active .file-size {
    color: rgba(255, 255, 255, 0.65);
}

.bad-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.bad-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color var(--transition);
}

.bad-item:hover {
    border-color: var(--text-subtle);
}

.bad-item input {
    margin-top: 0.25rem;
    flex-shrink: 0;
}

.bad-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.bad-content {
    font-size: 0.88rem;
    white-space: pre-wrap;
}

.analysis-output {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Fira Sans', sans-serif;
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 6px;
    max-height: 70vh;
    overflow-y: auto;
}

/* ── Announcements ── */
.announcement-preview {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-main);
    line-height: 1.6;
    max-height: 420px;
    overflow: auto;
    padding: 1rem;
    white-space: pre-wrap;
}

.announcement-preview a {
    color: var(--primary);
}

.announcement-preview ul,
.announcement-preview ol {
    padding-left: 1.25rem;
}

.announcement-preview p+p {
    margin-top: 0.75rem;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
    gap: 1rem;
}

.editor-pane {
    min-width: 0;
}

.editor-pane>label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

#html-editor {
    min-height: 420px;
    line-height: 1.55;
}

.media-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.media-choice {
    display: grid;
    grid-template-columns: auto 42px minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.025);
    color: var(--text-main);
    cursor: pointer;
    min-width: 0;
}

.media-choice:hover {
    background: rgba(255, 255, 255, 0.05);
}

.media-choice input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

.media-choice img,
.media-video {
    width: 42px;
    height: 42px;
    border-radius: 5px;
    object-fit: cover;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
}

.media-video {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
}

.media-choice span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
}

/* ── Logs ── */
.log-entry {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    padding: 0.38rem 0.65rem;
    border-bottom: 1px solid var(--border-color);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.log-error {
    background: rgba(239, 68, 68, 0.06);
}

.log-entry.log-warning {
    background: rgba(234, 179, 8, 0.06);
}

.log-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 0.15rem;
    font-family: 'Fira Code', monospace;
}

.log-badge--error {
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
}

.log-badge--warning {
    background: rgba(234, 179, 8, 0.18);
    color: #facc15;
}

.log-badge--info {
    background: rgba(99, 155, 255, 0.18);
    color: #93c5fd;
}

.log-badge--debug {
    background: rgba(156, 163, 175, 0.12);
    color: var(--text-muted);
}

.log-text {
    margin: 0;
    font-family: 'Fira Code', monospace;
    font-size: 0.78rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-main);
    flex: 1;
}

/* ── Utility ── */
.text-right {
    text-align: right;
}

.nowrap {
    white-space: nowrap;
}

.flex-center {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Page header row (flex title + action button) ── */
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.page-header-row>div {
    margin-bottom: 0;
}

.page-header-row h2 {
    margin-bottom: 0.3rem;
}

/* ── Stat / info cards ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.65rem 0.8rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.info-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.65rem 0.8rem;
}

/* ── User detail summary ── */
.user-summary {
    display: grid;
    grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
    gap: 0.65rem;
    align-items: start;
    margin-bottom: 1rem;
}

.user-balance-panel,
.user-metric {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.65rem 0.8rem;
}

.user-balance-value {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.45rem;
}

.balance-adjust-form {
    display: grid;
    grid-template-columns: 90px minmax(140px, 1fr) auto auto;
    gap: 0.35rem;
    align-items: center;
}

.balance-adjust-form .form-control {
    height: 30px;
    padding: 0.24rem 0.45rem;
    font-size: 0.84rem;
}

.user-metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.65rem;
}

.user-metric {
    min-height: 76px;
}

.user-metric-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.user-referer {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.stat-value-lg {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Fira Code', monospace;
}

/* ── Chart container ── */
.chart-container {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.75rem 0.9rem;
    margin-bottom: 1rem;
}

/* ── Filter form bar ── */
.filter-form {
    display: flex;
    gap: 0.45rem;
    align-items: center;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}

.filter-form label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    font-size: 0.84rem;
    cursor: pointer;
}

/* ── Pagination ── */
.pagination {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 0.85rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ── Back link ── */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.84rem;
    margin-bottom: 0.45rem;
    transition: color var(--transition);
}

.back-link:hover {
    color: var(--text-main);
}

/* ── Logo SVG icon ── */
.logo-svg {
    width: 1.45rem;
    height: 1.45rem;
    color: var(--primary);
    flex-shrink: 0;
}

/* ── Section heading with count ── */
.section-heading {
    margin: 1.5rem 0 0.6rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}

.section-heading .section-count {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 400;
}

/* ── Progress bar ── */
.progress-bar-track {
    height: 4px;
    border-radius: 2px;
    background: var(--border-color);
    margin-top: 3px;
    width: 80px;
}

.progress-bar-fill {
    height: 4px;
    border-radius: 2px;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ── Responsive layout ── */
@media (max-width: 1120px) {
    :root {
        --app-header-sticky-offset: 0px;
    }

    .app-header {
        height: auto;
        min-height: 56px;
        align-items: flex-start;
        flex-direction: column;
        position: static;
        padding: 0.75rem 1rem;
        gap: 0.65rem;
    }

    .main-nav {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 0.2rem;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    .nav-group--secondary {
        margin-left: 0.75rem;
        padding-left: 0.75rem;
    }

    .nav-link {
        flex: 0 0 auto;
    }

    .nav-dropdown-content {
        position: fixed;
        top: 5.4rem;
        left: 1rem;
        right: 1rem;
        width: auto;
    }
}

@media (max-width: 780px) {
    body {
        font-size: 0.9rem;
    }

    .app-header {
        position: static;
        padding: 0.7rem 0.75rem;
    }

    .logo h1 {
        font-size: 1rem;
    }

    .badge {
        font-size: 0.62rem;
        padding: 0.08rem 0.35rem;
    }

    .main-nav {
        align-items: stretch;
        gap: 0.45rem;
    }

    .nav-group {
        gap: 0.25rem;
    }

    .nav-link {
        padding: 0.42rem 0.65rem;
        font-size: 0.84rem;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid transparent;
    }

    .nav-link.active {
        border-color: rgba(99, 102, 241, 0.3);
    }

    .nav-search {
        margin-right: 0.25rem;
    }

    .nav-search-input {
        width: 120px;
    }

    .app-main {
        padding: 1rem 0.75rem 1.5rem;
    }

    .page-header,
    .page-header-row {
        margin-bottom: 1rem;
    }

    .page-header[style],
    .page-header-row {
        display: flex !important;
        flex-direction: column;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 0.75rem;
    }

    .page-header h2,
    .page-header-row h2 {
        font-size: 1.25rem;
        line-height: 1.25;
    }

    .subtitle {
        font-size: 0.84rem;
        line-height: 1.45;
    }

    .btn {
        min-height: 38px;
        white-space: normal;
        text-align: center;
    }

    .btn-sm {
        min-height: 32px;
    }

    .page-header .btn,
    .page-header-row .btn {
        width: 100%;
    }

    .filter-form,
    .filter-bar,
    .action-bar,
    .form-actions {
        align-items: stretch !important;
        gap: 0.5rem;
    }

    .filter-form>*,
    .filter-bar>*,
    .form-actions>*,
    .action-bar>* {
        width: 100%;
        max-width: 100%;
    }

    .filter-form label {
        min-height: 34px;
        padding: 0.25rem 0;
    }

    .form-section {
        padding: 1rem;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-group {
        width: 100%;
        min-width: 0;
    }

    .input-with-select {
        flex-direction: column;
    }

    .form-section div[style*="display: flex"],
    .form-section div[style*="display:flex"],
    .filter-form div[style*="display: flex"],
    .filter-form div[style*="display:flex"] {
        flex-wrap: wrap !important;
    }

    .form-section div[style*="display: flex"]>.form-control,
    .form-section div[style*="display:flex"]>.form-control {
        flex: 1 1 100%;
        min-width: 0;
    }

    .form-section div[style*="display: flex"]>.btn,
    .form-section div[style*="display:flex"]>.btn {
        flex: 1 1 auto;
    }

    .filter-form div[style*="display: flex"]>.btn,
    .filter-form div[style*="display:flex"]>.btn {
        flex: 1 1 0;
    }

    .sticky-bottom {
        position: static;
        margin: 0 -1rem -1rem;
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .sticky-bottom>*,
    .sticky-bottom .btn {
        width: 100%;
    }

    .table-container {
        border-radius: 6px;
        margin-left: -0.25rem;
        margin-right: -0.25rem;
        width: calc(100% + 0.5rem);
    }

    .data-table {
        min-width: 680px;
        font-size: 0.84rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.65rem 0.7rem;
    }

    .data-table td.actions,
    .data-table td[style*="text-align: right"] {
        text-align: left !important;
    }

    .data-table td.actions .btn,
    .data-table td[style*="text-align: right"] .btn {
        margin-top: 0.25rem;
    }

    .stats-grid,
    .stat-grid,
    .info-grid,
    .user-summary,
    .user-metric-grid {
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }

    .user-balance-panel {
        max-width: none;
    }

    .balance-adjust-form {
        grid-template-columns: minmax(90px, 0.8fr) minmax(140px, 1.2fr);
    }

    .balance-adjust-form .btn {
        width: 100%;
    }

    .stat-card,
    .info-card {
        padding: 0.85rem;
    }

    .stat-value {
        font-size: 1.55rem;
    }

    .knowledge-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .editor-layout {
        grid-template-columns: 1fr;
    }

    #html-editor {
        min-height: 320px;
    }

    .media-picker {
        grid-template-columns: 1fr;
        max-height: 280px;
    }

    .file-list {
        padding: 0.75rem;
    }

    .msg-meta,
    .bad-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.15rem;
    }

    .log-entry {
        padding: 0.65rem 0.75rem;
        flex-direction: column;
        gap: 0.35rem;
    }

    .subnav {
        overflow-x: auto;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
    }

    .subnav-link {
        flex: 0 0 auto;
    }

    .chart-container {
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .app-main {
        padding-left: 0.6rem;
        padding-right: 0.6rem;
    }

    .logo {
        gap: 0.45rem;
    }

    .logo h1 {
        font-size: 0.95rem;
    }

    .logo-svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    .nav-link {
        font-size: 0.8rem;
        padding: 0.38rem 0.55rem;
    }

    .form-section {
        padding: 0.85rem;
    }

    .data-table {
        min-width: 560px;
    }

    .pagination {
        justify-content: stretch;
    }

    .pagination .btn {
        flex: 1 1 auto;
    }

    .pagination span {
        flex: 1 0 100%;
        text-align: center;
        order: -1;
    }
}
/* Utility Classes */
.text-success { color: #2ecc71 !important; }
.text-danger { color: #e74c3c !important; }
.text-warning { color: #f1c40f !important; }
.text-info { color: #3498db !important; }
