* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-soft: #e9fbf8;
    --danger: #ef4444;
    --success: #16a34a;
    --warning: #d97706;
    --bg: #eef8f7;
    --card-bg: #ffffff;
    --border: #e5edf4;
    --border-strong: #d7e2ec;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.06);
    --radius: 8px;
}

.automation-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.automation-toolbar .toolbar-actions,
.automation-toolbar .toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.automation-table {
    width: 100%;
    min-width: 900px;
    table-layout: fixed;
}

.automation-table th,
.automation-table td {
    vertical-align: middle;
}

.automation-table td:not(.automation-copy) {
    white-space: normal;
    overflow-wrap: anywhere;
}

.automation-table .actions {
    min-width: 220px;
}

.automation-copy {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.automation-state-loading,
.automation-state-empty,
.automation-state-error {
    height: 104px;
    text-align: center;
    color: var(--text-muted);
}

.automation-state-error {
    color: var(--danger);
}

.automation-state-retry {
    margin-left: 10px;
}

.automation-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--primary-soft);
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

.automation-badge-active,
.automation-badge-approved,
.automation-badge-succeeded,
.automation-badge-available {
    color: var(--success);
}

.automation-badge-failed,
.automation-badge-rejected,
.automation-badge-cancelled {
    color: var(--danger);
}

.automation-badge-running,
.automation-badge-leased,
.automation-badge-ready,
.automation-badge-pending_review {
    color: var(--primary);
}

.automation-toggle {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 36px;
    margin: 4px 16px 10px 0;
    cursor: pointer;
}

.automation-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.automation-toggle > input + span {
    position: relative;
    width: 38px;
    height: 20px;
    flex: 0 0 38px;
    border-radius: 10px;
    background: var(--border-strong);
    transition: background .16s ease;
}

.automation-toggle > input + span::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: transform .16s ease;
}

.automation-toggle input:checked + span {
    background: var(--primary);
}

.automation-toggle input:checked + span::after {
    transform: translateX(18px);
}

.automation-toggle input:focus-visible + span {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.automation-modal {
    width: min(680px, 100%);
    max-height: calc(100vh - 44px);
    border-radius: 8px;
}

.automation-modal h4 {
    margin: 0 0 12px;
}

.automation-modal hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 18px 0;
}

.automation-modal textarea {
    min-height: 96px;
    resize: vertical;
}

.automation-modal-warning {
    margin: 0 0 14px;
    padding: 9px 11px;
    border-left: 3px solid var(--warning);
    border-radius: 4px;
    background: #fff8e6;
    color: #92400e;
    font-size: 13px;
    line-height: 1.5;
}

.automation-readonly {
    min-height: 72px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    white-space: pre-wrap;
}

.automation-detail {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 10px 16px;
}

.automation-detail dt {
    color: var(--text-muted);
}

.automation-detail dd {
    min-width: 0;
    overflow-wrap: anywhere;
}

.automation-table td.automation-full-copy {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    vertical-align: top;
}

