/* TodoAuto web — estética de apple.com: fondo gris claro, superficies limpias sin sombras,
   tipografía SF grande y apretada, barra global traslúcida, botones píldora e íconos de línea
   monocromos. Claro / oscuro según Settings > Theme o el sistema. */

:root {
    /* Datos (servicios, estados): los mismos colores que la app */
    --blue: #0071e3; --green: #28a745; --orange: #f56300; --purple: #8e44ad;
    --pink: #e3115b; --teal: #0e8fa8; --indigo: #5856d6; --red: #e30000; --gray: #86868b;
    --accent: #0071e3; --accent-hover: #0077ed;
    --bg: #f5f5f7; --card: #ffffff; --card-2: #f5f5f7; --hover: rgba(0, 0, 0, 0.04);
    --text: #1d1d1f; --muted: #6e6e73; --faint: #86868b;
    --line: #d2d2d7; --line-soft: #e8e8ed; --input: #ffffff;
    --nav-bg: rgba(250, 250, 252, 0.8);
    --good: #1d8a3a; --warn: #b64400; --error: #d70015;
    --radius: 18px;
    color-scheme: light;
    font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --blue: #2997ff; --green: #30d158; --orange: #ff9f0a; --purple: #bf5af2;
        --pink: #ff375f; --teal: #40c8e0; --indigo: #5e5ce6; --red: #ff453a; --gray: #98989d;
        --accent: #2997ff; --accent-hover: #47a6ff;
        --bg: #000000; --card: #161617; --card-2: #1d1d1f; --hover: rgba(255, 255, 255, 0.06);
        --text: #f5f5f7; --muted: #a1a1a6; --faint: #86868b;
        --line: #424245; --line-soft: #2c2c2e; --input: #1d1d1f;
        --nav-bg: rgba(22, 22, 23, 0.8);
        --good: #30d158; --warn: #ff9f0a; --error: #ff6961;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --blue: #2997ff; --green: #30d158; --orange: #ff9f0a; --purple: #bf5af2;
    --pink: #ff375f; --teal: #40c8e0; --indigo: #5e5ce6; --red: #ff453a; --gray: #98989d;
    --accent: #2997ff; --accent-hover: #47a6ff;
    --bg: #000000; --card: #161617; --card-2: #1d1d1f; --hover: rgba(255, 255, 255, 0.06);
    --text: #f5f5f7; --muted: #a1a1a6; --faint: #86868b;
    --line: #424245; --line-soft: #2c2c2e; --input: #1d1d1f;
    --nav-bg: rgba(22, 22, 23, 0.8);
    --good: #30d158; --warn: #ff9f0a; --error: #ff6961;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.47; letter-spacing: -0.01em; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif; font-weight: 600; letter-spacing: -0.015em; }
hr { border: 0; border-top: 1px solid var(--line-soft); margin: 12px 0; width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.icon { width: 1em; height: 1em; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.15em; }
.icon.flip { transform: rotate(180deg); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; }
.center { text-align: center; }
.mono, .mono-num { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0; }
.mono-num, .num { font-variant-numeric: tabular-nums; }
.selectable { user-select: text; }
.error { color: var(--error); }
.good { color: var(--good); }
.warn { color: var(--warn); }
.push { margin-left: auto; }
.grow { flex: 1; min-width: 0; }

/* Logo según el tema */
.dark-only { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .dark-only { display: block; }
    :root:not([data-theme="light"]) .light-only { display: none; }
}
:root[data-theme="dark"] .dark-only { display: block; }
:root[data-theme="dark"] .light-only { display: none; }

/* MARK: Barra global (apple.com) */

.shell { min-height: 100vh; }
.globalnav {
    position: sticky; top: 0; z-index: 30; height: 52px;
    background: var(--nav-bg); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.globalnav-inner { max-width: 1180px; height: 100%; margin: 0 auto; padding: 0 22px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; flex-shrink: 0; }
.brand-logo { height: 19px; width: auto; }
.nav-links { display: flex; align-items: center; gap: 4px; margin: 0 auto; }
.nav-link {
    display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 980px;
    color: var(--muted); font-size: 13px; font-weight: 500; letter-spacing: -0.005em; position: relative;
    transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); background: var(--hover); }
.nav-link .nav-icon { width: 16px; height: 16px; }
.nav-link .badge { margin-left: 2px; }
.nav-user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; flex-shrink: 0; }
.nav-user:hover { color: var(--text); }
.nav-user-name { max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

main { max-width: 1180px; margin: 0 auto; padding: 44px 22px 96px; outline: none; }

@media (max-width: 860px) {
    /* Sin backdrop-filter aquí: haría que la barra de pestañas (fixed) quede dentro del header. */
    .globalnav { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
    .globalnav-inner { gap: 12px; justify-content: space-between; }
    .sheet-filters .input.compact { flex: 1 1 140px; }
    .nav-user-name { display: none; }
    .nav-links {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; gap: 0; justify-content: space-around;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        background: var(--nav-bg); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
        border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
    }
    .nav-link { flex: 1; flex-direction: column; justify-content: center; height: 48px; gap: 3px; padding: 0; font-size: 10px; border-radius: 10px; }
    .nav-link.active { background: none; }
    .nav-link .nav-icon { width: 22px; height: 22px; }
    .nav-link .badge { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; }
    main { padding: 28px 16px calc(100px + env(safe-area-inset-bottom)); }
}

.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.loading { padding: 48px; text-align: center; color: var(--muted); }
.loading.small { padding: 8px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-title h1 { font-size: 40px; line-height: 1.1; letter-spacing: -0.02em; }
.page-title p { margin: 8px 0 0; font-size: 17px; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.page-actions .btn:not(.primary) { background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.page-actions .btn:not(.primary):hover { background: var(--card); box-shadow: inset 0 0 0 1px var(--faint); }
.back { display: inline-flex; align-items: center; gap: 2px; margin-bottom: 10px; font-size: 15px; }
@media (max-width: 860px) { .page-title h1 { font-size: 32px; } }

.narrow { max-width: 760px; }
/* Pantallas angostas (formularios, listas): título y contenido centrados, como en apple.com */
main:has(> .narrow) { max-width: 804px; }

/* Manage: hoy a la izquierda, menú a la derecha en pantallas anchas */
.manage-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 36px; align-items: start; }
.manage-grid .menu-group { max-width: none; }
.manage-menu > .group-title:first-child { margin-top: 0; }
.manage-grid .stack > .group-title:first-child { margin-top: 0; }
@media (max-width: 1000px) { .manage-grid { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-tight { display: flex; flex-direction: column; gap: 8px; }

/* MARK: Controles */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 18px; border-radius: 980px; border: 0; cursor: pointer; white-space: nowrap;
    background: var(--card-2); color: var(--text); font: inherit; font-size: 14px; font-weight: 500;
    min-height: 36px; text-align: center; transition: background 0.15s, opacity 0.15s;
}
.btn:hover { background: color-mix(in srgb, var(--card-2) 85%, var(--text) 15%); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn .icon { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.success { background: var(--text); color: var(--bg); }
.btn.success:hover { opacity: 0.85; background: var(--text); }
.btn.danger { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1px var(--line); }
.btn.danger:hover { background: color-mix(in srgb, var(--red) 8%, transparent); }
.btn.danger-text { background: transparent; color: var(--red); }
.btn.danger-text:hover { background: color-mix(in srgb, var(--red) 8%, transparent); }
.btn.danger-outline { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1px var(--line); }
.btn.link { background: none; padding: 6px 4px; min-height: 0; color: var(--accent); }
.btn.link:hover { background: none; text-decoration: underline; }
.btn.small { padding: 4px 12px; min-height: 30px; font-size: 13px; }
.btn.pill { box-shadow: inset 0 0 0 1px var(--line); background: var(--card); }
.btn.block { width: 100%; min-height: 44px; font-size: 15px; }
.card .btn:not(.primary):not(.success):not(.danger):not(.danger-text):not(.danger-outline):not(.link) { background: var(--card-2); }
.two-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.icon-btn { display: grid; place-items: center; width: 30px; height: 30px; background: var(--card-2); border: 0; color: var(--muted); cursor: pointer; border-radius: 50%; }
.icon-btn:hover { color: var(--text); }

.input {
    width: 100%; padding: 9px 14px; border-radius: 12px; font: inherit; font-size: 15px; color: var(--text);
    background: var(--input); border: 1px solid var(--line); min-height: 40px; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.input.compact { width: auto; min-height: 34px; padding: 6px 14px; font-size: 13px; border-radius: 980px; }
select.input.compact { padding-right: 32px; }
textarea.input { resize: vertical; }
.input.right { text-align: right; }
.input.mono { letter-spacing: 0.04em; }
.group .input { background: var(--card-2); border-color: transparent; }
.group .input:focus { border-color: var(--accent); }
select.input { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; }

.search-field {
    display: flex; align-items: center; gap: 8px; padding: 0 14px; height: 36px; border-radius: 980px;
    background: var(--card); border: 1px solid var(--line); color: var(--faint); min-width: 220px; flex: 0 1 300px;
}
.search-field:focus-within { border-color: var(--accent); }
.search-field input { border: 0; outline: none; background: none; font: inherit; font-size: 14px; color: var(--text); width: 100%; }

.switch { width: 44px; height: 26px; accent-color: var(--green); }

.badge {
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red);
    color: #fff; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; letter-spacing: 0;
}
.card > .tag { align-self: flex-start; }
.link-row.grow { justify-content: space-between; }
.tag {
    display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 980px; font-size: 12px; font-weight: 500;
    color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); white-space: nowrap;
}

/* MARK: Formularios */

.form { display: flex; flex-direction: column; gap: 8px; }
.group { background: var(--card); border-radius: var(--radius); padding: 4px 18px; }
.group > * + * { border-top: 1px solid var(--line-soft); }
.group-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 22px 0 2px 4px; letter-spacing: 0; font-family: inherit; }
.footnote { font-size: 13px; color: var(--muted); margin: 2px 4px; }
.row { display: flex; align-items: center; gap: 14px; padding: 10px 0; min-height: 52px; }
.row-label { flex: 0 0 150px; color: var(--text); }
.row > .input, .row > select, .row > .vin-row, .row > span:last-child { flex: 1; }
.row.missing { background: color-mix(in srgb, var(--red) 8%, transparent); margin: 0 -18px; padding-left: 18px; padding-right: 18px; }
.row.missing .row-label { color: var(--red); }
.row.changed { background: color-mix(in srgb, var(--accent) 8%, transparent); margin: 0 -18px; padding-left: 18px; padding-right: 18px; }
.group textarea { margin: 10px 0; }
.vin-row { display: flex; align-items: center; gap: 10px; }
.vin-seal { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.vin-seal .ok { color: var(--good); display: inline-flex; gap: 4px; align-items: center; }
.vin-seal .warn { color: var(--warn); display: inline-flex; gap: 4px; align-items: center; }
.suggestions:empty { display: none; }
.suggestion {
    display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 10px 0;
    background: none; border: 0; border-top: 1px solid var(--line-soft); cursor: pointer; color: var(--text); font: inherit; text-align: left;
}
.suggestion:hover { color: var(--accent); }
.suggestion:first-child { border-top: 0; }
.add-row { display: flex; gap: 10px; padding: 12px; align-items: center; }
.add-row > * + * { border-top: 0; }
.form > .btn.block, .form > .btn.success { margin-top: 18px; }

@media (max-width: 560px) {
    .row { flex-wrap: wrap; gap: 6px; }
    .row-label { flex-basis: 100%; font-size: 13px; color: var(--muted); }
}

/* MARK: Tarjetas y listas */

.card { background: var(--card); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; align-items: start; }
.cards > .empty, .cards > .loading, .cards > .btn.block { grid-column: 1 / -1; }
.record-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.record-head h3 { font-size: 17px; }
.meta { display: flex; gap: 16px; color: var(--muted); font-size: 13px; align-items: center; flex-wrap: wrap; }
.meta-item { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.meta-item .icon { width: 14px; height: 14px; color: var(--faint); }
.note { margin: 0; color: var(--muted); font-size: 13px; }
.card-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.card.clickable, button.card, a.card { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.card.clickable:hover, button.card:hover, a.card:hover { box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08); }
.card-link { color: inherit; display: flex; flex-direction: column; gap: 8px; }
button.card { border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; width: 100%; }
.money { color: var(--text); font-variant-numeric: tabular-nums; }
.money.big { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.total-row { flex-direction: row; justify-content: space-between; align-items: center; }
.warning-card { box-shadow: inset 3px 0 0 var(--red); }
.line-rows { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.line-row { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.line-row.total { color: var(--text); font-size: 17px; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.change { display: flex; flex-direction: column; gap: 2px; }
.link-text { color: var(--accent); }

.toolbar { margin-bottom: 12px; max-width: 760px; }
.search { border-radius: 980px; padding-left: 18px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.filters .input { width: auto; min-width: 160px; min-height: 34px; padding: 6px 32px 6px 14px; font-size: 13px; border-radius: 980px; }
.filters input[type="date"].input { padding-right: 14px; }

.thumbs { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0; }
.thumb { position: relative; flex: 0 0 auto; width: 76px; height: 100px; border-radius: 10px; overflow: hidden; background: var(--card-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-remove {
    position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; display: grid; place-items: center;
    background: rgba(0, 0, 0, 0.6); color: #fff; cursor: pointer;
}
.doc-picker { display: flex; flex-direction: column; gap: 10px; padding: 10px 0; align-items: flex-start; }
.doc-picker > * + * { border-top: 0; }
.doc-picker .thumbs:empty { display: none; }

.empty { text-align: center; padding: 64px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty h3 { color: var(--text); font-size: 21px; }
.empty p { margin: 0; max-width: 440px; }

.menu-group { background: var(--card); border-radius: var(--radius); overflow: hidden; max-width: 760px; }
.menu-row {
    display: flex; align-items: center; gap: 16px; padding: 14px 20px; color: var(--text); width: 100%;
    background: none; border: 0; font: inherit; text-align: left; cursor: pointer; transition: background 0.15s;
}
.menu-row + .menu-row { border-top: 1px solid var(--line-soft); }
a.menu-row:hover, button.menu-row:hover { background: var(--hover); }
.menu-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--card-2); color: var(--text); }
.menu-icon .icon { width: 20px; height: 20px; }
.menu-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.menu-title > span:first-child { font-weight: 500; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex-shrink: 0; }
.avatar.small { width: 28px; height: 28px; font-size: 11px; }
.chevron { color: var(--faint); }
.icon.chevron { width: 16px; height: 16px; }

.list { padding: 0 20px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.list-row + .list-row, .list > * + * { border-top: 1px solid var(--line-soft); }
.list-row.column { flex-direction: column; align-items: stretch; gap: 3px; }
.list-row.strong span:last-child { font-weight: 600; font-size: 20px; color: var(--text); letter-spacing: -0.02em; }
.link-row { background: none; border: 0; font: inherit; color: inherit; cursor: pointer; width: 100%; text-align: left; display: flex; align-items: center; gap: 12px; }
.list > .list-row.link-row:hover { color: var(--accent); }
.group.list > .chart-pad { padding: 16px 0; }

/* Today / Analytics */
.today { gap: 12px; }
.today-count { display: flex; align-items: baseline; gap: 10px; }
.today-count strong { font-size: 56px; line-height: 1; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.today .small { display: inline-flex; align-items: center; gap: 6px; }
.mini-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mini-tile { color: var(--text); gap: 6px; }
.mini-tile .icon { width: 20px; height: 20px; color: var(--faint); }
.mini-tile.highlight { box-shadow: inset 0 0 0 1.5px var(--c); }
.mini-tile.highlight .icon { color: var(--c); }
.tile-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tile { gap: 10px; }
.tile-head { display: flex; justify-content: space-between; align-items: center; color: var(--text); }
.tile-head .icon:first-child { width: 22px; height: 22px; }
.analytics { display: flex; flex-direction: column; gap: 16px; transition: opacity 0.2s; }
.dimmed { opacity: 0.5; pointer-events: none; }
.section-card { gap: 16px; padding: 22px 24px; }
.card-title { display: inline-flex; align-items: center; gap: 10px; font-size: 19px; }
.card-title .icon { width: 20px; height: 20px; }
.details { display: inline-flex; align-items: center; gap: 2px; }
.segmented { display: inline-flex; background: var(--card-2); border-radius: 980px; padding: 3px; gap: 2px; }
.card .segmented { background: var(--card-2); }
.segmented button { border: 0; background: none; font: inherit; font-size: 13px; font-weight: 500; padding: 6px 16px; border-radius: 980px; cursor: pointer; color: var(--muted); }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1); }
:root[data-theme="dark"] .segmented, :root[data-theme="dark"] .card .segmented { background: var(--card-2); }

/* MARK: Accounting (hoja de cálculo) */
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-head .segmented { background: var(--line-soft); }
.sheet-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.sheet-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.sheet-wrap {
    background: var(--card); border-radius: 14px; border: 1px solid var(--line-soft);
    overflow: auto; max-height: calc(100vh - 290px); min-height: 240px;
}
table.sheet { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; letter-spacing: 0; }
.sheet th, .sheet td { padding: 0 12px; height: 36px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); }
.sheet th:last-child, .sheet td:last-child { border-right: 0; }
.sheet thead th {
    position: sticky; top: 0; z-index: 2; background: var(--card); height: 40px; padding: 0;
    font-weight: 600; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line);
}
.th-btn {
    display: flex; align-items: center; gap: 4px; width: 100%; height: 40px; padding: 0 12px; border: 0; background: none;
    font: inherit; color: inherit; cursor: pointer; text-align: left; white-space: nowrap;
}
.th-btn:hover { color: var(--text); }
.sheet th[aria-sort="ascending"], .sheet th[aria-sort="descending"] { color: var(--text); }
.sheet .right, .sheet .right .th-btn { text-align: right; justify-content: flex-end; }
.sheet .rownum { position: sticky; left: 0; z-index: 1; width: 48px; min-width: 48px; text-align: right; color: var(--faint); background: var(--card); font-variant-numeric: tabular-nums; font-size: 12px; }
.sheet thead .rownum { z-index: 3; }
.sheet tbody tr:hover td { background: var(--hover); }
.sheet tbody tr:hover td.rownum { background: color-mix(in srgb, var(--card) 92%, var(--text) 8%); }
.sheet td.mono { font-size: 12.5px; }
.sheet td:last-child { white-space: normal; min-width: 200px; }
.svc { display: inline-flex; align-items: center; gap: 7px; }
.sheet tbody tr.clickable-row { cursor: pointer; }
.sheet tbody tr.clickable-row:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.payroll-cell { display: inline-flex; align-items: center; gap: 8px; }
.payroll-cell .icon { color: var(--accent); }
.open-hint { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-size: 12px; }
.doc-links { display: inline-flex; gap: 6px; }
.doc-link { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 980px; background: var(--card-2); color: var(--text); font-size: 12px; }
.doc-link:hover { color: var(--accent); }
.sheet-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; font-size: 13px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.sheet-footer > span:first-child { font-weight: 600; }

.sheet-actions { display: flex; gap: 8px; align-items: center; }
.row-actions { display: inline-flex; gap: 4px; }

/* Adjuntar archivos desde la computadora (Finance) */
.files-block { display: flex; flex-direction: column; gap: 10px; padding: 12px 0; }
.files-block > * + * { border-top: 0; }
.file-picker { display: flex; flex-direction: column; gap: 10px; }
.files-block.missing .drop-zone { border-color: var(--red); background: color-mix(in srgb, var(--red) 6%, transparent); }
.drop-zone {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 16px; text-align: center;
    border: 1.5px dashed var(--line); border-radius: 14px; color: var(--muted); cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.drop-zone .icon { width: 26px; height: 26px; color: var(--faint); }
.drop-zone strong { color: var(--text); font-weight: 500; }
.drop-zone:hover, .drop-zone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.file-list { display: flex; flex-direction: column; gap: 6px; }
.file-list:empty { display: none; }
.file-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--card-2); color: var(--text); }
.file-item .icon { width: 18px; height: 18px; color: var(--faint); }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.file-item:hover .file-name { color: var(--accent); }

/* MARK: Finance (resumen arriba de la hoja) */
.finance-summary { display: flex; flex-direction: column; gap: 16px; margin-bottom: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { gap: 4px; padding: 18px 20px; }
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finance-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.finance-charts .card { gap: 18px; padding: 22px 24px; }
@media (max-width: 900px) { .finance-charts { grid-template-columns: 1fr; } }
.compare-card { padding: 22px 24px; gap: 14px; }
.compare-card .record-head { flex-wrap: wrap; align-items: center; }
.compare-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
table.compare { width: 100%; border-collapse: collapse; font-size: 14px; letter-spacing: 0; }
.compare th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.compare td { padding: 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
.compare .right { text-align: right; }
.compare tfoot td { font-weight: 600; border-bottom: 0; border-top: 1px solid var(--line); }
.compare tbody tr:hover td { background: var(--hover); }
.share { display: inline-block; width: 56px; height: 6px; border-radius: 3px; background: var(--card-2); margin-right: 8px; vertical-align: middle; overflow: hidden; }
.share-bar { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.tiles.three { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tiles.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .tiles.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Facturado vs. recibido por dealer */
.pairs { display: flex; flex-direction: column; gap: 16px; }
.pair { display: flex; flex-direction: column; gap: 5px; }
.pair-row { display: grid; grid-template-columns: 64px 1fr 96px; align-items: center; gap: 10px; }
.pair-track { height: 6px; border-radius: 3px; background: var(--card-2); }
.pair-bar { height: 100%; border-radius: 3px; }
.pair-bar.invoiced { background: var(--accent); }
.pair-bar.received { background: var(--green); }
.pair-value { text-align: right; color: var(--text); }
.type-chip { display: inline-flex; align-items: center; gap: 6px; }
.type-chip.payment .icon { color: var(--green); }
.type-chip.invoice .icon { color: var(--accent); }
.open-list { padding: 0; }
.open-list .list-row { gap: 16px; }

/* Change Log */
.log-entry { padding: 0; gap: 0; overflow: hidden; }
.log-head { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 20px; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.log-head:hover { background: var(--hover); }
.log-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.log-table { margin: 0 20px 16px; width: calc(100% - 40px); }
.log-table td { white-space: normal; vertical-align: top; word-break: break-word; }
.log-before { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--red) 50%, transparent); }
.log-after { color: var(--text); }

/* MARK: Gráficas */
.chart-cols { display: flex; align-items: flex-end; gap: 14px; padding-top: 22px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.chart-bar { width: 100%; max-width: 52px; border-radius: 6px 6px 2px 2px; cursor: default; }
.chart-value { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chart-days-bars { display: flex; align-items: flex-end; gap: 2px; height: 160px; border-bottom: 1px solid var(--line-soft); }
.chart-day { flex: 1; border-radius: 4px 4px 0 0; min-width: 3px; max-width: 44px; }
.chart-days-bars { justify-content: center; }
.chart-day:hover, .chart-bar:hover { filter: brightness(1.12); }
.chart-days-axis { display: flex; justify-content: space-between; padding-top: 6px; }
.chart-rank { display: flex; flex-direction: column; gap: 12px; }
.chart-rank-row { display: flex; flex-direction: column; gap: 6px; }
.chart-rank-head { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.chart-rank-track { height: 6px; border-radius: 3px; background: var(--card-2); }
.chart-rank-bar { height: 100%; border-radius: 3px; }
.chart-rank-bar.split { display: flex; gap: 2px; overflow: hidden; }
.chart-split { display: flex; flex-direction: column; gap: 10px; }
.chart-split-bar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.chart-tooltip {
    position: fixed; z-index: 100; pointer-events: none; background: var(--card); color: var(--text);
    border-radius: 12px; padding: 8px 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.16); font-size: 15px;
    border: 1px solid var(--line-soft);
}

/* MARK: Modales y avisos */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.32); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    display: grid; place-items: center; padding: 16px; animation: aparecer 0.18s ease-out;
}
.modal {
    width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
    background: var(--bg); border-radius: 22px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3); overflow: hidden;
    animation: subir 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 8px; }
.modal-head h2 { font-size: 21px; }
.modal-body { padding: 8px 22px 22px; overflow-y: auto; }
.modal-body > p { margin: 0 0 12px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line-soft); background: var(--card); }
.scanner-video { width: 100%; border-radius: 14px; background: #000; aspect-ratio: 4 / 3; object-fit: cover; }
.toast {
    position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 20px); opacity: 0; z-index: 60;
    background: var(--text); color: var(--bg); padding: 10px 20px; border-radius: 980px; transition: 0.25s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }
@keyframes subir { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

/* Login y términos (el login se queda como estaba) */
.card.login { width: 100%; max-width: 380px; padding: 28px; gap: 12px; }
.card.login .btn.primary.block { border-radius: 12px; }
.login-logo { width: 260px; max-width: 100%; height: auto; margin: 8px auto 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.card.terms { max-width: 640px; gap: 14px; padding: 36px; }
.card.terms h1 { font-size: 32px; }
.card.terms p { margin: 0; }
.member-name { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; position: relative; width: 100%; }
.member-name > .icon:last-child { position: absolute; right: 0; top: 4px; width: 16px; height: 16px; }

/* MARK: Impresión / PDF (Payroll y Analytics) */
#print-root { display: none; }
@media print {
    @page { size: letter; margin: 0.5in; }
    body.printing > :not(#print-root) { display: none !important; }
    body.printing #print-root { display: block; }
    html, body.printing { background: #fff !important; }
}
.pdf { color: #000; background: #fff; font-size: 11px; display: flex; flex-direction: column; gap: 12px; }
.pdf .muted { color: #555; }
.pdf-head { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pdf-head img { width: 300px; }
.pdf-head h1 { font-size: 24px; }
.pdf-head.row-head { flex-direction: row; justify-content: space-between; align-items: center; border-bottom: 2px solid #000; padding-bottom: 10px; }
.pdf-head.row-head img { width: 220px; }
.pdf-head.row-head > div { text-align: right; }
.pdf-datos { display: flex; gap: 80px; }
.pdf-datos > div { display: flex; flex-direction: column; gap: 6px; }
.pdf-dato small { font-size: 8px; font-weight: 600; letter-spacing: 0.08em; }
.pdf-card { background: #f0f0f0; border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pdf-card hr { border-top-color: rgba(0, 0, 0, 0.15); margin: 4px 0; }
.pdf-card.total { background: #dedede; font-size: 15px; }
.pdf .line-row { color: #000; }
.pdf .line-row.strong { font-weight: 700; font-size: 13px; }
.pdf-card.total .line-row.strong { font-size: 16px; }
.pdf-title { font-size: 17px; display: flex; justify-content: space-between; border-bottom: 1px solid #000; padding-bottom: 4px; margin-top: 10px; break-after: avoid; }
.pdf-title span { font-weight: 500; }
.pdf-sub { font-size: 12px; margin-top: 4px; break-after: avoid; }
.pdf-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pdf-tile { border: 1px solid #ccc; border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.pdf-tile strong { font-size: 15px; }
.pdf-table { width: 100%; border-collapse: collapse; }
.pdf-table th { text-align: left; background: #e8e8e8; font-weight: 600; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pdf-table th, .pdf-table td { padding: 4px 6px; border-bottom: 1px solid #ddd; }
.pdf-table tr { break-inside: avoid; }
.pdf-table tbody tr:nth-child(even) td { background: #f7f7f7; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pdf .chart-cols { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.pdf .chart-value, .pdf .chart-label { color: #333; }

/* MARK: Create Invoice (Accounting > Finance) */
.btn.orange { background: var(--orange); color: #fff; }
.btn.orange:hover { background: color-mix(in srgb, var(--orange) 88%, #000); }
.invoice-dealer-info { padding: 8px 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.invoice-dealer-info:empty { display: none; }
.invoice-lines-wrap { overflow-x: auto; }
.invoice-lines { width: 100%; border-collapse: collapse; min-width: 760px; }
.invoice-lines th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 4px 6px; }
.invoice-lines td { padding: 2px 4px; }
.invoice-lines td:nth-child(1) { width: 11%; }
.invoice-lines td:nth-child(4) { width: 17%; }
.invoice-lines td:nth-child(6) { width: 12%; }
.invoice-lines td:last-child { width: 32px; }
.invoice-lines .input { width: 100%; }
.invoice-total { font-size: 17px; padding: 6px 2px; }
.invoice-line-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.rojo { background: var(--red); color: #fff; }
.btn.rojo:hover { background: color-mix(in srgb, var(--red) 88%, #000); }
.invoice-lines tr.discount-line .input { color: var(--red); }

