* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f3f7ff;
    color: #111827;
    font-family: Inter, Arial, Helvetica, sans-serif;
}

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

h1,
h2,
h3,
p {
    margin-top: 0;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid #d8e4ef;
    border-radius: 10px;
    background: #fff;
    color: #111827;
    font: inherit;
    outline: none;
}

textarea {
    min-height: 96px;
    padding: 12px;
    resize: vertical;
}

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

button,
.btn {
    min-height: 42px;
    padding: 0 16px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-ghost {
    background: #fff;
    color: #1f2937;
    border: 1px solid #d8e4ef;
}

.btn-danger {
    background: #fff1f1;
    color: #b42318;
    border: 1px solid #fecaca;
}

.mini-btn {
    min-height: 32px;
    padding: 0 10px;
    border-radius: 9px;
    font-size: 12px;
}

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

.login-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border: 1px solid #d8e4ef;
    border-radius: 22px;
    padding: 32px;
    box-shadow: 0 24px 70px rgba(23, 50, 95, .12);
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    font-weight: 700;
    margin-bottom: 14px;
}

.alert-danger {
    background: #fff1f1;
    color: #b42318;
    border: 1px solid #fecaca;
}

.hub-main {
    min-width: 0;
}

.hub-content {
    padding: 0 34px 34px;
    display: grid;
    gap: 18px;
}

.hub-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    text-decoration: none;
}

.hub-brand::before {
    content: "S";
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #7b3ff2, #365cff);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 900;
}

.hub-brand strong {
    display: block;
    font-size: 24px;
    color: #111827;
    letter-spacing: .02em;
}

.hub-brand strong span {
    color: #8b5cf6;
}

.hub-brand > span {
    display: block;
    font-size: 12px;
    color: #667085;
}

.hub-user {
    min-width: 180px;
    height: 58px;
    border: 1px solid #d8e4ef;
    background: #f8fafc;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    color: #111827;
}

.hub-user::before {
    content: "A";
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7b3ff2, #365cff);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}

.hub-user small {
    display: block;
    color: #667085;
    margin-top: 2px;
}

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

.kanban-col {
    background: #0f172a;
    border: 1px solid #d8e4ef;
    border-radius: 14px;
    min-height: 280px;
    overflow: hidden;
}

.kanban-col header {
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 900;
    background: #182234;
    color: #fff;
}

.kanban-col b {
    background: rgba(255, 255, 255, .08);
    border-radius: 999px;
    min-width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lead-card {
    margin: 10px;
    padding: 12px;
    border: 1px solid #d8e4ef;
    border-radius: 12px;
    background: #fff;
    display: grid;
    gap: 5px;
}

.lead-card strong {
    font-size: 14px;
    color: #111827;
}

.lead-card span,
.lead-card small,
.empty {
    color: #667085;
}

.empty {
    padding: 18px;
    text-align: center;
    font-size: 13px;
}


:root {
    --navy: #17325f;
    --navy-mid: #244a84;
    --accent: #00c896;
    --accent-dim: #00a87f;
    --bg: #f3f7ff;
    --primary: #2563eb;
    --primary-2: #1d4ed8;
    --text: #17325f;
}

.crm-brand::before,
.brand-badge {
    content: "C";
    background: linear-gradient(135deg, #00d4a0, #38bdf8);
    color: #17325f;
}

.crm-shell {
    min-height: 100vh;
    display: block;
    background: #eef5fb;
}

.crm-horizontal-header {
    min-height: 62px;
    background: #ffffff;
    border-bottom: 1px solid #d8e4ef;
    display: grid;
    grid-template-columns: 146px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 0 18px;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 2px 10px rgba(23, 50, 95, .05);
}

.crm-horizontal-header .hub-brand {
    min-height: 62px;
    margin: 0;
    padding: 0;
    border-bottom: 0;
    text-decoration: none;
}

.crm-horizontal-header .hub-brand::before {
    width: 30px;
    height: 30px;
    border-radius: 8px;
}

.crm-horizontal-header .hub-brand strong {
    font-size: 15px;
}

.crm-horizontal-header .hub-brand span {
    font-size: 10px;
}

.crm-topnav {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.crm-topnav a {
    min-height: 62px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-bottom: 3px solid transparent;
    color: #42526d;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.crm-topnav a:hover {
    background: #f3f7fc;
    color: var(--primary);
}

.crm-topnav a.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: #eef4ff;
}

.crm-horizontal-header .hub-user {
    min-width: 146px;
    min-height: 42px;
}

.crm-shell .hub-main {
    background: #eef5fb;
}

.crm-shell .hub-content {
    padding: 12px 12px 24px;
    gap: 12px;
}

.crm-shell .kanban {
    grid-template-columns: repeat(6, minmax(220px, 1fr));
    align-items: start;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
}

.crm-shell .kanban-col {
    min-height: calc(100vh - 190px);
    background: #e8f1f6;
    border-color: #cfdde8;
}

.crm-shell .kanban-col header {
    min-height: 50px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    border-top: 3px solid var(--primary);
}

.crm-shell .lead-card {
    border-radius: 7px;
    box-shadow: 0 2px 8px rgba(23, 50, 95, .08);
}

.crm-shell .lead-card strong {
    line-height: 1.25;
}

.crm-login-card {
    width: min(860px, 100%);
    display: grid;
    grid-template-columns: minmax(260px, .95fr) minmax(320px, 1fr);
    gap: 28px;
    align-items: center;
    padding: 0;
    overflow: hidden;
}

.crm-login-brand {
    min-height: 360px;
    padding: 34px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background:
        radial-gradient(circle at top right, rgba(0, 212, 160, .18), transparent 36%),
        linear-gradient(180deg, #f8fbff, #eef5fb);
    border-right: 1px solid #d8e4ef;
}

.crm-login-brand h1 {
    margin: 0 0 12px;
    font-size: 36px;
}

.crm-login-brand p {
    margin: 0;
    font-size: 16px;
    line-height: 1.55;
}

.crm-login-form {
    padding: 34px 34px 34px 6px;
}

.mini-stage-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
}

.mini-stage-form select {
    min-height: 30px;
    font-size: 12px;
    padding: 0 8px;
}

.lead-card button {
    margin-top: 6px;
}

.pipeline-actions {
    display: flex;
    justify-content: flex-end;
}

.crm-deal-card {
    cursor: pointer;
    transition: transform .14s ease, box-shadow .14s ease;
}

.crm-deal-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(23, 50, 95, .13);
}

.deal-card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.deal-card-meta span {
    min-height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: #eef4ff;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 800;
}

.deal-panel-backdrop .deal-panel {
    width: min(1180px, calc(100vw - 28px));
    max-height: calc(100vh - 34px);
    overflow: auto;
}

.deal-panel-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, .9fr);
    gap: 18px;
}

