:root {
    --background: #f8fafc;
    --foreground: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --card: #ffffff;
    --primary: #111827;
    --primary-foreground: #ffffff;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #2563eb;
    --radius: 16px;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: radial-gradient(circle at top left, #eef2ff 0, transparent 32rem), var(--background);
    color: var(--foreground);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-weight: 500;
}

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

.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    border-right: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, #111827, #334155);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.brand strong,
.brand span {
    display: block;
}

.brand span,
.muted {
    color: var(--muted);
    font-weight: 500;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav a,
.button {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    color: var(--foreground);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-weight: 700;
    gap: 8px;
    min-height: 42px;
    padding: 0 16px;
    transition: 0.18s ease;
}

.nav a {
    justify-content: flex-start;
}

.nav a:hover,
.nav a.active,
.button:hover {
    border-color: #cbd5e1;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

.button-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-foreground);
}

.button-ghost {
    background: transparent;
}

.button-small {
    min-height: 34px;
    padding: 0 12px;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.user-card {
    margin-top: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    padding: 16px;
}

.user-card span,
.user-card small {
    color: var(--muted);
    display: block;
}

.user-card a {
    color: var(--danger);
    display: inline-block;
    font-weight: 700;
    margin-top: 12px;
}

.content {
    padding: 32px;
}

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

.page-heading h1 {
    font-size: clamp(32px, 5vw, 48px);
    letter-spacing: -0.05em;
    line-height: 1;
    margin: 6px 0 10px;
}

.eyebrow {
    color: var(--info);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.14em;
    margin: 0;
    text-transform: uppercase;
}

.stats-grid,
.detail-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.stats-grid.enterprise {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

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

.detail-grid {
    align-items: start;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.8fr);
}

.stat-card,
.card,
.auth-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 20px;
}

.stat-card span {
    color: var(--muted);
    display: block;
    font-size: 14px;
}

.stat-card strong {
    display: block;
    font-size: 34px;
    letter-spacing: -0.04em;
    margin-top: 8px;
}

.stat-card .stat-text,
.stat-text {
    font-size: 18px;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.stat-card.danger strong {
    color: var(--danger);
}

.card {
    padding: 22px;
}

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

.card-header h2 {
    font-size: 20px;
    letter-spacing: -0.02em;
    margin: 0;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 180px auto auto;
    gap: 10px;
    margin-bottom: 18px;
}

.enterprise-toolbar {
    grid-template-columns: minmax(260px, 1.4fr) repeat(5, minmax(140px, 1fr)) auto auto;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--foreground);
    font: inherit;
    font-weight: 500;
    min-height: 42px;
    outline: none;
    padding: 10px 12px;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #94a3b8;
    box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.2);
}

.form-grid {
    display: grid;
    gap: 16px;
}

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

label {
    color: #334155;
    display: grid;
    font-size: 14px;
    font-weight: 700;
    gap: 8px;
}

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

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

.form-section {
    margin-bottom: 18px;
}

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

table {
    border-collapse: collapse;
    min-width: 1120px;
    width: 100%;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

td span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-top: 3px;
}

.badge {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #f8fafc;
    color: #475569;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1;
    padding: 7px 10px;
    text-transform: uppercase;
}

.badge-success {
    background: #dcfce7;
    border-color: #bbf7d0;
    color: #166534;
}

.badge-danger {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    border-color: #bfdbfe;
    color: #1e40af;
}

.description-list {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
}

.description-list div {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
}

.description-list dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.description-list dd {
    margin: 0;
}

.note-box {
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    margin-top: 16px;
    padding: 14px;
}

.note-box p {
    color: #334155;
    margin-bottom: 0;
}

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

.timeline {
    display: grid;
    gap: 18px;
}

.timeline-item {
    display: grid;
    gap: 14px;
    grid-template-columns: 14px 1fr;
}

.timeline-dot {
    width: 12px;
    height: 12px;
    border: 3px solid #bfdbfe;
    border-radius: 999px;
    background: var(--info);
    margin-top: 6px;
}

.timeline-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.timeline-title span,
.timeline-meta {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.timeline-item p {
    line-height: 1.6;
    margin: 8px 0;
}

.timeline-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}

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

.alert {
    border-radius: 14px;
    margin-bottom: 18px;
    padding: 13px 15px;
}

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

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
}

.auth-page {
    align-items: center;
    display: grid;
    min-height: 100vh;
    padding: 24px;
    place-items: center;
}

.auth-card {
    max-width: 460px;
    padding: 28px;
    width: 100%;
}

.auth-brand {
    margin-bottom: 24px;
}

.auth-hint {
    margin-bottom: 0;
    text-align: center;
}

