:root {
    --bg: #f7f8fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #667085;
    --line: #d9dee8;
    --primary: #156f87;
    --primary-dark: #0e5265;
    --accent: #b45f3c;
    --soft: #e8f4f7;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
}

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

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

.auth-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-shell {
    width: min(100%, 440px);
}

.auth-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 18px 50px rgba(23, 32, 51, 0.08);
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

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

.sidebar {
    background: #202733;
    color: #fff;
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    margin-bottom: 28px;
}

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

.nav-list a {
    color: #d8dde8;
    border-radius: 6px;
    padding: 10px 12px;
}

.nav-list a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.app-version {
    margin-top: auto;
    padding: 18px 12px 0;
    color: #9aa4b5;
    font-size: 12px;
    font-weight: 700;
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 66px;
    padding: 0 26px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.topbar span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
    text-transform: capitalize;
}

.content {
    padding: 28px;
}

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

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

.record-header h1 {
    margin-bottom: 6px;
    font-size: 32px;
}

.record-header p {
    color: var(--muted);
}

.record-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.record-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.record-summary div {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    min-width: 0;
}

.record-summary span,
.section-heading span,
.related-row span,
.deal-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.record-summary strong {
    display: block;
    margin-top: 5px;
    overflow-wrap: anywhere;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    align-items: start;
}

.workspace-main,
.workspace-side,
.side-form,
.pipeline-column {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.workspace-main {
    padding: 18px;
}

.workspace-side {
    display: grid;
    gap: 0;
    overflow: hidden;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.section-heading.spaced {
    margin-top: 24px;
}

.section-heading h2,
.side-form h2 {
    margin-bottom: 0;
    font-size: 18px;
}

.related-list {
    display: grid;
    gap: 8px;
}

.related-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.side-form {
    display: grid;
    gap: 12px;
    border-width: 0 0 1px;
    border-radius: 0;
    padding: 16px;
}

.side-form:last-child {
    border-bottom: 0;
}

.pipeline-board {
    display: grid;
    grid-template-columns: repeat(6, minmax(220px, 1fr));
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.pipeline-column {
    display: grid;
    align-content: start;
    gap: 10px;
    min-height: 420px;
    padding: 12px;
}

.pipeline-column-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.pipeline-column-head h2 {
    margin: 0;
    font-size: 15px;
    text-transform: capitalize;
}

.pipeline-column-head span {
    display: inline-grid;
    place-items: center;
    min-width: 26px;
    height: 26px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--primary-dark);
    font-weight: 800;
}

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

.deal-card-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--ink);
}

.deal-card-meta em {
    color: var(--muted);
    font-style: normal;
}

.page-heading h1 {
    margin-bottom: 6px;
    font-size: 30px;
}

.page-heading p,
.muted {
    color: var(--muted);
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 14px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.btn.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

.btn.primary:hover {
    background: var(--primary-dark);
}

.btn.ghost {
    background: transparent;
}

.form-stack,
.data-form {
    display: grid;
    gap: 15px;
}

.data-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 980px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.compact-form {
    align-content: start;
    max-width: none;
}

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

label {
    display: grid;
    gap: 7px;
    color: #344054;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 11px 12px;
    color: var(--ink);
    font: inherit;
}

textarea {
    resize: vertical;
}

.wide,
.form-actions {
    grid-column: 1 / -1;
}

.form-section {
    border-top: 1px solid var(--line);
    margin-top: 6px;
    padding-top: 18px;
}

.form-section:first-child {
    border-top: 0;
    margin-top: 0;
    padding-top: 0;
}

.form-section h2 {
    margin-bottom: 4px;
    font-size: 18px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 9px;
}

.check-row input {
    width: auto;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.alert {
    margin: 14px 0;
    border: 1px solid #f4b6a6;
    border-radius: 6px;
    background: #fff1ed;
    color: #953f25;
    padding: 12px;
}

.notice {
    margin: 14px 0;
    border: 1px solid #a9d7bf;
    border-radius: 6px;
    background: #eefaf3;
    color: #226344;
    padding: 12px;
}

.qr-wrap {
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 18px;
    margin: 18px 0;
}

.qr-code svg {
    display: block;
    width: 220px;
    height: 220px;
}

.secret-key {
    overflow-wrap: anywhere;
    color: var(--muted);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.metric,
.module-row {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.metric span,
.module-row span {
    color: var(--muted);
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 26px;
}

.section {
    margin-top: 20px;
}

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

.module-row {
    display: flex;
    justify-content: space-between;
}

.table-wrap {
    overflow-x: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

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

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

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--primary-dark);
    padding: 0 10px;
    text-transform: capitalize;
}

.table-action {
    color: var(--primary-dark);
    font-weight: 800;
}

.empty-cell,
.empty-state {
    color: var(--muted);
    text-align: center;
}

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

    .sidebar {
        position: static;
    }

    .metric-grid,
    .module-grid,
    .settings-grid,
    .data-form {
        grid-template-columns: 1fr;
    }

    .page-heading,
    .record-header,
    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .record-summary,
    .workspace-grid {
        grid-template-columns: 1fr;
    }
}
