:root {
    --bg: #ece6da;
    --surface: #fffaf2;
    --surface-soft: #f6f0e4;
    --surface-strong: #ffffff;
    --line: rgba(19, 50, 44, 0.12);
    --line-strong: rgba(19, 50, 44, 0.22);
    --text: #13322c;
    --muted: #61736f;
    --primary: #1f5f52;
    --primary-strong: #143d34;
    --primary-deep: #102924;
    --gold: #d6b36a;
    --gold-soft: rgba(214, 179, 106, 0.16);
    --success-soft: rgba(31, 95, 82, 0.08);
    --danger-soft: #f3e2db;
    --danger-text: #8f4335;
    --shadow: 0 20px 50px rgba(17, 41, 36, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Manrope", sans-serif;
    color: var(--text);
    background: var(--bg);
    max-width: 100%;
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

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

img,
svg,
video,
canvas {
    max-width: 100%;
    height: auto;
}

button {
    border: 0;
    cursor: pointer;
}

.dashboard-shell {
    display: grid;
    grid-template-columns: 276px minmax(0, 1fr);
    gap: 22px;
    width: min(1440px, calc(100% - 28px));
    margin: 0 auto;
    padding: max(18px, env(safe-area-inset-top, 0px) + 10px) 0 max(24px, env(safe-area-inset-bottom, 0px) + 16px);
}

.app-page-sales .dashboard-shell {
    grid-template-columns: 248px minmax(0, 1fr);
    gap: 18px;
    width: min(1480px, calc(100% - 24px));
}

.app-page-sales .sidebar {
    padding: 16px;
}

.app-page-sales .sidebar-link {
    min-height: 42px;
    padding: 0 12px;
}

.sidebar,
.topbar,
.panel,
.project-card,
.office-card,
.report-summary-card {
    border: 1px solid var(--line);
    background: rgba(255, 250, 242, 0.96);
    box-shadow: var(--shadow);
}

.sidebar {
    position: sticky;
    top: 18px;
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: calc(100vh - 36px);
    padding: 18px;
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(20, 61, 52, 0.98), rgba(16, 41, 36, 0.98));
    color: #f6f1e7;
}

.sidebar-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    max-width: 100%;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    gap: 12px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.sidebar-brand strong {
    display: block;
    font-family: "Space Grotesk", sans-serif;
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-brand span {
    display: block;
    margin-top: 4px;
    color: rgba(246, 241, 231, 0.72);
    font-size: 12px;
}

.sidebar-brand-mark {
    display: inline-grid;
    place-items: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #f8f4ed;
    overflow: hidden;
}

.sidebar-brand-mark img {
    display: block;
    width: 50px;
    height: 48px;
    object-fit: contain;
    object-position: center;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding-top: 14px;
    border-top: 1px solid rgba(248, 244, 237, 0.14);
    color: rgba(246, 241, 231, 0.56);
    font-size: 10px;
    line-height: 1.4;
    gap: 0;
}

.sidebar-footer-separator {
    display: inline-block;
    margin: 0 6px;
    color: rgba(246, 241, 231, 0.32);
}

.sidebar-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(248, 244, 237, 0.18);
    border-radius: 14px;
    background: rgba(248, 244, 237, 0.06);
    color: #f6f1e7;
}

.sidebar-menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: transform 160ms ease, opacity 160ms ease;
}

.sidebar-link {
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 0 14px;
    border-radius: 16px;
    color: rgba(246, 241, 231, 0.8);
    text-decoration: none;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.sidebar-link span {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f6f1e7;
    transform: translateX(2px);
}

.sidebar-link.disabled {
    opacity: 0.36;
    cursor: not-allowed;
    pointer-events: none;
}

.sidebar-link.disabled:hover {
    background: transparent;
    color: rgba(246, 241, 231, 0.8);
    transform: none;
}

.sidebar-link.disabled.active {
    background: transparent;
    color: rgba(246, 241, 231, 0.8);
}

.sidebar-link.active {
    background: rgba(214, 179, 106, 0.18);
    color: #fefbf5;
}

.sidebar-card {
    padding: 16px;
    border-radius: 20px;
    background: rgba(248, 244, 237, 0.08);
    border: 1px solid rgba(248, 244, 237, 0.12);
}

.sidebar-card-label {
    display: block;
    margin-bottom: 10px;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(246, 241, 231, 0.56);
    display: none;
}

.sidebar-card strong {
    display: block;
    font-size: 15px;
}

.sidebar-card p {
    margin: 6px 0 0;
    color: rgba(246, 241, 231, 0.68);
    font-size: 12px;
}

.role-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.role-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    color: rgba(246, 241, 231, 0.82);
    background: rgba(255, 255, 255, 0.08);
    text-decoration: none;
    font-size: 12px;
}

.role-chip.active {
    background: rgba(214, 179, 106, 0.2);
    color: #fffaf2;
}

.main-shell {
    display: grid;
    align-content: start;
    gap: 18px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    min-height: 78px;
    padding: 18px 20px;
    border-radius: 26px;
}

.topbar-copy {
    flex: 1 1 auto;
    min-width: 0;
}

.topbar-title {
    display: block;
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-copy p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.topbar-user-card {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    width: fit-content;
    min-width: 0;
    margin-left: auto;
    padding: 8px 10px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
}

.topbar-user-card strong {
    display: block;
    color: var(--text);
    font-size: 13px;
}

.topbar-user-card p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.topbar-user-card .role-switcher {
    margin-top: 0;
    flex-wrap: nowrap;
}

.topbar-user-card .role-chip {
    min-height: 30px;
    padding: 0 10px;
    background: rgba(19, 50, 44, 0.07);
    color: var(--primary-strong);
    font-size: 11px;
}

.topbar-user-card .role-chip.active {
    background: var(--primary);
    color: #fffaf2;
}

.topbar-user-actions {
    margin: 0;
}

.topbar-logout-button {
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.topbar-logout-button:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(19, 50, 44, 0.04);
}

.topbar-label,
.section-kicker,
.card-mini-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.login-page-body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(205, 174, 131, 0.24), transparent 32%),
        linear-gradient(160deg, #f7f1e8 0%, #fbf7f0 48%, #f1ede6 100%);
    color: var(--text);
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 18px;
}

.login-card {
    width: min(100%, 460px);
    padding: 32px 28px;
    border-radius: 28px;
    border: 1px solid rgba(19, 50, 44, 0.1);
    background: rgba(255, 250, 242, 0.94);
    box-shadow: 0 24px 60px rgba(19, 50, 44, 0.14);
}

.login-copy h1 {
    margin: 14px 0 10px;
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(28px, 4vw, 34px);
    line-height: 1.05;
}

