:root {
    color-scheme: only light;
    --bg: #f6f7f4;
    --panel: #ffffff;
    --ink: #1e2420;
    --muted: #657069;
    --line: #dfe5de;
    --accent: #0f766e;
    --accent-dark: #0b5d56;
    --danger: #b42318;
    --warning: #b45f06;
    --caution: #9a7b00;
    --success: #147a3c;
    --blue: #2457a6;
    --shadow: 0 18px 60px rgba(22, 34, 29, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

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;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-dark);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 32px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.88);
}

.brand {
    color: var(--ink);
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0;
}

.topnav {
    display: flex;
    align-items: center;
    gap: 18px;
    color: var(--muted);
    font-size: 0.94rem;
}

.topnav a {
    font-weight: 800;
}

main {
    width: 100%;
}

.messages {
    display: grid;
    gap: 8px;
    width: min(1080px, calc(100% - 32px));
    margin: 16px auto 0;
}

.message {
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: var(--panel);
    padding: 12px 14px;
    color: var(--ink);
}

.message.error {
    border-left-color: var(--danger);
}

.message.success {
    border-left-color: var(--success);
}

.auth-shell {
    display: grid;
    min-height: calc(100vh - 64px);
    place-items: center;
    padding: 48px 20px;
}

.auth-panel {
    width: min(430px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 34px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 10px;
    font-size: clamp(2rem, 4vw, 3.1rem);
    line-height: 1;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 0;
    font-size: 1.08rem;
}

h3 {
    margin: 0;
    font-size: 1rem;
}

.muted {
    color: var(--muted);
    line-height: 1.55;
}

.lead {
    max-width: 780px;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.55;
}

.form-stack {
    display: grid;
    gap: 12px;
    margin-top: 28px;
}

label {
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd6cf;
    border-radius: 8px;
    background: #fbfcfb;
    color: var(--ink);
    font: inherit;
}

input,
select {
    height: 48px;
    padding: 0 14px;
}

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

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
    outline: none;
}

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    padding: 0 18px;
}

button:hover,
.button-link:hover {
    background: var(--accent-dark);
    color: #ffffff;
}

.secondary-link {
    display: inline-block;
    margin-top: 20px;
    font-weight: 700;
}

.field-error {
    margin: -4px 0 0;
    color: var(--danger);
    font-size: 0.88rem;
}

.errorlist {
    margin: 8px 0 0;
    padding: 0;
    color: var(--danger);
    font-size: 0.84rem;
    font-weight: 700;
    list-style: none;
}

.dashboard {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 42px 0 64px;
}

.page-heading,
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

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

.contract-brand-preview {
    display: flex;
    align-items: center;
    gap: 18px;
    margin: 18px 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    padding: 12px 16px;
}

.contract-brand-preview img {
    width: 180px;
    max-width: 38vw;
    height: auto;
}

.contract-brand-preview div {
    display: grid;
    gap: 4px;
}

.contract-brand-preview strong {
    font-size: 0.95rem;
}

.contract-brand-preview span {
    color: var(--muted);
    font-size: 0.86rem;
}

.metric small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.82rem;
}

.metric-income {
    border-top: 4px solid var(--success);
}

.metric-expense {
    border-top: 4px solid var(--danger);
}

.finance-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
    gap: 18px;
    margin: 26px 0;
}

.wide-panel {
    min-height: 330px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    min-height: 250px;
    overflow-x: auto;
    padding: 24px 8px 4px;
}

.bar-column {
    display: grid;
    grid-template-rows: auto 160px auto;
    align-items: end;
    justify-items: center;
    min-width: 64px;
    gap: 8px;
}

.bar-column small {
    color: var(--muted);
    font-size: 0.74rem;
    text-align: center;
}

.bar-value {
    color: var(--muted);
    font-size: 0.76rem;
    white-space: nowrap;
}

.bar-track {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: 100%;
    height: 160px;
    border-bottom: 1px solid var(--line);
}

.bar {
    display: block;
    width: 28px;
    border-radius: 6px 6px 0 0;
    background: var(--accent);
}

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

