/* ==========================================================================
   Recompra · hoja de estilos única
   Paleta neutra: papel, tinta y grises cálidos.
   ========================================================================== */

:root {
    --bg: #f4f3ef;
    --card: #ffffff;
    --paper: #fbfaf7;
    --sunken: #f0eee8;
    --ink: #1d1d1b;
    --ink-2: #3f3e39;
    --muted: #7c7972;
    --muted-2: #9a968d;
    --line: #e3e0d8;
    --line-strong: #d1cdc3;
    --ok: #2f5d49;
    --ok-bg: #e9f0eb;
    --warn: #7a5a20;
    --warn-bg: #f5efe2;
    --danger: #8a3d36;
    --danger-bg: #f6eae8;
    --info: #3e4a58;
    --info-bg: #eaeef2;
    --accent: #1d1d1b;
    --accent-soft: #34332e;
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 0 rgba(29, 29, 27, .03), 0 1px 2px rgba(29, 29, 27, .04);
    --shadow: 0 18px 40px -26px rgba(29, 29, 27, .28);
    --shadow-lg: 0 30px 80px -24px rgba(29, 29, 27, .35);
    --sidebar: 248px;
    --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: 24px;
}

body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.sidebar-open {
    overflow: hidden;
}

h1,
h2,
h3,
p,
ul,
ol,
figure {
    margin: 0;
}

h1 {
    font-size: clamp(26px, 3vw, 34px);
    line-height: 1.1;
    letter-spacing: -.035em;
    font-weight: 680;
}

h2 {
    font-size: 19px;
    line-height: 1.25;
    letter-spacing: -.02em;
    font-weight: 650;
}

h3 {
    font-size: 15px;
    line-height: 1.3;
    font-weight: 650;
}

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

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

button {
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

ul,
ol {
    padding: 0;
}

.icon {
    width: 18px;
    height: 18px;
    flex: none;
}

.icon--sm {
    width: 15px;
    height: 15px;
}

.icon--lg {
    width: 22px;
    height: 22px;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 12px;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.mono {
    font-family: var(--mono);
    font-size: .92em;
}

.hidden-form {
    display: none;
}

.logo-preview__image .brand__monogram {
    font-size: 20px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 200;
    padding: 10px 14px;
    background: var(--ink);
    color: #fff;
    border-radius: 8px;
    transform: translateY(-160%);
    transition: transform .15s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

:focus-visible {
    outline: 3px solid rgba(29, 29, 27, .22);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Botones e iconos
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: var(--card);
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 620;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .05s ease;
}

.btn:hover {
    background: var(--paper);
    border-color: var(--ink-2);
}

.btn:active {
    transform: translateY(1px);
}

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

.btn--primary:hover {
    background: var(--accent-soft);
    border-color: var(--accent-soft);
}

.btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--ink-2);
}

.btn--ghost:hover {
    background: var(--sunken);
    border-color: transparent;
}

.btn--danger {
    background: transparent;
    border-color: rgba(138, 61, 54, .35);
    color: var(--danger);
}

.btn--danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
}

.btn--sm {
    min-height: 32px;
    padding: 0 10px;
    font-size: 12.5px;
    border-radius: 7px;
}

.btn--block {
    width: 100%;
}

.btn[disabled],
.btn.is-disabled {
    opacity: .45;
    pointer-events: none;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.icon-btn:hover {
    background: var(--sunken);
    color: var(--ink);
}

.icon-btn--bordered {
    border-color: var(--line);
    background: var(--card);
}

.icon-btn--danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* --------------------------------------------------------------------------
   Estructura de la aplicación
   -------------------------------------------------------------------------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    width: var(--sidebar);
    padding: 20px 16px 16px;
    background: var(--paper);
    border-right: 1px solid var(--line);
}

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

.sidebar__close {
    display: none;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.brand__mark {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: none;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.brand__mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 62%;
}

.brand__monogram {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    background: var(--ink);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: -.04em;
}

.brand__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand__text strong {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.02em;
    line-height: 1.1;
}

.brand__text small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 10.5px;
    letter-spacing: .01em;
    white-space: nowrap;
}

.nav {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 3px;
    margin-top: 30px;
    min-height: 0;
}

