:root {
    --navy-950: #0b1930;
    --navy-900: #10223e;
    --navy-800: #18304f;
    --purple-700: #5b21b6;
    --purple-600: #6d28d9;
    --purple-500: #7c3aed;
    --purple-100: #ede9fe;
    --purple-50: #f5f3ff;
    --gray-900: #172033;
    --gray-700: #475569;
    --gray-500: #64748b;
    --gray-300: #cbd5e1;
    --gray-200: #e2e8f0;
    --gray-100: #f1f5f9;
    --gray-50: #f8fafc;
    --white: #ffffff;
    --green-600: #16a34a;
    --green-100: #dcfce7;
    --red-600: #dc2626;
    --red-100: #fee2e2;
    --sidebar-width: 250px;
    --radius: 14px;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--gray-100);
}

body {
    margin: 0;
    min-width: 320px;
    color: var(--gray-900);
    background: var(--gray-100);
    font-family: Tahoma, "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

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

button,
input,
select {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    z-index: 20;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--sidebar-width);
    overflow-y: auto;
    color: #dbeafe;
    background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
    box-shadow: -8px 0 28px rgba(15, 23, 42, 0.12);
}

.brand {
    display: flex;
    min-height: 112px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: var(--white);
}

.brand-mark {
    color: var(--purple-600);
    font-size: 38px;
    font-weight: 800;
    letter-spacing: 3px;
    line-height: 1;
}

.brand-caption {
    margin-top: 6px;
    color: var(--navy-900);
    font-size: 12px;
    font-weight: 700;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
    padding: 22px 14px;
}

.nav-item {
    display: flex;
    min-height: 46px;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 10px;
    color: #d7e1f1;
    font-weight: 600;
    transition: 160ms ease;
}

.nav-item:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
    color: var(--white);
    background: linear-gradient(135deg, var(--purple-700), var(--purple-500));
    box-shadow: 0 8px 18px rgba(109, 40, 217, 0.3);
}

.nav-icon {
    display: inline-grid;
    width: 24px;
    height: 24px;
    place-items: center;
    font-size: 19px;
}

.main-content {
    min-width: 0;
    margin-right: var(--sidebar-width);
}

.topbar {
    display: flex;
    height: 72px;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--gray-200);
    background: rgba(255, 255, 255, 0.96);
}

.menu-button {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    color: var(--navy-900);
    background: var(--white);
    cursor: default;
    font-size: 20px;
}

.employee-card {
    display: flex;
    align-items: center;
    gap: 10px;
}

.employee-avatar {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: 50%;
    color: var(--white);
    background: var(--purple-600);
    font-weight: 700;
}

.employee-card strong,
.online-status {
    display: block;
}

.online-status {
    margin-top: 2px;
    color: var(--green-600);
    font-size: 11px;
}

.online-status i {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 4px;
    border-radius: 50%;
    background: var(--green-600);
}

.page-content {
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    padding: 26px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 20px;
}

.eyebrow {
    margin: 0 0 3px;
    color: var(--purple-600) !important;
    font-size: 12px;
    font-weight: 700;
}

.page-heading h1 {
    margin: 0;
    font-size: clamp(23px, 2.3vw, 32px);
}

.page-heading p {
    margin: 6px 0 0;
    color: var(--gray-500);
}

.card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow);
}

.filter-card {
    margin-bottom: 20px;
    padding: 20px;
}

.card-header,
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.card-header {
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--gray-100);
}

.card-header > div {
    display: flex;
    align-items: center;
    gap: 9px;
}

.card-header h2,
.table-toolbar h2 {
    margin: 0;
    font-size: 17px;
}

.section-icon {
    display: grid;
    width: 31px;
    height: 31px;
    place-items: center;
    border-radius: 9px;
    color: var(--purple-700);
    background: var(--purple-100);
    font-size: 18px;
}

.filter-hint {
    color: var(--gray-500);
    font-size: 12px;
}

.filter-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 16px;
    align-items: end;
}

.form-field {
    min-width: 0;
}

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

.form-field label {
    display: block;
    margin-bottom: 6px;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
}

.form-field input,
.form-field select {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--gray-300);
    border-radius: 9px;
    outline: none;
    color: var(--gray-900);
    background: var(--white);
    transition: 150ms ease;
}

