:root {
    --bg: #eef1f6;
    --surface: #ffffff;
    --surface-alt: #f8f9fb;
    --border: #dde3ec;
    --text: #1a1d24;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --incoming: #6366f1;
    --incoming-light: #e0e7ff;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
    --radius: 14px;
    --radius-sm: 8px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

html {
    scrollbar-gutter: stable;
}

.hidden {
    display: none !important;
}

.app {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 24px 32px 48px;
}

/* Header */
.header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px 20px;
    margin-bottom: 20px;
}

.header__left {
    justify-self: start;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
}

.header__left--brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.header__logo {
    width: 58px;
    height: 58px;
    object-fit: contain;
    flex-shrink: 0;
}

.header__center {
    justify-self: center;
    display: flex;
    justify-content: center;
}

.header__right {
    justify-self: end;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
}

.header__title {
    margin: 0 0 4px;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header__subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.header-menu {
    position: relative;
}

.header-menu__toggle {
    min-width: 0;
    white-space: nowrap;
}

.header-menu__toggle::after {
    content: '▾';
    margin-left: 6px;
    font-size: 11px;
    opacity: 0.7;
}

.header-menu__dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    min-width: 220px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.header-menu__dropdown[hidden] {
    display: none;
}

.header-menu__link {
    display: block;
    padding: 10px 12px;
    border-radius: calc(var(--radius-sm) - 2px);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.header-menu__link:hover {
    background: var(--surface-alt);
    color: var(--primary);
}

.date-nav {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.date-nav__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: none;
    background: var(--surface-alt);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    transition: background 0.15s;
}

.date-nav__btn:hover {
    background: var(--border);
}

.date-nav__input {
    border: none;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    padding: 0 14px;
    height: 42px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    min-width: 158px;
}

.date-nav__input:focus {
    outline: 2px solid var(--primary-light);
    outline-offset: -2px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 9px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.badge--missed-meter {
    position: relative;
    overflow: hidden;
    min-width: 300px;
    padding: 12px 22px;
    font-size: 16px;
    font-weight: 700;
    justify-content: center;
    background: #3f4654;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.badge--missed__fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--missed-fill, 0%);
    border-radius: 999px 0 0 999px;
    transition: width 0.35s ease, background 0.25s ease;
    pointer-events: none;
}

.badge--missed--ok .badge--missed__fill {
    background: rgba(22, 163, 74, 0.92);
}

.badge--missed--warn .badge--missed__fill {
    background: rgba(234, 179, 8, 0.95);
}

.badge--missed--bad .badge--missed__fill {
    background: rgba(220, 38, 38, 0.95);
}

.badge--missed__text {
    position: relative;
    z-index: 1;
    color: #fff;
}

/* Sync banner */
.sync-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.sync-banner--warning {
    background: var(--warning-light);
    border-color: rgba(217, 119, 6, 0.25);
}

.sync-banner--success {
    background: var(--success-light);
    border-color: rgba(22, 163, 74, 0.2);
}

.sync-banner__text {
    margin: 0;
    font-size: 13px;
    color: var(--text);
}

.sync-banner__text strong {
    font-weight: 600;
}

.sync-banner__meta {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

.sync-banner__action {
    flex-shrink: 0;
}

/* States */
.state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 72px 24px;
    text-align: center;
    color: var(--text-muted);
}

.state--empty {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin-top: 8px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s, background 0.15s;
    text-decoration: none;
}

.btn--primary {
    background: var(--primary);
    color: #fff;
}

.btn--primary:hover {
    opacity: 0.92;
}

.btn--ghost {
    padding: 9px 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 13px;
}

.btn--ghost:hover {
    background: var(--surface-alt);
    color: var(--text);
}

.btn--sm {
    padding: 7px 14px;
    font-size: 13px;
}

.btn--refresh {
    position: relative;
    overflow: hidden;
    min-width: 168px;
    padding: 9px 14px;
}

.btn--refresh__fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 0;
    width: 0%;
    background: linear-gradient(90deg, rgba(22, 163, 74, 0.45), rgba(34, 197, 94, 0.65));
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    transition: width 0.08s linear;
    pointer-events: none;
}

.btn--refresh--countdown {
    border-color: rgba(22, 163, 74, 0.35);
}

.btn--refresh--countdown .btn--refresh__label {
    color: var(--success);
    font-weight: 600;
}

.btn--refresh__label {
    position: relative;
    z-index: 1;
}

.btn--refresh--active {
    color: var(--success);
    border-color: rgba(22, 163, 74, 0.4);
}

.btn--refresh--active .btn--refresh__label {
    font-weight: 600;
}

.btn--refresh__fill--sync {
    width: 100% !important;
    transition: none;
    animation: refresh-sync-pulse 1.1s ease-in-out infinite;
}

@keyframes refresh-sync-pulse {
    0%, 100% {
        opacity: 0.55;
    }

    50% {
        opacity: 1;
    }
}

.btn--refresh--countdown .btn--refresh__fill {
    transition: width 0.12s linear;
}

.btn--refresh:disabled {
    cursor: wait;
    opacity: 1;
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 28px;
    box-shadow: var(--shadow);
}

.login-card__logo {
    display: block;
    width: 220px;
    max-width: 80%;
    height: auto;
    margin: 0 auto 22px;
}

.login-card__title {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
}

.login-card__subtitle {
    margin: 0 0 24px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

.login-card__error {
    margin-bottom: 16px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--danger-light);
    color: var(--danger);
    font-size: 13px;
    text-align: center;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-form__label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.login-form__input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
}

.login-form__input:focus {
    outline: 2px solid var(--primary-light);
    border-color: var(--primary);
}

.login-form__submit {
    width: 100%;
    padding: 11px;
    margin-top: 4px;
}

/* Dashboard layout */
.dashboard--silent-update {
    visibility: visible;
}

.dashboard--silent-update .dashboard-table-wrap,
.dashboard--silent-update #totalCard,
.dashboard--silent-update .cards-grid {
    opacity: 1;
}

#totalCard {
    margin-bottom: 16px;
}

#totalCard .card {
    margin: 0;
}