.category-bars {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.category-bars div {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

.category-bars span,
.category-bars strong {
    font-size: 0.9rem;
}

.category-bars i {
    grid-column: 1 / -1;
    display: block;
    height: 8px;
    border-radius: 999px;
    background: var(--bar-color, var(--accent));
}

.narrow {
    width: min(920px, calc(100% - 32px));
}

.action-row,
.filter-bar,
.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.action-row {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.button-link.subtle {
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--ink);
}

.button-link.subtle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.filter-bar {
    margin: 26px 0 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.filter-bar input {
    flex: 1;
    min-width: 260px;
}

.filter-bar select {
    width: 220px;
}

.table-shell,
.form-card,
.result-section {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 10px 32px rgba(22, 34, 29, 0.06);
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 880px;
}

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

.data-table th {
    background: #eef4f1;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.data-table small {
    display: block;
    color: var(--muted);
}

.status-pill,
.attention {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 0.78rem;
    font-weight: 800;
}

.status-pill {
    background: #eef4f1;
    color: var(--muted);
}

.status-active {
    background: #dcfce7;
    color: var(--success);
}

.status-review,
.status-expiring {
    background: #fff7d6;
    color: var(--warning);
}

.status-expired,
.status-cancelled {
    background: #fee4e2;
    color: var(--danger);
}

.attention {
    margin-left: 6px;
    background: #fff7d6;
    color: var(--warning);
}

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

.result-section {
    padding: 20px;
}

.compact-list {
    display: grid;
    gap: 8px;
    margin-top: 16px;
}

.compact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 58px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ink);
}

.compact-row strong,
.compact-row small {
    display: block;
}

.compact-row small,
.compact-row em {
    color: var(--muted);
    font-size: 0.86rem;
    font-style: normal;
}

.form-card {
    margin-top: 24px;
    padding: 22px;
}

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

.form-grid label {
    display: grid;
    gap: 7px;
}

.form-grid textarea,
.form-grid .check-field {
    grid-column: 1 / -1;
}

.check-field {
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

.check-field input {
    width: auto;
    height: auto;
}

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

.detail-list {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 10px 16px;
    margin: 18px 0 0;
}

.detail-list dt {
    color: var(--muted);
    font-weight: 800;
}

.detail-list dd {
    margin: 0;
}

.inline-form {
    display: grid;
    gap: 10px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.inline-form p {
    display: grid;
    gap: 6px;
    margin: 0;
}

.timeline {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.timeline article {
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: #fbfcfb;
    padding: 12px 14px;
}

.timeline span,
.timeline small {
    color: var(--muted);
    font-size: 0.86rem;
}

.timeline strong {
    display: block;
    margin: 4px 0;
}

.padded {
    padding: 12px 0;
}

@media (max-width: 840px) {
    .topbar,
    .page-heading,
    .filter-bar,
    .panel-grid,
    .finance-grid,
    .form-grid,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .topbar,
    .page-heading,
    .filter-bar {
        align-items: stretch;
    }

    .topbar {
        display: grid;
        gap: 12px;
        padding: 16px;
    }

    .topnav {
        flex-wrap: wrap;
    }

    .panel-grid {
        display: grid;
    }

    .form-grid {
        display: grid;
    }

    .filter-bar {
        display: grid;
    }

    .filter-bar select {
        width: 100%;
    }

    .detail-list {
        grid-template-columns: 1fr;
    }
}

.sheet-dashboard {
    width: min(1980px, calc(100% - 36px));
    margin: 0 auto;
    padding: 18px 14px 48px;
    color: #111111;
    font-family: Arial, Helvetica, sans-serif;
}

.sheet-dashboard form {
    min-width: 0;
}

.sheet-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 8px;
}

.month-picker {
    display: grid;
    gap: 4px;
    min-width: 160px;
    color: #333333;
}

.month-picker input,
.month-picker select {
    height: 36px;
    border-radius: 0;
    background: #ffffff;
    font-weight: 800;
}

.autosave-status {
    min-width: 86px;
    color: #657069;
    font-size: 0.78rem;
    font-weight: 800;
    text-align: left;
}

.autosave-status.saving {
    color: #2457a6;
}

.autosave-status.error {
    color: var(--danger);
}

.sheet-toolbar h1 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.2;
}

.sheet-top {
    display: grid;
    grid-template-columns: 150px 150px 200px 220px minmax(320px, 0.9fr);
    gap: 18px;
    align-items: start;
    min-height: 185px;
    padding: 8px 0 22px;
}

.donut-card {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    min-height: 170px;
    background: transparent;
}

.donut {
    display: grid;
    place-items: center;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: conic-gradient(#6fbe44 var(--paid), #d9ded8 0);
    position: relative;
}

.donut::after {
    content: "";
    position: absolute;
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: #ffffff;
}

.donut strong {
    position: relative;
    z-index: 1;
    font-size: 1.65rem;
}

.payment-donut {
    background: conic-gradient(#0f8a7a var(--paid), #d9ded8 0);
}

.donut-amounts {
    display: grid;
    gap: 2px;
    color: #111111;
    font-size: 0.68rem;
    text-align: center;
}

.donut-amounts strong {
    font-size: 0.9rem;
    font-weight: 900;
}

.donut-amounts span {
    color: #5d665f;
    font-weight: 700;
}

.donut-amounts small {
    color: #7a837d;
    font-size: 0.62rem;
    font-weight: 700;
}

.donut-amounts small b {
    color: #4d5751;
}

.summary-ledger {
    display: grid;
    gap: 8px;
    align-content: start;
    padding: 8px 10px;
    border-left: 3px solid #dfe5de;
}

.summary-ledger div {
    display: grid;
    grid-template-columns: 1fr;
    align-items: end;
    gap: 2px;
}

.summary-ledger div::before {
    content: none;
}

.summary-ledger strong {
    font-size: 1.14rem;
    letter-spacing: 0;
}

.summary-ledger a {
    color: #2457a6;
    font-size: 0.68rem;
    font-style: italic;
    font-weight: 900;
    text-decoration: underline;
}

.summary-ledger .profit-line strong {
    display: inline-block;
    width: fit-content;
    background: #d9f0c8;
    padding: 4px 12px;
}

.forecast-card {
    background: #ffffff;
    border: 1px solid #d6d6d6;
    padding: 8px 12px 4px;
}

.forecast-card h2 {
    margin: 0 0 4px;
    color: #5c5c5c;
    font-size: 1.05rem;
    text-align: center;
}

.forecast-card svg {
    display: block;
    width: 100%;
    height: 132px;
}

.forecast-card .grid-lines line {
    stroke: #dddddd;
    stroke-width: 1;
}

.forecast-card .line {
    fill: none;
    stroke-width: 3;
}

.forecast-card .zero-line {
    stroke: #9aa39b;
    stroke-dasharray: 4 4;
    stroke-width: 1.5;
}

.forecast-card .forecast {
    stroke: #f5b400;
}

.forecast-card .real {
    stroke: #8bc34a;
}

.forecast-card text {
    fill: #666666;
    font-size: 10px;
}

.forecast-card .axis-label {
    text-anchor: end;
    font-size: 9px;
    font-weight: 700;
}

.chart-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #606060;
    font-size: 0.75rem;
}

.forecast-dot,
.real-dot,
.zero-dot {
    display: inline-block;
    width: 24px;
    height: 3px;
}

.forecast-dot {
    background: #f5b400;
}

.real-dot {
    background: #8bc34a;
}

.zero-dot {
    background: repeating-linear-gradient(90deg, #9aa39b 0 5px, transparent 5px 8px);
}

.sheet-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 32px;
    align-items: start;
}

.dashboard-income-grid {
    grid-template-columns: minmax(0, 1fr);
}

.side-tables {
    display: grid;
    gap: 34px;
}

.bottom-tables {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
    align-items: start;
    margin-top: 38px;
}

.payments-page {
    width: min(1260px, calc(100vw - 42px));
    margin: 0 auto;
}

.payments-top {
    display: grid;
    grid-template-columns: 210px minmax(360px, 1fr);
    gap: 22px;
    align-items: start;
    margin: 8px 0 18px;
}

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

.personal-top {
    display: grid;
    grid-template-columns: 150px 150px 220px minmax(360px, 1fr);
    gap: 20px;
    align-items: start;
    margin: 8px 0 22px;
}

.personal-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.82fr) minmax(360px, 0.82fr);
    gap: 24px;
    align-items: start;
}

.personal-grid > .sheet-table:nth-child(4) {
    grid-column: 2;
}

.personal-summary {
    min-height: 170px;
}

.payment-progress-card {
    width: 210px;
    min-height: 190px;
}

.payment-forecast-card {
    min-height: 190px;
}

.payments-table {
    width: 100%;
}

.payments-table .date-col {
    width: 92px;
}

.payments-table .total-col {
    width: 118px;
}

.sheet-table tfoot .auto-total-row td {
    background: #f7faf7;
    color: #4f5b54;
}

.sheet-table tfoot .balance-row td {
    border-top-width: 4px;
    font-size: 0.88rem;
    font-weight: 900;
}

.sheet-table tfoot .balance-row td:last-child {
    text-align: right;
}

.sheet-table tfoot .balance-positive td:last-child {
    background: #d9f0c8;
}

.sheet-table tfoot .balance-negative td:last-child {
    background: #f6d8d8;
}

.sheet-table .status-cell {
    position: relative;
    padding-right: 24px;
}

.sheet-table .status-cell .money-input {
    background: transparent;
    padding-right: 18px;
}

.status-toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    display: block;
    width: 12px;
    min-width: 12px;
    height: 12px;
    min-height: 12px;
    transform: translateY(-50%);
    border: 2px solid #111111;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.status-toggle:focus {
    outline: 2px solid #138a43;
    outline-offset: 2px;
}