@media (max-width: 1280px) {
    .app-shell {
        grid-template-columns: 240px 1fr;
    }

    .content {
        padding: 24px;
    }

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

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

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

    .sidebar {
        align-items: center;
        border-bottom: 1px solid var(--border);
        border-right: 0;
        display: grid;
        grid-template-columns: minmax(220px, 1fr) minmax(320px, 1.4fr) auto;
        gap: 14px;
        height: auto;
        padding: 16px 24px;
        position: static;
    }

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

    .user-card {
        margin-top: 0;
        min-width: 210px;
        padding: 12px 14px;
    }

    .user-card span,
    .user-card small {
        font-size: 12px;
    }

    .user-card a {
        margin-top: 8px;
    }

    .stats-grid,
    .stats-grid.compact,
    .detail-grid,
    .form-grid.two-column,
    .description-list,
    .toolbar,
    .enterprise-toolbar,
    .split-notes {
        grid-template-columns: 1fr;
    }

    .page-heading {
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    body {
        background: var(--background);
    }

    .sidebar,
    .content {
        padding: 16px;
    }

    .sidebar {
        align-items: stretch;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .brand {
        align-items: center;
    }

    .brand-mark {
        width: 40px;
        height: 40px;
    }

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

    .nav a {
        justify-content: center;
        min-height: 44px;
        padding: 0 10px;
        text-align: center;
    }

    .user-card {
        align-items: center;
        display: flex;
        gap: 10px;
        justify-content: space-between;
        min-width: 0;
    }

    .user-card span,
    .user-card small {
        display: none;
    }

    .user-card strong {
        font-size: 14px;
    }

    .user-card a {
        margin-top: 0;
    }

    .content {
        padding-top: 20px;
    }

    .page-heading h1 {
        font-size: 34px;
    }

    .card,
    .auth-card,
    .stat-card {
        border-radius: 14px;
        padding: 16px;
    }

    .stats-grid.enterprise {
        grid-template-columns: 1fr;
    }

    .card-header,
    .timeline-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .description-list div {
        padding: 12px;
    }

    .button {
        width: 100%;
    }

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

    .form-actions .button,
    .button-group .button {
        flex: 1 1 100%;
    }

    .auth-page {
        padding: 16px;
    }
}

/* Premium CRM UI pass */
:root {
    --background: #f3f5f9;
    --foreground: #111827;
    --muted: #667085;
    --border: #dfe4ec;
    --card: #ffffff;
    --primary: #101828;
    --primary-foreground: #ffffff;
    --success: #15803d;
    --danger: #b42318;
    --warning: #b54708;
    --info: #175cd3;
    --radius: 18px;
    --shadow: 0 22px 55px rgba(16, 24, 40, 0.10);
}

body {
    background:
        radial-gradient(circle at 18% -10%, rgba(37, 99, 235, 0.12), transparent 30rem),
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    font-size: 14px;
    letter-spacing: -0.01em;
}

.app-shell {
    grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(17, 24, 39, 0.96)),
        radial-gradient(circle at top, rgba(37, 99, 235, 0.35), transparent 22rem);
    border-right: 0;
    box-shadow: 18px 0 45px rgba(15, 23, 42, 0.18);
    color: #f8fafc;
    gap: 22px;
    padding: 22px 18px;
}

.brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
    padding-bottom: 18px;
}

.brand-mark {
    background: linear-gradient(135deg, #ffffff, #dbeafe);
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.22);
    color: #111827;
}

.brand strong {
    color: #ffffff;
    font-size: 15px;
}

.brand span {
    color: #cbd5e1;
    font-size: 12px;
}

.nav {
    gap: 10px;
}

.nav a {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #dbeafe;
    font-size: 13px;
    min-height: 42px;
    padding: 0 12px;
}

.nav a:hover,
.nav a.active {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: none;
    color: #ffffff;
}

.user-card {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    padding: 14px;
}

.user-card span,
.user-card small {
    color: #cbd5e1;
    font-size: 11px;
}

.user-card strong {
    color: #ffffff;
    font-size: 13px;
}

.user-card a {
    color: #fecaca;
    font-size: 12px;
}

.content {
    padding: 28px;
}

.page-heading {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(239, 246, 255, 0.92)),
        radial-gradient(circle at right top, rgba(37, 99, 235, 0.16), transparent 18rem);
    border: 1px solid rgba(223, 228, 236, 0.92);
    border-radius: 22px;
    box-shadow: 0 12px 30px rgba(16, 24, 40, 0.07);
    margin-bottom: 18px;
    padding: 22px 24px;
}

.page-heading h1 {
    color: #0f172a;
    font-size: clamp(28px, 3vw, 38px);
    letter-spacing: -0.04em;
    margin-bottom: 8px;
}

.page-heading .muted {
    font-size: 13px;
    line-height: 1.5;
    max-width: 720px;
}

.eyebrow {
    color: #175cd3;
    font-size: 10px;
}

.button {
    background: #ffffff;
    border-color: #d0d5dd;
    border-radius: 13px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
    font-size: 13px;
    font-weight: 800;
    min-height: 40px;
    padding: 0 14px;
}

.button:hover {
    border-color: #98a2b3;
    box-shadow: 0 10px 24px rgba(16, 24, 40, 0.10);
}

.button-primary {
    background: linear-gradient(135deg, #101828, #1d2939);
    border-color: #101828;
    box-shadow: 0 16px 28px rgba(16, 24, 40, 0.20);
}

.button-ghost {
    background: #f8fafc;
}

.stat-card,
.card,
.auth-card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(223, 228, 236, 0.94);
    box-shadow: 0 12px 28px rgba(16, 24, 40, 0.06);
}