.login-copy p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.login-form {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

.login-submit-button {
    width: 100%;
    justify-content: center;
}

.topbar-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.context-chip {
    min-width: 130px;
    padding: 12px 14px;
    border-radius: 18px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
}

.context-chip span,
.report-summary-card span,
.entity-field span,
.filter-field span,
.sales-count-bar strong,
.table-sub-copy,
.report-summary-card small {
    color: var(--muted);
    font-size: 11px;
}

.context-chip strong {
    display: block;
    margin-top: 8px;
    font-size: 15px;
}

.page-shell {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.page-intro {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 18px;
}

.page-intro h1 {
    margin: 8px 0 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(24px, 2.4vw, 30px);
    line-height: 1.05;
}

.page-intro p {
    margin: 10px 0 0;
    max-width: 760px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

.page-intro-inline {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.communication-summary-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.communication-form {
    gap: 14px;
}

.communication-notice {
    display: grid;
    gap: 6px;
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 250, 242, 0.94);
}

.communication-notice strong {
    font-size: 13px;
    color: var(--primary-strong);
}

.communication-notice p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.communication-notice.is-warning {
    background: rgba(255, 247, 228, 0.96);
    border-color: rgba(176, 122, 23, 0.18);
}

.communication-notice.is-success {
    background: rgba(233, 245, 239, 0.96);
    border-color: rgba(19, 50, 44, 0.16);
}

.action-button,
.ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: transform 160ms ease, background-color 160ms ease;
}

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

.action-button {
    background: rgba(255, 250, 242, 0.94);
    color: var(--primary-strong);
}

.action-button.primary {
    background: var(--primary);
    border-color: rgba(20, 61, 52, 0.2);
    color: #fffaf2;
}

.action-button.secondary {
    background: var(--gold-soft);
}

.action-button.danger {
    background: var(--danger-soft);
    color: var(--danger-text);
}

.action-button:disabled,
.action-button[disabled] {
    opacity: 0.52;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
}

.inline-import-details {
    position: relative;
}

.inline-import-details summary {
    list-style: none;
    cursor: pointer;
}

.inline-import-details summary::-webkit-details-marker {
    display: none;
}

.inline-import-panel {
    display: grid;
    gap: 12px;
    width: min(460px, calc(100vw - 48px));
    margin-top: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 250, 242, 0.98);
    box-shadow: 0 18px 44px rgba(9, 28, 24, 0.08);
}

.inline-import-copy {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.inline-import-form {
    display: grid;
    gap: 12px;
}

.inline-import-field {
    margin: 0;
}

.ghost-button {
    min-height: 34px;
    background: transparent;
    color: var(--primary-strong);
}

.card-link-surface {
    color: inherit;
    text-decoration: none;
}

.brand-card-shell {
    position: relative;
}

.brand-card-link {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    min-height: 100%;
    color: inherit;
    text-decoration: none;
}

.brand-card-shell .entity-card-copy {
    padding-right: 30px;
}

.brand-favorite-button {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(20, 61, 52, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: rgba(20, 61, 52, 0.48);
    box-shadow: 0 8px 18px rgba(20, 61, 52, 0.08);
    transition: transform 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.brand-favorite-button:hover {
    transform: translateY(-1px);
    color: #c79211;
    box-shadow: 0 12px 22px rgba(20, 61, 52, 0.12);
}

.brand-favorite-button.is-active {
    color: #c79211;
    background: rgba(255, 247, 214, 0.96);
    border-color: rgba(199, 146, 17, 0.28);
}

.brand-favorite-button-icon {
    font-size: 16px;
    line-height: 1;
    pointer-events: none;
}

.inline-back-link {
    display: inline-flex;
    align-items: center;
    margin-bottom: 10px;
    color: var(--primary-strong);
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
}

.panel {
    padding: 20px;
    border-radius: 28px;
    min-width: 0;
}

.empty-panel {
    display: grid;
    gap: 10px;
    justify-items: flex-start;
}

.empty-panel strong {
    font-size: 16px;
}

.empty-panel p {
    margin: 0;
    max-width: 560px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

.project-grid,
.office-grid,
.report-summary,
.filters-grid {
    display: grid;
    gap: 14px;
}

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

.compact-office-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.project-card,
.office-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    padding: 16px;
    border-radius: 22px;
    text-align: left;
}

.compact-project-card,
.compact-office-card {
    min-height: 132px;
}

.interactive-card {
    align-items: stretch;
}

.selectable-project-card {
    padding: 0;
    overflow: hidden;
}

.selectable-project-card.is-selected {
    border-color: rgba(214, 179, 106, 0.54);
    box-shadow: 0 20px 54px rgba(20, 61, 52, 0.14);
}

.project-card-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 16px;
    padding: 16px 16px 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.entity-card-copy {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.entity-card-copy strong {
    font-family: "Space Grotesk", sans-serif;
    font-size: 18px;
    line-height: 1.05;
}

.entity-card-copy span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 0 16px 16px;
}

.app-page-projects .compact-actions {
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
}

.app-page-projects .compact-actions .action-button,
.app-page-projects .compact-actions .ghost-button {
    white-space: nowrap;
}

.card-meta {
    color: var(--muted);
    font-size: 12px;
}

.brand-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand-hero-main {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-hero-actions {
    margin-left: auto;
}

.section-head-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.section-head-inline strong {
    font-size: 15px;
}

.section-head-inline span {
    color: var(--muted);
    font-size: 12px;
}

.logo-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    background: rgba(214, 179, 106, 0.2);
    border: 1px solid rgba(214, 179, 106, 0.3);
    color: var(--primary-deep);
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    flex-shrink: 0;
}

.logo-badge-large {
    min-width: 58px;
    min-height: 58px;
    padding: 0 14px;
    font-size: 15px;
}

.project-card .logo-badge-large,
.selectable-project-card .logo-badge-large {
    display: inline-grid;
    place-items: center;
    flex: 0 0 60px;
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
    padding: 0;
    border-radius: 999px;
}

.logo-badge-image {
    display: inline-grid;
    place-items: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    min-width: 48px !important;
    min-height: 48px !important;
    padding: 0;
    overflow: hidden;
    border-radius: 999px;
    background: #ffffff;
    border: 0;
    aspect-ratio: 1 / 1;
}

.logo-badge img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-badge-image img {
    width: 50px;
    height: 48px;
    max-width: 50px;
    max-height: 48px;
    object-fit: contain;
    object-position: center;
}

.project-card .logo-badge-image img,
.selectable-project-card .logo-badge-image img {
    width: 62px;
    height: 60px;
    max-width: 62px;
    max-height: 60px;
}

.logo-badge-side {
    min-width: 54px;
    min-height: 54px;
    font-size: 15px;
}

.logo-badge-side.logo-badge-image {
    width: 54px;
    height: 54px;
    min-width: 54px !important;
    min-height: 54px !important;
}

.logo-badge-side.logo-badge-image img {
    width: 56px;
    height: 54px;
    max-width: 56px;
    max-height: 54px;
}

.brand-hero .logo-badge-large.logo-badge-image {
    width: 60px;
    height: 60px;
    min-width: 60px !important;
    min-height: 60px !important;
}

.brand-hero .logo-badge-large.logo-badge-image img {
    width: 62px;
    height: 60px;
    max-width: 62px;
    max-height: 60px;
}

.office-detail-card {
    flex-direction: row;
    align-items: center;
}

.brand-profile-office-card,
.brand-profile-office-card:hover,
.brand-profile-office-card .entity-card-copy,
.brand-profile-office-card .entity-card-copy strong,
.brand-profile-office-card .entity-card-copy span {
    text-decoration: none;
}

.brand-profile-office-card .entity-card-copy strong,
.office-detail-card .entity-card-copy strong {
    color: var(--text);
}

.office-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.brand-filter-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    background: rgba(19, 50, 44, 0.06);
    border: 1px solid var(--line);
    color: var(--primary-strong);
    font-size: 12px;
    transition: transform 160ms ease, background-color 160ms ease;
}

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

.brand-filter-button.active {
    background: var(--primary);
    color: #fffaf2;
}

.brand-filter-button.clear {
    background: transparent;
}

.selection-placeholder {
    display: block;
    padding: 18px;
    border-radius: 18px;
    background: rgba(19, 50, 44, 0.04);
    border: 1px dashed rgba(19, 50, 44, 0.18);
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

html.modal-open,
body.modal-open {
    overflow: hidden;
}

html.app-loading,
body.app-loading {
    overflow: hidden;
}

.app-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(16, 41, 36, 0.42);
    backdrop-filter: blur(6px);
}

.app-loading-overlay[hidden] {
    display: none;
}

.app-loading-card {
    display: grid;
    justify-items: center;
    gap: 10px;
    width: min(320px, calc(100% - 24px));
    padding: 26px 24px;
    border-radius: 24px;
    border: 1px solid rgba(255, 250, 242, 0.42);
    background: rgba(255, 250, 242, 0.96);
    box-shadow: 0 24px 60px rgba(16, 41, 36, 0.2);
    text-align: center;
}

.app-loading-card strong {
    font-size: 16px;
}

.app-loading-card p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.app-loading-spinner {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 3px solid rgba(19, 50, 44, 0.12);
    border-top-color: var(--primary);
    animation: app-loading-spin 0.7s linear infinite;
}

@keyframes app-loading-spin {
    to {
        transform: rotate(360deg);
    }
}

.entity-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    overflow: hidden;
    padding: 24px 0;
    overscroll-behavior: contain;
}

.entity-modal[hidden] {
    display: none;
}

.entity-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 41, 36, 0.38);
}

