:root {
    --bg: #edf2f7;
    --bg-alt: #e7edf5;
    --surface: #ffffff;
    --surface-alt: #f5f8fc;
    --surface-muted: #eef3f8;
    --sidebar: #0d1828;
    --sidebar-alt: #132338;
    --sidebar-line: rgba(145, 177, 214, 0.14);
    --line: #d6dfe9;
    --line-strong: #bfccd9;
    --text: #172b3d;
    --muted: #64778c;
    --muted-strong: #4d6176;
    --accent: #1f6bbd;
    --accent-soft: #e8f1fb;
    --success: #287448;
    --danger: #c53a2f;
    --warning: #ad6b19;
    --shadow: 0 18px 42px rgba(20, 36, 56, 0.08);
    --shadow-soft: 0 10px 26px rgba(20, 36, 56, 0.06);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "IBM Plex Sans", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(31, 107, 189, 0.12), transparent 22%),
        linear-gradient(180deg, #f4f7fb 0%, var(--bg) 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.cms-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 318px minmax(0, 1fr);
}

.cms-sidebar {
    position: sticky;
    top: 0;
    min-height: 100vh;
    padding: 1.4rem;
    border-right: 1px solid var(--sidebar-line);
    background:
        linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-alt) 100%);
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.sidebar-top,
.sidebar-section,
.sidebar-meta {
    border: 1px solid var(--sidebar-line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.sidebar-top,
.sidebar-meta {
    padding: 1rem;
}

.sidebar-section {
    padding: 0.95rem;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
}

.brand-wordmark-shell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid rgba(145, 177, 214, 0.16);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(18, 34, 53, 0.92), rgba(11, 23, 37, 0.86));
}

.brand-wordmark {
    width: min(100%, 234px);
    height: auto;
    filter: drop-shadow(0 16px 30px rgba(0, 0, 0, 0.28)) brightness(1.08);
}

.brand-mark-copy {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.95rem;
}

.brand-mark-copy strong,
.sidebar-meta strong {
    color: #f4f8fd;
}

.brand-mark-copy strong {
    font-size: 1rem;
    font-weight: 700;
}

.brand-mark-copy span,
.sidebar-section-label,
.sidebar-meta span {
    color: rgba(225, 235, 245, 0.74);
}

.brand-mark-copy span,
.sidebar-meta span {
    line-height: 1.65;
    font-size: 0.88rem;
}

.sidebar-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.8rem;
}

.sidebar-section-label,
.page-kicker,
.panel-label {
    margin: 0;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.sidebar-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 0.7rem;
    border-radius: 999px;
    border: 1px solid rgba(145, 177, 214, 0.16);
    background: rgba(255, 255, 255, 0.06);
    color: #dce8f3;
    font-size: 0.76rem;
    font-weight: 700;
}

.sidebar-nav,
.managed-page-list,
.sidebar-actions {
    display: grid;
    gap: 0.55rem;
}

.managed-page-list {
    max-height: 430px;
    overflow: auto;
    padding-right: 0.2rem;
}

.sidebar-link,
.managed-page-item {
    min-height: 44px;
    padding: 0.78rem 0.9rem;
    border: 1px solid rgba(145, 177, 214, 0.1);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    color: #e5eef7;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.sidebar-link:hover,
.sidebar-link.is-active,
.managed-page-item:hover,
.managed-page-item.is-active {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(145, 177, 214, 0.26);
    transform: translateY(-1px);
}

.managed-page-item {
    display: grid;
    gap: 0.22rem;
    color: #e5eef7;
}

.managed-page-item strong {
    font-size: 0.92rem;
}

.managed-page-item span {
    color: rgba(225, 235, 245, 0.68);
    font-size: 0.8rem;
}

.page-selector {
    display: grid;
    gap: 0.45rem;
    margin-bottom: 0.8rem;
}

.page-selector span,
.header-search span {
    color: rgba(225, 235, 245, 0.74);
    font-size: 0.82rem;
    font-weight: 600;
}

.page-selector select,
.page-selector input {
    width: 100%;
    min-height: 44px;
    padding: 0 0.9rem;
    border: 1px solid rgba(145, 177, 214, 0.16);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: #f4f8fd;
}

.page-selector input::placeholder {
    color: rgba(225, 235, 245, 0.48);
}

.sidebar-meta strong {
    display: block;
    margin-top: 0.5rem;
    font-size: 1rem;
}

.sidebar-actions {
    margin-top: auto;
}

.cms-main {
    padding: 1.35rem;
}

.cms-header,
.cms-command-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.cms-header {
    margin-bottom: 1rem;
}

.header-copy,
.header-utility {
    min-width: 0;
}

.cms-header h1,
.panel-card-head h2,
.form-section-head h3 {
    margin: 0;
    line-height: 1.08;
    letter-spacing: -0.03em;
}

.cms-header h1 {
    margin-top: 0.6rem;
    font-size: clamp(2rem, 3vw, 2.9rem);
}

.page-kicker,
.page-summary,
.panel-label,
.link-inline,
.stack-item p,
.detail-item span,
.status-text,
.empty-state,
.header-links a,
.workspace-jump,
.workflow-meta,
.preview-frame-toolbar,
.asset-output code,
.message-item time,
.header-search input,
.message-search label span {
    color: var(--muted);
}

.page-summary {
    max-width: 56rem;
    margin: 0.9rem 0 0;
    line-height: 1.75;
}

.header-utility {
    display: grid;
    gap: 0.85rem;
    justify-items: end;
}

.header-search {
    width: min(100%, 320px);
    display: grid;
    gap: 0.45rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow-soft);
}