.status-paid .status-toggle {
    background: #138a43;
}

.status-deferred .status-toggle {
    background: #b78600;
}

.payments-table .payment-description input {
    padding-left: 4px;
}

.sheet-table {
    background: #ffffff;
    min-width: 0;
    overflow: hidden;
}

.table-title {
    min-height: 20px;
    color: #111111;
    font-size: 0.86rem;
    font-weight: 700;
}

.sheet-table table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.delete-col {
    width: 30px;
}

.description-col {
    width: auto;
}

.money-col {
    width: 96px;
}

.total-col {
    width: 112px;
}

.date-col {
    width: 86px;
}

.sheet-table th {
    border: 2px solid #0c0c0c;
    background: #113b5d;
    color: #ffffff;
    font-size: 0.68rem;
    line-height: 1.1;
    padding: 3px 4px;
    text-align: left;
}

.sheet-table td {
    border: 2px solid #0c0c0c;
    background: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.15;
    padding: 2px 4px;
    vertical-align: middle;
}

.sheet-table input,
.sheet-table select {
    width: 100%;
    height: 22px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #111111;
    font: inherit;
    font-weight: 700;
    padding: 0 2px;
}

.sheet-table .short-date-input {
    text-align: center;
}

.sheet-table .total-input {
    text-align: right;
}

