:root {
    color-scheme: light;
    --ink: #172033;
    --muted: #647084;
    --line: #dbe2ea;
    --soft: #f5f7fa;
    --panel: #ffffff;
    --sidebar: #172033;
    --sidebar-soft: #222d42;
    --blue: #2563eb;
    --teal: #0f766e;
    --amber: #d97706;
    --rose: #be123c;
    --green: #15803d;
    --violet: #7c3aed;
    --shadow: 0 12px 30px rgba(23, 32, 51, .08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--soft);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
}

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

.code-block {
    overflow-x: auto;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #101828;
    color: #f8fafc;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
}

button,
input,
select,
textarea {
    font: inherit;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 520px) 1fr;
    background: #f3f6f8;
}

.auth-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px;
    background: #ffffff;
    border-right: 1px solid var(--line);
}

.auth-visual {
    display: grid;
    place-items: center;
    padding: 56px;
}

.visual-board {
    width: min(640px, 100%);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.visual-row {
    display: grid;
    grid-template-columns: 120px 1fr 80px;
    gap: 16px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.visual-row:last-child {
    border-bottom: 0;
}

.visual-bar {
    height: 10px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}

.visual-bar span {
    display: block;
    height: 100%;
    background: var(--teal);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 18px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--teal);
    color: #ffffff;
    font-weight: 900;
}

.auth-panel .brand {
    margin-bottom: 42px;
}

.auth-title {
    margin: 0 0 8px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.1;
}

.auth-copy,
.muted {
    color: var(--muted);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 22px;
    color: #eef4fb;
    background: var(--sidebar);
}

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

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #cdd6e4;
}

.nav-link:hover,
.nav-link.active {
    color: #ffffff;
    background: var(--sidebar-soft);
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 12px;
}

.user-tile {
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 8px;
    background: rgba(255, 255, 255, .05);
}

.main {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 72px;
    padding: 18px 28px;
    background: rgba(245, 247, 250, .95);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.content {
    padding: 28px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.page-title {
    margin: 0;
    font-size: 28px;
    line-height: 1.2;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

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

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

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

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

.panel,
.metric-card,
.table-wrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 20px;
}

.panel-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 0 0 16px;
    font-size: 17px;
}

.metric-card {
    padding: 18px;
}

.metric-label {
    color: var(--muted);
    font-size: 13px;
}

.metric-value {
    margin-top: 6px;
    font-size: 28px;
    font-weight: 800;
}

.metric-foot {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
}

.industry-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px;
    border: 1px solid #b7e2dc;
    border-radius: 8px;
    background: linear-gradient(135deg, #f8fffd 0%, #e7f7f4 100%);
    box-shadow: var(--shadow);
}

.industry-banner h2 {
    margin: 4px 0 6px;
    font-size: 22px;
}

.industry-banner p {
    max-width: 780px;
    margin: 0;
    color: #405065;
}

.eyebrow {
    color: var(--teal);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.section-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
}

.section-title h2 {
    margin: 4px 0 0;
    font-size: 22px;
}

.table-wrap {
    overflow: hidden;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    background: #f9fbfd;
}

tr:last-child td {
    border-bottom: 0;
}

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

.field {
    display: grid;
    gap: 7px;
}

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

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cfd7e2;
    border-radius: 8px;
    padding: 10px 12px;
    background: #ffffff;
    color: var(--ink);
    outline: none;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .14);
}

input.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: var(--rose);
    background: #fff8f9;
}

input.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(190, 18, 60, .14);
}

.field-error-text,
.form-error-summary {
    color: var(--rose);
    font-size: 12px;
    font-weight: 800;
}

.form-error-summary {
    grid-column: 1 / -1;
    padding: 10px 12px;
    border: 1px solid #fecdd3;
    border-radius: 8px;
    background: #fff1f2;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 9px 13px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--teal);
    color: #ffffff;
    font-weight: 800;
    cursor: pointer;
}

.btn:hover {
    filter: brightness(.96);
}

.btn.secondary {
    background: #ffffff;
    color: var(--ink);
    border-color: var(--line);
}

.btn.danger {
    background: var(--rose);
}