.nav__label {
    margin: 10px 10px 6px;
    color: var(--muted-2);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.nav__label--spaced {
    margin-top: 26px;
}

.nav__link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-2);
    font-size: 13.5px;
    font-weight: 560;
    text-align: left;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.nav__link:hover {
    background: var(--sunken);
    color: var(--ink);
}

.nav__link.is-active {
    background: var(--ink);
    color: #fff;
}

.nav__link .icon {
    color: currentColor;
    opacity: .8;
}

.nav__link--quiet {
    color: var(--muted);
    font-weight: 500;
}

.nav__link--quiet:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

.sidebar__bottom {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 10px 10px;
}

.sidebar__user > span:last-child {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar__user strong {
    font-size: 12.5px;
    font-weight: 620;
}

.sidebar__user small {
    color: var(--muted);
    font-size: 10.5px;
}

.avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 50%;
    background: var(--sunken);
    color: var(--ink-2);
    font-size: 11px;
    font-weight: 700;
}

.sidebar__version {
    padding: 8px 10px 0;
    color: var(--muted-2);
    font-size: 10px;
}

.sidebar-overlay {
    display: none;
}

.app-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    margin-left: var(--sidebar);
}

.topbar {
    display: none;
}

.main {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 30px clamp(18px, 3vw, 42px) 64px;
    flex: 1;
}

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

.page-head__copy {
    min-width: 0;
}

.page-head__copy h1 {
    margin-top: 4px;
}

.page-head__sub {
    max-width: 680px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 13.5px;
}

.page-head__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    padding-top: 4px;
}

.eyebrow {
    color: var(--muted-2);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   Tarjetas y estructura de contenido
   -------------------------------------------------------------------------- */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card + .card {
    margin-top: 18px;
}

.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 17px 20px;
    border-bottom: 1px solid var(--line);
}

.card__head h2 {
    font-size: 16px;
}

.card__body {
    padding: 20px;
}

.section-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.section-head__number {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: none;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.section-head__copy {
    min-width: 0;
}

.section-head__copy h2 {
    font-size: 16px;
}

.section-head__copy p {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.section-head__aside {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    background: var(--paper);
    border-radius: 0 0 var(--radius) var(--radius);
}

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

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

.stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

.row--between {
    justify-content: space-between;
}

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

.divider {
    height: 1px;
    margin: 16px 0;
    background: var(--line);
}

.notice {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--paper);
    color: var(--ink-2);
    font-size: 12.5px;
}

.notice .icon {
    margin-top: 1px;
    color: var(--muted);
}

.notice--warn {
    border-color: #e8dcc4;
    background: var(--warn-bg);
    color: var(--warn);
}

.notice--danger {
    border-color: #ecd2ce;
    background: var(--danger-bg);
    color: var(--danger);
}

.notice--ok {
    border-color: #d4e3d9;
    background: var(--ok-bg);
    color: var(--ok);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 56px 24px;
    text-align: center;
}

.empty-state__icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 6px;
    border-radius: 50%;
    background: var(--sunken);
    color: var(--muted);
}

.empty-state h3 {
    font-size: 16px;
}

.empty-state p {
    max-width: 420px;
    color: var(--muted);
    font-size: 13px;
}

.empty-state .btn {
    margin-top: 10px;
}

/* --------------------------------------------------------------------------
   Formularios
   -------------------------------------------------------------------------- */

.field {
    min-width: 0;
}

.field > label,
.field-label {
    display: block;
    margin-bottom: 5px;
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 620;
}

.field-hint {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.4;
}

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--card);
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

input,
select {
    height: 40px;
    padding: 0 11px;
}

textarea {
    min-height: 100px;
    padding: 10px 11px;
    line-height: 1.55;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: var(--muted-2);
}

input:hover,
select:hover,
textarea:hover {
    border-color: #bcb7ab;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(29, 29, 27, .09);
}

select {
    appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237c7972' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    cursor: pointer;
}

input[type="date"] {
    padding-right: 8px;
}

input[type="file"] {
    height: auto;
    padding: 8px;
    font-size: 12.5px;
}

input[type="checkbox"],
input[type="radio"] {
    width: 16px;
    height: 16px;
    min-height: 0;
    padding: 0;
    accent-color: var(--ink);
    cursor: pointer;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--ink-2);
    cursor: pointer;
    user-select: none;
}

.check input {
    flex: none;
}

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

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

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

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 20px;
}

.search {
    position: relative;
    flex: 1;
    min-width: 210px;
    max-width: 380px;
}