.stat-card {
    min-height: 104px;
    padding: 18px;
    position: relative;
}

.stat-card::before {
    background: linear-gradient(90deg, #2563eb, #7c3aed);
    border-radius: 999px;
    content: "";
    height: 3px;
    left: 18px;
    position: absolute;
    right: 18px;
    top: 12px;
}

.stat-card span {
    color: #667085;
    font-size: 10px;
    letter-spacing: 0.08em;
    margin-top: 8px;
    text-transform: uppercase;
}

.stat-card strong {
    color: #101828;
    font-size: 28px;
    line-height: 1.1;
}

.stat-card.danger::before {
    background: linear-gradient(90deg, #dc2626, #f97316);
}

.card {
    padding: 18px;
}

.card-header h2 {
    color: #101828;
    font-size: 18px;
}

.toolbar {
    background: #f8fafc;
    border: 1px solid #e4e7ec;
    border-radius: 16px;
    padding: 10px;
}

input,
select,
textarea {
    background: #ffffff;
    border-color: #d0d5dd;
    border-radius: 12px;
    color: #101828;
    font-size: 13px;
    min-height: 40px;
    padding: 9px 11px;
}

input::placeholder,
textarea::placeholder {
    color: #98a2b3;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

label {
    color: #344054;
    font-size: 13px;
    font-weight: 700;
}

.table-wrap {
    border: 1px solid #e4e7ec;
    border-radius: 18px;
}

table {
    background: #ffffff;
}

th {
    background: #f8fafc;
    color: #475467;
    font-size: 10px;
    font-weight: 900;
    padding: 13px 12px;
}

td {
    color: #101828;
    font-size: 13px;
    padding: 14px 12px;
}

tbody tr {
    transition: background 0.18s ease;
}

tbody tr:hover {
    background: #f8fafc;
}

.badge {
    border: 0;
    font-size: 10px;
    font-weight: 900;
    padding: 6px 9px;
}

.description-list div,
.note-box {
    background: #f8fafc;
    border-color: #e4e7ec;
}

.timeline-item {
    background: #ffffff;
    border: 1px solid #e4e7ec;
    border-radius: 18px;
    padding: 16px;
}

.timeline-dot {
    box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.10);
}

.alert {
    border: 1px solid transparent;
    box-shadow: 0 10px 24px rgba(16, 24, 40, 0.08);
}

.auth-page {
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.30), transparent 28rem),
        linear-gradient(135deg, #0f172a 0%, #1e293b 48%, #f8fafc 48%, #eef2f7 100%);
}

.auth-card {
    border-radius: 28px;
    max-width: 480px;
    padding: 34px;
}

.auth-card .brand {
    border-bottom: 0;
    padding-bottom: 0;
}

.auth-card .brand strong {
    color: #101828;
}

.auth-card .brand span {
    color: #667085;
}

@media (max-width: 1280px) {
    .app-shell {
        grid-template-columns: 260px minmax(0, 1fr);
    }
}

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

    .sidebar {
        background: rgba(255, 255, 255, 0.96);
        border-bottom: 1px solid #e4e7ec;
        box-shadow: 0 16px 35px rgba(16, 24, 40, 0.08);
        color: #101828;
    }

    .brand {
        border-bottom: 0;
        padding-bottom: 0;
    }

    .brand-mark {
        background: linear-gradient(135deg, #101828, #344054);
        color: #ffffff;
    }

    .brand strong {
        color: #101828;
    }

    .brand span,
    .user-card span,
    .user-card small {
        color: #667085;
    }

    .nav a {
        background: #f8fafc;
        border-color: #e4e7ec;
        color: #101828;
    }

    .nav a.active,
    .nav a:hover {
        background: #101828;
        border-color: #101828;
        color: #ffffff;
    }

    .user-card {
        background: #f8fafc;
        border-color: #e4e7ec;
    }

    .user-card strong {
        color: #101828;
    }
}

@media (max-width: 640px) {
    .app-shell {
        display: block;
    }

    .content {
        padding: 18px 14px;
    }

    .sidebar {
        border-radius: 0 0 22px 22px;
        display: flex;
        flex-direction: column;
        padding: 14px;
    }

    .brand {
        width: 100%;
    }

    .brand strong {
        font-size: 15px;
    }

    .brand span {
        font-size: 12px;
    }

    .nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .nav a {
        min-height: 42px;
        width: auto;
    }

    .user-card {
        width: 100%;
    }

    .page-heading {
        border-radius: 20px;
        padding: 20px;
    }

    .page-heading h1 {
        font-size: 32px;
    }

    .stats-grid,
    .stats-grid.enterprise,
    .stats-grid.compact {
        gap: 12px;
    }

    .stat-card {
        min-height: 116px;
    }

    .toolbar {
        padding: 12px;
    }

    .auth-page {
        background: linear-gradient(180deg, #0f172a 0%, #1e293b 34%, #eef2f7 34%, #eef2f7 100%);
    }
}