.delete-cell {
    text-align: center;
    width: 30px;
    min-width: 30px;
    padding: 2px !important;
    vertical-align: middle;
}

.drag-handle {
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    color: #555555;
    cursor: grab;
    font-size: 0.95rem;
    line-height: 1;
    user-select: none;
    z-index: 1;
    touch-action: none;
}

.description-cell:active .drag-handle {
    cursor: grabbing;
}

.dragging {
    opacity: 0.55;
}

.description-cell {
    position: relative;
    min-width: 0;
    padding-left: 28px !important;
    white-space: nowrap;
}

.description-cell input:not([type="hidden"]) {
    display: block;
    width: 100%;
    min-width: 12ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-delete {
    min-height: 20px;
    width: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: #6b7280;
    font-size: 0.95rem;
    font-weight: 900;
    padding: 0;
    line-height: 1;
}

.row-delete:hover {
    border-color: #cfd8d2;
    background: #eef2ef;
    color: #303733;
}

.pending-delete td {
    background: #ffe4e6 !important;
    opacity: 0.75;
    text-decoration: line-through;
}

.sheet-table tr.pending-delete {
    display: none;
}

.pending-delete .row-delete {
    text-decoration: none;
    color: #0f766e;
}

.delete-heading {
    text-align: center;
}

.confirm-modal[hidden] {
    display: none;
}

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.35);
}