.cards-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card--preview {
    padding: 14px 18px;
}

.card--preview.card--total {
    border-left: 4px solid var(--success);
    background: var(--success-light);
    margin-bottom: 4px;
}

.preview-card__layout {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    width: 100%;
}

.preview-card__layout--toggle {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.preview-card__layout--toggle:hover {
    background: var(--surface-alt);
}

.preview-card__name {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
    word-break: break-word;
}

.card--total .preview-card__name {
    font-size: 18px;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    min-width: 0;
}

.preview-item {
    min-width: 0;
}

.stat-label {
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-value {
    margin-top: 8px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.stat-value--split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stat-value__money {
    font-size: 14px;
    font-weight: 700;
    color: var(--success);
    white-space: nowrap;
}

.stat-value__money--zero {
    color: var(--text-muted);
}

.call-progress {
    display: flex;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface-alt);
    border: 1px solid var(--border);
}

.call-progress--empty {
    min-height: 28px;
}

.call-progress__seg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 100%;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

.call-progress__seg--success {
    background: #2563eb;
}

.call-progress__seg--missed {
    background: #ef4444;
}

.call-progress__seg--incoming {
    background: #84cc16;
}

.compact-progress {
    height: 8px;
    border-radius: 999px;
    background: #eef1f6;
    border: 1px solid var(--border);
    overflow: hidden;
}

.compact-progress__fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    max-width: 100%;
    transition: width 0.3s ease;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow);
}

.card--total {
    border-left: 4px solid var(--success);
    background: var(--success-light);
}

.card__metrics--total {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) minmax(140px, 1fr) minmax(100px, 0.7fr) minmax(140px, 1fr);
    gap: 28px 32px;
    align-items: start;
}

.card__metrics--total .metric {
    margin-bottom: 0;
}

.card__metrics .metric {
    margin-bottom: 16px;
}