.entity-modal-panel {
    position: relative;
    z-index: 1;
    width: min(640px, calc(100% - 24px));
    max-height: calc(100vh - 48px);
    margin: 0 auto;
    padding: 22px;
    overflow-y: auto;
    border-radius: 26px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: 0 24px 60px rgba(16, 41, 36, 0.18);
}

.entity-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 18px;
}

.entity-modal-head h2 {
    margin: 7px 0 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: 22px;
    line-height: 1;
}

.icon-button {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: rgba(19, 50, 44, 0.06);
    color: var(--primary-strong);
    font-size: 20px;
    line-height: 1;
}

.entity-form {
    display: grid;
    gap: 12px;
}

.entity-field {
    display: grid;
    gap: 6px;
}

.field-hint,
.entity-logo-preview-label {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
}

.entity-field input,
.entity-field select,
.filter-field input,
.filter-field select {
    width: 100%;
    min-height: 42px;
    padding: 0 40px 0 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
    font-size: 12px;
    outline: 0;
}

.entity-field input[readonly],
.entity-field select:disabled {
    background: rgba(246, 240, 228, 0.72);
}

.filter-field input[readonly],
.filter-field select:disabled {
    background: rgba(246, 240, 228, 0.72);
}

.entity-field input[type="file"] {
    padding: 10px 12px;
}

.entity-logo-preview {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(19, 50, 44, 0.04);
    border: 1px solid rgba(19, 50, 44, 0.08);
}

.entity-logo-preview[hidden] {
    display: none;
}

.entity-logo-preview-badge {
    justify-self: flex-start;
}

.entity-modal-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}

#consultant-modal .entity-modal-actions,
#customer-modal .entity-modal-actions {
    position: sticky;
    bottom: -22px;
    z-index: 2;
    padding: 14px 0 0;
    background: linear-gradient(180deg, rgba(255, 252, 246, 0) 0%, rgba(255, 252, 246, 0.96) 28%, rgba(255, 252, 246, 1) 100%);
}

#consultant-modal .entity-modal-actions [data-entity-toggle-edit],
#customer-modal .entity-modal-actions [data-entity-toggle-edit],
body.app-role-user #consultant-modal .entity-modal-actions [data-entity-toggle-edit],
body.app-role-user #customer-modal .entity-modal-actions [data-entity-toggle-edit] {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.entity-modal-panel-wide {
    width: min(880px, calc(100% - 24px));
}

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

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

#sale-detail-modal .entity-modal-panel {
    width: min(1180px, calc(100% - 24px));
}

.sale-detail-layout {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
    align-items: start;
}

.sale-detail-layout > * {
    min-width: 0;
}

.sale-detail-main {
    display: grid;
    gap: 18px;
    min-width: 0;
    align-self: start;
}

.sale-detail-movements-panel {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 12px;
    padding: 16px;
    border-radius: 20px;
    border: 1px solid rgba(19, 50, 44, 0.08);
    background: rgba(19, 50, 44, 0.04);
    min-height: 0;
    height: auto;
    align-self: start;
    overflow: hidden;
}

.sale-detail-movements-head {
    display: grid;
    gap: 4px;
}

.sale-detail-movements-head strong {
    font-family: "Space Grotesk", sans-serif;
    font-size: 18px;
    line-height: 1.1;
}

.sale-detail-movements-list {
    display: grid;
    gap: 10px;
    flex: 1 1 auto;
    min-height: 0;
    align-content: start;
    justify-items: stretch;
    overflow-y: auto;
    padding-right: 4px;
}

.sale-detail-movement-item {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(19, 50, 44, 0.09);
    background: rgba(246, 240, 228, 0.94);
}

.sale-detail-movement-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.sale-detail-movement-tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.sale-detail-movement-tag.is-info,
.sale-detail-movement-tag.is-success {
    background: rgba(31, 95, 82, 0.12);
    color: var(--primary);
}

.sale-detail-movement-tag.is-warning {
    background: rgba(214, 179, 106, 0.18);
    color: #8a6324;
}

.sale-detail-movement-tag.is-danger {
    background: rgba(143, 67, 53, 0.12);
    color: var(--danger-text);
}

.sale-detail-movement-tag.is-neutral {
    background: rgba(19, 50, 44, 0.08);
    color: var(--primary-strong);
}

.sale-detail-movement-date {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.sale-detail-movement-title {
    color: var(--text);
    font-size: 13px;
    line-height: 1.35;
}

.sale-detail-movement-amount {
    color: var(--primary-strong);
    font-size: 12px;
    font-weight: 700;
}

.sale-detail-movement-copy,
.sale-detail-movement-meta {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.55;
    white-space: pre-wrap;
}

#sale-detail-modal .entity-modal-actions {
    justify-content: space-between;
    align-items: center;
    margin-top: 0;
}

#sales-modal .entity-modal-panel {
    width: min(1120px, calc(100% - 24px));
}

#sales-create-form {
    gap: 12px;
    grid-template-columns: minmax(0, 1fr);
}

#sales-create-form .entity-field {
    align-content: start;
}

#sales-create-form .entity-field span {
    min-height: 18px;
}

#sales-create-form .sales-entry-section {
    margin: 0;
}

#sales-create-form .sales-entry-section .sales-entry-row + .sales-entry-row,
#sales-create-form .sales-entry-section .sales-project-availability-note {
    margin-top: 12px;
}

#sales-create-form .sales-entry-row {
    display: grid;
    gap: 12px;
    align-items: start;
}

#sales-create-form .sales-entry-row-primary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

#sales-create-form .sales-entry-row-customer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

#sales-create-form .sales-entry-field-customer-name {
    grid-column: auto;
}

#sales-create-form .sales-entry-field-identity {
    grid-column: auto;
}

#sales-create-form .sales-entry-field-phone {
    grid-column: auto;
}

#sales-create-form .sales-entry-field-email {
    grid-column: auto;
}

#sales-create-form .sales-entry-field-address {
    grid-column: 1 / -1;
}

#sales-create-form .sales-entry-row-notes {
    grid-template-columns: minmax(0, 1fr);
}

#sales-create-form .sales-entry-row-notes .entity-field {
    grid-column: 1 / -1;
}

#sales-create-form .field-hint {
    margin-top: 2px;
}

#sales-create-form .sales-project-availability-note {
    margin-top: 4px;
    color: #9f3f36;
    font-weight: 600;
}