.search .icon {
    position: absolute;
    top: 50%;
    left: 12px;
    color: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.search input {
    padding-left: 38px;
}

.search__clear {
    position: absolute;
    top: 50%;
    right: 7px;
    width: 26px;
    height: 26px;
    transform: translateY(-50%);
}

/* --------------------------------------------------------------------------
   Panel de control
   -------------------------------------------------------------------------- */

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

.kpi {
    position: relative;
    min-height: 112px;
    padding: 17px 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow-sm);
}

.kpi__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.kpi__label {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
}

.kpi__icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 8px;
    background: var(--sunken);
    color: var(--muted);
}

.kpi__value {
    margin-top: 12px;
    font-size: clamp(22px, 2.4vw, 29px);
    font-weight: 700;
    letter-spacing: -.045em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.kpi__meta {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11.5px;
}

.kpi--dark {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

.kpi--dark .kpi__label,
.kpi--dark .kpi__meta {
    color: #b9b5ac;
}

.kpi--dark .kpi__icon {
    background: #32322d;
    color: #d8d4cb;
}

.kpi--dark .kpi__value {
    color: #fff;
}

.kpi--dark .kpi__meta strong {
    color: #fff;
    font-weight: 650;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.toolbar__spacer {
    flex: 1;
}

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

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 99px;
    background: var(--card);
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.chip:hover {
    border-color: var(--line-strong);
    background: var(--paper);
}

.chip.is-active {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

.chip__count {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 99px;
    background: var(--sunken);
    color: var(--muted);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.chip.is-active .chip__count {
    background: #3a3933;
    color: #fff;
}

/* --------------------------------------------------------------------------
   Tablas
   -------------------------------------------------------------------------- */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.data-table th {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .07em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table th.num {
    text-align: right;
}

.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background .12s ease;
}

.data-table tbody tr:hover {
    background: #fcfbf8;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table .cell-ref {
    font-family: var(--mono);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ink-2);
    white-space: nowrap;
}

.data-table .cell-client {
    max-width: 260px;
}

.data-table .cell-client strong {
    display: block;
    font-size: 13.5px;
    font-weight: 620;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table .cell-client small {
    display: block;
    margin-top: 1px;
    color: var(--muted);
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table .cell-amount {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.data-table .cell-amount--muted {
    color: var(--muted);
    font-weight: 500;
}

.amount-positive {
    color: var(--ok);
}

.amount-negative {
    color: var(--danger);
}

.data-table .cell-date {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 2px;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 9px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
}

.status::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.status--borrador {
    background: var(--sunken);
    color: #65625b;
}

.status--enviada {
    background: var(--info-bg);
    color: var(--info);
}

.status--aceptada {
    background: var(--ok-bg);
    color: var(--ok);
}

.status--rechazada {
    background: var(--danger-bg);
    color: var(--danger);
}

.status--archivada {
    background: #eeece7;
    color: #8d897f;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.pagination__links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination__link {
    display: inline-grid;
    place-items: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 600;
}

.pagination__link:hover {
    background: var(--sunken);
}

.pagination__link.is-active {
    background: var(--ink);
    color: #fff;
}

.pagination__link.is-disabled {
    opacity: .35;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Editor de propuestas
   -------------------------------------------------------------------------- */

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 318px;
    gap: 20px;
    align-items: start;
}

.editor-main {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

.editor-aside {
    position: sticky;
    top: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.summary-card {
    padding: 18px;
}

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

.summary-card__title h2 {
    font-size: 14px;
}

.summary-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 12.5px;
}

.summary-row:last-of-type {
    border-bottom: 0;
}

.summary-row span:first-child {
    color: var(--muted);
}

.summary-row strong {
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

.summary-balance {
    margin-top: 12px;
    padding: 14px;
    border-radius: 10px;
    background: var(--ink);
    color: #fff;
}

.summary-balance__label {
    color: #b9b5ac;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.summary-balance__value {
    margin-top: 4px;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -.04em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.summary-balance__meta {
    margin-top: 3px;
    color: #b9b5ac;
    font-size: 11px;
}

.summary-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.summary-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 11.5px;
}

.summary-meta span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.summary-meta strong {
    color: var(--ink-2);
    font-weight: 600;
}

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

.items-table th {
    padding: 8px 6px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.items-table th.num {
    text-align: right;
}

.items-table td {
    padding: 4px 3px;
    border-bottom: 1px solid #efede7;
    vertical-align: middle;
}

.items-table tbody tr:last-child td {
    border-bottom: 0;
}

.items-table input {
    height: 34px;
    padding: 0 7px;
    border-color: transparent;
    background: transparent;
    border-radius: 6px;
    font-size: 12.5px;
}

.items-table input:hover {
    border-color: var(--line);
    background: var(--paper);
}

.items-table input:focus {
    border-color: var(--ink);
    background: var(--card);
    box-shadow: 0 0 0 3px rgba(29, 29, 27, .08);
}

.items-table .idx {
    width: 26px;
    color: var(--muted-2);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.items-table .line-total {
    width: 82px;
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 650;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.items-table .remove-cell {
    width: 34px;
    text-align: center;
}

.items-table .remove-cell .icon-btn {
    width: 28px;
    height: 28px;
    color: var(--muted-2);
}

.items-table .remove-cell .icon-btn:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.items-table--services {
    min-width: 680px;
}

.items-table--services .service-name {
    min-width: 180px;
}

.items-table--services .service-desc {
    min-width: 200px;
}

.table-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 20px 14px;
}

.table-tools__left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.add-row {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 11px;
    border: 1px dashed var(--line-strong);
    border-radius: 7px;
    background: transparent;
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 620;
    cursor: pointer;
}

.add-row:hover {
    border-color: var(--ink-2);
    background: var(--paper);
}

.line-summary {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 18px;
    padding: 12px 20px;
    border-top: 1px solid var(--line);
    background: var(--paper);
    border-radius: 0 0 var(--radius) var(--radius);
}

.line-summary span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.line-summary strong {
    font-size: 17px;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.conditions-card .card__body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.segmented {
    display: inline-flex;
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--sunken);
}

.segmented__item {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 620;
    cursor: pointer;
}

.segmented__item:hover {
    color: var(--ink);
}

.segmented__item.is-active,
.segmented__item:has(input:checked) {
    background: var(--card);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(29, 29, 27, .12);
}

.segmented__item:has(input:focus-visible) {
    outline: 3px solid rgba(29, 29, 27, .22);
    outline-offset: 1px;
}

.segmented__item input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.items-table tr.is-included {
    background: #fbfaf7;
}

.items-table tr.is-included [data-field="precio_unidad"]:disabled {
    color: var(--muted-2);
    text-decoration: line-through;
}

input:disabled,
select:disabled,
textarea:disabled {
    background: var(--sunken);
    color: var(--muted);
    cursor: not-allowed;
}

.textarea-lg {
    min-height: 210px;
}

.textarea-xl {
    min-height: 280px;
}

.char-count {
    float: right;
    color: var(--muted-2);
    font-size: 10.5px;
    font-weight: 400;
}

.editor-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.editor-savebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0 2px;
    color: var(--muted);
    font-size: 11.5px;
}

/* --------------------------------------------------------------------------
   Ajustes
   -------------------------------------------------------------------------- */

.settings-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.settings-nav {
    position: sticky;
    top: 22px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 560;
}

.settings-nav a:hover {
    background: var(--sunken);
    color: var(--ink);
}

.settings-nav a.is-active {
    background: var(--card);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

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

.logo-preview {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper);
}

.logo-preview__image {
    display: grid;
    place-items: center;
    width: 120px;
    height: 78px;
    padding: 8px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.logo-preview__image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.logo-preview__copy {
    flex: 1;
    min-width: 180px;
}

.logo-preview__copy strong {
    display: block;
    font-size: 13px;
}

.logo-preview__copy small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11.5px;
}

.status-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.status-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
    font-size: 12.5px;
}

.status-list__item:last-child {
    border-bottom: 0;
}

.status-list__label {
    color: var(--muted);
}

.status-list__value {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    text-align: right;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ok);
}

.dot--warn {
    background: var(--warn);
}

.dot--bad {
    background: var(--danger);
}

.password-meter {
    display: flex;
    gap: 4px;
    margin-top: 7px;
}

.password-meter span {
    height: 3px;
    flex: 1;
    border-radius: 99px;
    background: var(--line);
}

.password-meter span.is-on {
    background: var(--ink);
}

/* --------------------------------------------------------------------------
   Modales
   -------------------------------------------------------------------------- */

dialog {
    width: min(560px, calc(100vw - 28px));
    max-height: min(86vh, 780px);
    padding: 0;
    overflow: auto;
    border: 0;
    border-radius: 16px;
    background: var(--card);
    color: var(--ink);
    box-shadow: var(--shadow-lg);
}

dialog::backdrop {
    background: rgba(24, 24, 22, .5);
    backdrop-filter: blur(2px);
}

dialog.modal--wide {
    width: min(680px, calc(100vw - 28px));
}

.modal__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 20px 22px 14px;
    border-bottom: 1px solid var(--line);
}

.modal__head h2 {
    font-size: 18px;
}

.modal__head p {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12.5px;
}

.modal__body {
    padding: 20px 22px;
}

.modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 22px 20px;
    border-top: 1px solid var(--line);
    background: var(--paper);
}

.modal__foot--between {
    justify-content: space-between;
}

.modal-summary {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper);
}

.modal-summary__icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 50%;
    background: var(--sunken);
    color: var(--muted);
}

.modal-summary__icon--danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.modal-summary strong {
    display: block;
    font-size: 13px;
}

.modal-summary p {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

/* --------------------------------------------------------------------------
   Avisos flotantes
   -------------------------------------------------------------------------- */

.toast-stack {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(420px, calc(100vw - 36px));
    pointer-events: none;
}

.toast-stack--inline {
    position: static;
    width: 100%;
    margin: 18px 0;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    box-shadow: var(--shadow);
    color: var(--ink-2);
    font-size: 12.5px;
    pointer-events: auto;
    animation: toast-in .22s ease both;
}

.toast.is-out {
    animation: toast-out .2s ease both;
}

.toast__icon {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    flex: none;
    border-radius: 50%;
}

.toast__icon .icon {
    width: 13px;
    height: 13px;
}

.toast--success .toast__icon {
    background: var(--ok-bg);
    color: var(--ok);
}

.toast--error .toast__icon {
    background: var(--danger-bg);
    color: var(--danger);
}

.toast--info .toast__icon {
    background: var(--info-bg);
    color: var(--info);
}

.toast__text {
    flex: 1;
    padding-top: 1px;
    line-height: 1.4;
}

.toast__close {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.toast__close:hover {
    background: var(--sunken);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(-6px);
    }
}

/* --------------------------------------------------------------------------
   Documento público / vista de impresión
   -------------------------------------------------------------------------- */

.public-page {
    background: #eae8e1;
}

.public-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px clamp(16px, 4vw, 40px);
    border-bottom: 1px solid var(--line);
    background: var(--card);
}

.brand--public .brand__mark {
    width: 34px;
    height: 34px;
}

.brand--public .brand__text strong {
    font-size: 13px;
}

.public-topbar__tag {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.public-main {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 28px clamp(12px, 3vw, 30px) 60px;
}

.proposal-doc {
    padding: clamp(24px, 5vw, 56px);
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 24px 60px -38px rgba(29, 29, 27, .4);
}

.doc-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 14px;
}

.doc-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--ink);
}

.doc-head__brand img {
    max-width: 150px;
    max-height: 62px;
    object-fit: contain;
}

.doc-head__right {
    text-align: right;
}

.doc-head__right h1 {
    font-size: clamp(20px, 2.5vw, 26px);
    letter-spacing: -.03em;
}

.doc-head__right p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.doc-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 22px 0;
    border-bottom: 1px solid var(--line);
}

.doc-meta__label {
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.doc-meta__value {
    font-size: 13.5px;
    font-weight: 600;
}

.doc-meta__lines {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.doc-section {
    margin-top: 26px;
}

.doc-section__title {
    display: flex;
    align-items: baseline;
    gap: 9px;
    margin-bottom: 12px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--line-strong);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.doc-section__title span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
}

.doc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
}

.doc-table th {
    padding: 8px 9px;
    border-bottom: 1px solid var(--line-strong);
    background: var(--paper);
    color: var(--muted);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
}

.doc-table th.num {
    text-align: right;
}

.doc-table td {
    padding: 9px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.doc-table tbody tr:last-child td {
    border-bottom: 0;
}

.doc-table .num {
    white-space: nowrap;
}

.doc-table tfoot td {
    padding-top: 11px;
    border-top: 1px solid var(--line-strong);
    border-bottom: 0;
    font-weight: 700;
}

.doc-total {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 30px;
    padding: 12px 9px 0;
    font-size: 12px;
    font-weight: 700;
}

.doc-balance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-top: 18px;
    padding: 16px 18px;
    border-radius: 4px;
    background: var(--ink);
    color: #fff;
}

.doc-balance__label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #b9b5ac;
}

