:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #0f172a;
    --text: #1e293b;
    --muted: #64748b;
    --background: #f8fafc;
    --card: #ffffff;
    --border: #e2e8f0;
    --success: #15803d;
    --success-bg: #f0fdf4;
    --error: #b91c1c;
    --error-bg: #fef2f2;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --danger-bg: #fef2f2;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
    --shadow-small: 0 4px 15px rgba(15, 23, 42, 0.05);
    --radius: 16px;
    --content-width: 1180px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        linear-gradient(
            180deg,
            #f8fafc 0%,
            #f1f5f9 100%
        );
    font-family:
        Inter,
        ui-sans-serif,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;
    line-height: 1.6;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

a,
button,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.28);
    outline-offset: 3px;
}

[hidden] {
    display: none !important;
}

/* ==========================================
   DASHBOARD HEADER
========================================== */

.dashboard-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    background: rgba(255, 255, 255, 0.97);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 15px rgba(15, 23, 42, 0.04);
    backdrop-filter: blur(12px);
}

.dashboard-header-inner {
    width: min(calc(100% - 40px), var(--content-width));
    min-height: 76px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 25px;
}

.dashboard-logo {
    color: var(--secondary);
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.035em;
}

.dashboard-logo:hover {
    color: var(--primary);
}

.dashboard-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-email {
    max-width: 330px;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-button,
.logout-action-button {
    min-height: 42px;
    padding: 0 17px;
    color: #334155;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-weight: 700;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

.logout-button:hover,
.logout-action-button:hover {
    color: var(--error);
    background: #fff7f7;
    border-color: #fecaca;
}

/* ==========================================
   DASHBOARD
========================================== */

.dashboard-main {
    min-height: calc(100vh - 76px);
    padding: 55px 0 90px;
}

.dashboard-container,
.profile-container {
    width: min(calc(100% - 40px), var(--content-width));
    margin: 0 auto;
}

.dashboard-welcome {
    margin-bottom: 38px;
    padding: 34px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-small);
}

.auth-eyebrow {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 0.73rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.dashboard-welcome h1 {
    margin: 0;
    color: var(--secondary);
    font-size: clamp(2rem, 4vw, 2.8rem);
    line-height: 1.15;
    letter-spacing: -0.045em;
}

.dashboard-welcome p {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 1rem;
}

.dashboard-section,
.dashboard-card {
    margin-bottom: 30px;
}

.section-header {
    margin-bottom: 22px;
}

.section-header h2 {
    margin: 0;
    color: var(--secondary);
    font-size: 1.5rem;
    line-height: 1.25;
    letter-spacing: -0.025em;
}

.section-header p {
    max-width: 700px;
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

/* ==========================================
   STATISTICS
========================================== */

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
}

.dashboard-summary-card {
    padding: 24px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-small);
}

.summary-label {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.dashboard-summary-card strong {
    display: block;
    margin-top: 8px;
    color: var(--secondary);
    font-size: 2rem;
    line-height: 1;
    letter-spacing: -0.045em;
}

.dashboard-summary-card small {
    display: block;
    margin-top: 10px;
    color: #94a3b8;
    font-size: 0.76rem;
}

/* ==========================================
   STATUS
========================================== */

.status-message,
.profile-status {
    margin-bottom: 22px;
    padding: 14px 17px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 650;
}

.status-message[hidden],
.profile-status[hidden] {
    display: none;
}

.status-message.success,
.profile-status.success {
    color: var(--success);
    background: var(--success-bg);
    border-color: #bbf7d0;
}

.status-message.error,
.profile-status.error {
    color: var(--error);
    background: var(--error-bg);
    border-color: #fecaca;
}

/* ==========================================
   CUSTOMER FORM
========================================== */

.customer-form-section {
    padding: 30px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-small);
}

.customer-form-grid,
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-group.full-width,
.form-group-wide {
    grid-column: 1 / -1;
}

.form-group label {
    color: #334155;
    font-size: 0.84rem;
    font-weight: 700;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    color: var(--text);
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.form-group input,
.form-group select {
    min-height: 48px;
    padding: 0 13px;
}

.form-group textarea {
    min-height: 125px;
    padding: 13px;
    resize: vertical;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #94a3b8;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: #94a3b8;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 25px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

.primary-button,
.secondary-button,
.danger-button {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 23px;
    border-radius: 9px;
    font-weight: 750;
    text-decoration: none;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.primary-button {
    color: #ffffff;
    background: var(--primary);
    border: 1px solid var(--primary);
}

.primary-button:hover {
    color: #ffffff;
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
}

.secondary-button {
    color: #334155;
    background: #ffffff;
    border: 1px solid #cbd5e1;
}

.secondary-button:hover {
    color: var(--primary);
    background: #f8fafc;
    border-color: #93c5fd;
}

.danger-button {
    color: #ffffff;
    background: var(--danger);
    border: 1px solid var(--danger);
}

.danger-button:hover {
    color: #ffffff;
    background: var(--danger-dark);
    border-color: var(--danger-dark);
    transform: translateY(-1px);
}

.small-button {
    min-height: 40px;
    padding: 0 14px;
    font-size: 0.84rem;
}

/* ==========================================
   CUSTOMER DIRECTORY
========================================== */

.customer-directory-section {
    padding: 30px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-small);
}

.customer-directory-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) 1fr 1fr auto;
    gap: 14px;
    align-items: end;
    margin-bottom: 18px;
    padding: 18px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.toolbar-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toolbar-control label {
    color: #334155;
    font-size: 0.78rem;
    font-weight: 750;
}

.toolbar-control input,
.toolbar-control select {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    color: var(--text);
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}

.toolbar-control input:focus,
.toolbar-control select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.clear-filters-button {
    min-height: 44px;
    padding: 0 15px;
    color: #334155;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-weight: 700;
}

.clear-filters-button:hover {
    color: var(--primary);
    border-color: #93c5fd;
    background: #eff6ff;
}

.directory-result-information {
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 650;
}

.directory-state {
    padding: 34px 20px;
    text-align: center;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 13px;
}

.directory-state h3 {
    margin: 0;
    color: var(--secondary);
    font-size: 1.05rem;
}

.directory-state p {
    max-width: 540px;
    margin: 7px auto 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.customer-directory-content {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.customer-directory-card {
    padding: 22px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 13px;
    box-shadow: var(--shadow-small);
}

.customer-card-header {
    display: flex;
    align-items: center;
    gap: 13px;
}

.customer-avatar {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: #eff6ff;
    border-radius: 14px;
    font-size: 0.92rem;
    font-weight: 850;
}

.customer-card-heading {
    min-width: 0;
}

.customer-card-heading h3 {
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--secondary);
    font-size: 1rem;
}

.customer-type-badge {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    margin-top: 5px;
    padding: 0 9px;
    color: var(--primary-dark);
    background: #eff6ff;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 750;
}

.customer-card-details {
    display: grid;
    gap: 9px;
    margin-top: 20px;
}

.customer-card-details p {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
}

.customer-card-details strong {
    color: #64748b;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.customer-card-details span {
    color: var(--text);
    overflow-wrap: anywhere;
    font-size: 0.88rem;
}

.customer-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

/* ==========================================
   PROFILE
========================================== */

.profile-main {
    min-height: calc(100vh - 76px);
    padding: 50px 0 80px;
}

.profile-status {
    margin-bottom: 20px;
}

.profile-state {
    padding: 55px 25px;
    text-align: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-small);
}

.profile-state .state-icon {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    margin: 0 auto 16px;
    color: var(--primary);
    background: #eff6ff;
    border-radius: 14px;
    font-weight: 850;
}

.profile-state h1 {
    margin: 0;
    color: var(--secondary);
    font-size: 1.6rem;
}

.profile-state p {
    max-width: 550px;
    margin: 9px auto 24px;
    color: var(--muted);
}

.profile-header-card {
    display: flex;
    align-items: center;
    gap: 22px;
    margin-bottom: 24px;
    padding: 32px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-small);
}

.profile-initials {
    width: 84px;
    height: 84px;
    flex: 0 0 84px;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: var(--primary);
    border-radius: 22px;
    font-size: 1.35rem;
    font-weight: 850;
}

.profile-header-content h1 {
    margin: 0;
    color: var(--secondary);
    font-size: clamp(1.8rem, 4vw, 2.45rem);
    line-height: 1.15;
}

.profile-customer-name {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 1rem;
}

.profile-header-content .customer-type-badge {
    margin-top: 10px;
}

.profile-information-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.profile-info-card {
    padding: 26px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-small);
}