.form-field input:focus,
.form-field select:focus {
    border-color: var(--purple-500);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.form-field input::placeholder {
    color: #94a3b8;
}

.filter-actions {
    display: flex;
    grid-column: span 2;
    gap: 10px;
    justify-content: flex-start;
}

.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
    transition: 150ms ease;
}

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

.button-primary,
.button-call {
    color: var(--white);
    background: linear-gradient(135deg, var(--purple-700), var(--purple-500));
    box-shadow: 0 5px 13px rgba(109, 40, 217, 0.22);
}

.button-secondary {
    border-color: var(--gray-300);
    color: var(--gray-700);
    background: var(--white);
}

.button-secondary:hover {
    border-color: var(--purple-500);
    color: var(--purple-700);
    background: var(--purple-50);
}

.alert {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 18px;
    padding: 12px 16px;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
}

.alert-success {
    color: #166534;
    background: #f0fdf4;
}

.table-card {
    overflow: hidden;
}

.table-toolbar {
    padding: 17px 20px;
    border-bottom: 1px solid var(--gray-200);
}

.table-toolbar p {
    margin: 3px 0 0;
    color: var(--gray-500);
    font-size: 12px;
}

.table-toolbar-actions,
.page-size-form,
.pagination {
    display: flex;
    align-items: center;
}

.table-toolbar-actions {
    gap: 12px;
}

.page-size-form {
    gap: 8px;
}

.page-size-form label {
    color: var(--gray-500);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.page-size-form select {
    height: 38px;
    min-width: 72px;
    padding: 0 10px;
    border: 1px solid var(--gray-300);
    border-radius: 9px;
    outline: none;
    color: var(--gray-900);
    background: var(--white);
    font-variant-numeric: tabular-nums;
}

.page-size-form select:focus {
    border-color: var(--purple-500);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.result-count {
    display: flex;
    min-width: 92px;
    align-items: baseline;
    justify-content: center;
    gap: 5px;
    padding: 8px 13px;
    border-radius: 10px;
    color: var(--purple-700);
    background: var(--purple-50);
}

.result-count strong {
    font-size: 19px;
}

.result-count span {
    font-size: 11px;
}

.table-scroll {
    direction: rtl;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
}

.pagination {
    justify-content: center;
    gap: 6px;
    padding: 18px 20px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.pagination-link {
    display: inline-flex;
    min-width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    padding: 0 11px;
    border: 1px solid var(--gray-300);
    border-radius: 9px;
    color: var(--gray-700);
    background: var(--white);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    transition: 150ms ease;
}

a.pagination-link:hover {
    border-color: var(--purple-500);
    color: var(--purple-700);
    background: var(--purple-50);
}

.pagination-link.active {
    border-color: var(--purple-600);
    color: var(--white);
    background: linear-gradient(135deg, var(--purple-700), var(--purple-500));
    box-shadow: 0 5px 13px rgba(109, 40, 217, 0.2);
}

.pagination-link.disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.pagination-ellipsis {
    display: inline-grid;
    width: 28px;
    height: 38px;
    place-items: center;
    color: var(--gray-500);
    font-weight: 800;
}

.customer-table {
    width: 100%;
    min-width: 1850px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
    text-align: right;
}

.customer-table th,
.customer-table td {
    max-width: 190px;
    padding: 11px 12px;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
    white-space: nowrap;
}

.customer-table th {
    position: sticky;
    z-index: 4;
    top: 0;
    color: #334155;
    background: var(--gray-50);
    font-size: 11px;
    font-weight: 800;
}

.customer-table tbody tr {
    transition: background-color 130ms ease;
}

.customer-table tbody tr:hover td {
    background: var(--purple-50);
}

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

.sortable a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--navy-900);
}

.sortable a:hover {
    color: var(--purple-600);
}

.sort-arrow {
    color: var(--purple-600);
    font-size: 10px;
}

.numeric,
.ltr-text {
    direction: ltr;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.customer-name {
    font-weight: 700;
}

.long-cell {
    max-width: 180px !important;
    overflow: hidden;
    text-overflow: ellipsis;
}

.purchase-value {
    color: var(--navy-900);
    font-weight: 700;
}

.badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    justify-content: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
}

.badge-success {
    color: #166534;
    background: var(--green-100);
}

.badge-muted {
    color: var(--gray-500);
    background: var(--gray-200);
}

.badge-plan,
.badge-count {
    color: var(--purple-700);
    background: var(--purple-100);
}

.badge-followup {
    color: #991b1b;
    background: var(--red-100);
}

.sticky-action {
    position: sticky;
    z-index: 3;
    left: 0;
    min-width: 112px;
    border-right: 1px solid var(--gray-200);
    background: var(--white);
}

.customer-table th.sticky-action {
    z-index: 6;
    background: var(--gray-50);
}

.customer-table tbody tr:hover .sticky-action {
    background: var(--purple-50);
}

.button-call {
    min-height: 33px;
    padding: 6px 11px;
    font-size: 11px;
}

.empty-state {
    padding: 36px !important;
    color: var(--gray-500);
    text-align: center !important;
}

/* Register call page */
.call-page-heading {
    align-items: center;
}

.customer-summary-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 20px;
    padding: 18px 22px;
    border-top: 3px solid var(--purple-600);
}