.profile-list-block {
    display: grid;
    gap: 10px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.project-settings-block {
    margin-top: 4px;
    padding: 14px;
    border-top: 0;
    border-radius: 18px;
    background: rgba(197, 167, 92, 0.12);
    border: 1px solid rgba(197, 167, 92, 0.24);
}

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

.entity-modal.is-create-consultant [data-consultant-sales-block],
.entity-modal.is-create-consultant [data-entity-delete="consultant"] {
    display: none !important;
}

.entity-modal.is-create-customer [data-customer-sales-block],
.entity-modal.is-create-customer [data-entity-delete="customer"] {
    display: none !important;
}

.profile-list-head strong {
    font-size: 14px;
}

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

.profile-item {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(19, 50, 44, 0.04);
    border: 1px solid rgba(19, 50, 44, 0.08);
}

.profile-item-highlight {
    background: rgba(19, 50, 44, 0.08);
    border-color: rgba(19, 50, 44, 0.16);
}

.profile-item-with-logo {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
}

.profile-item-logo {
    align-self: center;
}

.profile-item-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.profile-item strong {
    font-size: 13px;
}

.profile-item span,
.profile-empty-copy {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.filters-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
    margin-bottom: 14px;
}

.sales-filter-form {
    grid-template-columns: 1fr;
    gap: 14px;
}

.consultant-filter-form {
    grid-template-columns: 1fr;
}

.consultant-filter-row {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.consultant-filter-actions {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.consultant-filter-actions-left,
.consultant-filter-actions-right {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.sales-filter-row {
    display: grid;
    gap: 12px;
}

.sales-filter-row-primary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sales-filter-row-secondary {
    grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(220px, 1.15fr);
}

.sales-filter-section {
    display: grid;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid rgba(19, 50, 44, 0.08);
    border-radius: 18px;
    background: var(--surface-soft);
}

.sales-filter-section-head {
    display: grid;
    gap: 4px;
}

.sales-filter-section-head h3 {
    margin: 0;
    color: var(--text);
    font-family: "Space Grotesk", sans-serif;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.15;
}

.sales-filter-section-kicker {
    margin: 0;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.sales-filter-row-tertiary {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
}

.sales-filter-bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.sales-filter-bar-left,
.sales-filter-bar-right {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-field {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.filter-input-wrap {
    position: relative;
}

.card-search-field {
    max-width: 420px;
    margin: 0 0 18px;
}

.panel-toolbar-inline {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    min-width: 0;
}

.panel-toolbar-inline .card-search-field {
    margin: 0;
    flex: 1 1 320px;
}

.panel-toolbar-inline form {
    flex: 1 1 320px;
}

.panel-toolbar-actions {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.filter-action-row {
    grid-column: 1 / -1;
}

.brand-profile-filter-form {
    grid-template-columns: minmax(220px, 320px) minmax(260px, 420px) auto;
    align-items: end;
}

.brand-profile-filter-form .card-search-field {
    max-width: none;
    margin: 0;
}

.brand-profile-filter-actions {
    align-self: end;
    justify-content: flex-start;
}

.card-search-empty {
    margin-top: 18px;
}

.office-location-label {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    min-height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(19, 50, 44, 0.08);
    color: var(--primary-strong);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.brand-profile-office-card .entity-card-copy {
    min-width: 0;
}

body.app-role-user #sales-modal .entity-field:has(input[name="earned_commission"]),
body.app-role-user #sale-detail-form .entity-field:has(input[name="earned_commission"]) {
    display: none;
}

body.app-role-user [data-entity-delete],
body.app-role-user [data-delete-sale-entry],
body.app-role-user .action-button.danger,
body.app-role-user .ghost-button.danger-ghost-button {
    display: none !important;
}

.combo-box-toggle {
    position: absolute;
    top: 50%;
    right: 36px;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: transparent;
    color: var(--primary-strong);
    font-size: 12px;
    line-height: 1;
}

.combo-box-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 12;
    display: grid;
    gap: 4px;
    max-height: 220px;
    overflow-y: auto;
    padding: 8px;
    border-radius: 16px;
    border: 1px solid var(--line-strong);
    background: var(--surface-strong);
    box-shadow: 0 18px 30px rgba(16, 41, 36, 0.12);
}

.combo-box-panel:not(.is-open) {
    display: none;
}

.combo-box-panel.is-open {
    display: grid;
}

.sales-combo-panel {
    max-height: 392px;
}

.combo-box-panel[hidden] {
    display: none;
}

.combo-box-panel:empty {
    display: none;
}

.combo-box-option {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    text-align: left;
    font-size: 12px;
}

.combo-box-option:hover {
    background: rgba(19, 50, 44, 0.06);
}

.combo-box-option[hidden] {
    display: none;
}

.combo-box-checkbox-option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
}

.combo-box-checkbox-option:hover {
    background: rgba(19, 50, 44, 0.06);
}

.combo-box-checkbox-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 16px;
    margin: 0;
    padding: 0;
    accent-color: var(--primary-strong);
}

.combo-box-checkbox-option span {
    font-size: 12px;
    color: var(--text);
}

.combo-box-checkbox-option[hidden] {
    display: none;
}

.sales-filter-multiselect-input {
    cursor: pointer;
    background: #fff !important;
}

.sales-filter-checkbox-panel {
    gap: 6px;
}

.sales-filter-legacy-select {
    display: none !important;
}

.clear-filter-button {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: rgba(19, 50, 44, 0.08);
    color: var(--primary-strong);
    font-size: 14px;
    line-height: 1;
}

.clear-filter-button[hidden] {
    display: none;
}

.filter-submit-wrap {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.sales-table-toolbar {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "meta sort"
        "actions actions";
    align-items: flex-end;
    gap: 14px;
    margin-top: 0;
}

.sales-toolbar-left {
    grid-area: meta;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.sales-date-controls {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
    min-width: 0;
}

.sales-date-controls .compact-filter-field {
    min-width: 164px;
}

.sales-sort-controls {
    grid-area: sort;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 10px;
    margin-left: 0;
    flex-wrap: nowrap;
}

.sales-sort-controls .action-button {
    min-height: 34px;
}

.sales-action-controls {
    grid-area: actions;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
    padding-top: 2px;
}

.sales-action-controls .action-button,
.sales-action-controls .ghost-button,
.sales-action-controls .inline-import-details > summary {
    min-height: 34px;
    min-width: 108px;
    padding: 0 12px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    white-space: nowrap;
}

.sales-action-controls .sales-count-bar-inline {
    flex: 1 0 100%;
    margin-left: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    text-align: right;
    white-space: nowrap;
    padding-top: 10px;
    border-top: 1px dashed rgba(19, 50, 44, 0.12);
}

.sales-action-controls .ghost-button {
    border-radius: 12px;
}

.sales-action-controls .sales-filter-command-group {
    display: inline-flex;
    align-items: flex-end;
    gap: 6px;
    margin-left: auto;
}

.sales-action-controls .inline-import-details {
    display: none !important;
}

.sales-action-controls > summary,
.sales-action-controls > .inline-import-panel,
.sales-action-controls > .inline-import-copy,
.sales-action-controls [form="sales-import-form"] {
    display: none !important;
}

#sale-detail-modal .entity-modal-actions .sale-excluded-button {
    display: inline-flex;
    min-width: 152px;
}

.project-create-card {
    padding: 0;
    overflow: hidden;
}

.project-create-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    height: 100%;
    padding: 16px;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.project-create-copy {
    display: grid;
    gap: 6px;
}

.project-create-copy strong {
    color: var(--text);
    font-family: "Space Grotesk", sans-serif;
    font-size: 18px;
    line-height: 1.05;
}

.project-create-copy span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.compact-filter-field {
    width: 136px;
}

.compact-filter-field-narrow {
    width: 84px;
}

.compact-filter-field select {
    min-height: 34px;
    padding-right: 24px;
    border-radius: 11px;
    font-size: 11px;
}

.sales-sort-controls .compact-filter-field {
    width: 148px;
}

.sales-sort-controls .compact-filter-field-narrow {
    width: 96px;
}

.sales-count-bar {
    margin-bottom: 0;
}

.sales-count-bar-row {
    grid-column: 1 / -1;
    margin-top: 2px;
}

@media (max-width: 1460px) {
    .sales-filter-row-secondary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sales-filter-row-tertiary {
        grid-template-columns: 1fr;
    }

    .sales-table-toolbar {
        grid-template-columns: 1fr;
        grid-template-areas:
            "meta"
            "sort"
            "actions";
        align-items: stretch;
    }

    .sales-toolbar-left,
    .sales-date-controls,
    .sales-action-controls,
    .sales-sort-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .sales-sort-controls {
        justify-content: flex-start;
        margin-left: 0;
        flex-wrap: wrap;
    }
}

.mini-action-button {
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.mini-action-button:hover {
    background: rgba(245, 232, 208, 0.85);
    border-color: rgba(190, 152, 111, 0.85);
}

.mini-action-button:active {
    transform: translateY(1px);
}

.mini-action-button-clear {
    width: 34px;
    min-width: 34px;
    padding: 0;
    font-size: 14px;
    line-height: 1;
}

.mini-action-button-apply {
    padding: 0 14px;
}

.table-wrap,
.nested-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 250, 242, 0.96);
}

.nested-table-wrap {
    margin-top: 8px;
}

.sales-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.app-page-sales .sales-table {
    min-width: 0;
    table-layout: fixed;
}

.sales-select-column,
.sales-row-select-cell {
    width: 42px;
    min-width: 42px;
    text-align: center !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
}

.sales-number-column,
.sales-number-cell {
    width: 78px;
    min-width: 78px;
    white-space: nowrap;
}

.sales-payment-column,
.sales-payment-cell {
    width: 102px;
    min-width: 102px;
    white-space: nowrap;
}

.sales-select-column input[type="checkbox"],
.sales-row-select-cell input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 16px;
    margin: 0;
    accent-color: var(--primary-strong);
}

.sales-table th,
.sales-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.app-page-sales .sales-table th,
.app-page-sales .sales-table td {
    padding: 11px 8px;
    overflow-wrap: anywhere;
}

.app-page-sales .sales-payment-cell {
    white-space: nowrap;
}

.sales-note-column,
.sales-note-cell {
    width: 56px;
    min-width: 56px;
    text-align: center !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
}

.sales-table th {
    background: rgba(19, 50, 44, 0.05);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.sales-table td {
    font-size: 12px;
    vertical-align: top;
}

.app-page-sales .sales-table td {
    font-size: 11px;
}

.app-page-sales .sales-table th {
    font-size: 9px;
    letter-spacing: 0.1em;
}

.app-page-sales .sales-table .payment-status-badge {
    min-height: 24px;
    padding: 0 8px;
    font-size: 10px;
    white-space: nowrap;
}

.sales-row-trigger {
    cursor: pointer;
}

.sales-row-trigger:hover td {
    background: rgba(19, 50, 44, 0.04);
}

.sales-note-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: rgba(19, 50, 44, 0.08);
    color: var(--primary-strong);
    font-size: 14px;
    line-height: 1;
}

.customer-link-button {
    padding: 0;
    background: transparent;
    color: var(--primary-strong);
    font-size: 12px;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.customer-mini-popover {
    position: fixed;
    z-index: 80;
    display: grid;
    gap: 6px;
    width: min(280px, calc(100vw - 24px));
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--line-strong);
    background: var(--surface-strong);
    box-shadow: 0 18px 32px rgba(16, 41, 36, 0.16);
}

.customer-mini-popover strong {
    font-size: 13px;
}

.customer-mini-popover span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.entity-field textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
    font-size: 12px;
    resize: vertical;
    outline: 0;
}

.entity-field textarea[readonly] {
    background: rgba(246, 240, 228, 0.72);
}

.summary-row td {
    background: rgba(255, 250, 242, 0.88);
}

.nested-level td {
    background: rgba(246, 240, 228, 0.76);
}

.nested-level.deeper td {
    background: rgba(235, 241, 238, 0.82);
}

.detail-row td {
    padding-top: 0;
}

.consultant-name-cell {
    display: inline-flex;
    align-items: flex-start;
    gap: 10px;
}

.table-sub-copy {
    display: block;
    margin-top: 5px;
    line-height: 1.6;
}

.expand-button {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: rgba(19, 50, 44, 0.08);
    border: 1px solid rgba(19, 50, 44, 0.12);
    color: var(--primary);
    font-size: 16px;
    flex-shrink: 0;
}

.report-summary {
    margin-bottom: 14px;
}

.expanded-report-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.report-trend-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.report-comparison-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}

.report-summary-card {
    padding: 16px;
    border-radius: 20px;
}

.report-page-top {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.report-summary-panel {
    order: 0;
}

.report-filters-panel {
    order: 0;
}

.report-summary-card strong {
    display: block;
    margin-top: 10px;
    font-family: "Space Grotesk", sans-serif;
    font-size: 18px;
    line-height: 1.1;
}

.report-summary-card small {
    display: block;
    margin-top: 8px;
    font-size: 9px;
}

.report-summary-card span {
    font-size: 9px;
}

.report-summary-panel .report-summary-card strong {
    font-size: 15px;
}

.report-summary-panel .report-summary-card span,
.report-summary-panel .report-summary-card small {
    font-size: 7px;
}

.commission-payments-summary .report-summary-card strong {
    font-size: 14px;
}

.commission-payments-summary .report-summary-card span,
.commission-payments-summary .report-summary-card small {
    font-size: 10px;
}

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

.commission-payments-summary .report-summary-card {
    display: grid;
    align-content: start;
    gap: 6px;
}

.commission-payments-summary .report-summary-card strong {
    margin-top: 2px;
}

.commission-payments-summary .report-summary-card small {
    margin-top: 0;
}

.loan-calculator-actions {
    justify-content: flex-start;
}

.loan-layout {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 360px);
    align-items: start;
}

.loan-form-panel,
.loan-summary-grid {
    min-width: 0;
}

.loan-summary-grid {
    grid-template-columns: minmax(0, 1fr);
    margin-bottom: 0;
}

.report-trend-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.84);
}