.profile-notes-card {
    grid-column: 1 / -1;
}

.profile-section-heading {
    margin-bottom: 20px;
}

.profile-section-label {
    display: block;
    margin-bottom: 5px;
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 850;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.profile-section-heading h2 {
    margin: 0;
    color: var(--secondary);
    font-size: 1.2rem;
}

.profile-details {
    display: grid;
    gap: 16px;
    margin: 0;
}

.profile-details div {
    display: grid;
    gap: 3px;
}

.profile-details dt {
    color: #64748b;
    font-size: 0.74rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.profile-details dd {
    margin: 0;
    color: var(--text);
    overflow-wrap: anywhere;
    font-size: 0.92rem;
}

.profile-contact-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 20px;
}

.profile-notes {
    margin: 0;
    color: var(--text);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.profile-actions-section {
    margin-top: 24px;
    padding: 26px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-small);
}

.profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.profile-actions .danger-button {
    margin-left: auto;
}

.confirmation-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.52);
}

.confirmation-dialog {
    width: min(100%, 460px);
    padding: 30px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 25px 70px rgba(15, 23, 42, 0.22);
}

.confirmation-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    margin-bottom: 17px;
    color: var(--danger-dark);
    background: var(--danger-bg);
    border-radius: 13px;
    font-weight: 850;
}