.doc-balance__value {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -.04em;
    font-variant-numeric: tabular-nums;
}

.doc-balance__meta {
    margin-top: 2px;
    color: #b9b5ac;
    font-size: 10.5px;
}

.doc-copy {
    color: var(--ink-2);
    font-size: 11.5px;
    line-height: 1.65;
    text-align: justify;
}

.doc-conditions {
    margin: 0;
    padding-left: 20px;
    color: var(--ink-2);
    font-size: 11.5px;
    line-height: 1.55;
}

.doc-conditions li {
    margin-bottom: 6px;
    padding-left: 2px;
}

.doc-footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-top: 34px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 9.5px;
    line-height: 1.5;
}

.expired-banner {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    margin-bottom: 18px;
    padding: 11px 13px;
    border: 1px solid #e8dcc4;
    border-radius: 8px;
    background: var(--warn-bg);
    color: var(--warn);
    font-size: 12px;
}

/* --------------------------------------------------------------------------
   Autenticación e instalación
   -------------------------------------------------------------------------- */

.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 26px;
    background: #e9e7e0;
}

.auth-shell {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    width: min(1120px, 100%);
    min-height: 650px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--card);
    box-shadow: var(--shadow-lg);
}

.auth-brand {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 34px;
    padding: 42px;
    background: var(--ink);
    color: #fff;
}