.card__metrics .metric:last-child {
    margin-bottom: 0;
}

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

.card__header--toggle {
    width: 100%;
    margin: -4px -6px 18px;
    padding: 4px 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius-sm);
    text-align: left;
    font: inherit;
    color: inherit;
    transition: background 0.15s;
}

.card__header--toggle:hover {
    background: var(--surface-alt);
}

.card__toggle-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-left: 8px;
    background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath d='M5.5 7.5 10 12l4.5-4.5'/%3E%3C/svg%3E");
    transition: transform 0.2s ease;
}

.card__header--toggle-open .card__toggle-icon {
    transform: rotate(180deg);
}

.card--expanded {
    border-color: rgba(37, 99, 235, 0.25);
    box-shadow: 0 8px 28px rgba(37, 99, 235, 0.08);
}

.card__details {
    margin-top: 4px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.card__title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
}

.card__title--total {
    font-size: 19px;
}

.card__paid {
    font-size: 16px;
    font-weight: 700;
    color: var(--success);
    white-space: nowrap;
}

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

/* Metric rows */
.metric {
    margin-bottom: 16px;
}

.metric:last-child {
    margin-bottom: 0;
}

.metric__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.metric__label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.metric__values {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.metric__values span {
    color: var(--text-muted);
    font-weight: 400;
}

/* Segmented call bar */
.call-bar {
    display: flex;
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface-alt);
    border: 1px solid var(--border);
}

.call-bar__segment {
    height: 100%;
    min-width: 0;
    transition: width 0.3s ease;
}

.call-bar__segment--success { background: var(--success); }
.call-bar__segment--missed { background: var(--danger); }
.call-bar__segment--incoming { background: var(--incoming); }

.call-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.call-legend__item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-muted);
}

.call-legend__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.call-legend__dot--success { background: var(--success); }
.call-legend__dot--missed { background: var(--danger); }
.call-legend__dot--incoming { background: var(--incoming); }

/* Progress bar */
.progress {
    height: 12px;
    border-radius: 999px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    overflow: hidden;
}

.progress__fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.3s ease;
    max-width: 100%;
}

.progress__fill--minutes {
    background: linear-gradient(90deg, #3b82f6, #2563eb);
}

.progress__fill--invoices {
    background: linear-gradient(90deg, #8b5cf6, #7c3aed);
}

.progress__fill--over {
    background: linear-gradient(90deg, #16a34a, #15803d);
}

/* View toggle */
.view-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}

.view-toggle__btn {
    padding: 9px 14px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.view-toggle__btn:hover {
    background: var(--surface-alt);
    color: var(--text);
}

.view-toggle__btn--active {
    background: var(--primary);
    color: #fff;
}

.view-toggle__btn--active:hover {
    background: var(--primary);
    color: #fff;
}

.view-toggle--icons .view-toggle__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
}

.view-toggle__icon {
    display: block;
    fill: currentColor;
}

/* Table view */
.dashboard-table-wrap {
    width: 100%;
    max-height: calc(100vh - 168px);
    min-height: 280px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
}

.dashboard-table-scroll {
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 168px);
    overflow: auto;
    overscroll-behavior: contain;
}

.dashboard-table {
    --table-cols: 1.4fr 1.2fr 1fr 1.2fr 1.2fr 1fr 0.9fr 0.9fr 0.9fr 0.9fr;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    background: var(--surface);
}

.table-row {
    display: grid;
    grid-template-columns: var(--table-cols);
    align-items: stretch;
    border-bottom: 1px solid var(--border);
}

.table-row:last-child {
    border-bottom: none;
}

.table-row--header {
    background: #f8f9fb;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #495057;
}

.table-row--header .table-cell {
    padding: 10px 8px;
    justify-content: center;
    text-align: center;
}

.table-row--total {
    background: var(--success-light);
    font-weight: 600;
}

.table-row--total .table-cell {
    background: var(--success-light);
}

.table-row--total .table-cell--name {
    color: var(--success);
    font-weight: 700;
}

.table-row--body:nth-child(even) {
    background: #fafbfc;
}

.table-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 8px;
    text-align: center;
    border-right: 1px solid var(--border);
    min-height: var(--table-row-min-height, 72px);
    min-width: 0;
    overflow: hidden;
}