.header-search input {
    width: 100%;
    min-height: 36px;
    padding: 0;
    border: 0;
    background: transparent;
}

.header-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
}

.header-links a,
.link-inline {
    font-weight: 600;
}

.cms-command-row {
    margin-bottom: 1rem;
}

.cms-header-strip,
.workspace-jumpbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.cms-status-pill,
.workspace-jump {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.cms-status-pill.is-good {
    border-color: rgba(40, 116, 72, 0.22);
    background: rgba(40, 116, 72, 0.08);
    color: var(--success);
}

.cms-status-pill.is-watch {
    border-color: rgba(173, 107, 25, 0.22);
    background: rgba(173, 107, 25, 0.08);
    color: var(--warning);
}

.workspace-jump {
    cursor: pointer;
}

.workspace-jump.is-active {
    border-color: rgba(31, 107, 189, 0.2);
    background: var(--accent-soft);
    color: var(--accent);
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.85rem;
}

.metric-card,
.panel-card,
.form-section-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.metric-card {
    padding: 1rem;
}

.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 0.86rem;
}

.metric-card strong {
    display: block;
    margin-top: 0.4rem;
    font-size: 1.55rem;
}

.overview-board,
.workspace-grid,
.records-layout,
.form-grid,
.workspace-form-grid {
    display: grid;
    gap: 1rem;
}

.overview-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 1rem;
}

.workspace-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
    align-items: start;
}

.records-layout {
    grid-template-columns: minmax(320px, 0.82fr) minmax(0, 1.18fr);
    margin-top: 0.2rem;
}

.panel-card {
    padding: 1.2rem;
}

.panel-span-2 {
    grid-column: span 2;
}

.panel-card-head,
.form-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.9rem;
}

.panel-card-head {
    margin-bottom: 1rem;
}

.panel-card-head h2 {
    margin-top: 0.55rem;
    font-size: 1.4rem;
}

.trend-chart,
.stack-list,
.message-thread,
.detail-list {
    display: grid;
    gap: 0.75rem;
}

.trend-bar,
.stack-item,
.quote-list-item,
.conversation-item,
.message-item,
.detail-item {
    padding: 0.95rem 1rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-alt);
}

.trend-bar-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.55rem;
}

.trend-bar-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #dfe8f0;
}

.trend-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), #7eabd8);
}

.stack-item strong,
.quote-list-item strong,
.conversation-item strong,
.detail-item strong,
.message-item strong {
    display: block;
}

.stack-item p,
.quote-list-item p,
.conversation-item p,
.message-item p,
.detail-item span {
    margin: 0.45rem 0 0;
    line-height: 1.65;
}

.quote-list-item,
.conversation-item {
    cursor: pointer;
    transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.quote-list-item:hover,
.conversation-item:hover,
.quote-list-item.is-active,
.conversation-item.is-active {
    border-color: #9db8d5;
    background: #f4f8fc;
    transform: translateY(-1px);
}

.page-workspace-card {
    padding-bottom: 1rem;
    min-width: 0;
}

.content-form,
.detail-form,
.asset-upload-form,
.message-compose,
.message-search {
    display: grid;
    gap: 1rem;
}

.workspace-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.content-section-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.content-section-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 0.8rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-alt);
    color: var(--muted-strong);
    font-size: 0.84rem;
    font-weight: 700;
    transition: border-color 180ms ease, background 180ms ease, color 180ms ease, transform 180ms ease;
}

.content-section-link:hover {
    color: var(--accent);
    border-color: #9db8d5;
    background: #f4f8fc;
    transform: translateY(-1px);
}

.form-section-card {
    padding: 1rem;
}

.form-section-card-wide {
    grid-column: span 2;
}

.form-section-head {
    margin-bottom: 0.9rem;
}

.form-section-head h3 {
    margin-top: 0.5rem;
    font-size: 1.1rem;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-span-2 {
    grid-column: span 2;
}

.advanced-json-field,
.content-form label,
.detail-form label,
.message-search label {
    display: grid;
    gap: 0.42rem;
}

.advanced-json-shell {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-alt);
}