.btn.ghost {
    background: transparent;
    color: inherit;
    border-color: rgba(255, 255, 255, .18);
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.chip,
.tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #edf2f7;
    color: #344054;
    font-size: 12px;
    font-weight: 800;
}

.chip.open,
.chip.pending {
    background: #eff6ff;
    color: var(--blue);
}

.chip.won,
.chip.completed,
.chip.active {
    background: #ecfdf3;
    color: var(--green);
}

.chip.lost,
.chip.urgent,
.chip.suspended {
    background: #fff1f2;
    color: var(--rose);
}

.chip.high {
    background: #fff7ed;
    color: var(--amber);
}

.tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.section-divider {
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

.section-divider span {
    display: block;
    margin-top: 2px;
}

.pipeline-list,
.timeline,
.stack-list {
    display: grid;
    gap: 12px;
}

.pipeline-item {
    display: grid;
    grid-template-columns: 110px 1fr 96px;
    gap: 12px;
    align-items: center;
}

.progress {
    height: 10px;
    border-radius: 999px;
    background: #edf2f7;
    overflow: hidden;
}

.progress span {
    display: block;
    height: 100%;
    background: var(--stage-color, var(--teal));
}

.timeline-item,
.stack-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.timeline-item:last-child,
.stack-item:last-child {
    border-bottom: 0;
}

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

.detail {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.detail span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

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

.module-card {
    min-height: 72px;
    display: grid;
    align-content: center;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.module-card span {
    color: var(--muted);
    font-size: 12px;
}

.matrix-list {
    display: grid;
    gap: 10px;
}

.matrix-list div {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.matrix-list span {
    color: var(--muted);
    font-size: 13px;
}

.alert-metric {
    border-left: 4px solid var(--teal);
}

.alert-list {
    display: grid;
    gap: 10px;
}

.alert-item {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.alert-item:hover {
    border-color: #9fcac5;
    background: #f0faf8;
}

.severity-dot {
    width: 10px;
    height: 10px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--teal);
}

.alert-item.critical .severity-dot {
    background: var(--rose);
}

.alert-item.warning .severity-dot {
    background: var(--amber);
}

.alert-item.info .severity-dot {
    background: var(--blue);
}

.chart-panel {
    overflow: hidden;
}

.bar-chart {
    display: grid;
    gap: 13px;
}

.bar-chart.compact {
    gap: 10px;
}

.bar-row {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(180px, 2fr) minmax(90px, auto);
    gap: 12px;
    align-items: center;
}

.bar-row.small {
    grid-template-columns: minmax(110px, 1fr) minmax(120px, 2fr) 38px;
}

.bar-row span,
.owner-row span,
.trend-col span {
    color: var(--muted);
    font-size: 12px;
}

.bar-track {
    position: relative;
    min-height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #edf2f7;
}

.bar-track.dual {
    display: grid;
    gap: 5px;
    min-height: 29px;
    padding: 4px;
    border-radius: 8px;
}

.bar-fill {
    display: block;
    height: 100%;
    min-height: 12px;
    border-radius: inherit;
    background: var(--teal);
}

.bar-fill.value {
    background: var(--amber);
}

.bar-fill.danger {
    background: var(--rose);
}

.chart-note {
    margin-top: 14px;
    color: var(--muted);
    font-size: 12px;
}

.chart-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 14px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.chart-legend.vertical {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    margin-top: 0;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--teal);
}

.legend-dot.teal,
.legend-dot.open,
.legend-dot.medium {
    background: var(--teal);
}

.legend-dot.blue,
.legend-dot.low {
    background: var(--blue);
}

.legend-dot.amber,
.legend-dot.high {
    background: var(--amber);
}

.legend-dot.rose,
.legend-dot.lost,
.legend-dot.urgent {
    background: var(--rose);
}

.legend-dot.green,
.legend-dot.won {
    background: var(--green);
}

.legend-dot.violet {
    background: var(--violet);
}

.donut-wrap {
    display: grid;
    grid-template-columns: 138px minmax(0, 1fr);
    gap: 18px;
    align-items: center;
}

.donut {
    width: 138px;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(23, 32, 51, .08);
}

.donut span {
    width: 76px;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #ffffff;
    color: var(--ink);
    font-size: 19px;
    font-weight: 900;
}

.trend-chart {
    min-height: 230px;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
    padding-top: 8px;
}

.trend-col {
    min-width: 0;
    display: grid;
    gap: 7px;
    text-align: center;
}

.trend-stack {
    height: 156px;
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 5px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.trend-bar {
    width: 18px;
    min-height: 8px;
    border-radius: 999px 999px 4px 4px;
}

.trend-bar.count {
    background: var(--teal);
}

.trend-bar.value {
    background: var(--violet);
}

.owner-chart {
    display: grid;
    gap: 12px;
}

.owner-row {
    display: grid;
    grid-template-columns: minmax(160px, 1.1fr) minmax(150px, 1fr) minmax(110px, auto);
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.owner-row > div:first-child,
.owner-kpis {
    display: grid;
    gap: 3px;
}

.report-filters {
    align-items: end;
    margin-bottom: 18px;
}

.report-filter-action {
    align-self: end;
}

.report-chart-card {
    min-height: 330px;
}

.report-canvas {
    width: 100%;
    display: block;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

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

.insight-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.kanban-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    align-items: start;
}

.kanban-column {
    min-height: 280px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.kanban-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px;
    border-top: 4px solid var(--stage-color, var(--teal));
    border-bottom: 1px solid var(--line);
}

.kanban-cards {
    display: grid;
    gap: 12px;
    padding: 12px;
}

.kanban-card {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfe;
}

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #ffffff;
}

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

.alert.error {
    border-color: #fecdd3;
    background: #fff1f2;
    color: #9f1239;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px;
}

.pagination a,
.pagination span {
    min-width: 34px;
    min-height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.pagination .active {
    background: var(--teal);
    color: #ffffff;
    border-color: var(--teal);
}

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

.inline-edit {
    min-width: 280px;
}

.inline-edit summary {
    cursor: pointer;
    list-style: none;
    width: max-content;
}

.inline-edit summary::-webkit-details-marker {
    display: none;
}

.inline-edit[open] summary {
    margin-bottom: 12px;
}

.inline-edit-form {
    width: min(680px, 78vw);
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbfc;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

    .sidebar {
        position: relative;
        height: auto;
    }

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

    .auth-visual {
        display: none;
    }

    .grid.cols-4,
    .grid.cols-3,
    .grid.cols-2,
    .module-grid,
    .module-grid.compact,
    .mini-canvas-grid,
    .insight-columns,
    .donut-wrap,
    .owner-row,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .filters {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 700px) {
    body {
        font-size: 13px;
    }

    .app-shell,
    .sidebar,
    .main,
    .topbar,
    .content,
    .brand,
    .sidebar-footer {
        min-width: 0;
        max-width: 100%;
    }

    .app-shell {
        overflow-x: hidden;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 30;
        gap: 12px;
        padding: 14px;
        overflow: hidden;
    }

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

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

    .nav {
        display: flex;
        gap: 8px;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    .nav::-webkit-scrollbar {
        display: none;
    }

    .nav-link {
        flex: 0 0 auto;
        min-height: 38px;
        white-space: nowrap;
    }

    .sidebar-footer {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .sidebar-footer form .btn {
        width: auto;
        white-space: nowrap;
    }

    .user-tile {
        min-width: 0;
    }

    .user-tile .muted {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .content,
    .topbar,
    .auth-panel {
        padding: 18px;
    }

    .page-head,
    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .nav,
    .filters,
    .detail-list,
    .pipeline-item,
    .bar-row,
    .bar-row.small {
        grid-template-columns: 1fr;
    }

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

    .actions {
        width: 100%;
    }

    .topbar .actions .btn,
    .page-head .actions .btn,
    .auth-panel .btn {
        width: 100%;
    }

    .panel,
    .metric-card {
        padding: 16px;
    }

    .page-title {
        font-size: 23px;
    }

    .metric-value {
        font-size: 24px;
    }

    .table-scroll {
        max-width: calc(100vw - 36px);
    }

    .inline-edit,
    .inline-edit-form {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .content,
    .topbar,
    .auth-panel {
        padding: 14px;
    }

    .sidebar {
        padding: 12px;
    }

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

    .sidebar-footer {
        grid-template-columns: 1fr;
    }

    .sidebar-footer form .btn {
        width: 100%;
    }
}