.report-comparison-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.84);
}

.report-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.report-section-head strong {
    display: block;
    margin-top: 4px;
    color: var(--primary-strong);
    font-family: "Space Grotesk", sans-serif;
    font-size: 18px;
    line-height: 1.2;
}

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

.comparison-metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(19, 50, 44, 0.08);
    background: rgba(19, 50, 44, 0.04);
}

.comparison-metric span,
.leader-card span {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
}

.comparison-metric strong,
.leader-card strong {
    display: block;
    margin-top: 4px;
    color: var(--primary-strong);
    font-family: "Space Grotesk", sans-serif;
    font-size: 18px;
    line-height: 1.15;
}

.comparison-metric small,
.leader-card small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.comparison-metric em {
    font-style: normal;
    font-weight: 700;
    white-space: nowrap;
}

.comparison-up em {
    color: #1f7f5c;
}

.comparison-down em {
    color: #b24a4a;
}

.comparison-flat em {
    color: var(--muted);
}

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

.leader-card {
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(19, 50, 44, 0.08);
    background: rgba(19, 50, 44, 0.04);
}

.leader-card-meta {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
}

.table-action-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    border-radius: 10px;
    color: #fffaf2;
    background: var(--primary);
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.table-action-link:hover {
    background: var(--primary-strong);
}

