:root {
    --dt-primary: #d21249;
    --dt-primary-dark: #a90f3b;
    --dt-primary-soft: #fde8f0;
    --dt-blue: #155dfc;
    --dt-blue-soft: #eaf2ff;
    --dt-red: #e11d48;
    --dt-ink: #111827;
    --dt-text: #334155;
    --dt-muted: #667085;
    --dt-line: #dfe5ee;
    --dt-line-strong: #cbd5e1;
    --dt-page: #f7f8fb;
    --dt-surface: #ffffff;
    --dt-row: #f9fafb;
    --dt-row-active: #e8f1ff;
    --dt-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.04);
    --dt-sidebar: 264px;
    --dt-sidebar-collapsed: 84px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    background: var(--dt-page);
    color: var(--dt-text);
    font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.94rem;
    letter-spacing: 0;
    margin: 0;
}

a {
    color: var(--dt-primary);
}

.portal-shell {
    display: grid;
    grid-template-columns: var(--dt-sidebar) minmax(0, 1fr);
    min-height: 100vh;
}

.portal-sidebar {
    background: var(--dt-surface);
    border-right: 1px solid var(--dt-line);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: sticky;
    top: 0;
    z-index: 20;
}

.sidebar-collapse-toggle {
    align-items: center;
    background: var(--dt-surface);
    border: 1px solid var(--dt-line);
    border-radius: 999px;
    color: #667085;
    display: inline-flex;
    height: 30px;
    justify-content: center;
    position: absolute;
    right: -15px;
    top: 54px;
    width: 30px;
    z-index: 999;
}

.sidebar-collapse-toggle:hover {
    background: #f8fafc;
    color: var(--dt-ink);
}

.portal-shell.is-sidebar-collapsed {
    grid-template-columns: var(--dt-sidebar-collapsed) minmax(0, 1fr);
}

.portal-shell.is-sidebar-collapsed .sidebar-collapse-toggle i {
    transform: rotate(180deg);
}

.portal-shell.is-sidebar-collapsed .portal-brand {
    justify-content: center;
    padding: 0;
}

.portal-shell.is-sidebar-collapsed .portal-brand > span:last-child,
.portal-shell.is-sidebar-collapsed .portal-nav-link span,
.portal-shell.is-sidebar-collapsed .portal-section-title,
.portal-shell.is-sidebar-collapsed .portal-user > span:last-child {
    display: none;
}

.portal-shell.is-sidebar-collapsed .portal-nav,
.portal-shell.is-sidebar-collapsed .portal-sidebar-section {
    justify-items: center;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}

.portal-shell.is-sidebar-collapsed .portal-nav-link {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    width: 100%;
}

.portal-shell.is-sidebar-collapsed .portal-user {
    justify-content: center;
    min-height: 64px;
    padding: 0;
}

.portal-brand {
    align-items: center;
    border-bottom: 1px solid var(--dt-line);
    color: var(--dt-ink);
    display: flex;
    gap: 0.75rem;
    min-height: 70px;
    padding: 0 1.25rem;
    text-decoration: none;
}