.table-cell--resizable {
    position: relative;
}

.table-cell:last-child {
    border-right: none;
}

.table-cell--name {
    align-items: flex-start;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    padding-left: 16px;
}

.table-cell--name-toggle {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
    color: inherit;
    transition: background 0.15s;
}

.table-cell--name-toggle:hover {
    background: rgba(37, 99, 235, 0.06);
}

.table-cell--name-toggle--open {
    color: var(--primary);
}

.table-cell__toggle-icon {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath d='M7.5 5.5 12 10l-4.5 4.5'/%3E%3C/svg%3E");
    transition: transform 0.2s ease;
}

.table-cell--name-toggle--open .table-cell__toggle-icon {
    transform: rotate(90deg);
}

.table-cell--name-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin: 0;
    border: none;
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
    color: var(--primary);
    font-weight: 600;
    transition: color 0.15s, background 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

.table-cell--name-btn:hover {
    color: #1d4ed8;
    background: rgba(37, 99, 235, 0.06);
}

.table-cell--name-btn:focus {
    outline: none;
}

.table-cell--name-btn:focus-visible {
    box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.35);
}

.table-row--expanded {
    background: #f8fbff;
}

.table-row--details {
    background: #f8fbff;
}

.table-cell--details {
    grid-column: 1 / -1;
    align-items: stretch;
    text-align: left;
    padding: 0 16px 16px;
    min-height: auto;
    border-right: none;
}

/* Manager expand details */
.manager-details__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.manager-details__panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
}

.manager-details__title {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.manager-details__labels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text);
}

.manager-details__labels--bottom {
    margin-bottom: 0;
    margin-top: 12px;
}

.manager-details__labels strong {
    font-weight: 600;
    color: #334155;
}

/* Manager modal */
body.modal-open {
    overflow: hidden;
}

.manager-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.manager-modal.hidden {
    display: none;
}