.confirm-dialog {
    width: min(420px, calc(100% - 32px));
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
    padding: 22px;
}

.confirm-dialog h2 {
    margin: 0 0 8px;
    font-size: 1.2rem;
}

.sheet-table select {
    min-width: 94px;
    font-size: 0.72rem;
}

.sheet-table input:focus,
.sheet-table select:focus {
    background: #fff8c5;
    box-shadow: inset 0 0 0 2px #138a43;
    color: #111111;
    outline: none;
}

.sheet-table .money-input,
.calc-cell {
    background: #ffffff;
    text-align: right;
}

.sheet-table .qty-input,
.sheet-table .tax-input {
    background: #ffffff;
    text-align: right;
}

.iva-cell {
    background: #ffffff;
    text-align: right;
}

.iva-display {
    display: block;
    padding: 3px 4px;
    color: #0c0c0c;
    font-size: 0.78rem;
    font-weight: 900;
    text-align: right;
}

.sheet-table .delete-check {
    width: 16px;
    height: 16px;
    margin: 0 auto;
    display: block;
}

.sheet-table .new-row td {
    background: #ffffff;
}

.sheet-table .new-row input,
.sheet-table .new-row select {
    color: #4b5563;
}

.sheet-table .total-cell,
.income-table tbody td:nth-child(5) {
    background: #ffffff;
    text-align: right;
}

.sheet-table .status-cell {
    cursor: pointer;
    user-select: none;
}

.payroll-table .status-cell {
    cursor: pointer;
}

.payroll-table .monthly-input {
    background: transparent;
    text-align: right;
}

.sheet-table .status-cell:focus {
    box-shadow: inset 0 0 0 3px #138a43;
    outline: none;
}

.sheet-table .status-paid {
    background: #8dd34c !important;
}

.sheet-table .status-deferred {
    background: #ffd966 !important;
}

.sheet-table .status-pending {
    background: #ffffff !important;
}

.sheet-table tfoot td {
    background: #ffffff;
    font-weight: 900;
    text-align: right;
}

.sales-table tbody td:nth-child(4),
.sales-table tbody td:nth-child(5),
.side-tables tbody td:nth-child(4),
.side-tables tbody td:nth-child(5) {
    background: #ffffff;
    text-align: right;
}

@media (max-width: 1280px) {
    .sheet-dashboard {
        overflow-x: auto;
    }

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

.score-panel {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.6fr);
    gap: 0;
    margin-top: 30px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.score-summary {
    display: grid;
    align-content: center;
    min-height: 230px;
    padding: 30px;
    background: #16221f;
    color: #ffffff;
}

.score-summary span,
.score-summary small {
    color: rgba(255, 255, 255, 0.76);
    font-weight: 700;
}

.score-summary strong {
    display: block;
    margin: 12px 0;
    font-size: clamp(4rem, 10vw, 7rem);
    line-height: 0.9;
}

.score-detail {
    display: grid;
    align-content: center;
    gap: 16px;
    padding: 30px;
}

.score-detail h2 {
    font-size: clamp(1.9rem, 4vw, 3.4rem);
    line-height: 1;
}

.score-detail p:not(.eyebrow) {
    max-width: 700px;
    color: var(--muted);
    line-height: 1.55;
}

.maturity-bar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 800;
}