.deal-panel h3 {
    margin: 0 0 12px;
    font-size: 16px;
    color: var(--text);
}

.deal-edit-form,
.deal-comment-form,
.proposal-form {
    margin-bottom: 18px;
}

.timeline-box,
.proposal-box {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #f8fbff;
    padding: 16px;
}

.timeline-item {
    background: #fff;
    border: 1px solid #dfe8f2;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
}

.timeline-item strong,
.proposal-link strong {
    display: block;
    color: var(--text);
}

.timeline-item span,
.proposal-link span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.timeline-item p {
    margin: 8px 0 0;
    color: #42526d;
    font-size: 13px;
    line-height: 1.45;
}

.proposal-box {
    margin-top: 18px;
}

.proposal-box > div:first-child {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.proposal-box p {
    margin: 0;
    color: var(--muted);
}

.proposal-history {
    margin-top: 12px;
}

.proposal-link {
    display: grid;
    gap: 2px;
    background: #fff;
    border: 1px solid #dfe8f2;
    border-radius: 12px;
    padding: 12px;
    margin-top: 8px;
    text-decoration: none;
}

.settings-stage-grid {
    display: grid;
    grid-template-columns: 90px minmax(220px, 1fr) 110px minmax(120px, .55fr);
    gap: 10px;
    align-items: center;
}

.settings-stage-head {
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.settings-stage-grid code {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f7f9ff;
    color: var(--muted);
    display: flex;
    align-items: center;
    padding: 0 12px;
}

.switch-row {
    min-height: 42px;
    margin: 0;
    display: flex;
    align-items: center;
}

.switch-row input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-row span {
    width: 48px;
    height: 26px;
    border-radius: 999px;
    background: #d7e1ec;
    position: relative;
    transition: background .15s ease;
}

.switch-row span::before {
    content: "";
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    left: 3px;
    top: 3px;
    box-shadow: 0 2px 8px rgba(23, 50, 95, .18);
    transition: transform .15s ease;
}

.switch-row input:checked + span {
    background: var(--primary);
}

.switch-row input:checked + span::before {
    transform: translateX(22px);
}

.settings-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

@media (max-width: 920px) {
    .crm-horizontal-header {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
        padding: 8px 12px 0;
    }

    .crm-horizontal-header .hub-brand {
        min-height: 44px;
    }

    .crm-topnav {
        grid-column: 1 / -1;
        margin: 0 -12px;
        padding: 0 12px;
        border-top: 1px solid #d8e4ef;
    }

    .crm-topnav a {
        min-height: 42px;
        padding: 0 12px;
        font-size: 13px;
    }

    .crm-horizontal-header .hub-user {
        min-width: 42px;
        width: 42px;
        overflow: hidden;
        padding: 0 5px;
    }

    .crm-horizontal-header .hub-user div {
        display: none;
    }

    .crm-shell .hub-content {
        padding: 10px;
    }

    .crm-shell .kanban {
        grid-template-columns: repeat(6, minmax(245px, 82vw));
    }

    .crm-shell .hub-card,
    .crm-shell .dashboard-panel {
        padding: 14px;
        border-radius: 12px;
    }

    .crm-shell .section-heading {
        gap: 10px;
        margin-bottom: 12px;
    }

    .crm-shell .section-heading h2 {
        font-size: 20px;
    }

    .crm-shell .metric-grid,
    .crm-shell .product-dashboard {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crm-shell .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .crm-login-card {
        grid-template-columns: 1fr;
    }

    .crm-login-brand {
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid #d8e4ef;
    }

    .crm-login-form {
        padding: 0 28px 28px;
    }

    .settings-stage-grid {
        grid-template-columns: 70px minmax(0, 1fr);
    }

    .settings-stage-head {
        display: none;
    }

    .settings-stage-grid code,
    .settings-stage-grid input[type="number"] {
        grid-column: 2;
    }
}

@media (max-width: 560px) {
    .crm-horizontal-header {
        position: sticky;
    }

    .crm-horizontal-header .hub-brand strong {
        font-size: 14px;
    }

    .crm-horizontal-header .hub-brand span {
        display: none;
    }

    .crm-topnav a {
        min-height: 40px;
        padding: 0 10px;
        font-size: 12px;
    }

    .crm-shell .hub-content {
        padding: 8px;
    }

    .crm-shell .kanban {
        grid-template-columns: repeat(6, minmax(238px, 88vw));
    }

    .crm-shell .kanban-col {
        min-height: calc(100vh - 176px);
    }

    .crm-shell .metric-grid,
    .crm-shell .product-dashboard {
        grid-template-columns: 1fr;
    }

    .crm-shell .hub-form {
        grid-template-columns: 1fr;
    }

    .crm-shell .hub-form textarea,
    .crm-shell .hub-form button,
    .crm-shell .hub-form .full {
        grid-column: auto;
    }

    .deal-panel-grid {
        grid-template-columns: 1fr;
    }

    .crm-login-brand {
        padding: 26px;
    }

    .crm-login-brand h1 {
        font-size: 30px;
    }

    .crm-login-form {
        padding: 0 22px 24px;
    }

    .settings-stage-grid {
        grid-template-columns: 1fr;
    }

    .settings-stage-grid code,
    .settings-stage-grid input[type="number"] {
        grid-column: auto;
    }
}

/* CRM production stabilization */
.crm-horizontal-header .hub-brand {
    display: grid;
    grid-template-columns: 30px auto;
    align-items: center;
    gap: 10px;
}

.crm-horizontal-header .hub-brand::before {
    width: 30px;
    height: 30px;
    border-radius: 8px;
}

.crm-horizontal-header .hub-brand strong {
    display: block;
    margin: 0;
    font-size: 22px;
    line-height: 1;
    color: #17325f;
}

.crm-horizontal-header .hub-brand strong span {
    font-size: inherit;
    color: #8b5cf6;
}

.crm-horizontal-header .hub-brand > span {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: #667085;
}

.crm-horizontal-header .hub-user {
    min-width: 190px;
    padding-right: 16px;
}

.crm-horizontal-header .hub-user div {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.crm-horizontal-header .hub-user small {
    font-size: 13px;
}

.crm-shell .hub-content {
    padding: 20px 20px 28px;
}

.crm-shell .kanban-col header {
    color: #ffffff;
}

.crm-login-card {
    max-width: 920px;
}

.crm-login-form {
    padding: 34px;
}

.crm-login-form label {
    display: block;
    margin: 0 0 6px;
    font-weight: 700;
    color: #344054;
}

.crm-login-form input {
    margin-bottom: 12px;
}

.crm-login-form button {
    width: 100%;
    margin-top: 8px;
}