.automation-detail-copy {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.automation-unknown-resolution {
    display: grid;
    gap: 12px;
}

.automation-unknown-resolution .form-group {
    margin-bottom: 0;
}

.automation-unknown-resolution .actions {
    flex-wrap: wrap;
}

@media (max-width: 720px) {
    .publish-plan-editor-grid { grid-template-columns: 1fr; }
    .publish-plan-editor-grid .field-full { grid-column: 1; }
    .automation-toolbar,
    .automation-toolbar .toolbar-actions,
    .automation-toolbar .toolbar-right {
        align-items: stretch;
        flex-direction: column;
        width: 100%;
    }

    .automation-toolbar select,
    .automation-toolbar input,
    .automation-toolbar .btn {
        width: 100%;
    }

    .automation-detail {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .automation-detail dd {
        margin-bottom: 10px;
    }
}

.keyword-task-toolbar { align-items: end; }
.keyword-task-table { min-width: 1180px; table-layout: fixed; }
.keyword-task-table th:nth-child(1) { width: 150px; }
.keyword-task-table th:nth-child(2) { width: 180px; }
.keyword-task-table th:nth-child(3) { width: 125px; }
.keyword-task-table th:nth-child(4) { width: 145px; }
.keyword-task-table th:nth-child(5) { width: 90px; }
.keyword-task-table th:nth-child(6) { width: 145px; }
.keyword-task-table th:nth-child(7) { width: 125px; }
.keyword-task-table th:nth-child(8) { width: 70px; }
.keyword-task-table th:nth-child(9) { width: 145px; }
.keyword-task-table th:nth-child(10) { width: 180px; }
.keyword-task-table td { vertical-align: middle; overflow-wrap: anywhere; }
.keyword-task-table td small { display: block; margin-top: 3px; color: var(--text-muted); }
.keyword-task-keywords, .keyword-task-post-body { white-space: normal; overflow-wrap: anywhere; }
.keyword-task-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.keyword-task-source-link { overflow-wrap: anywhere; }
.keyword-task-editor-modal { width: min(760px, 100%); }
.keyword-task-editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.keyword-task-form-section { padding: 2px 0 20px; border-bottom: 1px solid var(--border); }
.keyword-task-form-section + .keyword-task-form-section { padding-top: 20px; }
.keyword-task-form-section:last-child { padding-bottom: 0; border-bottom: 0; }
.keyword-task-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.keyword-task-section-heading h4 { margin: 0 0 4px; color: var(--text); font-size: 15px; }
.keyword-task-section-heading p { margin: 0; color: var(--text-muted); font-size: 12px; line-height: 1.45; }
.keyword-task-section-step { flex: 0 0 auto; color: var(--text-muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.keyword-task-form-section .form-group { margin-bottom: 0; }
.keyword-task-form-section .field-full { min-width: 0; }
.keyword-task-keywords-field textarea { min-height: 124px; }
.keyword-task-field-status > .automation-toggle { min-height: 40px; }
.keyword-task-input-with-suffix { display: flex; align-items: center; min-width: 0; }
.keyword-task-input-with-suffix input { min-width: 0; border-radius: 8px 0 0 8px; }
.keyword-task-input-with-suffix span { display: inline-flex; align-items: center; align-self: stretch; padding: 0 11px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 8px 8px 0; background: var(--bg); color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.keyword-task-multipart-toggle { align-items: flex-start; width: 100%; min-height: 48px; margin-right: 0; padding: 11px 13px; border: 1px solid var(--border); border-radius: 8px; background: #f8fbff; }
.keyword-task-toggle-copy { display: flex; flex: 1 1 auto; min-width: 0; flex-direction: column; gap: 2px; }
.keyword-task-toggle-copy strong { color: var(--text); font-size: 13px; }
.keyword-task-toggle-copy small { color: var(--text-secondary); font-size: 12px; font-weight: 400; line-height: 1.4; }
.keyword-task-feedback-section { padding-top: 18px; }
.keyword-task-feedback-section .modal-error { min-height: 20px; margin: 0; }
.keyword-task-detail-modal { width: min(1080px, 100%); }
.keyword-task-detail-section { margin-top: 22px; min-width: 0; }
.modal-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.modal-section-heading h4 { margin: 0; }
.keyword-task-state-loading, .keyword-task-state-empty, .keyword-task-state-error { height: 104px; text-align: center; color: var(--text-muted); }
.keyword-task-state-error { color: var(--danger); }
.keyword-task-state-retry { margin-left: 10px; }
.keyword-task-detail-state { min-height: 0; }
.keyword-task-detail-tabs { display: inline-flex; max-width: 100%; margin-top: 22px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.keyword-task-detail-tab { min-height: 36px; padding: 7px 16px; border: 0; border-right: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); cursor: pointer; }
.keyword-task-detail-tab:last-child { border-right: 0; }
.keyword-task-detail-tab.active { background: var(--primary); color: #fff; }
.keyword-task-detail-tab:focus-visible { position: relative; outline: 2px solid var(--primary); outline-offset: -3px; }
.keyword-batch-table, .keyword-run-table, .keyword-post-table { min-width: 960px; table-layout: fixed; }
.keyword-batch-table td small, .keyword-run-table td small, .keyword-post-table td small { display: block; margin-top: 4px; color: var(--text-muted); white-space: normal; overflow-wrap: anywhere; }

@media (max-width: 720px) {
    .keyword-task-toolbar, .keyword-task-toolbar .toolbar-actions, .keyword-task-toolbar .toolbar-right { align-items: stretch; flex-direction: column; width: 100%; }
    .keyword-task-toolbar select, .keyword-task-toolbar input, .keyword-task-toolbar .btn { width: 100%; }
    .keyword-task-editor-grid { grid-template-columns: 1fr; }
    .keyword-task-editor-modal .modal-body { padding: 18px 16px; }
    .keyword-task-editor-modal .modal-actions { position: sticky; bottom: 0; z-index: 1; }
    .keyword-task-table { min-width: 900px; }
    .keyword-task-table th:nth-child(2), .keyword-task-table td:nth-child(2), .keyword-task-table th:nth-child(3), .keyword-task-table td:nth-child(3), .keyword-task-table th:nth-child(6), .keyword-task-table td:nth-child(6) { display: none; }
    .keyword-task-table th:nth-child(10) { width: 160px; }
    .keyword-task-actions { gap: 3px; }
    .keyword-task-detail-modal .modal-body { padding: 14px; }
    .keyword-task-detail-tabs { display: flex; width: 100%; }
    .keyword-task-detail-tab { flex: 1 1 0; min-width: 0; padding-right: 8px; padding-left: 8px; }
}

.toolbar.material-toolbar {
    display: grid;
    grid-template-columns: minmax(160px, 1.4fr) repeat(4, minmax(100px, .8fr)) repeat(2, minmax(160px, 1fr)) auto;
    align-items: end;
    gap: 10px;
}

.material-toolbar > input,
.material-toolbar > select,
.material-toolbar .material-time-filter input {
    width: 100%;
    min-width: 0;
}

.material-time-filter {
    display: grid;
    gap: 5px;
    min-width: 0;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 800;
}

.material-toolbar-actions,
.material-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.material-table {
    width: 100%;
    min-width: 1040px;
    table-layout: fixed;
}

.material-col-body { width: 30%; }
.material-col-author { width: 13%; }
.material-col-count { width: 8%; }
.material-col-time { width: 13%; }
.material-col-usage { width: 9%; }
.material-col-status { width: 8%; }
.material-col-actions { width: 220px; }

.material-table th,
.material-table td {
    vertical-align: middle;
}

.material-body-cell,
.material-author {
    min-width: 0;
    white-space: normal;
}

.material-body-preview {
    display: -webkit-box;
    width: 100%;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow-wrap: anywhere;
    white-space: normal;
    text-align: left;
    line-height: 1.5;
}

.material-state-row {
    min-height: 104px;
    height: 104px;
    text-align: center;
    color: var(--text-muted);
}

.material-state-error { color: var(--danger); }
.material-state-retry { margin-left: 10px; }

.modal.material-detail-modal {
    width: min(1040px, 100%);
    max-height: calc(100vh - 44px);
}

.material-detail {
    display: grid;
    gap: 18px;
    min-height: 180px;
}

.material-detail-main,
.material-detail-grid,
.material-collections {
    min-width: 0;
}

.material-detail-heading,
.material-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.material-section-heading { margin-top: 24px; }
.material-section-heading span { color: var(--text-muted); font-size: 12px; }

.material-full-body {
    max-height: 260px;
    overflow: auto;
    padding: 14px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    line-height: 1.65;
}

.material-detail-grid {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) 110px minmax(0, 1fr);
    gap: 10px 16px;
}

.material-detail-grid dt { color: var(--text-muted); }
.material-detail-grid dd { min-width: 0; overflow-wrap: anywhere; }
.material-hash { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }

.material-collection-wrap { max-height: 300px; }
.material-collection-table { min-width: 820px; table-layout: fixed; }
.material-collection-table th:first-child { width: 180px; }
.material-collection-table th:nth-child(2) { width: 250px; }
.material-collection-table td { white-space: normal; overflow-wrap: anywhere; }
.material-collection-table td strong,
.material-collection-table td small { display: block; }
.material-collection-table td small { margin-top: 3px; color: var(--text-muted); }
.material-source-link { display: block; max-width: 100%; overflow-wrap: anywhere; }
.material-source small { display: block; margin-top: 4px; color: var(--text-muted); }
.badge-deleted { background: #fee2e2; color: #b91c1c; }
.badge-unused { background: #e5e7eb; color: #374151; }
.badge-processing { background: #fef3c7; color: #92400e; }
.badge-used { background: #dcfce7; color: #166534; }

@media (max-width: 1200px) {
    .toolbar.material-toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
    .material-toolbar-actions { align-self: end; }
}

@media (max-width: 720px) {
    .toolbar.material-toolbar { grid-template-columns: 1fr 1fr; align-items: stretch; }
    .material-toolbar > input:first-child,
    .material-time-filter,
    .material-toolbar-actions { grid-column: 1 / -1; }
    .material-toolbar-actions .btn:first-child { flex: 1; }
    .material-table { min-width: 720px; }
    .material-table .material-secondary,
    .material-table th:nth-child(2),
    .material-table th:nth-child(3),
    .material-table th:nth-child(4),
    .material-table th:nth-child(5),
    .material-table td:nth-child(5) { display: none; }
    .material-table th,
    .material-table td { padding-right: 4px; padding-left: 4px; }
    .material-table th:nth-child(6),
    .material-table th:nth-child(7) { font-size: 0; }
    .material-table th:nth-child(6)::after { content: "使用"; font-size: 12px; }
    .material-table th:nth-child(7)::after { content: "状态"; font-size: 12px; }
    .material-col-body { width: 42%; }
    .material-col-time { width: 20%; }
    .material-col-usage { width: 16%; }
    .material-col-status { width: 14%; }
    .material-col-actions { width: 180px; }
    .material-detail-grid { grid-template-columns: 100px minmax(0, 1fr); }
    .material-actions { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .toolbar.material-toolbar { grid-template-columns: 1fr; }
    .material-toolbar > input:first-child,
    .material-toolbar > select,
    .material-time-filter,
    .material-toolbar-actions { grid-column: 1; }
    .material-detail-modal .modal-actions { flex-wrap: wrap; }
    .material-detail-modal .modal-actions .btn { flex: 1 1 calc(50% - 6px); min-width: 0; }
    .material-detail-heading,
    .material-section-heading { align-items: flex-start; flex-direction: column; }
}

html, body { min-height: 100%; }
html { overflow-x: hidden; }

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #f8fcfc 0%, var(--bg) 52%, #f7fbfb 100%);
    color: var(--text);
    font-family: "Aptos", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button { user-select: none; }

/* Keep every single-value select aligned with the device-management filters. */
select:not([multiple]),
.select-control {
    appearance: none;
    -webkit-appearance: none;
    min-height: 40px;
    padding: 8px 36px 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background-color: var(--card-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364758b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 14px 14px;
    color: var(--text);
    cursor: pointer;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

select:not([multiple]):hover,
.select-control:hover { border-color: #9fb5c5; }

select:not([multiple]):focus,
.select-control:focus,
.select-control:focus-within {
    border-color: #5eead4;
    box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.16);
}

select:not([multiple]):disabled,
.select-control:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

#loginPage {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #f0fdfa;
}

#loginPage.login-hidden { display: none; }

.login-box {
    width: 390px;
    max-width: 100%;
    padding: 34px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 28px 76px rgba(15, 23, 42, 0.2);
}

.login-box h2 {
    margin-bottom: 24px;
    text-align: center;
    font-size: 24px;
    font-weight: 900;
}

.login-error,
.form-error {
    min-height: 20px;
    margin-top: 8px;
    color: var(--danger);
    font-size: 13px;
}

.app-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: clip;
    padding: 18px 14px;
    border-right: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 8px 0 24px rgba(15, 23, 42, 0.03);
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 10px 22px;
    flex-shrink: 0;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #ccfbf1;
    color: var(--primary-hover);
    font-size: 20px;
    font-weight: 900;
}

.brand-block h1 { font-size: 21px; line-height: 1.15; }
.brand-block p { color: var(--text-secondary); font-size: 12px; }

.nav-tabs {
    display: flex;
    flex: 1;
    min-height: 0;
    max-width: 100%;
    flex-direction: column;
    gap: 7px;
    overflow-x: clip;
    overflow-y: auto;
}

.nav-tab {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 18px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #475569;
    cursor: pointer;
    text-align: left;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nav-tab svg {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-tab span { display: none; }
.nav-tab strong { font-size: 15px; font-weight: 800; }
.nav-tab:hover { transform: translateX(2px); background: #f0fdfa; color: var(--primary-hover); }
.nav-tab.active { background: var(--primary-soft); color: var(--primary); }

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
}

.theme-toggle strong {
    min-width: 32px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    text-align: center;
}

.workspace { min-width: 0; padding: 0 28px 28px; }

.workspace-header {
    position: sticky;
    top: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 -28px 24px;
    padding: 16px 38px;
    border-bottom: 1px solid var(--border);
    background: rgba(248, 252, 252, 0.94);
    backdrop-filter: blur(18px);
}

.workspace-header h2 { font-size: 25px; line-height: 1.15; font-weight: 900; }
.eyebrow { margin-top: 2px; color: var(--text-secondary); font-size: 13px; }
.main-container { max-width: 1510px; margin: 0 auto; }

.topbar-actions { display: flex; align-items: center; gap: 18px; }
.profile-menu { position: relative; }

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.profile-avatar {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #14b8a6;
    color: #fff;
    font-size: 18px;
    font-weight: 900;
}

.profile-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }

.direct-message-console { display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(210px, 260px); min-height: 560px; border: 1px solid var(--border-color, #e5e7eb); background: var(--surface, #fff); }
.direct-conversation-pane, .direct-profile-pane { min-width: 0; padding: 14px; background: var(--surface-muted, #f8fafc); }
.direct-conversation-pane { border-right: 1px solid var(--border-color, #e5e7eb); }
.direct-profile-pane { border-left: 1px solid var(--border-color, #e5e7eb); }
.direct-pane-heading { display: flex; justify-content: space-between; margin-bottom: 10px; }
.direct-conversation-list { display: flex; flex-direction: column; gap: 4px; }
.direct-conversation-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 9px; width: 100%; padding: 10px 8px; text-align: left; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; }
.direct-conversation-item:hover, .direct-conversation-item.active { background: var(--accent-soft, #eef2ff); }
.direct-avatar { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; overflow: hidden; border-radius: 50%; background: #dbeafe; color: #1d4ed8; font-weight: 600; }
.direct-avatar img { width: 100%; height: 100%; object-fit: cover; }
.direct-conversation-copy { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.direct-conversation-copy span { overflow: hidden; color: var(--muted, #64748b); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.direct-conversation-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; color: var(--muted, #64748b); font-size: 11px; }
.direct-conversation-meta b { min-width: 18px; padding: 1px 5px; border-radius: 10px; background: #2563eb; color: #fff; text-align: center; }
.direct-message-pane { display: flex; min-width: 0; flex-direction: column; }
.direct-message-header { padding: 16px 20px; border-bottom: 1px solid var(--border-color, #e5e7eb); }
.direct-message-stream { flex: 1; overflow: auto; padding: 20px; background: #f8fafc; }
.direct-message-row { display: flex; margin: 8px 0; }
.direct-message-row.outbound { justify-content: flex-end; }
.direct-bubble { max-width: min(72%, 560px); padding: 10px 13px; border-radius: 12px; background: #fff; box-shadow: 0 1px 2px #00000012; white-space: pre-wrap; word-break: break-word; }
.direct-message-row.outbound .direct-bubble { background: #2563eb; color: #fff; }
.direct-bubble time { display: block; margin-top: 5px; color: #94a3b8; font-size: 10px; text-align: right; }
.direct-message-row.outbound .direct-bubble time { color: #dbeafe; }
.direct-date-divider { margin: 18px 0 8px; color: var(--muted, #64748b); font-size: 11px; text-align: center; }
.direct-profile-pane { text-align: center; }
.direct-profile-avatar { margin: 10px auto 12px; width: 72px; height: 72px; font-size: 24px; }
.direct-profile-pane h4 { margin: 0 0 18px; }
.direct-profile-pane dl { margin: 0; text-align: left; }
.direct-profile-pane dt { margin-top: 12px; color: var(--muted, #64748b); font-size: 11px; }
.direct-profile-pane dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.direct-message-state { padding: 28px 12px; color: var(--muted, #64748b); text-align: center; }
@media (max-width: 900px) { .direct-message-console { grid-template-columns: minmax(190px, 230px) minmax(0, 1fr); } .direct-profile-pane { display: none; } }
@media (max-width: 640px) { .direct-message-console { display: block; min-height: 0; } .direct-conversation-pane { border-right: 0; border-bottom: 1px solid var(--border-color, #e5e7eb); } .direct-conversation-list { max-height: 260px; overflow: auto; } .direct-message-pane { min-height: 420px; } .direct-bubble { max-width: 86%; } }
.profile-text small { color: var(--text-secondary); font-size: 13px; }
.profile-chevron svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; }

.profile-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 230px;
    display: none;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.16);
}

.profile-menu.open .profile-dropdown { display: block; }
.profile-dropdown-head { padding: 14px 16px; border-bottom: 1px solid #eef2f7; }
.profile-dropdown-head strong, .profile-dropdown-head small { display: block; }
.profile-dropdown-head small { margin-top: 2px; color: var(--text-secondary); }

.profile-dropdown button {
    width: 100%;
    padding: 13px 16px;
    border: none;
    border-bottom: 1px solid #eef2f7;
    background: #fff;
    color: #334155;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
}

.profile-dropdown button:hover { background: #f8fafc; }
.profile-dropdown .dropdown-danger { color: var(--danger); }

.tab-content { display: none; }
.tab-content.active { display: block; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}

.stat-card {
    min-height: 110px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(15, 23, 42, 0.12); }
.stat-num { font-size: 30px; font-weight: 900; }
.stat-label { margin-top: 8px; color: var(--text-secondary); font-size: 13px; font-weight: 800; }

.dashboard-status { min-height: 24px; margin-bottom: 12px; color: var(--text-secondary); font-size: 13px; }
.dashboard-status.is-error { color: var(--danger); }
.dashboard-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.dashboard-stat-card { min-height: 126px; cursor: default; }
.dashboard-stat-card:hover { transform: none; }
.dashboard-stat-label { display: block; color: var(--text-secondary); font-size: 13px; font-weight: 800; }
.dashboard-stat-card .stat-num { display: block; }
.dashboard-stat-card small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 12px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr); gap: 24px; margin-top: 24px; }
.dashboard-section { min-width: 0; padding: 4px 0 20px; border-bottom: 1px solid var(--border); }
.dashboard-section-head { min-height: 46px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.dashboard-section-head h3 { font-size: 17px; }
.dashboard-section-head p { margin-top: 2px; color: var(--text-secondary); font-size: 12px; }
.dashboard-alert-list, .dashboard-resource-overview { min-height: 150px; display: grid; align-content: start; gap: 8px; }
.dashboard-alert-item, .dashboard-resource-row { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.dashboard-alert-item:last-child, .dashboard-resource-row:last-child { border-bottom: none; }
.dashboard-alert-copy { min-width: 0; }
.dashboard-alert-copy strong, .dashboard-alert-copy small { display: block; overflow-wrap: anywhere; }
.dashboard-alert-copy small { margin-top: 2px; color: var(--text-secondary); }
.dashboard-quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.dashboard-heartbeats { margin-top: 24px; }
.dashboard-heartbeats .table-wrap { max-height: 380px; }

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: var(--shadow-soft);
}

.toolbar-right { display: flex; align-items: center; gap: 9px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }

.toolbar select,
.toolbar input,
.form-group input,
.form-group select,
.form-group textarea {
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background-color: #fff;
    color: var(--text);
    outline: none;
    transition: border 0.18s ease, box-shadow 0.18s ease;
}

.toolbar select, .toolbar input { min-height: 38px; padding: 7px 36px 7px 10px; font-size: 13px; }
.toolbar input { width: 190px; }

.automation-toolbar select,
.keyword-task-toolbar select {
    width: 130px;
    min-height: 38px;
    min-width: 0;
    max-width: none;
    padding: 7px 36px 7px 10px;
    font-size: 13px;
}

.toolbar select:focus,
.toolbar input:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #5eead4;
    box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.16);
}

.btn {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    transition: transform 0.16s ease, background 0.16s ease, border 0.16s ease, color 0.16s ease;
}

.btn:hover { transform: translateY(-1px); background: #f8fafc; }
.btn-primary { border-color: var(--primary); background: #0d9488; color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger); color: #fff; }
.btn-sm { min-height: 30px; padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; min-height: 44px; font-size: 15px; }
.btn-plus { font-size: 18px; line-height: 1; }

.table-wrap {
    max-height: 66vh;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }

table { width: 100%; min-width: max-content; border-collapse: collapse; }
th, td { padding: 13px 15px; text-align: left; white-space: nowrap; font-size: 13px; }

th {
    position: sticky;
    top: 0;
    z-index: 3;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    font-weight: 900;
}

td { border-bottom: 1px solid #edf2f7; color: #26364d; }
tr:hover td { background: #f8fffd; }
tr:last-child td { border-bottom: none; }
th:last-child, td:last-child { position: sticky; right: 0; z-index: 1; background: #fff; box-shadow: -4px 0 8px rgba(15, 23, 42, 0.06); }
th:last-child { z-index: 4; background: #f8fafc; }
tr:hover td:last-child { background: #f8fffd; }

.cell-link { color: var(--primary); font-weight: 800; cursor: pointer; text-decoration: none; }
.cell-link:hover { text-decoration: underline; }
.cell-link-button { border: none; background: transparent; padding: 0; font: inherit; }
.muted { color: var(--text-muted); }
.empty-text { padding: 28px 16px; color: var(--text-muted); text-align: center; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.admin-status-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 800;
}
.admin-status-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.admin-status-switch span {
    width: 38px;
    height: 22px;
    position: relative;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background 0.16s ease;
}
.admin-status-switch span::after {
    content: "";
    width: 18px;
    height: 18px;
    position: absolute;
    top: 2px;
    left: 2px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.22);
    transition: transform 0.16s ease;
}
.admin-status-switch input:checked + span { background: var(--primary); }
.admin-status-switch input:checked + span::after { transform: translateX(16px); }
.admin-status-switch input:disabled + span { opacity: 0.58; cursor: not-allowed; }
.admin-status-switch input:disabled ~ strong { opacity: 0.62; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-control { display: flex; align-items: stretch; gap: 8px; }
.inline-control select { flex: 1; min-width: 0; }
.btn-icon { width: 40px; padding: 0; justify-content: center; font-size: 18px; font-weight: 800; }
.bulk-result { margin-top: 10px; color: var(--text-secondary); font-size: 13px; }
.bulk-result ul { margin-top: 8px; padding-left: 18px; color: var(--danger); }
.qr-box { display: grid; gap: 14px; justify-items: center; }
.qr-box img { width: 220px; height: 220px; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 8px; }
.qr-box textarea { width: 100%; }
.binding-list { display: flex; flex-wrap: wrap; gap: 6px; max-width: 260px; }
.binding-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 26px;
    padding: 3px 7px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--primary-soft);
}
.binding-chip button {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: rgba(15, 118, 110, 0.14);
    color: var(--primary-hover);
    cursor: pointer;
    line-height: 1;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 850;
}

.badge-active, .badge-normal { background: #dcfce7; color: #15803d; }
.badge-idle { background: #dbeafe; color: #1d4ed8; }
.badge-maintenance, .badge-deprecated { background: #fef3c7; color: #b45309; }
.badge-retired, .badge-disabled { background: #f1f5f9; color: #64748b; }
.badge-banned, .badge-expired { background: #fee2e2; color: #dc2626; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 14px;
    font-size: 13px;
    font-weight: 600;
}

.pagination-inner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pagination-btns { display: flex; align-items: center; gap: 3px; }
.pagination-info { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

.page-arrow, .page-num {
    min-width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
}

.page-num.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.page-arrow[disabled] { cursor: not-allowed; opacity: 0.4; }
.page-dots { min-width: 30px; text-align: center; color: var(--text-muted); }
.page-size-select { margin-left: 4px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); color: var(--text-secondary); }

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 50px 20px;
    background: rgba(15, 23, 42, 0.46);
    backdrop-filter: blur(8px);
}

.modal-overlay.active { display: flex; }

.modal {
    width: 520px;
    max-width: 100%;
    max-height: 84vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
}

.modal-lg { width: 760px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    background: #f8fbff;
}

.modal-header h3 { font-size: 18px; }
.modal-close { width: 32px; height: 32px; border: none; border-radius: 8px; background: #eef2f7; color: var(--text-secondary); cursor: pointer; font-size: 22px; line-height: 1; }
.modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 15px 22px; border-top: 1px solid var(--border); background: #fbfdff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 15px 22px; border-top: 1px solid var(--border); background: #fbfdff; }
.device-credential-modal { width: min(600px, 100%); }
.device-credential-warning { margin: 0 0 18px; color: #b45309; font-size: 14px; line-height: 1.55; }
.device-credential-modal input[readonly] { font-family: Consolas, "Courier New", monospace; overflow: hidden; text-overflow: ellipsis; }
.device-credential-actions { flex-wrap: wrap; }
.device-credential-actions .btn { white-space: nowrap; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-group { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.form-grid .form-group { margin-bottom: 0; }
.field-full { grid-column: 1 / -1; }

.form-group label { color: var(--text-secondary); font-size: 13px; font-weight: 800; }
.form-group input, .form-group select, .form-group textarea { width: 100%; min-height: 40px; padding: 8px 11px; font-size: 14px; }
.form-group select:not([multiple]) { padding-right: 36px; }
.form-group textarea { min-height: 84px; resize: vertical; }
.form-group select[multiple] { min-height: 130px; padding: 8px; }
.publish-plan-table { min-width: 980px; table-layout: fixed; }
.publish-plan-table th:nth-child(1) { width: 150px; }
.publish-plan-table th:nth-child(2) { width: 150px; }
.publish-plan-table th:nth-child(4) { width: 180px; }
.publish-plan-table th:last-child { width: 300px; }
.publish-plan-editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; align-items: start; }
.publish-plan-editor-grid > .form-group { min-width: 0; margin-bottom: 0; }
.publish-plan-account-select { width: 100%; min-height: 132px; border-radius: 6px; }
.publish-plan-conditional[hidden] { display: none !important; }
.publish-plan-modal { width: min(760px, 100%); }
.required { color: var(--danger); }
.field-help { color: var(--text-muted); font-size: 12px; }

.settings-page { display: flex; flex-direction: column; gap: 18px; }
.settings-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.settings-page-head h3 { margin: 2px 0 6px; font-size: 22px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.settings-error { min-height: 20px; color: var(--danger); font-size: 13px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.settings-card { min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--card-bg); box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05); }
.settings-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.settings-card-head h4 { font-size: 16px; }
.settings-status { color: var(--primary); font-size: 12px; font-weight: 800; }
.settings-inline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.segmented-control { display: inline-flex; width: 100%; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.segmented-control button { flex: 1; min-height: 36px; border: 0; border-radius: 6px; background: transparent; color: var(--text-secondary); cursor: pointer; font-weight: 700; }
.segmented-control button.active { background: var(--primary); color: #fff; }
.switch-row { display: flex; align-items: center; gap: 9px; min-height: 34px; margin-top: 10px; color: var(--text-secondary); font-size: 13px; font-weight: 700; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--primary); }
.settings-health { display: grid; gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; }
.settings-health > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--bg); font-size: 13px; }
.settings-health > div strong { max-width: 65%; overflow: hidden; color: var(--text); text-align: right; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
    .settings-grid { grid-template-columns: 1fr; }
    .settings-page-head { flex-direction: column; }
    .settings-actions { width: 100%; }
    .settings-actions .btn { flex: 1 1 160px; }
}

.publish-plan-toolbar .toolbar-actions { min-width: 0; }

.app-dialog {
    width: 380px;
    max-width: 100%;
    padding: 24px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 26px 76px rgba(15, 23, 42, 0.26);
    text-align: center;
}

.app-dialog-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    margin: 0 auto 12px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 900;
}

.app-dialog h3 { margin-bottom: 8px; font-size: 18px; }
.app-dialog p { color: var(--text-secondary); font-size: 14px; }
.app-dialog-actions { display: flex; justify-content: center; gap: 10px; margin-top: 20px; }

.menu-toggle-btn {
    display: none;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
}

.menu-toggle-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

body.dark-mode {
    --bg: #0f172a;
    --card-bg: #111827;
    --border: #263244;
    --border-strong: #334155;
    --text: #e5eef8;
    --text-secondary: #9fb0c4;
    --text-muted: #64748b;
    background: linear-gradient(135deg, #08111f 0%, #0f172a 55%, #111827 100%);
}

body.dark-mode .sidebar,
body.dark-mode .workspace-header,
body.dark-mode .stat-card,
body.dark-mode .toolbar,
body.dark-mode .table-wrap,
body.dark-mode .modal,
body.dark-mode .profile-dropdown,
body.dark-mode .theme-toggle,
body.dark-mode .app-dialog {
    background: #111827;
    color: var(--text);
    border-color: var(--border);
}

body.dark-mode th,
body.dark-mode .modal-header,
body.dark-mode .modal-footer,
body.dark-mode .modal-actions { background: #172033; }
body.dark-mode td,
body.dark-mode .profile-dropdown button { background: #111827; color: var(--text); border-color: var(--border); }
body.dark-mode tr:hover td,
body.dark-mode tr:hover td:last-child { background: #1e293b; }
body.dark-mode th:last-child { background: #172033; }
body.dark-mode td:last-child { background: #111827; }

body.dark-mode .toolbar input,
body.dark-mode .toolbar select,
body.dark-mode .form-group input,
body.dark-mode .form-group select,
body.dark-mode .form-group textarea {
    background: #0f172a;
    color: #e5eef8;
    border-color: #334155;
}

body.dark-mode select:not([multiple]),
body.dark-mode .select-control {
    background-color: #0f172a;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.account-avatar-picker { display: flex; align-items: center; gap: 14px; }
.account-avatar-preview {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    border: 1px solid var(--border);
    object-fit: cover;
    background: #f1f5f9;
}
.account-avatar-field input[type="file"] { max-width: 100%; }

.material-full-body > div + div,
.material-body-preview > div + div {
    margin-top: 0.75rem;
}

.content-parts-extra textarea,
#contentEditPart2,
#contentEditPart3 {
    min-height: 96px;
}

body.dark-mode .keyword-task-multipart-toggle { border-color: #334155; background: #172033; }
body.dark-mode .keyword-task-input-with-suffix span { border-color: #334155; background: #111827; }

body.dark-mode .btn { background: #172033; color: #e5eef8; border-color: #334155; }
body.dark-mode .btn-primary { background: #0d9488; color: #fff; border-color: #0d9488; }
body.dark-mode .btn-danger { color: #fecaca; border-color: #7f1d1d; }
body.dark-mode .cell-link { color: #5eead4; }
body.dark-mode .modal-close { background: #263244; color: #cbd5e1; }

@media (max-width: 1200px) {
    .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .dashboard-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .menu-toggle-btn { display: flex; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 100;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 8px 0 32px rgba(15, 23, 42, 0.18);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .workspace { padding: 0 16px 16px; }
    .workspace-header { margin: 0 -16px 20px; padding: 15px 16px; }
    .workspace-header > div { flex: 1; min-width: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; gap: 20px; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .toolbar-right { width: 100%; margin-left: 0; flex-direction: column; align-items: stretch; }
    .toolbar input, .toolbar select { width: 100%; }
    .automation-toolbar select,
    .keyword-task-toolbar select { width: 100%; max-width: none; }
    .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .stats-grid { grid-template-columns: 1fr; }
    .dashboard-stats { grid-template-columns: 1fr; }
    .dashboard-stat-card { min-height: 108px; }
    .dashboard-alert-item, .dashboard-resource-row { grid-template-columns: auto minmax(0, 1fr); }
    .dashboard-alert-item .btn, .dashboard-resource-row .btn { grid-column: 2; justify-self: start; }
    .workspace-header h2 { font-size: 22px; }
    .profile-text { display: none; }
    .profile-dropdown { right: -8px; }
    .modal-overlay { padding: 22px 12px; }
    .device-credential-actions .btn { flex: 1 1 calc(50% - 10px); min-width: 0; }
}

@media (max-width: 480px) {
    .automation-modal .modal-actions { flex-wrap: wrap; }
    .automation-modal .modal-actions .btn { flex: 1 1 100%; min-width: 0; }
}