.brand-mark {
    align-items: center;
    background: var(--dt-primary-soft);
    border-radius: 8px;
    color: var(--dt-primary);
    display: inline-flex;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.brand-mark img {
    display: block;
    height: 22px;
    width: 22px;
}

.portal-brand strong,
.portal-user strong {
    display: block;
    font-size: 1rem;
    line-height: 1.1;
}

.portal-brand small,
.portal-user small {
    color: var(--dt-muted);
    display: block;
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

.portal-nav,
.portal-sidebar-section {
    display: grid;
    gap: 0.25rem;
    padding: 1rem 0.75rem 0;
}

.portal-sidebar-section {
    margin-top: 0.75rem;
}

.portal-section-title {
    color: #98a2b3;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.75rem 0.75rem 0.35rem;
    text-transform: uppercase;
}

.portal-nav-link {
    align-items: center;
    border-radius: 8px;
    border: 0;
    color: #344054;
    display: flex;
    font-weight: 600;
    gap: 0.7rem;
    min-height: 38px;
    padding: 0.55rem 0.75rem;
    text-decoration: none;
}

.portal-nav-button {
    background: transparent;
    font: inherit;
    text-align: left;
}

.portal-nav-button:disabled {
    color: #98a2b3;
    cursor: not-allowed;
    opacity: 0.75;
}

.portal-nav-link:hover {
    background: #f2f4f7;
    color: var(--dt-ink);
}

.portal-nav-button:disabled:hover {
    background: transparent;
    color: #98a2b3;
}

.portal-nav-link.active {
    background: var(--dt-primary-soft);
    color: var(--dt-primary);
}

.portal-nav-link i,
.portal-topbar i,
.btn i,
.brand-mark i,
.portal-avatar i {
    font-size: 0.95rem;
    line-height: 1;
    text-align: center;
}

.portal-user {
    align-items: center;
    border-top: 1px solid var(--dt-line);
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
    min-height: 78px;
    padding: 0 1.25rem;
}

.portal-avatar {
    align-items: center;
    background: #eef2f7;
    border-radius: 999px;
    color: #667085;
    display: inline-flex;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.portal-main {
    min-width: 0;
}

.modal-backdrop {
    z-index: 1990;
}

.modal {
    z-index: 2000;
}

.btn.portal-mobile-menu-button,
.portal-mobile-nav-backdrop,
.portal-topbar-brand,
.portal-mobile-nav-tools {
    display: none;
}

.portal-topbar {
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--dt-line);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    min-height: 70px;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.portal-global-search {
    align-items: center;
    background: var(--dt-surface);
    border: 1px solid var(--dt-line);
    border-radius: 12px;
    color: #98a2b3;
    display: flex;
    gap: 0.6rem;
    height: 40px;
    max-width: 420px;
    padding: 0 0.8rem;
    width: min(42vw, 420px);
}

.portal-global-search input {
    border: 0;
    color: var(--dt-text);
    min-width: 0;
    outline: 0;
    width: 100%;
}

.portal-topbar-actions {
    align-items: center;
    display: flex;
    gap: 0.75rem;
}

.portal-status {
    background: #f2f4f7;
    border: 1px solid var(--dt-line);
    border-radius: 999px;
    color: #475467;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.3rem 0.65rem;
}

.portal-content {
    padding: 1.5rem;
}

.page-header {
    align-items: start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.page-header h1 {
    color: var(--dt-ink);
    font-size: 1.55rem;
    font-weight: 750;
    line-height: 1.2;
    margin: 0;
}

.page-header p {
    color: var(--dt-muted);
    margin: 0.25rem 0 0;
}

.page-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: end;
}

.btn {
    align-items: center;
    border-radius: 8px;
    display: inline-flex;
    font-weight: 700;
    gap: 0.45rem;
}

.btn-primary {
    background: var(--dt-primary);
    border-color: var(--dt-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--dt-primary-dark);
    border-color: var(--dt-primary-dark);
}

.btn.copy-ok {
    background: var(--dt-primary-soft);
    border-color: #f7b4ca;
    color: var(--dt-primary);
}

.surface,
.content-panel,
.auth-panel,
.module-tile {
    background: var(--dt-surface);
    border: 1px solid var(--dt-line);
    border-radius: 8px;
    box-shadow: var(--dt-shadow);
}

.content-panel,
.surface {
    padding: 1rem;
}

.search-card {
    margin-bottom: 1rem;
    padding: 0.75rem;
}

.search-bar {
    align-items: center;
    display: flex;
    gap: 0.65rem;
    margin: 0;
    max-width: none;
}

.search-bar .form-control {
    border-color: var(--dt-line);
    border-radius: 8px;
    min-height: 38px;
}

.workbench {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
}

.workbench-wide {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr);
}

.list-panel {
    min-width: 0;
    overflow: hidden;
    padding: 0;
}

.panel-header {
    align-items: center;
    border-bottom: 1px solid var(--dt-line);
    display: flex;
    justify-content: space-between;
    min-height: 52px;
    padding: 0.8rem 1rem;
}

.panel-header h2,
.detail-panel h2,
.module-tile span {
    color: var(--dt-ink);
    font-size: 1rem;
    font-weight: 750;
    margin: 0;
}

.record-count {
    color: var(--dt-muted);
    font-size: 0.8rem;
}

.table-responsive {
    max-height: calc(100vh - 260px);
    overflow: auto;
}

.table {
    --bs-table-bg: transparent;
    background: var(--dt-surface);
    border: 0;
    margin: 0;
}

.table thead th {
    background: #f8fafc;
    border-bottom: 1px solid var(--dt-line);
    color: #475467;
    font-size: 0.73rem;
    font-weight: 500;
    height: 40px;
    letter-spacing: 0;
    position: sticky;
    text-transform: uppercase;
    top: 0;
    z-index: 1;
}

.table th,
.table td {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.table th:first-child,
.table td:first-child {
    padding-left: 1rem;
}

.table th:last-child,
.table td:last-child {
    padding-right: 1rem;
}

.table tbody td {
    border-bottom: 1px solid #edf1f6;
    color: #243040;
    height: 42px;
    vertical-align: middle;
}

.table tbody tr:nth-child(even) {
    background: var(--dt-row);
}

.table tbody tr:hover {
    background: var(--dt-row-active);
}

.table strong {
    color: var(--dt-ink);
    font-weight: 750;
}

.text-col {
    max-width: 28rem;
}

.detail-panel {
    align-self: start;
    display: grid;
    gap: 1rem;
    padding: 1rem;
}

.detail-block {
    display: grid;
    gap: 0.35rem;
}

.detail-label {
    color: #667085;
    font-size: 0.73rem;
    font-weight: 800;
    text-transform: uppercase;
}

.detail-value {
    background: #f8fafc;
    border: 1px solid var(--dt-line);
    border-radius: 8px;
    color: var(--dt-ink);
    min-height: 38px;
    padding: 0.55rem 0.65rem;
}

.module-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.module-tile {
    color: inherit;
    display: grid;
    gap: 0.6rem;
    min-height: 118px;
    padding: 1rem;
    text-decoration: none;
}

.module-tile-button {
    appearance: none;
    cursor: not-allowed;
    font: inherit;
    text-align: left;
}

.module-tile-button:disabled {
    opacity: 0.72;
}

.module-tile:hover {
    border-color: #b8ccff;
    transform: translateY(-1px);
}

.module-tile-button:disabled:hover {
    border-color: var(--dt-line);
    transform: none;
}

.module-tile small {
    color: var(--dt-muted);
}

.module-icon {
    align-items: center;
    background: var(--dt-primary-soft);
    border-radius: 8px;
    color: var(--dt-primary);
    display: inline-flex;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.dashboard-header {
    margin-bottom: 1.35rem;
}

.dashboard-metric-grid {
    display: grid;
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.dashboard-metric-grid.primary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-metric-grid.secondary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-metric {
    align-items: center;
    display: flex;
    gap: 0.95rem;
    min-height: 92px;
    padding: 1rem;
}

.dashboard-metric.compact {
    min-height: 78px;
}

.dashboard-metric small {
    color: #667085;
    display: block;
    font-size: 0.84rem;
    margin-bottom: 0.1rem;
}

.dashboard-metric strong {
    color: var(--dt-ink);
    display: block;
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1;
}

.dashboard-metric-icon {
    align-items: center;
    border-radius: 8px;
    display: inline-flex;
    flex: 0 0 42px;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.dashboard-metric-icon.red,
.dashboard-action.red {
    background: var(--dt-primary-soft);
    color: var(--dt-primary);
}

.dashboard-metric-icon.blue,
.dashboard-action.blue {
    background: #eaf1ff;
    color: #1f5cff;
}

.dashboard-metric-icon.green {
    background: #e7f8ef;
    color: #0f9f5d;
}

.dashboard-metric-icon.amber {
    background: #fff4d8;
    color: #b77900;
}

.dashboard-metric-icon.cyan {
    background: #dcf8fd;
    color: #0891b2;
}

.dashboard-metric-icon.purple {
    background: #f2e8ff;
    color: #7c3aed;
}

.dashboard-metric-icon.slate,
.dashboard-action.slate {
    background: #eef2f6;
    color: #475467;
}

.dashboard-workbench {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
    margin-bottom: 1rem;
}

.dashboard-panel {
    overflow: hidden;
    padding: 0;
}

.dashboard-panel .panel-header {
    min-height: 72px;
}

.dashboard-panel .panel-header p {
    color: var(--dt-muted);
    font-size: 0.86rem;
    margin: 0.25rem 0 0;
}

.dashboard-panel-link {
    align-items: center;
    color: var(--dt-primary);
    display: inline-flex;
    font-size: 0.86rem;
    gap: 0.25rem;
    text-decoration: none;
}

.dashboard-activity-list {
    display: grid;
    min-height: 210px;
    padding: 0.7rem 1rem 1rem;
}

.dashboard-activity-item {
    align-items: center;
    border-bottom: 1px solid #edf1f6;
    color: inherit;
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    min-height: 52px;
    text-decoration: none;
}

.dashboard-activity-item:last-child {
    border-bottom: 0;
}

a.dashboard-activity-item {
    border-radius: 8px;
    margin-left: -0.35rem;
    margin-right: -0.35rem;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

a.dashboard-activity-item:hover {
    background: #f8fafc;
}

.dashboard-activity-item strong {
    color: var(--dt-ink);
    display: block;
    font-size: 0.92rem;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-activity-item small,
.dashboard-activity-item time {
    color: var(--dt-muted);
    font-size: 0.78rem;
}

.dashboard-activity-icon {
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--dt-line);
    border-radius: 8px;
    color: #667085;
    display: inline-flex;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.dashboard-empty {
    align-self: center;
    color: var(--dt-muted);
    justify-self: center;
}

.dashboard-action-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 1rem;
}

.dashboard-action {
    align-items: center;
    border-radius: 8px;
    display: inline-flex;
    font-weight: 650;
    gap: 0.55rem;
    min-height: 48px;
    padding: 0.75rem 0.85rem;
    text-decoration: none;
}

.dashboard-attention {
    margin-bottom: 1rem;
}

.dashboard-table {
    max-height: none;
}

.status-pill {
    border-radius: 999px;
    display: inline-flex;
    font-size: 0.75rem;
    font-weight: 650;
    line-height: 1.15;
    min-width: max-content;
    padding: 0.34rem 0.65rem;
    white-space: nowrap;
}

.status-pill.ready {
    background: #e7f8ef;
    color: #087443;
}

.status-pill.in-progress {
    background: #fff0c2;
    color: #624500;
}

.status-pill.muted {
    background: #eef2f6;
    color: #475467;
}

.table-actions {
    align-items: center;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: flex-end;
}

.table-actions form {
    margin: 0;
}

.user-form {
    display: grid;
    gap: 1rem;
    max-width: 640px;
    padding: 1rem;
}

.user-form label {
    color: #475467;
    font-size: 0.78rem;
    font-weight: 500;
}

.form-actions {
    align-items: center;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.auth-main {
    background: url("/login-bg.jpg") center / cover no-repeat;
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1rem;
}

.auth-shell {
    display: grid;
    width: 100%;
}

.auth-panel {
    max-width: 27rem;
    margin: 0 auto;
    padding: 1.25rem;
    width: 100%;
}

.auth-panel h1 {
    color: var(--dt-ink);
    font-size: 1.45rem;
    font-weight: 750;
    margin-bottom: 1rem;
}

.auth-panel .portal-brand {
    gap: 0.85rem;
    margin-bottom: 1.6rem !important;
}

.auth-panel .brand-mark {
    height: 42px;
    width: 42px;
}

.auth-panel .brand-mark img {
    height: 27px;
    width: 27px;
}

.auth-panel .portal-brand strong {
    font-size: 1.12rem;
}

.auth-panel .portal-brand small {
    font-size: 0.84rem;
}

.auth-credit {
    color: var(--dt-muted);
    font-size: 0.82rem;
    margin: 0.85rem auto 0;
    max-width: 27rem;
    text-align: center;
}

.auth-credit a {
    color: var(--dt-primary);
    font-weight: 650;
    text-decoration: none;
}

.auth-credit a:hover {
    text-decoration: underline;
}

.form-control,
.form-select {
    border-color: var(--dt-line);
    border-radius: 8px;
}

.wysiwyg-lite {
    min-height: 18rem;
}

@media (max-width: 980px) {
    .portal-shell {
        grid-template-columns: 1fr;
    }

    .portal-sidebar {
        border-right: 0;
        box-shadow: var(--dt-shadow);
        left: 0;
        max-width: min(86vw, 340px);
        min-height: 100vh;
        position: fixed;
        top: 0;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        width: 100%;
        z-index: 1101;
    }

    .sidebar-collapse-toggle {
        display: none;
    }

    .portal-shell.is-mobile-nav-open .portal-sidebar {
        transform: translateX(0);
    }

    .portal-mobile-nav-backdrop {
        background: rgba(15, 23, 42, 0.45);
        display: none;
        inset: 0;
        position: fixed;
        z-index: 1100;
    }

    .portal-shell.is-mobile-nav-open .portal-mobile-nav-backdrop {
        display: block;
    }

    .portal-user {
        display: none;
    }

    .portal-topbar {
        align-items: center;
        justify-content: space-between;
        padding: 0.75rem 1rem;
    }

    .btn.portal-mobile-menu-button {
        display: inline-flex;
        margin-left: auto;
    }

    .portal-topbar-brand {
        align-items: center;
        color: var(--dt-ink);
        display: inline-flex;
        gap: 0.6rem;
        text-decoration: none;
    }

    .portal-topbar-brand strong {
        display: block;
        font-size: 0.98rem;
        line-height: 1.1;
    }

    .portal-topbar-brand small {
        color: var(--dt-muted);
        display: block;
        font-size: 0.75rem;
    }

    .portal-global-search {
        display: none;
    }

    .portal-topbar-actions {
        display: none;
    }

    .portal-status {
        display: none;
    }

    .portal-mobile-nav-tools {
        border-top: 1px solid var(--dt-line);
        display: grid;
        gap: 0.65rem;
        margin-top: 0.75rem;
        padding: 0.85rem 0.75rem 1rem;
    }

    .portal-mobile-nav-tools .portal-global-search {
        display: flex;
        max-width: none;
        width: 100%;
    }

    .portal-content {
        padding: 1rem;
    }

    .dashboard-metric-grid.primary,
    .dashboard-metric-grid.secondary,
    .dashboard-workbench {
        grid-template-columns: 1fr;
    }

    body.mobile-nav-open {
        overflow: hidden;
    }

    .workbench {
        grid-template-columns: 1fr;
        width: 100%;
    }
}

@media (max-width: 640px) {
    .portal-content {
        padding: 1rem;
    }

    .page-header {
        display: grid;
    }

    .dashboard-action-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-activity-item {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .dashboard-activity-item time {
        grid-column: 2;
    }

    .table-responsive {
        max-height: none;
    }
}

.customer-workspace {
    display: grid;
    gap: 1rem;
    grid-template-columns: 360px minmax(0, 1fr);
    height: calc(100vh - 118px);
    min-height: 0;
}

.customer-list-panel {
    align-self: stretch;
    display: grid;
    gap: 0.75rem;
    grid-column: 1;
    grid-row: 1;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    min-height: 0;
    padding: 1rem;
}

.customer-list-title.page-header {
    align-items: center;
    margin-bottom: 0;
}

.customer-list-title.page-header h1 {
    font-weight: 650;
}

.customer-search {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: minmax(0, 1fr) auto;
}

.customer-list-meta {
    border-top: 1px solid var(--dt-line);
    color: var(--dt-muted);
    font-size: 0.8rem;
    padding-top: 0.1rem;
}

.customer-list {
    border-radius: 8px;
    min-height: 0;
    overflow: auto;
}

.customer-list-item {
    border-radius: 0;
    color: var(--dt-text);
    display: grid;
    gap: 0.2rem;
    min-height: 58px;
    padding: 0.7rem 0.75rem;
    text-decoration: none;
}

.customer-list-item:nth-child(even) {
    background: var(--dt-row);
}

.customer-list-item:hover {
    background: #eef4ff;
}

.customer-list-item.active {
    background: var(--dt-primary);
    color: #fff;
}

.customer-list-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.customer-list-item small {
    color: inherit;
    opacity: 0.78;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.customer-detail-shell {
    grid-column: 2;
    grid-row: 1;
    height: 100%;
    min-width: 0;
    overflow: auto;
}

.customer-detail-view {
    display: grid;
    gap: 1rem;
}

.customer-empty-state {
    align-items: center;
    color: var(--dt-muted);
    display: grid;
    justify-items: center;
    min-height: 320px;
    padding: 2rem;
    text-align: center;
}

.customer-empty-state i {
    color: #98a2b3;
    font-size: 2rem;
    margin-bottom: 0.7rem;
}

.customer-detail-header {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.customer-action-stack {
    display: grid;
    gap: 0.55rem;
    justify-items: end;
}

.customer-title-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.customer-detail-header h2 {
    color: var(--dt-ink);
    font-size: 1.6rem;
    font-weight: 650;
    margin: 0;
}

.customer-number-badge {
    background: #eef2f7;
    border: 1px solid var(--dt-line);
    border-radius: 999px;
    color: var(--dt-muted);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.28rem 0.65rem;
}

.customer-detail-header p {
    color: var(--dt-muted);
    margin: 0.55rem 0 0;
}

.customer-detail-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(300px, 0.9fr) minmax(300px, 0.85fr) minmax(520px, 1.5fr);
}

.customer-card {
    min-width: 0;
    overflow: hidden;
    padding: 0;
}

.panel-header.compact {
    min-height: 58px;
}

.panel-header.compact h2 {
    align-items: center;
    display: flex;
    gap: 0.65rem;
    font-weight: 600;
}

.panel-header.compact h2 i {
    color: var(--dt-muted);
}

.field-grid {
    display: grid;
    gap: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0.8rem 1rem 1.1rem;
}

.field-row {
    display: grid;
    gap: 0.35rem;
    padding: 0.55rem 0;
}

.field-row.full {
    grid-column: 1 / -1;
}

.field-row span {
    color: #475467;
    font-size: 0.75rem;
    font-weight: 500;
}

.customer-field {
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--dt-line);
    border-radius: 0;
    color: var(--dt-ink);
    min-height: 31px;
    outline: 0;
    padding: 0 0 0.35rem;
    width: 100%;
}

textarea.customer-field {
    min-height: 3.4rem;
    resize: vertical;
}

.customer-field[readonly] {
    cursor: default;
}

.customer-detail-view.is-editing .customer-field:not([readonly]),
.customer-field:not([readonly]):focus {
    border-bottom-color: var(--dt-primary);
    background: #fff;
}

.customer-flags {
    display: flex;
    gap: 0.5rem;
    grid-column: 1 / -1;
    padding-top: 0.8rem;
}

.flag {
    background: #f2f4f7;
    border: 1px solid var(--dt-line);
    border-radius: 999px;
    color: #667085;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35rem 0.7rem;
}

.flag-toggle {
    align-items: center;
    cursor: default;
    display: inline-flex;
    gap: 0.35rem;
    margin: 0;
}

.flag-toggle input {
    display: none;
}

.customer-detail-view.is-editing .flag-toggle {
    cursor: pointer;
}

.flag.on {
    background: var(--dt-primary-soft);
    border-color: #f7b4ca;
    color: var(--dt-primary);
}

.contacts-card {
    grid-column: 3;
}

.relations-card {
    grid-column: 1 / span 2;
}

.note-card {
    grid-column: 3;
    display: flex;
    flex-direction: column;
}

.contacts-table {
    max-height: 330px;
}

.contact-name {
    color: var(--dt-ink);
    font-weight: 500;
}

.contact-name-wrap {
    align-items: center;
    display: inline-flex;
    gap: 0.35rem;
    min-width: 0;
}

.contact-edit-button {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 999px;
    color: var(--dt-muted);
    display: inline-flex;
    height: 1.75rem;
    justify-content: center;
    opacity: 0;
    padding: 0;
    transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;
    width: 1.75rem;
}

.contacts-table tbody tr:hover .contact-edit-button,
.contact-edit-button:focus-visible {
    opacity: 1;
}

.contact-edit-button:hover,
.contact-edit-button:focus-visible {
    background: var(--dt-primary-soft);
    color: var(--dt-primary);
    outline: 0;
}

.contact-edit-modal .modal-title {
    color: var(--dt-ink);
    font-size: 1rem;
    font-weight: 600;
}

.contact-modal-grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-field {
    display: grid;
    gap: 0.35rem;
}

.form-field.full {
    grid-column: 1 / -1;
}

.form-field span {
    color: #475467;
    font-size: 0.75rem;
    font-weight: 500;
}

.field-value-static {
    background: #f8fafc;
    border: 1px solid var(--dt-line);
    border-radius: 8px;
    color: var(--dt-ink);
    min-height: 38px;
    padding: 0.5rem 0.7rem;
}

.offers-modal .modal-title {
    color: var(--dt-ink);
    font-size: 1rem;
    font-weight: 600;
}

.offers-modal-body {
    padding: 1rem;
}

.offers-layout {
    display: grid;
    gap: 1rem;
    grid-template-columns: 320px minmax(0, 1fr);
}

.offers-list-pane {
    align-content: start;
    display: grid;
    gap: 0.7rem;
    grid-template-rows: auto minmax(0, 1fr);
}

.offers-list-pane [data-create-offer] {
    justify-content: center;
    min-height: 38px;
}

.offers-list {
    border: 1px solid var(--dt-line);
    border-radius: 8px;
    max-height: 420px;
    overflow: auto;
}

.offer-list-item {
    background: transparent;
    border: 0;
    border-bottom: 1px solid #edf1f6;
    color: var(--dt-text);
    display: grid;
    gap: 0.15rem;
    padding: 0.6rem 0.75rem;
    text-align: left;
    width: 100%;
}

.offer-list-item:last-child {
    border-bottom: 0;
}

.offer-list-item:hover {
    background: #f8fafc;
}

.offer-list-item.active {
    background: var(--dt-primary-soft);
    color: var(--dt-primary);
}

.offer-item-title {
    font-weight: 600;
}

.offer-item-sub {
    color: var(--dt-muted);
    font-size: 0.78rem;
}

.offers-edit-pane {
    border: 1px solid var(--dt-line);
    border-radius: 8px;
    display: grid;
    gap: 0.8rem;
    padding: 0.9rem;
}

.offers-fields {
    display: grid;
    gap: 0.8rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.offers-actions {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

.offers-actions-right {
    display: flex;
    gap: 0.5rem;
}

.relation-grid {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 1rem;
}

.relation-grid h3 {
    color: var(--dt-ink);
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 0.7rem;
}

.relation-row {
    border-bottom: 1px solid var(--dt-line);
    display: grid;
    gap: 0.15rem;
    padding: 0.5rem 0;
}

.relation-id {
    color: var(--dt-ink);
    font-weight: 600;
}

.relation-row span,
.relation-row small,
.empty-copy {
    color: var(--dt-muted);
}

.relation-row small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.customer-note {
    border: 0;
    border-radius: 0;
    flex: 1;
    min-height: 320px;
    padding: 1rem;
    resize: vertical;
}

.customer-note.is-dirty {
    box-shadow: inset 3px 0 0 var(--dt-primary);
}

.customer-danger-actions {
    display: flex;
    grid-column: 3;
    justify-content: flex-end;
}

.machine-group-type-filter {
    min-width: 180px;
}

.machine-group-layout {
    display: grid;
    gap: 1rem;
    grid-template-columns: 360px minmax(0, 1fr);
}

.machine-group-general-card,
.machine-group-wordpress-card {
    grid-column: 1;
}

.machine-group-questions-card {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.machine-group-questions-card .contacts-table {
    min-height: calc(100vh - 260px);
}

.wordpress-links {
    display: grid;
    gap: 0.55rem;
    padding: 0.8rem 1rem 1rem;
}

.wordpress-relation-link {
    align-items: center;
    border: 1px solid var(--dt-line);
    border-radius: 8px;
    color: var(--dt-text);
    display: flex;
    justify-content: space-between;
    min-height: 40px;
    padding: 0.45rem 0.6rem;
    text-decoration: none;
}

.wordpress-relation-link:hover {
    background: #f8fafc;
    color: var(--dt-ink);
}

.wordpress-relation-link strong {
    background: var(--dt-primary-soft);
    border-radius: 999px;
    color: var(--dt-primary);
    font-size: 0.78rem;
    padding: 0.22rem 0.55rem;
}

.question-table .question-drag-column {
    width: 36px;
}

.question-drag-handle {
    background: transparent;
    border: 0;
    color: #98a2b3;
    cursor: default;
    opacity: 0.3;
    padding: 0.2rem;
}

.question-sort-unlocked .question-drag-handle {
    color: var(--dt-primary);
    cursor: grab;
    opacity: 1;
}

.question-sort-unlocked [data-question-sort-item] {
    cursor: grab;
}

.question-sort-unlocked [data-question-sort-item].is-dragging {
    cursor: grabbing;
    opacity: 0.72;
}

.question-sort-unlocked [data-question-sort-item].is-drag-over {
    box-shadow: inset 0 2px 0 var(--dt-primary);
}

.question-drag-active {
    cursor: grabbing;
    user-select: none;
}

.customer-mobile-filter-toggle,
.customer-mobile-backdrop {
    display: none;
}

@media (max-width: 1500px) {
    .customer-detail-grid {
        grid-template-columns: repeat(2, minmax(280px, 1fr));
    }

    .contacts-card,
    .relations-card,
    .note-card,
    .customer-danger-actions {
        grid-column: 1 / -1;
    }

    .machine-group-layout {
        grid-template-columns: 360px minmax(0, 1fr);
    }
}

@media (max-width: 1100px) {
    .customer-workspace {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 0;
    }

    .customer-list-panel,
    .customer-detail-shell {
        grid-column: 1;
        grid-row: auto;
    }

    .customer-detail-shell {
        height: auto;
        overflow: visible;
    }

    .customer-list {
        max-height: 360px;
    }

    .customer-list-panel {
        min-height: auto;
    }

    .machine-group-layout {
        grid-template-columns: 1fr;
    }

    .machine-group-general-card,
    .machine-group-wordpress-card,
    .machine-group-questions-card {
        grid-column: 1;
        grid-row: auto;
    }
}

@media (max-width: 760px) {
    .customer-detail-grid,
    .field-grid,
    .relation-grid,
    .contact-modal-grid,
    .offers-layout,
    .offers-fields {
        grid-template-columns: 1fr;
    }

    .customer-detail-header {
        align-items: start;
        display: grid;
    }

    .customer-detail-header > div:first-child {
        order: 2;
    }

    .customer-action-stack {
        justify-items: start;
        order: 1;
        width: 100%;
    }

    .customer-action-stack .page-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .customer-list-panel {
        display: none;
    }

    .customer-mobile-filter-toggle {
        align-items: center;
        border-radius: 999px;
        bottom: 1rem;
        box-shadow: 0 10px 25px rgba(16, 24, 40, 0.2);
        display: inline-flex;
        left: 50%;
        position: fixed;
        transform: translateX(-50%);
        z-index: 1062;
    }

    .customer-mobile-backdrop {
        background: rgba(16, 24, 40, 0.5);
        inset: 0;
        position: fixed;
        z-index: 1060;
    }

    .customer-workspace.is-mobile-list-open + .customer-mobile-filter-toggle + .customer-mobile-backdrop {
        display: block;
    }

    .customer-workspace.is-mobile-list-open .customer-list-panel {
        border-radius: 16px 16px 0 0;
        bottom: 0;
        display: grid;
        left: 0;
        max-height: 78vh;
        position: fixed;
        right: 0;
        top: auto;
        z-index: 1061;
    }

    body.mobile-list-open {
        overflow: hidden;
    }
}