.table-action-link.secondary {
    background: rgba(19, 50, 44, 0.1);
    color: var(--primary-strong);
}

.table-action-link.secondary:hover {
    background: rgba(19, 50, 44, 0.16);
}

.table-action-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.report-table .table-action-link {
    padding: 5px 8px;
    border-radius: 8px;
    font-size: 10px;
}

.report-table .table-action-group {
    gap: 6px;
}

.report-trend-head,
.report-trend-foot {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.report-trend-head strong,
.report-trend-totals strong {
    display: block;
    color: var(--primary-strong);
    font-family: "Space Grotesk", sans-serif;
    font-size: 18px;
    line-height: 1.1;
}

.report-trend-totals {
    text-align: right;
}

.report-trend-totals span,
.report-trend-foot span {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
}

.trend-chart {
    display: grid;
    gap: 14px;
}

.trend-bar-stage {
    position: relative;
    height: 188px;
    padding: 16px 14px 14px;
    border-radius: 24px;
    border: 1px solid rgba(19, 50, 44, 0.08);
    background:
        radial-gradient(circle at top right, rgba(45, 123, 103, 0.14), transparent 42%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(19, 50, 44, 0.04) 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.76),
        0 12px 28px rgba(19, 50, 44, 0.08);
    overflow: hidden;
}

.trend-bar-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.24) 0%, transparent 24%),
        linear-gradient(90deg, rgba(19, 50, 44, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 20% 100%;
    pointer-events: none;
}

.trend-bar-grid {
    position: relative;
    z-index: 1;
    display: grid;
    height: 100%;
    gap: 12px;
    align-items: end;
}

.trend-bar-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    height: 100%;
    min-width: 0;
}

.trend-bar-value {
    color: rgba(19, 50, 44, 0.72);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.trend-bar-track {
    flex: 1;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.trend-bar-fill {
    display: block;
    width: clamp(8px, 18%, 12px);
    min-height: 2px;
    border-radius: 999px;
    background: linear-gradient(180deg, #2d7b67 0%, #214d43 100%);
    box-shadow: 0 4px 10px rgba(19, 50, 44, 0.12);
}

.trend-bar-fill.is-latest {
    background: linear-gradient(180deg, #1d5f50 0%, #13322c 100%);
    box-shadow: 0 5px 12px rgba(19, 50, 44, 0.18);
}

.trend-bar-labels {
    display: grid;
    gap: 6px;
    padding: 0 4px;
}

.trend-bar-label {
    color: var(--muted);
    font-size: 11px;
    text-align: center;
    white-space: nowrap;
    color: rgba(19, 50, 44, 0.78);
}

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

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

.report-section-inline-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin: 0;
}

.report-section-project-field {
    min-width: 260px;
    max-width: 360px;
}

.pagination-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    background: rgba(19, 50, 44, 0.06);
    border: 1px solid var(--line);
    color: var(--primary-strong);
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
}

.pagination-link.active {
    background: var(--primary);
    color: #fffaf2;
}

.pagination-link.disabled {
    background: transparent;
    color: var(--muted);
    pointer-events: none;
}

.empty-state {
    color: var(--muted);
    text-align: center;
}

.table-link-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary-strong);
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.table-link-button:hover {
    color: var(--primary);
}

.payment-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.payment-status-unpaid {
    background: rgba(143, 67, 53, 0.12);
    color: var(--danger-text);
}

.payment-status-partial {
    background: rgba(214, 179, 106, 0.18);
    color: #8a6324;
}

.payment-status-paid {
    background: rgba(31, 95, 82, 0.12);
    color: var(--primary);
}

.commission-payment-detail-wrap {
    display: grid;
    gap: 14px;
    overflow: visible;
}

.commission-payment-detail-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, 420px);
    align-items: start;
}

.commission-payment-detail-grid > * {
    min-width: 0;
}

.commission-payment-history {
    display: grid;
    gap: 12px;
    min-width: 0;
    overflow: hidden;
}

.commission-payment-history-table {
    width: 100%;
    max-width: 100%;
}

.commission-payment-history .nested-table {
    min-width: 0;
}

.commission-payment-history-grid {
    width: 100%;
    table-layout: fixed;
}

.commission-payment-history-grid th,
.commission-payment-history-grid td {
    padding: 8px 9px;
    font-size: 11px;
    vertical-align: top;
}

.commission-payment-history-grid th:nth-child(1),
.commission-payment-history-grid td:nth-child(1) {
    width: 96px;
}

.commission-payment-history-grid th:nth-child(2),
.commission-payment-history-grid td:nth-child(2) {
    width: 88px;
}

.commission-payment-history-grid th:nth-child(3),
.commission-payment-history-grid td:nth-child(3) {
    width: 150px;
}

.commission-payment-history-grid th:nth-child(5),
.commission-payment-history-grid td:nth-child(5) {
    width: 52px;
    white-space: nowrap;
}

.commission-payment-history-grid td:nth-child(3),
.commission-payment-history-grid td:nth-child(4) {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.commission-payment-form-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(19, 50, 44, 0.04);
    border: 1px solid rgba(19, 50, 44, 0.08);
}

.commission-payment-form {
    gap: 12px;
}

.commission-payment-remaining-input {
    font-size: 13px;
    font-weight: 600;
    padding-inline: 12px;
    resize: none;
    min-height: 64px;
    line-height: 1.45;
}

.payment-field-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.payment-quick-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.payment-quick-action {
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(19, 50, 44, 0.14);
    background: #fff;
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.payment-quick-action:hover {
    background: rgba(19, 50, 44, 0.06);
    border-color: rgba(19, 50, 44, 0.28);
}

.commission-payment-complete-copy {
    margin: 0;
    text-align: left;
}

.commission-sales-filters {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.commission-sales-layout {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    margin-bottom: 14px;
}

.commission-sales-filter-panel,
.commission-sales-bulk-panel {
    min-width: 0;
    height: 100%;
}

.commission-sales-filter-panel {
    display: flex;
    padding: 16px;
    border-radius: 18px;
    border: 1px solid rgba(19, 50, 44, 0.08);
    background: rgba(19, 50, 44, 0.04);
}

.commission-sales-filter-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    flex: 1;
}

.commission-sales-filter-grid .filter-field-wide,
.commission-sales-filter-grid .commission-sales-filter-actions {
    grid-column: auto;
}

.commission-sales-selection-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr);
}

.commission-sales-bulk-panel {
    display: flex;
    flex-direction: column;
}

.filter-action-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.commission-sales-filter-actions {
    margin-top: auto;
    padding-top: 4px;
}

.commission-sales-bulk-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
    min-height: 0;
}

.commission-sales-bulk-fields {
    display: grid;
    gap: 14px;
    align-content: start;
    flex: 1;
}

.commission-sales-bulk-panel .entity-modal-actions {
    margin-top: auto;
    padding-top: 4px;
    justify-content: flex-start;
}

.commission-offset-summary-panel {
    margin-top: 14px;
}

.commission-offset-workspace {
    display: grid;
    gap: 10px;
}

.commission-offset-inline-panel {
    margin-top: 6px;
    margin-bottom: 6px;
    padding-top: 10px;
}

.commission-offset-inline-layout {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
}

.commission-offset-filter-panel {
    padding: 12px;
    margin-bottom: 0;
}

.commission-offset-filter-panel .commission-sales-filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 12px;
}

.commission-offset-inline-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0;
}

.commission-offset-inline-form {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(200px, 1fr) minmax(190px, 0.8fr) minmax(260px, 1.25fr) auto;
    align-items: end;
}

