:root {
    color-scheme: light;
    --ink: #1f2328;
    --muted: #656d76;
    --subtle: #8c959f;
    --line: #d8dee4;
    --line-strong: #afb8c1;
    --surface: #ffffff;
    --surface-soft: #f6f8fa;
    --canvas: #f6f8fa;
    --accent: #0969da;
    --accent-strong: #0550ae;
    --accent-soft: #ddf4ff;
    --danger: #cf222e;
    --danger-soft: #ffebe9;
    --warning: #9a6700;
    --warning-soft: #fff8c5;
    --success: #1a7f37;
    --success-soft: #dafbe1;
    --radius-lg: 10px;
    --radius-md: 8px;
    --radius-sm: 6px;
    --shadow-overlay: 0 8px 24px rgba(140, 149, 159, .24);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 14px; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Authentication */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 40px 20px;
    background: var(--surface-soft);
}
.auth-shell { width: min(440px, 100%); }
.auth-card {
    padding: 32px;
    display: grid;
    gap: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
}
.auth-brand, .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
}
.brand-mark {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--accent);
    border-radius: 8px;
    font-size: 17px;
    font-weight: 700;
}
.auth-brand strong, .auth-brand small {
    display: block;
}
.auth-brand strong { color: var(--ink); font-size: 14px; }
.auth-brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.auth-heading { padding-top: 4px; }
.auth-heading h1 { margin: 0; font-size: 24px; line-height: 1.3; letter-spacing: -.02em; }
.auth-heading p { margin: 7px 0 0; }
.auth-switch { margin: 0; padding-top: 2px; color: var(--muted); text-align: center; font-size: 13px; }

/* Forms and controls */
.muted { color: var(--muted); }
.form-stack { display: grid; gap: 16px; }
.form-stack label:not(.check-row), .field {
    display: grid;
    gap: 7px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
}
input, textarea, select {
    width: 100%;
    min-height: 38px;
    padding: 8px 11px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--subtle); }
input:hover, textarea:hover, select:hover { border-color: #8c959f; }
input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(9, 105, 218, .14);
}
input[readonly] { color: #57606a; background: var(--surface-soft); }
textarea { min-height: 90px; resize: vertical; }
.check-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.check-row input { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--accent); }
.field small { margin-top: -1px; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.5; }