.auth-brand .brand__mark {
    width: 48px;
    height: 48px;
    border-color: #3f3e38;
    background: #fff;
}

.auth-brand .brand__text strong {
    color: #fff;
}

.auth-brand .brand__text small {
    color: #b9b5ac;
}

.auth-brand__copy {
    max-width: 450px;
}

.auth-brand__copy .eyebrow {
    color: #a7a298;
}

.auth-brand__copy h1 {
    margin-top: 12px;
    font-size: clamp(28px, 3.2vw, 40px);
    line-height: 1.08;
    letter-spacing: -.045em;
}

.auth-brand__copy p:not(.eyebrow) {
    margin-top: 16px;
    max-width: 390px;
    color: #c9c5bc;
    font-size: 13.5px;
    line-height: 1.65;
}

.auth-points {
    display: flex;
    flex-direction: column;
    gap: 10px;
    list-style: none;
}

.auth-points li {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    color: #c9c5bc;
    font-size: 12px;
    line-height: 1.45;
}

.auth-points .icon {
    width: 15px;
    height: 15px;
    margin-top: 1px;
    color: #fff;
}

.auth-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 42px 38px;
}

.auth-card {
    width: min(390px, 100%);
}

.auth-card h2 {
    margin-top: 8px;
    font-size: clamp(24px, 2.4vw, 30px);
    letter-spacing: -.035em;
}