.commission-offset-inline-field-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.commission-offset-fill-button {
    min-height: 28px;
    padding: 0 10px;
    font-size: 10px;
    line-height: 1;
}

.commission-offset-inline-notes {
    grid-column: 3;
    min-width: 0;
}

.commission-offset-inline-notes textarea {
    min-height: 84px;
}

.commission-offset-inline-actions {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 12px;
    min-width: max-content;
    height: 100%;
}

.commission-offset-inline-actions .action-button {
    min-width: 132px;
}

.commission-offset-inline-helper {
    grid-column: 1 / -1;
    margin: 0;
}

.commission-offset-workspace .sales-count-bar {
    margin-top: 0;
}

.commission-offset-workspace .table-wrap {
    margin-top: 0;
}

.commission-offset-inline-summary .report-summary-card {
    min-width: 0;
}

.commission-offset-inline-summary .report-summary-card strong {
    line-height: 1.35;
    overflow-wrap: anywhere;
}

@media (max-width: 1360px) {
    .commission-offset-filter-panel .commission-sales-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .commission-offset-inline-form {
        grid-template-columns: minmax(180px, 1fr) minmax(170px, 0.8fr) minmax(220px, 1fr) auto;
    }
}

.commission-sales-hidden-inputs {
    display: none;
}

.commission-selected-sales-panel {
    margin-top: 14px;
}