.confirmation-dialog h2 {
    margin: 0;
    color: var(--secondary);
    font-size: 1.35rem;
}

.confirmation-dialog p {
    margin: 9px 0 0;
    color: var(--muted);
}

.confirmation-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

/* ==========================================
   AUTH PAGES
========================================== */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.auth-container {
    width: 100%;
    max-width: 480px;
    padding: 36px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-container h1 {
    margin: 0 0 10px;
    color: var(--secondary);
    font-size: 2rem;
    text-align: center;
}

.auth-container > p {
    margin: 0 0 25px;
    color: var(--muted);
    text-align: center;
}

.auth-container .form-group {
    margin-bottom: 18px;
}

.auth-container input {
    width: 100%;
    min-height: 48px;
    padding: 0 13px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #ffffff;
}

.auth-container input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-container button[type="submit"] {
    width: 100%;
}

.form-message {
    min-height: 24px;
    margin: 15px 0;
    padding: 0;
    font-size: 0.88rem;
    font-weight: 650;
}

.form-message.success {
    color: var(--success);
}

.form-message.error {
    color: var(--error);
}

.form-message.loading {
    color: var(--primary);
}

.auth-link {
    margin-top: 20px;
    color: var(--muted);
    text-align: center;
}

.auth-link a {
    color: var(--primary);
    font-weight: 700;
}

/* ==========================================
   RESPONSIVE
========================================== */

@media (max-width: 1000px) {
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .customer-directory-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .customer-search-control {
        grid-column: 1 / -1;
    }

    .clear-filters-button {
        width: 100%;
    }
}

@media (max-width: 760px) {
    .dashboard-header-inner {
        width: min(calc(100% - 28px), var(--content-width));
        min-height: 68px;
    }

    .dashboard-user {
        gap: 9px;
    }

    .user-email {
        display: none;
    }

    .dashboard-main,
    .profile-main {
        padding: 30px 0 60px;
    }

    .dashboard-container,
    .profile-container {
        width: min(calc(100% - 28px), var(--content-width));
    }

    .dashboard-welcome {
        padding: 25px;
        margin-bottom: 28px;
    }

    .customer-form-section,
    .customer-directory-section {
        padding: 22px;
    }

    .summary-grid,
    .customer-content-grid,
    .customer-directory-content,
    .profile-information-grid {
        grid-template-columns: 1fr;
    }

    .customer-directory-toolbar {
        grid-template-columns: 1fr;
    }

    .customer-search-control {
        grid-column: auto;
    }

    .customer-form-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group.full-width,
    .form-group-wide {
        grid-column: auto;
    }

    .form-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .form-actions .primary-button,
    .form-actions .secondary-button {
        width: 100%;
    }

    .customer-card-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .customer-card-actions .primary-button,
    .customer-card-actions .secondary-button {
        width: 100%;
    }

    .profile-header-card {
        align-items: flex-start;
        padding: 25px;
    }

    .profile-information-grid {
        gap: 16px;
    }

    .profile-info-card,
    .profile-actions-section {
        padding: 22px;
    }

    .profile-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .profile-actions .primary-button,
    .profile-actions .secondary-button,
    .profile-actions .danger-button,
    .profile-actions .logout-action-button {
        width: 100%;
        margin-left: 0;
    }

    .profile-contact-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .profile-contact-actions .secondary-button {
        width: 100%;
    }

    .confirmation-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .confirmation-actions .secondary-button,
    .confirmation-actions .danger-button {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .auth-page {
        padding: 20px;
    }

    .auth-container {
        padding: 28px 21px;
    }

    .dashboard-summary-card {
        padding: 20px;
    }

    .profile-header-card {
        flex-direction: column;
    }

    .profile-initials {
        width: 68px;
        height: 68px;
        flex-basis: 68px;
        border-radius: 18px;
    }

    .profile-state {
        padding: 40px 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}