.customer-summary-main {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 14px;
}

.customer-avatar {
    display: grid;
    width: 58px;
    height: 58px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 16px;
    color: var(--white);
    background: linear-gradient(135deg, var(--purple-700), var(--purple-500));
    box-shadow: 0 8px 18px rgba(109, 40, 217, 0.24);
    font-size: 23px;
    font-weight: 800;
}

.summary-label {
    display: block;
    margin-bottom: 2px;
    color: var(--gray-500);
    font-size: 11px;
}

.customer-summary-main h2 {
    margin: 0 0 4px;
    overflow: hidden;
    font-size: 21px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.customer-code {
    color: var(--gray-500);
    font-size: 12px;
}

.summary-stat {
    min-width: 120px;
    padding: 10px 16px;
    border-radius: 11px;
    text-align: center;
    background: var(--purple-50);
}

.summary-stat span,
.summary-stat strong {
    display: block;
}

.summary-stat span {
    color: var(--gray-500);
    font-size: 10px;
}

.summary-stat strong {
    margin-top: 2px;
    color: var(--purple-700);
    font-size: 18px;
}

.call-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(330px, 0.75fr);
    gap: 20px;
    align-items: start;
    direction: ltr;
}

.call-form-card,
.history-panel {
    direction: rtl;
}

.call-form-card {
    padding: 20px;
}

.call-card-header {
    margin-bottom: 20px;
}

.required-note {
    color: var(--gray-500);
    font-size: 11px;
}

.alert-error {
    margin-bottom: 18px;
    border-color: #fecaca;
    color: #991b1b;
    background: #fef2f2;
}

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

.call-form-grid .form-field label em {
    color: var(--red-600);
    font-style: normal;
}

.call-form-grid .form-field input,
.call-form-grid .form-field select,
.call-form-grid .form-field textarea {
    width: 100%;
    border: 1px solid var(--gray-300);
    border-radius: 9px;
    outline: none;
    color: var(--gray-900);
    background: var(--white);
    transition: 150ms ease;
}

.call-form-grid .form-field input,
.call-form-grid .form-field select {
    height: 42px;
    padding: 0 12px;
}

.call-form-grid .form-field textarea {
    min-height: 92px;
    padding: 10px 12px;
    resize: vertical;
    font: inherit;
    line-height: 1.7;
}

.call-form-grid .form-field input:focus,
.call-form-grid .form-field select:focus,
.call-form-grid .form-field textarea:focus {
    border-color: var(--purple-500);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.call-form-grid .form-field textarea::placeholder,
.call-form-grid .form-field input::placeholder {
    color: #94a3b8;
}

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

.call-form-actions {
    display: flex;
    gap: 10px;
    padding-top: 4px;
}

.history-panel {
    position: sticky;
    top: 18px;
    max-height: calc(100vh - 108px);
    overflow: hidden;
}

.history-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 17px 18px;
    border-bottom: 1px solid var(--gray-200);
}

.history-heading > div {
    display: flex;
    align-items: center;
    gap: 9px;
}

.history-heading h2 {
    margin: 0;
    font-size: 16px;
}

.history-count {
    padding: 4px 9px;
    border-radius: 999px;
    color: var(--purple-700);
    background: var(--purple-50);
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
}