.commission-selected-sales-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.bulk-helper-copy {
    margin: -2px 0 0;
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.commission-sales-selection-head {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.checkbox-cell {
    width: 40px;
    text-align: center;
}

.checkbox-cell input {
    width: 16px;
    height: 16px;
}

.table-action-cell {
    width: 1%;
    white-space: nowrap;
}

.table-inline-danger {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--danger-text);
    font: inherit;
    font-weight: 700;
}

.table-inline-danger:hover {
    text-decoration: underline;
}

.table-inline-danger-large {
    font-size: 13px;
    line-height: 1.2;
    padding: 4px 0;
}

@media (max-width: 1180px) {
    .commission-payments-summary {
        grid-template-columns: minmax(0, 1fr);
    }

    .commission-payment-detail-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .commission-sales-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .commission-sales-filter-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .commission-sales-selection-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .commission-offset-inline-layout,
    .commission-offset-inline-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .commission-offset-filter-panel .commission-sales-filter-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .commission-offset-inline-summary {
        grid-template-columns: minmax(0, 1fr);
    }

    .commission-offset-inline-notes {
        grid-column: auto;
    }

    .commission-offset-inline-actions {
        min-width: 0;
        height: auto;
    }

    .commission-offset-inline-actions .action-button {
        width: 100%;
    }

    .commission-payment-history .nested-table {
        min-width: 0;
    }

    .commission-payment-remaining-input {
        font-size: 12px;
    }
}

.profile-item-with-actions {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.profile-item-actions {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.page-actions form,
.profile-item-actions form {
    margin: 0;
}

.danger-ghost-button {
    color: #9f2f2f;
}

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

.office-profile-split {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.office-finance-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 14px;
}

.office-finance-grid-single {
    grid-template-columns: minmax(0, 1fr);
}

.office-finance-card {
    display: grid;
    gap: 8px;
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid rgba(19, 50, 44, 0.08);
    background: rgba(255, 250, 242, 0.96);
}

.office-finance-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.office-finance-value {
    font-size: clamp(1.2rem, 1rem + 0.4vw, 1.55rem);
    line-height: 1.1;
    color: var(--text);
}

.office-finance-card-breakdown {
    gap: 10px;
}

.office-finance-breakdown {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.office-finance-breakdown-item {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.office-finance-breakdown-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    line-height: 1.35;
}

.office-finance-breakdown-value {
    font-size: clamp(0.95rem, 0.85rem + 0.22vw, 1.12rem);
    line-height: 1.25;
    color: var(--text);
    word-break: break-word;
}

.office-profile-block {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.office-commission-form {
    margin-top: 16px;
    margin-bottom: 18px;
}

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

.user-management-actions {
    grid-column: 1 / -1;
}

.office-commission-notes-field {
    grid-column: 1 / -1;
}

.office-commission-actions {
    justify-content: flex-start;
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
}

.office-commission-actions .action-button {
    white-space: nowrap;
}

.project-commission-block .profile-list-head {
    align-items: center;
}

.project-commission-form {
    margin-top: 14px;
    margin-bottom: 14px;
    padding: 16px;
    border-radius: 18px;
    border: 1px solid rgba(19, 50, 44, 0.08);
    background: rgba(255, 255, 255, 0.72);
}

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

    .sidebar {
        position: static;
    }
}

@media (max-width: 1080px) {
    .project-grid,
    .compact-office-grid,
    .expanded-report-summary,
    .report-trend-grid,
    .report-comparison-grid,
    .filters-grid,
    .office-profile-split,
    .office-summary-grid,
    .office-finance-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .loan-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    #sales-create-form .sales-entry-row-primary,
    #sales-create-form .sales-entry-row-customer {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #sales-create-form .sales-entry-field-customer-name,
    #sales-create-form .sales-entry-field-identity,
    #sales-create-form .sales-entry-field-phone,
    #sales-create-form .sales-entry-field-email,
    #sales-create-form .sales-entry-field-address {
        grid-column: auto;
    }

    .panel-toolbar-inline {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .panel-toolbar-inline .card-search-field,
    .panel-toolbar-inline form,
    .panel-toolbar-actions {
        width: 100%;
        flex: 1 1 auto;
    }

    .panel-toolbar-actions {
        justify-content: flex-start;
    }

    .panel-toolbar-actions > .action-button,
    .panel-toolbar-actions > .ghost-button,
    .panel-toolbar-actions > .inline-import-details,
    .panel-toolbar-actions > form {
        flex: 1 1 180px;
    }

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

    .sales-filter-row-primary,
    .sales-filter-row-secondary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sales-filter-row-tertiary {
        grid-template-columns: minmax(0, 1fr);
    }

    .sales-filter-bar,
    .sales-filter-bar-left,
    .sales-filter-bar-right {
        width: 100%;
    }

    .sales-filter-bar-right,
    .sales-sort-controls {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .sales-date-controls .compact-filter-field,
    .sales-sort-controls .compact-filter-field,
    .sales-sort-controls .compact-filter-field-narrow {
        min-width: 0;
        flex: 1 1 150px;
    }

    .sales-action-controls .action-button,
    .sales-action-controls .ghost-button,
    .sales-action-controls .inline-import-details,
    .sales-action-controls .inline-import-details > summary {
        flex: 1 1 150px;
        min-width: 0;
    }

    .app-page-reports .report-filter-form .filter-submit-wrap {
        width: 100%;
        flex-wrap: wrap;
    }
}

@media (max-width: 720px) {
    #sales-create-form .sales-entry-row-primary,
    #sales-create-form .sales-entry-row-customer,
    #sales-create-form .sales-entry-row-notes {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 760px) {
    .dashboard-shell {
        width: min(100% - 14px, 100%);
        gap: 14px;
        padding-top: max(12px, env(safe-area-inset-top, 0px) + 6px);
    }

    .sidebar {
        position: relative;
        top: 0;
        gap: 0;
        min-height: auto;
        padding: max(14px, env(safe-area-inset-top, 0px) + 6px) 16px 14px;
        width: min(100%, calc(100vw - 18px));
        max-width: calc(100vw - 18px);
        min-width: 0;
        justify-self: start;
        overflow: hidden;
    }

    .sidebar-menu-toggle {
        display: inline-flex;
    }

    .sidebar-nav {
        display: none;
        margin-top: 14px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: hidden;
    }

    .sidebar.is-mobile-open .sidebar-nav {
        display: grid;
    }

    .sidebar-footer {
        margin-top: 14px;
        padding-top: 12px;
    }

    .sidebar.is-mobile-open .sidebar-menu-toggle span:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }

    .sidebar.is-mobile-open .sidebar-menu-toggle span:nth-child(2) {
        opacity: 0;
    }

    .sidebar.is-mobile-open .sidebar-menu-toggle span:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }

    .topbar,
    .page-intro {
        flex-direction: column;
        align-items: flex-start;
    }

    .panel {
        padding: 18px;
    }

    .page-intro-inline {
        width: 100%;
    }

    .topbar-meta,
    .topbar-user-card,
    .page-actions {
        width: 100%;
    }

    .topbar-user-card {
        justify-content: space-between;
        min-width: 0;
        margin-left: 0;
        padding: 10px 12px;
        flex-wrap: wrap;
    }

    .filter-submit-wrap {
        justify-content: flex-start;
    }

    .topbar {
        gap: 12px;
        min-height: 0;
        padding: 16px 18px;
    }

    .topbar-title {
        white-space: normal;
        line-height: 1.35;
    }

    .sales-table-toolbar {
        grid-template-columns: 1fr;
        grid-template-areas:
            "meta"
            "sort"
            "actions";
        align-items: stretch;
    }

    .sales-sort-controls {
        justify-content: flex-start;
        margin-left: 0;
        flex-wrap: wrap;
    }

    .sales-toolbar-left,
    .sales-date-controls,
    .sales-action-controls {
        flex-wrap: wrap;
    }

    .sales-action-controls .sales-filter-command-group {
        margin-left: auto;
    }

    .sales-action-controls .sales-count-bar-inline {
        width: 100%;
        margin-left: 0;
        text-align: right;
    }

    .app-page-reports .report-filter-form .filter-submit-wrap,
    .app-page-brands .panel-toolbar-actions,
    .app-page-consultants .consultant-filter-actions,
    .app-page-customers .panel-toolbar-actions {
        width: 100%;
    }

    .app-page-reports .report-filter-form .action-button,
    .app-page-reports .report-filter-form button,
    .app-page-brands .panel-toolbar-actions > .action-button,
    .app-page-brands .panel-toolbar-actions > .inline-import-details,
    .app-page-customers .panel-toolbar-actions > .action-button {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .entity-modal {
        padding: 10px 0;
    }

    .project-grid,
    .compact-office-grid,
    .expanded-report-summary,
    .report-trend-grid,
    .report-comparison-grid,
    .filters-grid,
    .office-profile-split,
    .office-summary-grid,
    .office-finance-grid {
        grid-template-columns: 1fr;
    }

    .report-trend-head,
    .report-trend-foot {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .communication-summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .report-trend-totals {
        text-align: left;
    }

    .panel,
    .topbar,
    .project-card,
    .office-card,
    .sidebar {
        border-radius: 22px;
    }

    .panel {
        padding: 16px;
    }

    .project-card-link,
    .office-detail-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .brand-hero,
    .section-head-inline {
        flex-direction: column;
        align-items: flex-start;
    }

    .brand-hero-actions {
        margin-left: 0;
    }

    .card-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .app-page-projects .card-footer {
        align-items: stretch;
    }

    .app-page-projects .compact-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .entity-modal-panel {
        width: min(100vw - 12px, 100%);
        max-height: calc(100vh - 20px);
        margin: 0 auto;
        padding: 16px;
    }

    .two-column-form {
        grid-template-columns: 1fr;
    }

    .field-span-2 {
        grid-column: auto;
    }

    .sale-detail-layout {
        grid-template-columns: 1fr;
    }

    .sales-sort-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .sales-action-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .sales-filter-row-primary,
    .sales-filter-row-secondary,
    .sales-filter-row-tertiary,
    .consultant-filter-row {
        grid-template-columns: 1fr;
    }

    .consultant-filter-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .consultant-filter-actions-left,
    .consultant-filter-actions-right {
        width: 100%;
        justify-content: flex-start;
    }

    .sales-table-toolbar {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .sales-filter-bar,
    .sales-filter-bar-left,
    .sales-filter-bar-right,
    .sales-toolbar-left,
    .sales-date-controls {
        width: 100%;
    }

    .sales-date-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .compact-filter-field,
    .compact-filter-field-narrow {
        flex: 1 1 140px;
        width: auto;
    }

    .sales-action-controls .sales-filter-command-group,
    .sales-filter-bar-right {
        margin-left: 0;
        justify-content: flex-start;
    }

    .sales-action-controls .sales-count-bar-inline {
        justify-content: flex-start;
        text-align: left;
    }

    .inline-import-panel {
        width: min(100vw - 28px, 100%);
        padding: 14px;
    }

    .report-summary-card,
    .report-comparison-card,
    .report-trend-card,
    .office-finance-card {
        padding: 14px;
        border-radius: 18px;
    }

    .report-summary-card strong {
        font-size: 16px;
    }

    .commission-payments-summary .report-summary-card strong {
        font-size: 13px;
    }

    .commission-payments-summary .report-summary-card span,
    .commission-payments-summary .report-summary-card small {
        font-size: 11px;
    }

    .sales-table {
        min-width: 620px;
    }

    .sales-table th,
    .sales-table td {
        padding: 11px 10px;
    }

    .topbar-user-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-user-card .role-switcher {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    #sales-modal .entity-modal-panel {
        width: min(100vw - 12px, 100%);
    }

    #sales-create-form .sales-entry-row-primary,
    #sales-create-form .sales-entry-row-customer,
    #sales-create-form .sales-entry-row-notes {
        grid-template-columns: 1fr;
    }

    .dashboard-shell {
        width: min(100% - 10px, 100%);
        gap: 10px;
        padding-bottom: max(18px, env(safe-area-inset-bottom, 0px) + 10px);
    }

    .sidebar,
    .topbar,
    .panel,
    .project-card,
    .office-card,
    .report-summary-card {
        border-radius: 18px;
    }

    .sidebar {
        padding-left: 14px;
        padding-right: 14px;
    }

    .topbar {
        padding: 14px;
    }

    .topbar-user-card {
        width: 100%;
    }

    .action-button,
    .ghost-button,
    .topbar-logout-button {
        min-height: 38px;
        padding: 0 12px;
        font-size: 11px;
    }

    .sales-filter-section {
        padding: 12px;
        border-radius: 16px;
    }

    .sales-table {
        min-width: 540px;
    }

    .sales-table th {
        font-size: 9px;
        letter-spacing: 0.1em;
    }

    .sales-table td {
        font-size: 11px;
        line-height: 1.45;
    }
}

@media (display-mode: standalone) {
    html,
    body {
        height: auto;
        min-height: 100dvh;
        overflow-y: auto;
        overscroll-behavior-y: auto;
    }

    body {
        min-height: 100dvh;
        overflow-x: hidden;
    }

    .dashboard-shell {
        min-height: 100dvh;
        max-height: 100dvh;
        align-items: start;
        padding-top: max(12px, env(safe-area-inset-top, 0px) + 4px);
        overflow: hidden;
    }

    .main-shell {
        min-height: 0;
        max-height: calc(100dvh - max(24px, env(safe-area-inset-bottom, 0px) + 16px));
        overflow-y: auto;
        overscroll-behavior-y: contain;
        scrollbar-gutter: stable;
        padding-right: 2px;
    }

    .sidebar {
        max-height: calc(100dvh - max(24px, env(safe-area-inset-bottom, 0px) + 16px));
        overflow-y: auto;
        overscroll-behavior-y: contain;
    }
}