.manager-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.manager-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(920px, 100%);
    max-height: min(88vh, 900px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.manager-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.manager-modal__title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.manager-modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    color: var(--text-muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.manager-modal__close:hover {
    background: var(--border);
    color: var(--text);
}

.manager-modal__body {
    padding: 24px;
    overflow: auto;
}

@media (max-width: 768px) {
    .manager-modal {
        padding: 12px;
    }

    .manager-modal__header,
    .manager-modal__body {
        padding: 16px;
    }
}

.call-bar--detail {
    height: 28px;
    border-radius: 6px;
}

.call-bar--detail .call-bar__segment {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    min-width: 28px;
}

.call-bar__segment--outgoing {
    background: #2563eb;
}

.call-bar__segment--incoming-detail {
    background: #84cc16;
}

@media (max-width: 900px) {
    .manager-details__grid {
        grid-template-columns: 1fr;
    }

    .manager-details__labels {
        grid-template-columns: 1fr;
    }
}

.table-cell--hot {
    background: #fffef0;
    border-left: 2px solid #fff000;
    border-right: 2px solid #fff000;
}

.table-header-block {
    display: grid;
    grid-template-columns: var(--table-cols);
    background: #f8f9fb;
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #495057;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 0 var(--border);
}

.table-header-block .row-resize-handle {
    grid-column: 1 / -1;
    position: relative;
    height: 0;
    margin: 0;
    padding: 0;
    border: none;
    z-index: 12;
}

.row-resize-handle {
    display: block;
    position: absolute;
    left: 0;
    right: 0;
    bottom: -5px;
    height: 10px;
    cursor: row-resize;
    z-index: 12;
}

.row-resize-handle::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 3px;
    height: 3px;
    background: transparent;
    border-radius: 2px;
    transition: background 0.15s;
}

.row-resize-handle:hover::after,
body.row-resizing .row-resize-handle::after {
    background: rgba(22, 163, 74, 0.55);
}

body.row-resizing {
    cursor: row-resize;
    user-select: none;
}

body.row-resizing * {
    cursor: row-resize !important;
}

.table-header-block .table-cell {
    padding: 10px 8px;
    justify-content: center;
    text-align: center;
    min-height: auto;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.table-header-block .table-cell:last-child {
    border-right: none;
}

.table-cell--rowspan {
    grid-row: 1 / span 2;
    align-self: stretch;
}

.table-cell--rowspan.table-cell--name {
    align-items: flex-start;
    text-align: left;
    padding-left: 16px;
}

.table-cell--hot-header {
    background: #fff000;
    color: #1a1a1a;
}

.table-row--header.table-row--header-main {
    border-bottom: none;
}

.table-row--header.table-row--header-sub {
    background: #f8f9fb;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #636e72;
}

.table-row--header.table-row--header-sub .table-cell {
    padding: 6px 8px 10px;
    min-height: auto;
}

.table-funnel-group {
    display: contents;
}

.table-cell--empty {
    color: #adb5bd;
    font-size: 13px;
}

.table-cell__main {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
}

.fact-plan {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    line-height: 1.15;
    text-align: center;
}

.fact-plan__fact {
    font-size: 1em;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.fact-plan__meta {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.stat-value .fact-plan {
    align-items: flex-start;
}

.stat-value--split .fact-plan {
    align-items: flex-start;
}

.table-cell__sub {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.3;
}

.table-calls-details {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
}

.table-calls-details__in {
    color: var(--incoming);
}

.table-calls-details__out {
    color: var(--success);
}

.table-calls-details__miss {
    color: var(--danger);
}

.table-hot-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    background: #fff000;
    color: #1a1a1a;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.table-hot-count {
    font-size: 20px;
    font-weight: 700;
}

.table-header-funnel {
    color: #adb5bd;
}

.col-resize-handle {
    position: absolute;
    top: 0;
    right: -4px;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    z-index: 3;
    touch-action: none;
}

.col-resize-handle::after {
    content: '';
    position: absolute;
    top: 15%;
    bottom: 15%;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    border-radius: 1px;
    background: transparent;
    transition: background 0.15s;
}

.col-resize-handle:hover::after,
body.col-resizing .col-resize-handle::after {
    background: rgba(37, 99, 235, 0.55);
}

body.col-resizing {
    cursor: col-resize;
    user-select: none;
}

body.col-resizing * {
    cursor: col-resize !important;
}

.table-sort-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 0;
    padding: 2px 6px;
    border: none;
    border-radius: 4px;
    background: transparent;
    font: inherit;
    font-size: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: inherit;
    cursor: pointer;
    max-width: 100%;
    transition: background 0.15s, color 0.15s;
}

.table-cell--name .table-sort-btn {
    justify-content: flex-start;
    width: calc(100% - 8px);
}

.table-sort-btn:hover {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.table-sort-btn--asc,
.table-sort-btn--desc {
    color: var(--primary);
}

.table-sort-btn__icon {
    flex-shrink: 0;
    font-size: 10px;
    line-height: 1;
    opacity: 0.4;
}

.table-sort-btn__icon::after {
    content: '⇅';
}

.table-sort-btn--asc .table-sort-btn__icon,
.table-sort-btn--desc .table-sort-btn__icon {
    opacity: 1;
}

.table-sort-btn--asc .table-sort-btn__icon::after {
    content: '↑';
}

.table-sort-btn--desc .table-sort-btn__icon::after {
    content: '↓';
}

@media (max-width: 1400px) {
    .card__metrics--total {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1024px) {
    .preview-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .preview-card__layout {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

@media (max-width: 1100px) {
    .header {
        grid-template-columns: 1fr;
        justify-items: stretch;
    }

    .header__left {
        justify-self: start;
    }

    .header__center {
        justify-self: center;
        width: 100%;
    }

    .badge--missed-meter {
        min-width: 0;
        width: 100%;
        max-width: 420px;
    }

    .header__right {
        justify-self: stretch;
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }

    .dashboard-table-wrap,
    .dashboard-table-scroll {
        max-height: calc(100vh - 220px);
    }
}

@media (max-width: 640px) {
    .app {
        padding: 20px 16px 40px;
    }

    .header {
        gap: 14px;
    }

    .header__right {
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
    }

    .date-nav,
    .sync-banner {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .date-nav__input {
        flex: 1;
    }

    .badge,
    .sync-banner__action .btn {
        justify-content: center;
        width: 100%;
    }

    .cards-grid {
        gap: 10px;
    }

    .card__metrics--total {
        grid-template-columns: 1fr;
    }
}

/* Account / users admin */
.account-alert {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.account-alert--success {
    background: var(--success-light);
    border: 1px solid rgba(22, 163, 74, 0.25);
    color: #166534;
}

.account-alert--error {
    background: var(--danger-light);
    border: 1px solid rgba(220, 38, 38, 0.2);
    color: var(--danger);
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
}

.account-grid--wide {
    grid-template-columns: 1fr;
}

.account-grid--single {
    grid-template-columns: minmax(0, 440px);
    justify-content: center;
    margin: 0 auto;
}

.account-grid--single .account-form {
    max-width: none;
}

.account-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.account-card--full {
    grid-column: 1 / -1;
}

.account-card__title {
    margin: 0 0 20px;
    font-size: 18px;
    font-weight: 700;
}

.account-dl {
    margin: 0;
}

.account-dl__row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.account-dl__row:last-child {
    border-bottom: none;
}

.account-dl dt {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.account-dl dd {
    margin: 0;
    font-weight: 600;
}

.account-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 420px;
}

.account-form--inline {
    max-width: none;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.account-form--inline .login-form__label {
    flex: 1 1 160px;
    margin: 0;
}

.account-form--inline .btn {
    flex: 0 0 auto;
    margin-bottom: 2px;
}

.account-form__hint {
    margin: -6px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

.login-form__input--sm {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 13px;
}

.users-table-wrap {
    overflow-x: auto;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.users-table th,
.users-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.users-table th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--surface-alt);
}

.users-table__row--self {
    background: #f8fbff;
}

.users-table__badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
}

.users-table__status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.users-table__status--active {
    background: var(--success-light);
    color: #166534;
}

.users-table__status--inactive {
    background: var(--surface-alt);
    color: var(--text-muted);
}

.users-table__actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 240px;
}

.users-table__reset-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.users-table__inline-form {
    margin: 0;
}

@media (max-width: 900px) {
    .account-grid {
        grid-template-columns: 1fr;
    }

    .account-form--inline {
        flex-direction: column;
        align-items: stretch;
    }

    .managers-plans-form {
        flex-direction: column;
        align-items: stretch;
    }
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.admin-nav__link {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.admin-nav__link:hover {
    background: var(--surface-alt);
    color: var(--text);
}

.admin-nav__link--active {
    background: var(--primary-light);
    color: var(--primary);
}

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

.account-card__toolbar .account-card__title {
    margin-bottom: 0;
}

.account-card__toolbar-form {
    margin: 0;
}

.managers-plans-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.managers-plans-form__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 88px;
}

.managers-plans-form__label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.managers-plans-table__meta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.managers-plans-effective {
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
}

.users-table__row--inactive {
    opacity: 0.72;
}

.guest-link-copy {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 280px;
}

.guest-link-copy__input {
    flex: 1;
    min-width: 0;
}

.header__guest-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--surface-muted, #f3f4f6);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.btn--icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
}

.btn--icon:hover {
    background: var(--surface-alt);
}

.btn--icon--danger {
    color: var(--danger);
    border-color: rgba(220, 38, 38, 0.25);
}

.btn--icon--danger:hover {
    background: #fef2f2;
    border-color: rgba(220, 38, 38, 0.4);
}

.btn--icon .btn__icon {
    display: block;
}

.guest-link-delete-form {
    margin: 0;
}