.advanced-json-shell summary {
    display: grid;
    gap: 0.38rem;
    padding: 1rem;
    cursor: pointer;
    list-style: none;
}

.advanced-json-shell summary::-webkit-details-marker {
    display: none;
}

.advanced-json-shell summary span {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.55;
}

.advanced-json-shell[open] {
    background: var(--surface);
}

.advanced-json-body {
    padding: 0 1rem 1rem;
}

.advanced-json-field span,
.content-form label span,
.detail-form label span,
.message-search label span {
    font-size: 0.88rem;
    font-weight: 600;
}

.content-form input,
.content-form select,
.content-form textarea,
.detail-form input,
.detail-form select,
.detail-form textarea,
.message-search input,
.message-compose textarea {
    width: 100%;
    min-height: 44px;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-alt);
    color: var(--text);
    resize: vertical;
}

.content-form textarea,
.detail-form textarea,
.message-compose textarea {
    min-height: 120px;
}

#field-content-json {
    min-height: 300px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.84rem;
}

.content-form input:focus,
.content-form select:focus,
.content-form textarea:focus,
.detail-form input:focus,
.detail-form select:focus,
.detail-form textarea:focus,
.message-search input:focus,
.message-compose textarea:focus,
.header-search input:focus,
.page-selector select:focus,
.page-selector input:focus {
    outline: none;
    border-color: #8fb2d8;
    box-shadow: 0 0 0 3px rgba(31, 107, 189, 0.12);
}

.form-actions,
.content-action-group,
.content-preview-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    align-items: center;
}

.content-head-actions {
    display: grid;
    justify-items: end;
    gap: 0.4rem;
}

.workflow-meta {
    max-width: 22rem;
    text-align: right;
    font-size: 0.78rem;
    line-height: 1.5;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 1rem;
    border: 1px solid transparent;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    color: #ffffff;
    background: linear-gradient(135deg, #1f6bbd, #3f88d6);
}

.button-secondary {
    color: var(--text);
    background: var(--surface);
    border-color: var(--line);
}

.preview-frame-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.85rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-alt);
    font-size: 0.82rem;
    font-weight: 600;
}

.content-side-stack {
    position: sticky;
    top: 1rem;
    display: grid;
    gap: 1rem;
    align-self: start;
}

.upload-dropzone {
    display: grid;
    gap: 0.6rem;
    padding: 1rem;
    border: 1px dashed #b8c9d9;
    border-radius: 14px;
    background: var(--surface-alt);
}

.upload-dropzone span {
    font-weight: 600;
}

.asset-output {
    margin-top: 1rem;
}

.asset-output code {
    display: block;
    margin-top: 0.45rem;
    padding: 0.75rem 0.85rem;
    border-radius: 12px;
    background: var(--surface-muted);
    word-break: break-all;
}

.preview-frame-wrap {
    min-height: 480px;
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    background: #dde6ef;
}

.preview-empty-state {
    display: grid;
    gap: 0.55rem;
    padding: 1rem 1.05rem;
    border: 1px dashed #b8c9d9;
    border-radius: 16px;
    background: var(--surface-alt);
}

.preview-empty-state strong {
    font-size: 0.96rem;
}

.preview-empty-state span {
    color: var(--muted);
    line-height: 1.6;
}

.content-preview-frame {
    width: 100%;
    min-height: 480px;
    border: 0;
    background: #ffffff;
}

.detail-item strong {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.message-thread {
    max-height: 560px;
    overflow: auto;
}

.message-item time {
    display: block;
    margin-top: 0.45rem;
    font-size: 0.82rem;
}

.empty-state {
    padding: 1rem 0;
}

.status-text {
    min-height: 1.2rem;
    margin: 0;
    font-size: 0.9rem;
}

.status-text.is-success {
    color: var(--success);
}

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

.hidden {
    display: none !important;
}

@media (max-width: 1360px) {
    .metrics-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .overview-board {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .panel-span-2 {
        grid-column: span 2;
    }
}

@media (max-width: 1180px) {
    .cms-shell {
        grid-template-columns: 1fr;
    }

    .cms-sidebar {
        position: static;
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    .workspace-grid,
    .records-layout,
    .overview-board,
    .workspace-form-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .panel-span-2,
    .form-section-card-wide,
    .form-span-2 {
        grid-column: span 1;
    }

    .content-head-actions,
    .workflow-meta {
        justify-items: start;
        text-align: left;
    }

    .content-side-stack {
        position: static;
    }
}

@media (max-width: 760px) {
    .cms-main,
    .cms-sidebar {
        padding: 1rem;
    }

    .cms-header,
    .cms-command-row {
        flex-direction: column;
    }

    .header-utility {
        width: 100%;
        justify-items: stretch;
    }

    .header-search {
        width: 100%;
    }

    .cms-header-strip,
    .workspace-jumpbar,
    .content-preview-links,
    .preview-frame-toolbar,
    .form-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }
}