.auth-card__sub {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.auth-card .field {
    margin-top: 18px;
}

.auth-card .btn {
    margin-top: 8px;
}

.auth-footer {
    color: var(--muted-2);
    font-size: 10.5px;
    text-align: center;
}

.auth-links {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    color: var(--muted);
    font-size: 11.5px;
}

.auth-links a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Página de error
   -------------------------------------------------------------------------- */

.error-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--bg);
}

.error-card {
    width: min(480px, 100%);
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
}

.error-card h1 {
    margin: 8px 0 10px;
    font-size: 26px;
}

.error-card p {
    color: var(--muted);
    font-size: 13px;
}

.error-card .btn {
    margin-top: 18px;
}

/* --------------------------------------------------------------------------
   Impresión
   -------------------------------------------------------------------------- */

@media print {
    @page {
        size: A4;
        margin: 14mm;
    }

    html,
    body {
        background: #fff !important;
        color: #111 !important;
    }

    .public-topbar,
    .doc-actions,
    .toast-stack,
    .no-print,
    .btn {
        display: none !important;
    }

    .public-main {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .proposal-doc {
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .doc-head {
        break-inside: avoid;
    }

    .doc-section,
    .doc-table tr,
    .doc-conditions li,
    .doc-balance {
        break-inside: avoid;
    }

    .doc-table th {
        background: #f2f1ed !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .doc-balance {
        background: #111 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

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

/* --------------------------------------------------------------------------
   Adaptación a pantallas
   -------------------------------------------------------------------------- */

@media (max-width: 1180px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .editor-layout {
        grid-template-columns: minmax(0, 1fr) 290px;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 20px 0 50px -30px rgba(0, 0, 0, .4);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar__close {
        display: inline-grid;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 35;
        display: block;
        background: rgba(24, 24, 22, .45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }

    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .app-body {
        margin-left: 0;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 30;
        display: flex;
        align-items: center;
        gap: 8px;
        height: 58px;
        padding: 0 14px;
        border-bottom: 1px solid var(--line);
        background: rgba(251, 250, 247, .92);
        backdrop-filter: blur(10px);
    }

    .topbar__brand {
        flex: 1;
        display: flex;
        justify-content: center;
        min-width: 0;
    }

    .topbar__brand .brand__mark {
        width: 30px;
        height: 30px;
        border-radius: 8px;
    }

    .topbar__brand .brand__text strong {
        font-size: 13px;
    }

    .topbar__brand .brand__text small {
        display: none;
    }

    .main {
        padding-top: 24px;
    }

    .editor-layout {
        grid-template-columns: 1fr;
    }

    .editor-aside {
        position: static;
    }

    .settings-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .settings-nav {
        position: static;
        flex-direction: row;
        gap: 4px;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .settings-nav a {
        white-space: nowrap;
        background: var(--card);
        border: 1px solid var(--line);
    }
}

@media (max-width: 760px) {
    .page-head {
        flex-direction: column;
        gap: 14px;
    }

    .page-head__actions {
        width: 100%;
        justify-content: flex-start;
    }

    .page-head__actions .btn {
        flex: 1;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .kpi {
        min-height: 100px;
        padding: 14px;
    }

    .kpi__value {
        font-size: 22px;
    }

    .form-grid,
    .form-grid--3,
    .form-grid--4,
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .card__head {
        padding: 14px 16px;
    }

    .card__body {
        padding: 16px;
    }

    .section-head {
        padding: 14px 16px;
    }

    .section-head__aside {
        display: none;
    }

    .table-tools,
    .line-summary {
        padding-left: 16px;
        padding-right: 16px;
    }

    .auth-page {
        padding: 12px;
    }

    .auth-shell {
        grid-template-columns: 1fr;
        min-height: 0;
        border-radius: 16px;
    }

    .auth-brand {
        gap: 18px;
        padding: 26px;
    }

    .auth-brand__copy h1 {
        font-size: 26px;
    }

    .auth-brand__copy p:not(.eyebrow) {
        display: none;
    }

    .auth-points {
        display: none;
    }

    .auth-panel {
        padding: 28px 24px 30px;
    }

    .public-main {
        padding-top: 16px;
    }

    .proposal-doc {
        padding: 22px 18px;
    }

    .doc-head {
        flex-direction: column;
        gap: 14px;
    }

    .doc-head__right {
        text-align: left;
    }

    .doc-meta {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .doc-balance {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .doc-table {
        min-width: 620px;
    }

    .doc-section {
        overflow-x: auto;
    }

    .doc-footer {
        flex-direction: column;
        gap: 8px;
    }

    .hide-sm {
        display: none !important;
    }

    .toolbar .search {
        max-width: none;
    }

    .toolbar .chip-row {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
    }

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

@media (max-width: 520px) {
    .main {
        padding-left: 12px;
        padding-right: 12px;
    }

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

    .page-head__actions .btn {
        min-width: 0;
        padding: 0 10px;
        font-size: 12.5px;
    }

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

    .page-editor .page-head__actions > * {
        justify-content: center;
    }

    .page-editor .page-head__actions > .btn--primary {
        grid-column: 1 / -1;
    }

    .toolbar {
        align-items: stretch;
    }

    .toolbar > * {
        width: 100%;
    }

    .toolbar .chip-row {
        width: 100%;
    }

    .editor-actions {
        width: 100%;
    }

    .editor-actions .btn {
        flex: 1;
    }

    .modal__foot {
        flex-wrap: wrap;
    }

    .modal__foot .btn {
        flex: 1;
    }

    .toast-stack {
        top: 10px;
        right: 10px;
        width: calc(100vw - 20px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
