:root {
    --bg: #f7fafa;
    --panel: #ffffff;
    --line: #efefef;
    --line-soft: #f7f7f7;
    --text: #292929;
    --text-soft: #656565;
    --text-muted: #989898;
    --primary: #0ba9aa;
    --primary-soft: #f1f6f7;
    --success: #027a48;
    --danger: #b42318;
    --warning: #b45309;
    --radius: 12px;
    color-scheme: light;
}

html[data-theme="dark"] {
    --bg: #0b1120;
    --panel: #111827;
    --line: #2a3547;
    --line-soft: #1f2937;
    --text: #f8fafc;
    --text-soft: #cbd5e1;
    --text-muted: #94a3b8;
    --primary-soft: rgba(11, 169, 170, 0.14);
    --success: #3ddc84;
    --danger: #ff8a80;
    --warning: #fbbf24;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}

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

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

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

.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--line);
    min-height: 100vh;
    position: sticky;
    top: 0;
    align-self: start;
}

.brand {
    height: 80px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--line-soft);
}

.brand-mark {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background:
        radial-gradient(circle at 30% 30%, #ffffff 0 2px, transparent 3px),
        linear-gradient(135deg, var(--tenant-color, var(--primary)), #62d6ce);
    box-shadow: 0 8px 18px rgba(11, 169, 170, 0.2);
}

.brand strong {
    font-size: 20px;
    line-height: 1;
    letter-spacing: 0;
}

.nav {
    padding: 16px 20px 28px;
}

.nav-label {
    color: #7c7c7c;
    font-size: 12px;
    line-height: 18px;
    margin: 18px 12px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    background: var(--primary-soft);
}

.nav-link svg,
.icon-button svg,
.btn svg {
    width: 16px;
    height: 16px;
}

.main {
    min-width: 0;
}

.topbar {
    height: 80px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 24px;
}

.search-box {
    width: min(440px, 100%);
    height: 40px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    color: var(--text-muted);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-button {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 32px;
    background: #fafafa;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-profile-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #d2eeeb;
    color: var(--text);
    font-weight: 700;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.small-avatar {
    width: 34px;
    height: 34px;
    font-size: 12px;
    flex: 0 0 auto;
}

.user-list-cell,
.profile-heading {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-list-cell strong,
.user-list-cell span span {
    display: block;
}

.user-meta strong,
.user-meta span {
    display: block;
    white-space: nowrap;
}

.user-meta strong {
    font-size: 14px;
}

.user-meta span {
    color: var(--text-soft);
    font-size: 12px;
    line-height: 18px;
}

.content {
    padding: 24px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.page-title h1 {
    font-size: 24px;
    line-height: 1.25;
    margin: 0 0 4px;
}

.page-title p {
    color: var(--text-soft);
    margin: 0;
}

.grid {
    display: grid;
    gap: 16px;
}

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

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

.card {
    background: var(--panel);
    border: 1px solid rgba(0, 0, 0, 0.03);
    border-radius: 20px;
    padding: 24px;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.metric-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #464646;
    font-weight: 500;
}

.metric-value {
    font-size: 24px;
    line-height: 1;
    font-weight: 700;
}

.metric-note {
    color: var(--text-soft);
    display: flex;
    align-items: center;
    gap: 4px;
}

.metric-note strong {
    color: #02af47;
    font-weight: 500;
}

.table-card {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: 20px;
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line-soft);
}

.table-header h2 {
    margin: 0;
    font-size: 18px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #fafafa;
    border-bottom: 1px solid #f5f5f5;
    color: #45556c;
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
    padding: 8px 16px;
    text-align: left;
}

.data-table td {
    border-bottom: 1px solid var(--line-soft);
    color: #45556c;
    height: 64px;
    padding: 12px 16px;
    vertical-align: middle;
}

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

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

.small {
    font-size: 12px;
    line-height: 18px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 5px;
    padding: 2px 8px;
    font-size: 12px;
    line-height: 18px;
    font-weight: 600;
}

.badge.success {
    background: #ecfdf3;
    color: var(--success);
}

.badge.neutral {
    background: #efefef;
    color: #464646;
}

.badge.info {
    background: #eff8ff;
    color: #1447e6;
}

.badge.danger {
    background: #fef3f2;
    color: var(--danger);
}

.btn-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 14px;
    background: var(--panel);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
}

.btn.primary {
    background: var(--tenant-color, var(--primary));
    border-color: var(--tenant-color, var(--primary));
    color: #ffffff;
}

.btn.support {
    background: #eff8ff;
    border-color: #b2ddff;
    color: #175cd3;
}

.impersonation-banner {
    min-height: 58px;
    padding: 9px 24px;
    border-bottom: 1px solid #b2ddff;
    background: #eff8ff;
    color: #1849a9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.impersonation-banner-copy {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.impersonation-banner-copy > svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

.impersonation-banner-copy > div {
    display: grid;
    gap: 2px;
}

.impersonation-banner-copy span {
    color: #175cd3;
    font-size: 13px;
}

.impersonation-banner .btn {
    min-height: 36px;
    border-color: #84caff;
    color: #1849a9;
    white-space: nowrap;
}

.btn.danger {
    border-color: #fecdca;
    color: var(--danger);
}

.btn.ghost {
    border-color: transparent;
    background: transparent;
    color: var(--text-soft);
}

.btn.icon-only {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-track {
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: #d1d5db;
    padding: 2px;
    position: relative;
    transition: background 160ms ease;
}

.toggle-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(17, 24, 39, 0.2);
    display: block;
    transition: transform 160ms ease;
}

.toggle input:checked + .toggle-track {
    background: var(--tenant-color, var(--primary));
}

.toggle input:checked + .toggle-track .toggle-thumb {
    transform: translateX(20px);
}

.toggle input:focus-visible + .toggle-track {
    outline: 3px solid rgba(11, 169, 170, 0.2);
    outline-offset: 2px;
}

.toggle-label {
    color: var(--text-soft);
    font-weight: 600;
}

.calendar-card {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: 20px;
    margin-bottom: 18px;
    overflow: hidden;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line-soft);
}

.calendar-header h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.calendar-header p {
    margin: 0;
    color: var(--text-soft);
}

.calendar-scroll {
    overflow-x: auto;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(126px, 1fr));
    min-width: 882px;
}

.calendar-weekdays {
    background: #fafafa;
    border-bottom: 1px solid var(--line-soft);
}

.calendar-weekday {
    color: #45556c;
    font-size: 12px;
    font-weight: 700;
    padding: 10px 12px;
}

.calendar-day {
    min-height: 134px;
    border-right: 1px solid var(--line-soft);
    border-bottom: 1px solid var(--line-soft);
    padding: 10px;
    background: #ffffff;
}

.calendar-day:nth-child(7n) {
    border-right: 0;
}

.calendar-date {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.calendar-date span {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
    font-weight: 700;
}

.calendar-day.today .calendar-date span {
    background: var(--tenant-color, var(--primary));
    color: #ffffff;
}

.calendar-day.muted-month {
    background: #fbfbfb;
}

.calendar-day.muted-month .calendar-date span {
    color: #c0c0c0;
}

.calendar-events {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.calendar-booking {
    display: grid;
    gap: 2px;
    border-left: 3px solid var(--tenant-color, var(--primary));
    border-radius: 6px;
    background: var(--primary-soft);
    padding: 6px 8px;
    color: var(--text);
    line-height: 1.25;
}

.calendar-booking strong {
    font-size: 12px;
}

.calendar-booking span {
    color: var(--text-soft);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-more {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
}

.form-card {
    background: var(--panel);
    border: 1px solid rgba(0, 0, 0, 0.03);
    border-radius: 20px;
    padding: 24px;
    max-width: 920px;
}

.form-card.compact {
    max-width: none;
    padding: 18px;
    margin-bottom: 18px;
}

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

.form-grid.compact-grid {
    gap: 12px;
    width: 100%;
}

.profile-form-card {
    max-width: 1040px;
}

.profile-form-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.profile-picture-card {
    display: grid;
    gap: 16px;
    align-content: start;
}

.profile-picture-card h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.profile-picture-card p {
    margin: 0;
}

.display-picture-field {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    background: #fafafa;
}

.display-picture-inputs {
    min-width: 0;
    display: grid;
    gap: 8px;
}

.display-picture-preview {
    width: 70px;
    height: 70px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #d2eeeb;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    overflow: hidden;
    flex: 0 0 auto;
}

.display-picture-preview.large {
    width: 132px;
    height: 132px;
    font-size: 42px;
}

.display-picture-preview.heading-picture {
    width: 58px;
    height: 58px;
    font-size: 20px;
}

.display-picture-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tenant-user-profile {
    display: grid;
    gap: 18px;
}

.profile-hero-card {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: 20px;
    overflow: hidden;
}

.profile-hero-accent {
    height: 92px;
    background:
        linear-gradient(135deg, var(--tenant-color, var(--primary)), #6bdad1);
}

.profile-hero-main {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    padding: 0 24px 22px;
}

.profile-identity {
    display: flex;
    align-items: flex-end;
    gap: 18px;
    min-width: 0;
    margin-top: -42px;
}

.profile-avatar {
    width: 116px;
    height: 116px;
    border: 5px solid #ffffff;
    border-radius: 28px;
    background: #d2eeeb;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    font-weight: 800;
    overflow: hidden;
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.12);
    flex: 0 0 auto;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-title-block {
    min-width: 0;
    padding-bottom: 4px;
}

.profile-title-block h1 {
    margin: 8px 0 6px;
    font-size: 30px;
    line-height: 1.15;
}

.profile-title-block p {
    margin: 0;
    color: var(--text-soft);
}

.profile-hero-actions {
    justify-content: flex-end;
    padding-bottom: 4px;
}

.profile-contact-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    border-top: 1px solid var(--line-soft);
    background: var(--line-soft);
}

.profile-contact-tile {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #ffffff;
    padding: 18px 24px;
}

.profile-contact-icon,
.profile-metric-icon,
.profile-timeline-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--tenant-color, var(--primary));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.profile-contact-icon svg,
.profile-metric-icon svg,
.profile-timeline-icon svg {
    width: 18px;
    height: 18px;
}

.profile-contact-tile small,
.profile-contact-tile strong {
    display: block;
}

.profile-contact-tile small {
    color: var(--text-soft);
    font-size: 12px;
    line-height: 18px;
}

.profile-contact-tile strong {
    color: var(--text);
    overflow-wrap: anywhere;
}

.profile-metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.profile-metric-card {
    min-height: 92px;
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: 18px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-metric-card strong,
.profile-metric-card small {
    display: block;
}

.profile-metric-card strong {
    color: var(--text);
    font-size: 22px;
    line-height: 1.1;
}

.profile-metric-card small {
    color: var(--text-soft);
    margin-top: 4px;
}

.profile-content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    align-items: start;
}

.profile-side-stack {
    display: grid;
    gap: 18px;
}

.profile-panel {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: 20px;
    padding: 20px;
}

.profile-section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.profile-section-heading h2 {
    margin: 0 0 4px;
    font-size: 18px;
    line-height: 1.25;
}

.profile-section-heading p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.5;
}

.profile-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.profile-field-card {
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    background: #ffffff;
    padding: 14px;
    display: grid;
    gap: 12px;
    min-width: 0;
}

.profile-field-card.wide {
    grid-column: 1 / -1;
}

.profile-field-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.profile-field-card-head strong,
.profile-field-card-head small {
    display: block;
}

.profile-field-card-head small {
    color: var(--text-soft);
    font-size: 12px;
    line-height: 18px;
    margin-top: 2px;
    overflow-wrap: anywhere;
}

.profile-field-value {
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.field.full {
    grid-column: 1 / -1;
}

.field label {
    color: #464646;
    font-weight: 600;
    font-size: 13px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    min-height: 42px;
    padding: 10px 12px;
    background: #ffffff;
    color: var(--text);
}

.field textarea {
    min-height: 150px;
    resize: vertical;
}

.field input[type="color"] {
    padding: 4px;
    min-height: 42px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.article-form-card {
    max-width: none;
}

.article-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 24px;
    align-items: start;
}

.article-main {
    min-width: 0;
}

.editor-shell {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
    overflow: hidden;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 8px;
    border-bottom: 1px solid var(--line-soft);
    background: #fafafa;
}

.editor-toolbar button,
.editor-toolbar select {
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
}

.editor-toolbar button {
    width: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.editor-toolbar select {
    width: auto;
    padding: 6px 9px;
}

.editor-toolbar svg {
    width: 16px;
    height: 16px;
}

.wysiwyg-editor {
    min-height: 420px;
    padding: 18px;
    outline: none;
    color: var(--text);
    line-height: 1.65;
}

.wysiwyg-editor h2,
.wysiwyg-editor h3,
.phone-body h2,
.phone-body h3 {
    line-height: 1.25;
    margin: 18px 0 10px;
}

.wysiwyg-editor p,
.phone-body p {
    margin: 0 0 14px;
}

.wysiwyg-editor blockquote,
.phone-body blockquote {
    border-left: 3px solid var(--tenant-color, var(--primary));
    color: var(--text-soft);
    margin: 16px 0;
    padding-left: 14px;
}

.wysiwyg-editor img,
.phone-body img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

.phone-preview {
    position: sticky;
    top: 96px;
}

.phone-frame {
    width: 100%;
    border-radius: 34px;
    background: #111827;
    padding: 12px;
    box-shadow: 0 22px 50px rgba(17, 24, 39, 0.18);
}

.phone-speaker {
    width: 88px;
    height: 5px;
    border-radius: 999px;
    background: #374151;
    margin: 0 auto 10px;
}

.phone-screen {
    min-height: 660px;
    max-height: 760px;
    overflow-y: auto;
    border-radius: 24px;
    background: #ffffff;
}

.phone-hero {
    min-height: 170px;
    background: #eef6f6;
}

.phone-hero:empty {
    min-height: 64px;
}

.phone-hero img {
    width: 100%;
    height: 210px;
    object-fit: cover;
    display: block;
}

.phone-content {
    padding: 18px;
}

.phone-content h2 {
    margin: 12px 0 8px;
    font-size: 22px;
    line-height: 1.2;
}

.phone-excerpt {
    color: var(--text-soft);
    line-height: 1.5;
    margin: 0 0 16px;
}

.phone-body {
    color: var(--text);
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.article-list-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.article-list-title img {
    width: 54px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    flex: 0 0 auto;
}

.article-tags,
.hidden-tags {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.tag-more {
    border: 0;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font-weight: 700;
    padding: 0;
}

.article-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    white-space: nowrap;
}

.category-icon-preview {
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    overflow: hidden;
}

.category-icon-preview img,
.category-icon-preview svg {
    width: 24px;
    height: 24px;
    max-width: 24px;
    max-height: 24px;
    object-fit: contain;
    flex: 0 0 auto;
}

.category-manager {
    align-items: start;
}

.tag-manager {
    display: grid;
    gap: 16px;
}

.tag-form-card,
.phrase-form-card {
    max-width: none;
}

.phrase-manager {
    display: grid;
    gap: 16px;
}

.social-manager {
    display: grid;
    gap: 16px;
}

.social-form-card {
    max-width: none;
}

.social-icon-field {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.social-icon-preview {
    width: 44px;
    height: 44px;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8fbfb;
    color: var(--tenant-color, var(--primary));
    font-size: 20px;
    flex: 0 0 auto;
}

.social-icon-preview.small {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 16px;
}

.social-platform {
    display: flex;
    align-items: center;
    gap: 12px;
}

.social-link {
    display: inline-block;
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}

.book-form {
    display: grid;
    gap: 18px;
}

.book-form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 18px;
    align-items: start;
}

.book-main-card,
.book-label-card,
.book-builder-card,
.book-import-card {
    max-width: none;
}

.book-save-card {
    display: grid;
    gap: 12px;
    position: sticky;
    top: 96px;
}

.book-save-card h2 {
    margin: 0;
    font-size: 18px;
}

.book-builder-section {
    display: grid;
    gap: 12px;
    padding: 18px 0;
    border-top: 1px solid var(--line-soft);
}

.book-builder-section:first-of-type {
    border-top: 0;
}

.builder-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.builder-title-row h3,
.builder-title-row h4 {
    margin: 0;
}

.builder-title-row.small {
    margin-top: 12px;
}

.builder-title-row.small h4 {
    font-size: 14px;
}

.builder-card {
    position: relative;
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    background: #fbfdfd;
}

.builder-card.compact {
    margin-bottom: 10px;
}

.builder-card.nested {
    background: var(--panel);
    padding: 12px;
}

.section-card {
    margin-bottom: 14px;
    background: #f9fbfb;
}

.block-card {
    background: #ffffff;
}

.builder-card-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.builder-row-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.builder-card label {
    display: grid;
    gap: 6px;
    color: #464646;
    font-size: 13px;
    font-weight: 600;
}

.builder-card input,
.builder-card select,
.builder-card textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    min-height: 40px;
    padding: 9px 11px;
    background: #ffffff;
    color: var(--text);
}

.builder-card textarea {
    min-height: 86px;
    resize: vertical;
}

.builder-empty {
    padding: 14px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    color: var(--text-soft);
    background: #fbfdfd;
}

.json-preview-card {
    padding: 0;
}

.json-preview-card pre,
.json-preview-inline {
    margin: 0;
    padding: 18px;
    overflow: auto;
    color: var(--text);
    background: #0b1120;
    color: #e5edf7;
    font-size: 12px;
    line-height: 1.6;
}

.json-preview-inline {
    margin-top: 16px;
    border-radius: 12px;
    max-height: 460px;
}

.book-import-help {
    margin-top: 18px;
}

.book-help-body {
    padding: 18px 20px;
    color: var(--text-soft);
}

.book-help-body p {
    margin: 0 0 10px;
}

.has-error {
    border-color: var(--danger) !important;
}

.form-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.form-heading-row h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.form-heading-row p {
    margin: 0;
    color: var(--text-soft);
}

.category-icon-current,
.category-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.category-list-item strong,
.category-list-item span span {
    display: block;
}

.category-list-item .muted {
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-picker {
    position: relative;
}

.tag-picker-control {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    padding: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    cursor: text;
}

.field .tag-picker-control input {
    width: 160px;
    min-width: 140px;
    flex: 1 1 160px;
    min-height: 30px;
    border: 0;
    border-radius: 0;
    padding: 4px 6px;
    outline: none;
}

.tag-pills {
    display: contents;
}

.tag-pill {
    min-height: 30px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 10px;
    font-weight: 600;
}

.tag-pill button {
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-soft);
    cursor: pointer;
    line-height: 1;
}

.tag-suggestions {
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.12);
    padding: 6px;
}

.tag-suggestions button {
    width: 100%;
    min-height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 8px 10px;
    cursor: pointer;
}

.tag-suggestions button:hover {
    background: var(--primary-soft);
}

.help {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 18px;
}

.alert {
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    background: #ffffff;
}

.alert.success {
    background: #ecfdf3;
    border-color: #abefc6;
    color: #027a48;
}

.alert.error {
    background: #fef3f2;
    border-color: #fecdca;
    color: var(--danger);
}

.key-box,
.code-box {
    background: #111827;
    color: #f9fafb;
    border-radius: 12px;
    padding: 16px;
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
    background: var(--bg);
}

.auth-card {
    width: min(560px, 100%);
    background: #ffffff;
    border: 1px solid var(--line-soft);
    border-radius: 20px;
    padding: 28px;
}

.auth-card.wide {
    width: min(920px, 100%);
}

.pagination {
    padding: 16px 20px;
}

.pagination-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.pagination-summary {
    margin: 0;
}

.pagination-list {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination-link {
    min-width: 34px;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    line-height: 1.2;
    text-decoration: none;
}

.pagination-link.active {
    background: var(--tenant-color, var(--primary));
    border-color: var(--tenant-color, var(--primary));
    color: #ffffff;
}

.pagination-link.disabled,
.pagination-link.ellipsis {
    cursor: default;
    opacity: 0.64;
}

.inline-form {
    display: inline;
}

.cancel-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.cancel-form input {
    min-height: 40px;
    width: 190px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 12px;
}

.rating-stats {
    margin-bottom: 18px;
}

.rating-stars {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    color: #d4d4d4;
    font-size: 18px;
    line-height: 1;
    white-space: nowrap;
}

.rating-stars .filled {
    color: #f59e0b;
}

.rating-review {
    max-width: 420px;
    color: var(--text-soft);
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: normal;
}

.rating-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.notification-stats {
    margin-bottom: 18px;
}

.notification-form-card {
    max-width: 1040px;
}

.notification-form-card select[multiple] {
    min-height: 180px;
}

.notification-table-card {
    margin-top: 18px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 34px;
    color: var(--text);
    font-size: 14px;
}

.check-row input {
    width: 18px;
    min-height: 18px;
    height: 18px;
    flex: 0 0 auto;
    accent-color: var(--primary);
}

.mail-log-table td {
    height: auto;
}

.mail-log-details {
    margin-top: 8px;
}

.mail-log-details summary {
    color: var(--primary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.mail-log-details.danger summary {
    color: var(--danger);
}

.mail-log-details pre {
    max-width: 520px;
    margin: 8px 0 0;
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    padding: 10px;
    background: #fafafa;
    color: var(--text-soft);
    font: inherit;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.mail-filter-actions {
    justify-content: end;
}

.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.service-card {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.service-card-image {
    height: 190px;
    flex: 0 0 190px;
    position: relative;
    background: #eef3f4;
}

.service-card-image > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.service-card-placeholder,
.service-current-placeholder {
    width: 100%;
    height: 100%;
    min-height: 132px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #eef3f4;
    color: var(--text-muted);
}

.service-card-placeholder svg,
.service-current-placeholder svg {
    width: 28px;
    height: 28px;
}

.service-card-icon {
    position: absolute;
    left: 14px;
    bottom: -24px;
    width: 54px;
    height: 54px;
    border: 4px solid var(--panel);
    border-radius: 14px;
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 12px 24px rgba(17, 24, 39, 0.12);
}

.service-card-icon img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.service-card-body {
    padding: 34px 14px 14px;
    display: grid;
    gap: 14px;
    flex: 1;
}

.service-card-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.service-card-body h2 {
    margin: 0 0 8px;
    font-size: 16px;
    line-height: 1.35;
}

.service-card-body p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.service-form-card {
    max-width: 1040px;
}

.service-current-media {
    display: grid;
    grid-template-columns: minmax(0, 420px) 132px;
    gap: 16px;
    align-items: end;
}

.service-current-media .help {
    display: block;
    margin-bottom: 8px;
}

.service-current-icon {
    width: 132px;
    height: 132px;
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.service-current-icon img {
    width: 72px;
    height: 72px;
    object-fit: contain;
}

.service-current-icon svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.gallery-card {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.gallery-card-image {
    height: 210px;
    flex: 0 0 210px;
    background: #eef3f4;
}

.gallery-card-image img,
.gallery-current-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-card-body {
    padding: 14px;
    display: grid;
    gap: 14px;
    flex: 1;
}

.gallery-card-body h2 {
    margin: 0 0 6px;
    font-size: 15px;
    line-height: 1.35;
}

.gallery-card-body p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.gallery-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gallery-current-image {
    width: min(420px, 100%);
    aspect-ratio: 4 / 3;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    overflow: hidden;
    background: #eef3f4;
}

.gallery-upload-progress {
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    padding: 14px;
    background: #f8fbfb;
}

.gallery-upload-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    color: var(--text);
}

.gallery-upload-progress-header strong,
.gallery-upload-progress-header span {
    font-size: 13px;
    line-height: 1.4;
}

.gallery-upload-progress-track {
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: #dbe7e8;
}

.gallery-upload-progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--tenant-color);
    transition: width 180ms ease;
}

.gallery-upload-progress p {
    margin: 10px 0 0;
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.5;
}

.gallery-duplicate-stats {
    margin-bottom: 18px;
}

.gallery-duplicate-empty {
    padding: 22px;
}

.gallery-duplicate-empty p {
    margin: 8px 0 0;
}

.gallery-duplicate-actions {
    padding: 18px 20px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.gallery-duplicate-actions h2 {
    margin: 0 0 6px;
    font-size: 18px;
}

.gallery-duplicate-actions p {
    margin: 0;
}

.gallery-duplicate-list {
    display: grid;
    gap: 18px;
}

.gallery-duplicate-group {
    overflow: hidden;
}

.gallery-duplicate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
    padding: 18px;
}

.gallery-duplicate-card {
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    overflow: hidden;
    background: #ffffff;
    min-width: 0;
}

.gallery-duplicate-card.keeper {
    border-color: rgba(2, 175, 71, 0.35);
}

.gallery-duplicate-image {
    height: 150px;
    position: relative;
    background: #eef3f4;
}

.gallery-duplicate-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-duplicate-image .badge {
    position: absolute;
    top: 10px;
    left: 10px;
}

.gallery-duplicate-body {
    padding: 12px;
    display: grid;
    gap: 4px;
    overflow-wrap: anywhere;
}

.custom-field-value-cell {
    min-width: 320px;
    color: var(--text);
    vertical-align: top;
}

.json-field-value {
    max-width: 100%;
    color: var(--text);
}

.json-tree-node {
    border: 1px solid var(--line-soft);
    border-radius: 10px;
    background: #ffffff;
    overflow: hidden;
}

.json-tree-node + .json-tree-node,
.json-tree-leaf + .json-tree-node,
.json-tree-node + .json-tree-leaf {
    margin-top: 8px;
}

.json-tree-node summary {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.json-tree-node summary::-webkit-details-marker {
    display: none;
}

.json-tree-node summary::before {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--text-soft);
    border-bottom: 2px solid var(--text-soft);
    transform: rotate(-45deg);
    transition: transform 140ms ease;
    flex: 0 0 auto;
}

.json-tree-node[open] > summary::before {
    transform: rotate(45deg);
}

.json-tree-label {
    color: var(--text);
    font-weight: 700;
}

.json-tree-meta {
    color: var(--text-soft);
    font-size: 12px;
    line-height: 18px;
}

.json-tree-children {
    display: grid;
    gap: 8px;
    border-top: 1px solid var(--line-soft);
    padding: 10px 12px 12px 22px;
    background: #fafafa;
}

.json-tree-leaf {
    display: grid;
    grid-template-columns: minmax(100px, 180px) minmax(0, 1fr);
    gap: 10px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: #ffffff;
    padding: 8px 10px;
}

.json-tree-key {
    color: var(--text-soft);
    font-weight: 700;
}

.json-tree-scalar {
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.json-tree-empty {
    color: var(--text-soft);
    font-size: 12px;
    line-height: 18px;
    padding: 4px 0;
}

.profile-rating-card {
    display: grid;
    gap: 10px;
}

.profile-rating-card strong {
    font-size: 24px;
    line-height: 1;
}

.profile-rating-card p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.55;
}

.profile-stars {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: #d0d5dd;
}

.profile-stars svg {
    width: 18px;
    height: 18px;
}

.profile-stars .filled {
    color: #f59e0b;
    fill: currentColor;
}

.profile-timeline {
    display: grid;
    gap: 12px;
}

.profile-timeline-item {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 12px;
}

.profile-timeline-item strong {
    display: block;
    color: var(--text);
    margin-bottom: 6px;
}

.profile-timeline-item p {
    margin: 8px 0 0;
    color: var(--text-soft);
    line-height: 1.5;
}

.profile-timeline-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--text-soft);
    font-size: 12px;
    line-height: 18px;
}

.profile-article-list {
    display: grid;
    gap: 8px;
}

.profile-article-item {
    min-width: 0;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
}

.profile-article-item:hover {
    border-color: var(--tenant-color, var(--primary));
    background: var(--primary-soft);
}

.profile-article-item strong,
.profile-article-item small {
    display: block;
}

.profile-article-item strong {
    line-height: 1.35;
}

.profile-article-item small {
    color: var(--text-soft);
    font-size: 12px;
    line-height: 18px;
    margin-top: 3px;
}

.profile-article-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-soft);
    flex: 0 0 auto;
}

.profile-empty {
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: #ffffff;
}

.report-form-card {
    max-width: 1120px;
}

.report-builder-section {
    border: 1px solid var(--line-soft);
    border-radius: 16px;
    background: #fafafa;
    padding: 16px;
}

.report-builder-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.report-builder-heading h2 {
    margin: 0 0 4px;
    font-size: 18px;
}

.report-builder-heading p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.5;
}

.report-field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.report-field-option {
    min-height: 72px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    cursor: pointer;
}

.report-field-option:hover {
    border-color: var(--tenant-color, var(--primary));
}

.report-field-option input {
    position: absolute;
    width: 1px;
    min-height: 0;
    margin: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

.report-check {
    width: 24px;
    height: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.report-check svg {
    width: 14px;
    height: 14px;
}

.report-field-option input:checked + .report-check {
    background: var(--tenant-color, var(--primary));
    border-color: var(--tenant-color, var(--primary));
    color: #ffffff;
}

.report-field-option input:focus-visible + .report-check {
    outline: 3px solid rgba(11, 169, 170, 0.2);
    outline-offset: 2px;
}

.report-field-option strong,
.report-field-option small {
    display: block;
}

.report-field-option small {
    color: var(--text-soft);
    margin-top: 3px;
    overflow-wrap: anywhere;
}

.report-field-pills {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.report-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.report-empty {
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: #ffffff;
}

.report-run-form {
    margin-bottom: 18px;
}

.report-run-action .btn {
    width: fit-content;
}

.report-user-heading {
    display: flex;
    align-items: center;
    gap: 12px;
}

.report-user-heading h2 {
    margin: 0 0 2px;
    font-size: 18px;
}

.report-table td {
    height: auto;
    vertical-align: top;
}

.report-field-name strong,
.report-field-name span {
    display: block;
}

.report-value-cell {
    color: var(--text);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.report-value-link {
    color: var(--primary);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.report-json-map {
    display: grid;
    gap: 8px;
    margin: 0;
}

.report-json-map > div {
    display: grid;
    grid-template-columns: minmax(110px, 180px) minmax(0, 1fr);
    gap: 10px;
    border-bottom: 1px solid var(--line-soft);
    padding-bottom: 8px;
}

.report-json-map > div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.report-json-map dt {
    color: var(--text-soft);
    font-weight: 700;
}

.report-json-map dd {
    margin: 0;
    min-width: 0;
}

.report-json-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding-left: 18px;
}

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .card,
html[data-theme="dark"] .table-card,
html[data-theme="dark"] .calendar-card,
html[data-theme="dark"] .form-card,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .profile-hero-card,
html[data-theme="dark"] .profile-panel,
html[data-theme="dark"] .profile-metric-card,
html[data-theme="dark"] .gallery-card,
html[data-theme="dark"] .gallery-duplicate-card,
html[data-theme="dark"] .service-card,
html[data-theme="dark"] .social-icon-preview,
html[data-theme="dark"] .report-builder-section,
html[data-theme="dark"] .gallery-upload-progress {
    background: var(--panel);
    border-color: var(--line);
}

html[data-theme="dark"] .icon-button,
html[data-theme="dark"] .search-box,
html[data-theme="dark"] .profile-contact-tile,
html[data-theme="dark"] .profile-field-card,
html[data-theme="dark"] .profile-article-item,
html[data-theme="dark"] .display-picture-field,
html[data-theme="dark"] .profile-picture-card,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .editor-shell,
html[data-theme="dark"] .editor-toolbar button,
html[data-theme="dark"] .editor-toolbar select,
html[data-theme="dark"] .tag-picker-control,
html[data-theme="dark"] .tag-suggestions,
html[data-theme="dark"] .tag-suggestions button,
html[data-theme="dark"] .category-icon-preview,
html[data-theme="dark"] .service-card-icon,
html[data-theme="dark"] .service-current-icon,
html[data-theme="dark"] .json-tree-node,
html[data-theme="dark"] .json-tree-leaf,
html[data-theme="dark"] .report-field-option,
html[data-theme="dark"] .report-empty,
html[data-theme="dark"] .profile-empty,
html[data-theme="dark"] .pagination-link {
    background: #172033;
    border-color: var(--line);
    color: var(--text);
}

html[data-theme="dark"] .pagination-link.active {
    background: var(--tenant-color, var(--primary));
    border-color: var(--tenant-color, var(--primary));
    color: #ffffff;
}

html[data-theme="dark"] .icon-button:hover,
html[data-theme="dark"] .profile-article-item:hover,
html[data-theme="dark"] .tag-suggestions button:hover,
html[data-theme="dark"] .nav-link:hover,
html[data-theme="dark"] .nav-link.active {
    background: var(--primary-soft);
}

html[data-theme="dark"] .brand,
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .table-header,
html[data-theme="dark"] .calendar-header,
html[data-theme="dark"] .calendar-weekdays,
html[data-theme="dark"] .editor-toolbar,
html[data-theme="dark"] .json-tree-children {
    border-color: var(--line);
}

html[data-theme="dark"] .nav-label,
html[data-theme="dark"] .metric-label,
html[data-theme="dark"] .field label,
html[data-theme="dark"] .data-table th,
html[data-theme="dark"] .calendar-weekday,
html[data-theme="dark"] .profile-field-card-head small,
html[data-theme="dark"] .json-tree-key,
html[data-theme="dark"] .report-json-map dt {
    color: var(--text-soft);
}

html[data-theme="dark"] .data-table th,
html[data-theme="dark"] .calendar-weekdays,
html[data-theme="dark"] .editor-toolbar {
    background: #0f172a;
}

html[data-theme="dark"] .data-table th,
html[data-theme="dark"] .data-table td,
html[data-theme="dark"] .calendar-day,
html[data-theme="dark"] .calendar-weekdays,
html[data-theme="dark"] .calendar-booking,
html[data-theme="dark"] .report-json-map > div {
    border-color: var(--line);
}

html[data-theme="dark"] .data-table td {
    color: var(--text-soft);
}

html[data-theme="dark"] .calendar-day,
html[data-theme="dark"] .calendar-day.muted-month,
html[data-theme="dark"] .json-tree-children,
html[data-theme="dark"] .mail-log-details pre {
    background: #111a2b;
}

html[data-theme="dark"] .calendar-day.muted-month .calendar-date span {
    color: #64748b;
}

html[data-theme="dark"] .calendar-booking,
html[data-theme="dark"] .tag-pill {
    background: var(--primary-soft);
}

html[data-theme="dark"] .btn {
    background: #172033;
    border-color: var(--line);
}

html[data-theme="dark"] .btn.primary {
    background: var(--tenant-color, var(--primary));
    border-color: var(--tenant-color, var(--primary));
    color: #ffffff;
}

html[data-theme="dark"] .btn.ghost {
    background: transparent;
    border-color: transparent;
}

html[data-theme="dark"] .btn.danger {
    border-color: rgba(255, 138, 128, 0.45);
}

html[data-theme="dark"] .btn.support,
html[data-theme="dark"] .impersonation-banner {
    background: rgba(37, 99, 235, 0.16);
    border-color: rgba(96, 165, 250, 0.35);
    color: #bfdbfe;
}

html[data-theme="dark"] .impersonation-banner-copy span {
    color: #93c5fd;
}

html[data-theme="dark"] .impersonation-banner .btn {
    background: #111827;
    border-color: rgba(96, 165, 250, 0.5);
    color: #bfdbfe;
}

html[data-theme="dark"] .badge.neutral {
    background: #273244;
    color: #dbe5f3;
}

html[data-theme="dark"] .badge.info {
    background: rgba(37, 99, 235, 0.22);
    color: #bfdbfe;
}

html[data-theme="dark"] .badge.success,
html[data-theme="dark"] .alert.success {
    background: rgba(2, 122, 72, 0.22);
    color: #98f5c7;
    border-color: rgba(61, 220, 132, 0.3);
}

html[data-theme="dark"] .badge.danger,
html[data-theme="dark"] .alert.error {
    background: rgba(180, 35, 24, 0.22);
    color: #fecaca;
    border-color: rgba(255, 138, 128, 0.35);
}

html[data-theme="dark"] .alert {
    background: var(--panel);
    border-color: var(--line);
}

html[data-theme="dark"] .avatar,
html[data-theme="dark"] .display-picture-preview,
html[data-theme="dark"] .profile-avatar {
    background: #203044;
    color: var(--text);
}

html[data-theme="dark"] .profile-avatar {
    border-color: var(--panel);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .profile-contact-grid {
    background: var(--line);
    border-color: var(--line);
}

html[data-theme="dark"] .profile-contact-icon,
html[data-theme="dark"] .profile-metric-icon,
html[data-theme="dark"] .profile-timeline-icon {
    background: rgba(11, 169, 170, 0.16);
}

html[data-theme="dark"] .phone-frame,
html[data-theme="dark"] .key-box,
html[data-theme="dark"] .code-box {
    background: #020617;
}

html[data-theme="dark"] .phone-speaker {
    background: #334155;
}

html[data-theme="dark"] .gallery-card-image,
html[data-theme="dark"] .gallery-duplicate-image,
html[data-theme="dark"] .service-card-image,
html[data-theme="dark"] .service-card-placeholder,
html[data-theme="dark"] .service-current-placeholder,
html[data-theme="dark"] .gallery-current-image,
html[data-theme="dark"] .phone-hero,
html[data-theme="dark"] .gallery-upload-progress-track {
    background: #1e293b;
}

html[data-theme="dark"] .phone-screen,
html[data-theme="dark"] .phone-content {
    background: #ffffff;
    color: #292929;
}

html[data-theme="dark"] .phone-body,
html[data-theme="dark"] .phone-content h2 {
    color: #292929;
}

html[data-theme="dark"] .phone-excerpt {
    color: #656565;
}

html[data-theme="dark"] .tag-suggestions {
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #64748b;
}

.empty {
    padding: 32px;
    text-align: center;
    color: var(--text-soft);
}

.source-filter-bar {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 190px 150px auto auto;
    gap: 10px;
    margin-bottom: 16px;
}

.source-filter-bar input,
.source-filter-bar select {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text);
    padding: 9px 12px;
    font: inherit;
}

.source-search {
    position: relative;
}

.source-search svg {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--text-soft);
}

.source-search input {
    width: 100%;
    padding-left: 38px;
}

.source-title-cell {
    display: grid;
    gap: 4px;
    min-width: 280px;
}

.source-title-cell span {
    max-width: 520px;
    overflow: hidden;
    color: var(--text-soft);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-title-cell code,
.source-usage-link {
    color: var(--tenant-color, var(--primary));
}

.citation-picker {
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft, #f8fafc);
}

.citation-picker-head,
.citation-add-row,
.citation-item,
.citation-item-source,
.citation-item-actions {
    display: flex;
    align-items: center;
}

.citation-picker-head {
    justify-content: space-between;
    gap: 16px;
}

.citation-picker-head > div:first-child {
    display: grid;
    gap: 3px;
}

.citation-picker-head span,
.citation-item-source span,
.citation-empty {
    color: var(--text-soft);
    font-size: 13px;
}

.builder-citations {
    display: grid;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.builder-citation-list {
    display: grid;
    gap: 8px;
}

.builder-citation-item {
    display: grid;
    grid-template-columns: minmax(180px, .8fr) minmax(260px, 1.4fr) auto;
    gap: 12px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
}

.builder-citation-item > div:first-child,
.builder-citation-item label {
    display: grid;
    gap: 4px;
}

.builder-citation-item span,
.builder-citation-item label {
    color: var(--text-soft);
    font-size: 12px;
}

.builder-citation-item textarea {
    min-height: 54px;
}

.citation-add-row {
    gap: 10px;
}

.citation-add-row select {
    flex: 1;
}

.citation-list {
    display: grid;
    gap: 10px;
}

.citation-item {
    display: grid;
    grid-template-columns: minmax(220px, .8fr) minmax(280px, 1.4fr) auto;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
}

.citation-item-source {
    gap: 10px;
    min-width: 0;
}

.citation-item-source > div {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.citation-item-source strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.citation-order {
    display: grid;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--tenant-color, var(--primary));
    font-weight: 700;
}

.citation-item label {
    display: grid;
    gap: 6px;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 600;
}

.citation-item textarea {
    min-height: 62px;
    resize: vertical;
}

.citation-item-actions {
    gap: 6px;
}

.citation-empty {
    padding: 14px;
    border: 1px dashed var(--line);
    border-radius: 6px;
    text-align: center;
}

html[data-theme="dark"] .citation-picker {
    background: #111a2b;
}

@media (max-width: 1040px) {
    .citation-picker-head,
    .citation-add-row {
        align-items: stretch;
        flex-direction: column;
    }

    .citation-item {
        grid-template-columns: 1fr;
    }

    .builder-citation-item {
        grid-template-columns: 1fr;
    }
}

.btn-row.nowrap {
    flex-wrap: nowrap;
}

html[data-theme="dark"] .source-filter-bar input,
html[data-theme="dark"] .source-filter-bar select {
    background: var(--panel);
    border-color: var(--line);
}

@media (max-width: 1040px) {
    .source-filter-bar {
        grid-template-columns: 1fr;
    }
}

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

    .impersonation-banner {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }

    .impersonation-banner .btn {
        width: 100%;
    }

    .sidebar {
        position: static;
        min-height: auto;
    }

    .nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding: 12px;
    }

    .nav-label {
        display: none;
    }

    .nav-link {
        white-space: nowrap;
    }

    .grid.stats,
    .grid.two,
    .form-grid,
    .article-workspace,
    .profile-form-layout,
    .profile-contact-grid,
    .profile-metric-grid,
    .profile-content-grid,
    .profile-field-grid,
    .service-current-media,
    .json-tree-leaf,
    .report-json-map > div {
        grid-template-columns: 1fr;
    }

    .profile-hero-main,
    .profile-identity {
        align-items: flex-start;
        flex-direction: column;
    }

    .profile-identity {
        margin-top: -56px;
    }

    .profile-hero-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .phone-preview {
        position: static;
    }

    .topbar {
        height: auto;
        align-items: flex-start;
        flex-direction: column;
    }

    .calendar-header,
    .top-actions {
        width: 100%;
    }

    .calendar-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .calendar-header .btn-row {
        justify-content: space-between;
    }

    .top-actions {
        justify-content: space-between;
    }
}