.maturity-track {
    height: 16px;
    border-radius: 999px;
    background: linear-gradient(90deg, #b42318 0%, #d97706 38%, #d8b400 58%, #63b56d 82%, #147a3c 100%);
    overflow: hidden;
}

.maturity-fill {
    height: 100%;
    border-right: 4px solid #ffffff;
    background: rgba(255, 255, 255, 0.36);
}

.score-red .score-summary {
    background: #8f1d16;
}

.score-orange .score-summary {
    background: #a94d05;
}

.score-yellow .score-summary {
    background: #8c7100;
}

.score-light-green .score-summary {
    background: #2e7d4f;
}

.score-green .score-summary {
    background: #126c35;
}

.metric {
    min-height: 120px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 20px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.metric strong {
    display: block;
    margin-top: 14px;
    font-size: 2.5rem;
    line-height: 1;
}

.table-section,
.result-section,
.maturity-map,
.assessment-form-section {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    overflow: hidden;
}

.section-heading {
    padding: 20px;
    border-bottom: 1px solid var(--line);
}

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

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

th {
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

td {
    color: var(--ink);
}

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

.empty-state {
    display: grid;
    gap: 12px;
    justify-items: start;
    padding: 42px 20px;
}

.empty-state p {
    color: var(--muted);
}

.result-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    margin-bottom: 28px;
}

.priority-list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.priority-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.priority-list li:last-child {
    border-bottom: 0;
}

.priority-list span {
    font-weight: 800;
}

.priority-list strong {
    color: var(--warning);
}

.contact-box {
    display: grid;
    gap: 16px;
    justify-items: start;
    padding: 20px;
}

.contact-box p {
    color: var(--muted);
    line-height: 1.55;
}

.padded {
    padding: 20px;
}

.maturity-map {
    margin-bottom: 28px;
}

.control-map-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    background: var(--line);
}

.control-tile {
    display: grid;
    gap: 10px;
    min-height: 130px;
    background: var(--panel);
    padding: 16px;
}

.control-tile span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.control-tile strong {
    line-height: 1.25;
}

.control-tile small {
    align-self: end;
    width: fit-content;
    border-radius: 999px;
    padding: 5px 10px;
    color: #ffffff;
    font-weight: 900;
}

.level-0 small,
.level-1 small {
    background: var(--danger);
}

.level-2 small {
    background: var(--warning);
}

.level-3 small {
    background: var(--caution);
}

.level-4 small {
    background: #4b9561;
}

.level-5 small {
    background: var(--success);
}

.assessment-form-section {
    scroll-margin-top: 24px;
}

.assessment-form {
    display: grid;
    gap: 22px;
    padding: 20px;
}

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

.levels-help {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}

.levels-help span {
    display: grid;
    gap: 4px;
    min-height: 72px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.25;
    padding: 10px;
}

.levels-help strong {
    color: var(--ink);
    font-size: 1.25rem;
}

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

.control-question {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
    padding: 16px;
}

.control-question span {
    color: var(--blue);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.control-question p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.score-options {
    display: grid;
    grid-template-columns: repeat(6, 42px);
    gap: 6px;
}

.score-options label {
    display: grid;
    place-items: center;
}

.score-options input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.score-options span {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid #cbd6cf;
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font-size: 0.95rem;
    font-weight: 900;
    letter-spacing: 0;
}

.score-options input:checked + span {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.form-actions p {
    max-width: 680px;
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.quote-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr);
    gap: 18px;
    align-items: start;
}

.quote-dashboard .metric-grid {
    margin-bottom: 18px;
}

.quote-form label {
    display: grid;
    gap: 8px;
}

.search-form {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto;
    gap: 10px;
    width: min(620px, 100%);
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-line input {
    width: 18px;
    height: 18px;
}

.import-history {
    margin-top: 24px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    background: #eef3f0;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 900;
    padding: 0 10px;
}

.status-sent {
    background: #e6efff;
    color: var(--blue);
}

.status-approved {
    background: #e4f6eb;
    color: var(--success);
}

.status-rejected {
    background: #fde9e7;
    color: var(--danger);
}

.quote-summary-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    margin: 30px 0 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--line);
    overflow: hidden;
}

.quote-summary-panel div {
    display: grid;
    gap: 12px;
    background: var(--panel);
    padding: 24px;
}

.quote-summary-panel span {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 800;
}

.quote-summary-panel strong {
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1;
}

.quote-facts {
    display: grid;
    gap: 0;
    margin: 0;
}

.quote-facts div {
    display: grid;
    grid-template-columns: minmax(140px, 0.45fr) minmax(0, 1fr);
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}

.quote-facts div:last-child {
    border-bottom: 0;
}

.quote-facts dt {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 900;
    text-transform: uppercase;
}

.quote-facts dd {
    margin: 0;
    font-weight: 700;
}

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

.secondary-button {
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--accent);
}

.secondary-button:hover {
    border-color: var(--accent);
    background: #edf7f4;
    color: var(--accent-dark);
}

.diagram-page {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: calc(100vh - 64px);
}