.call-timeline {
    position: relative;
    display: grid;
    max-height: calc(100vh - 178px);
    gap: 12px;
    overflow-y: auto;
    padding: 16px 22px 18px 16px;
}

.call-timeline::before {
    position: absolute;
    top: 18px;
    right: 10px;
    bottom: 18px;
    width: 2px;
    background: var(--purple-100);
    content: "";
}

.history-card {
    position: relative;
    padding: 14px;
    border: 1px solid var(--gray-200);
    border-radius: 11px;
    background: var(--white);
}

.history-card::before {
    position: absolute;
    top: 19px;
    right: -17px;
    width: 9px;
    height: 9px;
    border: 3px solid var(--white);
    border-radius: 50%;
    background: var(--purple-500);
    box-shadow: 0 0 0 1px var(--purple-200, #ddd6fe);
    content: "";
}

.history-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.history-date strong,
.history-date span {
    display: block;
    direction: ltr;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.history-date strong {
    font-size: 12px;
}

.history-date span {
    margin-top: 2px;
    color: var(--gray-500);
    font-size: 10px;
}

.call-status-badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
}

.status-success {
    color: #166534;
    background: var(--green-100);
}

.status-danger {
    color: #991b1b;
    background: var(--red-100);
}

.status-warning {
    color: #92400e;
    background: #fef3c7;
}

.status-neutral {
    color: var(--gray-700);
    background: var(--gray-200);
}

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

.history-details div {
    min-width: 0;
}

.history-details dt {
    color: var(--gray-500);
    font-size: 9px;
}

.history-details dd {
    margin: 2px 0 0;
    overflow-wrap: anywhere;
    color: #334155;
    font-size: 11px;
    font-weight: 700;
}

.history-note {
    margin-top: 11px;
    padding-top: 10px;
    border-top: 1px dashed var(--gray-200);
}

.history-note span {
    color: var(--gray-500);
    font-size: 9px;
}

.history-note p {
    margin: 3px 0 0;
    overflow-wrap: anywhere;
    color: #334155;
    font-size: 11px;
    line-height: 1.7;
    white-space: normal;
}

.history-empty {
    display: grid;
    min-height: 250px;
    place-items: center;
    align-content: center;
    padding: 28px;
    color: var(--gray-500);
    text-align: center;
}

.history-empty > span {
    display: grid;
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
    place-items: center;
    border-radius: 14px;
    color: var(--purple-600);
    background: var(--purple-50);
    font-size: 22px;
}

.history-empty strong {
    color: var(--gray-700);
}

.history-empty p {
    margin: 5px 0 0;
    font-size: 11px;
}

@media (max-width: 1180px) {
    :root {
        --sidebar-width: 215px;
    }

    .filter-form {
        grid-template-columns: repeat(3, minmax(160px, 1fr));
    }

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

    .history-panel {
        position: static;
        max-height: none;
    }

    .call-timeline {
        max-height: none;
    }
}

@media (max-width: 860px) {
    .sidebar {
        position: static;
        width: 100%;
    }

    .brand {
        min-height: 86px;
    }

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding: 10px;
    }

    .nav-item {
        flex: 0 0 auto;
        min-height: 40px;
        padding: 8px 12px;
    }

    .main-content {
        margin-right: 0;
    }

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

    .field-wide,
    .filter-actions {
        grid-column: span 2;
    }

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

@media (max-width: 560px) {
    .page-content,
    .topbar {
        padding-right: 14px;
        padding-left: 14px;
    }

    .page-heading,
    .card-header,
    .table-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .table-toolbar-actions {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }

    .page-size-form {
        justify-content: space-between;
    }

    .result-count {
        width: 100%;
    }

    .pagination {
        justify-content: flex-start;
        overflow-x: auto;
    }

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

    .field-wide,
    .filter-actions {
        grid-column: span 1;
    }

    .call-page-heading .button {
        width: 100%;
    }

    .customer-summary-card,
    .history-card-top {
        align-items: flex-start;
        flex-direction: column;
    }

    .summary-stat {
        width: 100%;
    }

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

    .full-span {
        grid-column: span 1;
    }

    .call-form-actions {
        flex-direction: column;
    }

    .call-form-actions .button {
        width: 100%;
    }

    .history-details {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        flex-direction: column;
    }

    .filter-actions .button {
        width: 100%;
    }
}