.button {
    min-height: 34px;
    padding: 7px 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    appearance: none;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background .12s, border-color .12s;
}
.button:hover { color: var(--ink); background: #f3f4f6; border-color: #8c959f; }
.button-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button-primary:hover { color: #fff; background: var(--accent-strong); border-color: var(--accent-strong); }
.button-secondary { color: var(--ink); background: var(--surface); }
.button-ghost { color: var(--ink); background: transparent; border-color: var(--line); }
.button-danger { color: var(--danger); background: var(--surface); border-color: #ff8182; }
.button-danger:hover { color: #a40e26; background: var(--danger-soft); border-color: #ff8182; }
.button-block { width: 100%; min-height: 40px; }
.button-sm { min-height: 30px; padding: 6px 10px; font-size: 12px; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.alert {
    padding: 11px 13px;
    border: 1px solid;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.5;
}
.alert-error { color: #82071e; background: var(--danger-soft); border-color: #ff8182; }
.alert-success { color: #116329; background: var(--success-soft); border-color: #4ac26b; }
.alert-info { color: #0a3069; background: var(--accent-soft); border-color: #54aeff; }

/* Application shell */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: 100vh;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    color: var(--ink);
    background: var(--surface);
    border-right: 1px solid var(--line);
}
.sidebar-brand {
    min-width: 0;
    padding: 2px 7px 18px;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
}
.sidebar-brand:hover { color: var(--ink); }
.sidebar-brand strong, .sidebar-brand small {
    max-width: 154px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-brand strong {
    max-height: 2.7em;
    font-size: 13px;
    line-height: 1.35;
    white-space: normal;
}
.sidebar-brand small { margin-top: 2px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.sidebar-nav { display: grid; gap: 3px; padding-top: 14px; }
.sidebar-nav a {
    min-height: 38px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #57606a;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
}
.sidebar-nav svg { width: 18px; height: 18px; flex: 0 0 auto; fill: currentColor; }
.sidebar-nav a:hover { color: var(--ink); background: var(--surface-soft); }
.sidebar-nav a.active { color: var(--ink); background: #eaeef2; font-weight: 600; }
.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.user-chip { min-width: 0; padding: 6px 7px; display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: #0a3069;
    background: var(--accent-soft);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
}
.user-chip div { min-width: 0; }
.user-chip strong, .user-chip small {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.user-chip strong { font-size: 12px; }
.user-chip small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.logout-button {
    width: 100%;
    margin-top: 3px;
    padding: 7px;
    color: var(--muted);
    background: transparent;
    border: 0;
    text-align: left;
    font-size: 12px;
    cursor: pointer;
}
.logout-button:hover { color: var(--danger); }

.main { min-width: 0; padding: 28px clamp(22px, 3vw, 40px) 48px; }
.main > * { width: min(1440px, 100%); margin-left: auto; margin-right: auto; }
.page-header {
    min-height: 58px;
    margin-bottom: 22px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}
.page-header h1 { margin: 0; font-size: 24px; line-height: 1.3; letter-spacing: -.02em; }
.page-header p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* General content */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}
.panel-header {
    min-height: 52px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
}
.panel-header h2, .panel-header h3 { margin: 0; font-size: 14px; }
.panel-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-grid {
    margin-bottom: 18px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.stat { min-height: 112px; padding: 17px; }
.stat small { color: var(--muted); font-size: 12px; }
.stat strong { display: block; margin-top: 9px; font-size: 26px; line-height: 1; letter-spacing: -.02em; }
.stat .muted { display: block; margin-top: 8px; font-size: 11px; }
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 7px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success { color: #116329; background: var(--success-soft); border-color: #aceebb; }
.badge-neutral { color: #57606a; background: var(--surface-soft); border-color: var(--line); }
.badge-warning { color: #7d4e00; background: var(--warning-soft); border-color: #d4a72c; }
.badge-danger { color: #82071e; background: var(--danger-soft); border-color: #ff8182; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.empty-state { padding: 52px 24px; color: var(--muted); text-align: center; }
.empty-state h3 { margin: 0 0 7px; color: var(--ink); font-size: 16px; }
.empty-state p { margin: 0 0 16px; }
.bot-status-list, .recent-list { display: grid; }
.bot-status-row {
    padding: 13px 16px;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
}
.bot-status-row:last-child, .recent-list a:last-child { border-bottom: 0; }
.bot-status-row:hover, .recent-list a:hover { color: var(--ink); background: var(--surface-soft); }
.bot-status-row strong, .bot-status-row small, .recent-list strong, .recent-list small { display: block; }
.bot-status-row strong, .recent-list strong { font-size: 13px; }
.bot-status-row small, .recent-list small {
    margin-top: 3px;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.recent-list a {
    min-width: 0;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
}
.recent-list a > span { min-width: 0; }
.recent-list time { flex: none; color: var(--muted); font-size: 11px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
    font-size: 13px;
}
th { color: var(--muted); background: var(--surface-soft); font-size: 11px; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.truncate { max-width: 330px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.code-field { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12px; }

/* Conversations */
.bot-switcher { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.bot-pill {
    padding: 7px 10px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
}
.bot-pill.active { color: #0a3069; background: var(--accent-soft); border-color: #54aeff; }
.inbox-stats { margin: -5px auto 14px; display: flex; flex-wrap: wrap; gap: 18px; color: var(--muted); font-size: 12px; }
.inbox-stats strong { color: var(--ink); }
.inbox {
    height: calc(100vh - 168px);
    min-height: 580px;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}
.conversation-pane { min-width: 0; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); }
.conversation-search { padding: 12px 12px 8px; }
.conversation-search input { min-height: 34px; padding: 7px 10px; background: var(--surface-soft); border-color: var(--line); }
.conversation-tabs { display: flex; gap: 18px; padding: 0 13px 8px; border-bottom: 1px solid var(--line); }
.conversation-tabs a { padding: 6px 0; color: var(--muted); font-size: 12px; font-weight: 500; }
.conversation-tabs a.active { color: var(--ink); border-bottom: 2px solid var(--accent); font-weight: 600; }
.conversation-list { min-height: 0; overflow-y: auto; }
.conversation-item {
    position: relative;
    padding: 12px 13px;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 10px;
    color: var(--ink);
    border-bottom: 1px solid var(--line);
}
.conversation-item:hover { color: var(--ink); background: var(--surface-soft); }
.conversation-item.active { background: #f0f6fc; box-shadow: inset 3px 0 var(--accent); }
.conversation-avatar {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    color: #0a3069;
    background: var(--accent-soft);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
}
.conversation-copy { min-width: 0; display: grid; gap: 4px; }
.conversation-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conversation-title strong { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.conversation-title time { flex: none; color: var(--subtle); font-size: 10px; }
.conversation-preview { overflow: hidden; color: var(--muted); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.unread {
    position: absolute;
    right: 13px;
    bottom: 8px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--danger);
    border-radius: 999px;
    font-size: 9px;
    font-weight: 700;
}
.empty-compact { padding: 44px 20px; color: var(--muted); text-align: center; font-size: 12px; }
.chat-pane { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--surface-soft); }
.chat-header {
    min-height: 66px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.chat-header h2 { margin: 0; font-size: 15px; }
.chat-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.chat-title-row { display: flex; align-items: center; gap: 8px; }
.chat-empty { grid-row: 1 / -1; display: grid; place-items: center; align-content: center; color: var(--muted); text-align: center; }
.chat-empty span { color: var(--subtle); font-size: 30px; }
.chat-empty h3 { margin: 9px 0 4px; color: var(--ink); }
.chat-empty p { margin: 0; }
.message-list { min-height: 0; padding: 20px clamp(16px, 4vw, 40px); overflow-y: auto; scroll-behavior: smooth; }
.message-row { display: flex; margin: 9px 0; }
.message-row.outgoing { justify-content: flex-end; }
.message-bubble {
    max-width: min(620px, 78%);
    padding: 9px 12px 7px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
}
.message-row.outgoing .message-bubble { color: #0a3069; background: var(--accent-soft); border-color: #b6e3ff; }
.message-content { overflow-wrap: anywhere; font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.message-meta { margin-top: 5px; display: flex; justify-content: flex-end; gap: 7px; color: var(--subtle); font-size: 9px; }
.message-status.failed, .message-error { color: var(--danger); }
.message-error { max-width: 470px; margin-top: 6px; font-size: 10px; line-height: 1.4; }
.attachment { display: block; margin-top: 7px; padding: 7px 9px; color: var(--accent); background: rgba(255, 255, 255, .65); border-radius: 5px; font-size: 11px; }
.composer { padding: 11px 14px 13px; background: var(--surface); border-top: 1px solid var(--line); }
.composer textarea { min-height: 56px; max-height: 170px; padding: 5px 3px; border: 0; box-shadow: none; }
.composer textarea:focus { box-shadow: none; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 10px; }

/* Plugins */
.plugin-alert { margin-bottom: 16px; }
.secret-reveal {
    margin-bottom: 16px;
    padding: 15px 17px;
    display: grid;
    grid-template-columns: 1fr minmax(260px, .8fr);
    align-items: center;
    gap: 18px;
    color: #0a3069;
    background: var(--accent-soft);
    border: 1px solid #54aeff;
    border-radius: var(--radius-md);
}
.secret-reveal p { margin: 4px 0 0; font-size: 11px; }
.copy-field { display: flex; gap: 7px; }
.copy-field input { min-width: 0; }
.plugin-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr); gap: 16px; }
.plugin-card { padding: 20px; }
.plugin-heading { margin-bottom: 20px; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: start; gap: 12px; }
.plugin-heading.compact { grid-template-columns: 36px minmax(0, 1fr); margin-bottom: 13px; }
.plugin-heading h2 { margin: 1px 0 5px; font-size: 17px; }
.plugin-heading p:last-child { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.plugin-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: #0a3069;
    background: var(--accent-soft);
    border: 1px solid #b6e3ff;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
}
.plugin-form { display: grid; gap: 17px; }
.toggle-line, .api-credential {
    padding: 13px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.toggle-line strong, .toggle-line small, .api-credential strong, .api-credential small { display: block; }
.toggle-line small, .api-credential small { margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 400; }
.toggle-line input { width: 38px; height: 20px; min-height: 0; accent-color: var(--accent); }
.plugin-options { display: flex; gap: 20px; flex-wrap: wrap; }
.form-actions { display: flex; justify-content: flex-end; }
.plugin-side { align-content: start; }
.api-doc h3 { margin: 0 0 9px; font-size: 15px; }
.api-doc > p { font-size: 11px; line-height: 1.6; }
.api-doc pre { margin: 12px 0; padding: 12px; overflow: auto; color: #e6edf3; background: #24292f; border-radius: var(--radius-sm); font-size: 10px; line-height: 1.55; }
.delivery-panel { margin-top: 16px; }
.delivery-panel .panel-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }

/* Profile, workspaces and bots */
.profile-info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.profile-info span, .profile-info strong { display: block; }
.profile-info span { margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.profile-info strong { overflow-wrap: anywhere; font-size: 13px; }
.profile-workspaces { grid-column: 1 / -1; }
.workspace-row { padding: 12px 16px; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 11px; border-bottom: 1px solid var(--line); }
.workspace-row:last-child { border-bottom: 0; }
.workspace-row strong, .workspace-row small { display: block; }
.workspace-row small { margin-top: 3px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: 10px; }
.workspace-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.workspace-pane { position: sticky; top: 24px; overflow: hidden; }
.workspace-list { display: grid; }
.workspace-link { padding: 12px 14px; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px; color: var(--ink); border-bottom: 1px solid var(--line); }
.workspace-link:hover { color: var(--ink); background: var(--surface-soft); }
.workspace-link.active { color: var(--ink); background: #f0f6fc; box-shadow: inset 3px 0 var(--accent); }
.workspace-link strong, .workspace-link small { display: block; }
.workspace-link strong { font-size: 12px; }
.workspace-link small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.dot.online { color: var(--success); background: var(--success); }
.dot.offline { color: var(--subtle); background: var(--subtle); }
.workspace-settings { padding: 12px 14px 14px; }
.workspace-settings summary { color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer; }
.compact-form { margin: 14px 0; gap: 12px; }
.bot-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr)); gap: 16px; }
.bot-card { padding: 18px; overflow: visible; }
.bot-card-header { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 11px; }
.bot-logo {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    color: #0a3069;
    background: var(--accent-soft);
    border: 1px solid #b6e3ff;
    border-radius: var(--radius-sm);
    font-weight: 700;
}
.bot-card-header h2 { margin: 0; font-size: 15px; }
.bot-card-header p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.bot-facts { margin: 18px 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bot-facts div { min-width: 0; padding: 9px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.bot-facts dt { color: var(--muted); font-size: 10px; }
.bot-facts dd { margin: 5px 0 0; overflow: hidden; font-size: 11px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.webhook-field { margin-bottom: 16px; }
.bot-actions { position: relative; display: flex; gap: 7px; flex-wrap: wrap; }
.bot-settings-details { position: relative; }
.bot-settings-details > summary { list-style: none; }
.bot-settings-details > summary::-webkit-details-marker { display: none; }
.bot-settings-popover {
    position: absolute;
    right: 0;
    bottom: 40px;
    z-index: 8;
    width: min(490px, calc(100vw - 80px));
    padding: 17px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-overlay);
}
.danger-actions { padding-top: 12px; display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); }
.qr-content { display: grid; justify-items: center; text-align: center; }
.qr-content h3 { margin: 15px 0 5px; }
.qr-stage { width: 248px; height: 248px; padding: 12px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.qr-stage img, .qr-stage canvas { max-width: 100%; height: auto; }
.qr-spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Modals */
.modal-backdrop { position: fixed; inset: 0; z-index: 40; padding: 24px; display: none; place-items: center; background: rgba(31, 35, 40, .48); }
.modal-backdrop.open { display: grid; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 48px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-overlay); }
.modal-header, .modal-footer { padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-header { border-bottom: 1px solid var(--line); }
.modal-footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.modal-body { padding: 18px; }
.modal h2 { margin: 0; font-size: 16px; }

/* User administration */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 14px; align-items: end; }
.form-grid label { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 600; }
.form-grid input { width: 100%; }
.form-grid .form-actions { padding-bottom: 1px; }
.table-subtitle { display: block; margin-top: 4px; color: var(--muted); }
.inline-actions, .inline-reset { display: flex; align-items: center; gap: 8px; }
.inline-actions { flex-wrap: wrap; }
.inline-reset input { width: 138px; min-height: 32px; padding: 6px 9px; }

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 72px minmax(0, 1fr); }
    .sidebar { padding-inline: 10px; }
    .sidebar-brand { justify-content: center; padding-inline: 0; }
    .sidebar-brand div, .sidebar-nav span, .user-chip div { display: none; }
    .sidebar-nav a { justify-content: center; }
    .user-chip { justify-content: center; }
    .logout-button { overflow: hidden; font-size: 0; text-align: center; }
    .logout-button::after { content: "退出"; font-size: 11px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .inbox { grid-template-columns: 280px minmax(0, 1fr); }
    .plugin-grid { grid-template-columns: 1fr; }
    .workspace-layout { grid-template-columns: 1fr; }
    .workspace-pane { position: static; }
    .bot-card-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
    .auth-page { padding: 0; background: var(--surface); }
    .auth-shell { width: 100%; min-height: 100vh; }
    .auth-card { min-height: 100vh; padding: 28px 22px; align-content: center; border: 0; border-radius: 0; }
    .app-shell { display: block; }
    .sidebar {
        position: sticky;
        width: 100%;
        height: auto;
        padding: 9px 12px;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .sidebar-brand { padding: 0; border: 0; }
    .sidebar-brand .brand-mark { width: 32px; height: 32px; }
    .sidebar-nav { margin-left: auto; padding: 0; display: flex; overflow-x: auto; }
    .sidebar-nav a { min-width: 34px; min-height: 34px; padding: 7px 8px; }
    .sidebar-nav svg { width: 17px; height: 17px; }
    .sidebar-footer { display: none; }
    .main { padding: 22px 14px 36px; }
    .page-header { min-height: 0; align-items: flex-start; flex-direction: column; }
    .page-header h1 { font-size: 22px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
    .stat { min-height: 94px; }
    .inbox { height: auto; min-height: 0; grid-template-columns: 1fr; }
    .conversation-pane { max-height: 380px; border-right: 0; border-bottom: 1px solid var(--line); }
    .chat-pane { min-height: 600px; }
    .chat-header { align-items: flex-start; flex-direction: column; }
    .chat-title-row { align-items: flex-start; }
    .chat-header .header-actions { width: 100%; }
    .bot-switcher { justify-content: flex-start; }
    .secret-reveal { grid-template-columns: 1fr; }
    .profile-info { grid-template-columns: 1fr; }
    .profile-workspaces { grid-column: auto; }
    .form-grid { grid-template-columns: 1fr; }
    .inline-reset { width: 100%; }
    .inline-reset input { flex: 1; }
}