.diagram-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
    padding: 18px 24px;
}

.diagram-topbar h1 {
    margin: 0;
    font-size: 1.6rem;
}

.diagram-shell {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    min-height: calc(100vh - 150px);
}

.stencil-panel {
    display: grid;
    align-content: start;
    gap: 16px;
    border-right: 1px solid var(--line);
    background: #ffffff;
    padding: 18px;
}

.stencil-panel label {
    display: grid;
    gap: 8px;
}

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

.stencil-actions button {
    min-height: 38px;
    padding: 0 8px;
    font-size: 0.82rem;
}

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

.stencil-list button {
    min-height: 56px;
    border: 1px solid var(--line);
    background: #fbfcfb;
    color: var(--ink);
    font-size: 0.82rem;
    line-height: 1.15;
    padding: 8px;
}

.stencil-list button:hover,
.stencil-list button.is-active {
    border-color: var(--accent);
    background: #edf7f4;
    color: var(--accent-dark);
}

.diagram-workspace {
    position: relative;
    min-width: 0;
    overflow: auto;
    background:
        linear-gradient(#edf1ee 1px, transparent 1px),
        linear-gradient(90deg, #edf1ee 1px, transparent 1px),
        #f8faf8;
    background-size: 24px 24px;
    padding: 18px;
}

.diagram-hint {
    position: sticky;
    top: 0;
    z-index: 2;
    width: fit-content;
    max-width: min(720px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 10px 12px;
}

.diagram-canvas {
    display: block;
    width: 1200px;
    height: 760px;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow);
    touch-action: none;
}

.diagram-link-line {
    stroke: #51605a;
    stroke-width: 3;
    stroke-linecap: round;
}

.diagram-canvas marker path {
    fill: #51605a;
}

.diagram-node {
    cursor: grab;
}

.diagram-node rect,
.diagram-node-preview rect {
    fill: #ffffff;
    stroke: #aab8b1;
    stroke-width: 2;
}

.diagram-node.is-selected rect {
    stroke: var(--accent);
    stroke-width: 4;
}

.diagram-node.is-connecting rect {
    fill: #edf7f4;
    stroke: var(--accent);
}

.diagram-node-icon,
.diagram-node-label,
.diagram-node-preview text {
    fill: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    text-anchor: middle;
    user-select: none;
}

.diagram-node-icon,
.diagram-node-preview text:first-of-type {
    font-size: 20px;
    font-weight: 900;
}

.diagram-node-label,
.diagram-node-preview text:last-of-type {
    font-size: 13px;
    font-weight: 800;
}

.diagram-azure rect {
    fill: #eef6ff;
    stroke: #2f72bc;
}

.diagram-firewall rect,
.diagram-checkpoint rect {
    fill: #fff0ed;
    stroke: #d4482f;
}

.diagram-aruba rect,
.diagram-unifi rect,
.diagram-switch rect {
    fill: #edf7f4;
    stroke: var(--accent);
}

.diagram-kaspersky rect {
    fill: #e9fbf6;
    stroke: #00a88e;
}

.diagram-physical-server rect,
.diagram-virtual-server rect {
    fill: #f3f5f7;
    stroke: #59636e;
}

.diagram-users rect,
.diagram-laptop rect {
    fill: #fff8e6;
    stroke: #b68416;
}

.diagram-preview {
    padding: 16px;
}

.diagram-preview svg {
    display: block;
    width: 100%;
    min-height: 280px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.diagram-node-preview text {
    font-size: 12px;
}

@media (max-width: 760px) {
    .topbar,
    .page-heading,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar {
        padding: 16px 20px;
    }

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

    .score-panel,
    .result-grid,
    .form-grid,
    .quote-grid,
    .quote-summary-panel,
    .diagram-shell,
    .search-form,
    .control-question,
    .form-actions {
        grid-template-columns: 1fr;
    }

    .diagram-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .stencil-panel {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .form-actions {
        align-items: stretch;
    }

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

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

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

    .score-options span {
        width: 100%;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .auth-panel {
        padding: 26px 20px;
    }

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

    .control-map-grid,
    .levels-help {
        grid-template-columns: 1fr;
    }
}
