/* ============================================================
   PCSeguridad · App móvil
   Tema base: fondo blanco con dorado corporativo.
   Modo oscuro (negro + oro): html[data-tema="oscuro"], al final
   del archivo. La barra inferior es negra en ambos modos.
   ============================================================ */

:root {
    /* Superficies */
    --bg: #ffffff;
    --bg-soft: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --surface-3: #eef2f7;
    --surface-a: #ffffff;
    --surface-b: #ffffff;
    --sheet-a: #ffffff;
    --hero-a: #ffffff;
    --hero-b: #f1f5f9;
    --signature: #ffffff;
    --input-focus: #ffffff;
    --toast-bg: rgba(255, 255, 255, 0.99);
    --header-a: rgba(255, 255, 255, 0.94);
    --header-b: rgba(255, 255, 255, 0.60);
    --loader: rgba(255, 255, 255, 0.72);
    --backdrop: rgba(15, 23, 42, 0.35);
    --fade: rgba(255, 255, 255, 0);

    /* Líneas y rellenos */
    --line: rgba(184, 145, 47, 0.30);
    --line-strong: rgba(184, 145, 47, 0.55);
    --line-1: rgba(15, 23, 42, 0.08);
    --line-2: rgba(15, 23, 42, 0.12);
    --line-3: rgba(15, 23, 42, 0.14);
    --fill-1: rgba(15, 23, 42, 0.045);
    --fill-2: rgba(15, 23, 42, 0.09);
    --fill-3: rgba(15, 23, 42, 0.06);
    --fill-tiny: rgba(15, 23, 42, 0.02);
    --grab: rgba(15, 23, 42, 0.18);

    /* Dorado y tipografía */
    --gold: #b8912f;
    --gold-soft: #8a6a1f;
    --gold-deep: #6f5417;
    --gold-on-dark: #ebd08a;
    --text: #101828;
    --text-soft: #384252;
    --muted: #5b6573;

    /* Estados */
    --danger: #b42318;
    --ok: #1f7a53;
    --warn: #9a6700;
    --info: #1f6fb2;
    --tone-ok-line: rgba(31, 122, 83, 0.40);
    --tone-ok-bg: rgba(31, 122, 83, 0.10);
    --tone-info-line: rgba(31, 111, 178, 0.40);
    --tone-info-bg: rgba(31, 111, 178, 0.10);
    --tone-warn-line: rgba(154, 103, 0, 0.40);
    --tone-warn-bg: rgba(154, 103, 0, 0.10);
    --tone-danger-line: rgba(180, 35, 24, 0.45);
    --tone-danger-bg: rgba(180, 35, 24, 0.10);

    /* Controles */
    --switch-knob: #ffffff;
    --badge-ring: #ffffff;

    /* Formas y sombras */
    --radius-lg: 22px;
    --radius: 16px;
    --radius-sm: 11px;
    --shadow: 0 16px 34px rgba(15, 23, 42, 0.10);
    --shadow-1: rgba(15, 23, 42, 0.14);
    --shadow-2: rgba(15, 23, 42, 0.16);
    --shadow-3: rgba(15, 23, 42, 0.12);
    --shadow-4: rgba(15, 23, 42, 0.08);

    --nav-h: 76px;
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-brand: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background:
        radial-gradient(120% 70% at 50% -10%, rgba(216, 182, 92, 0.10) 0%, var(--fade) 55%),
        radial-gradient(90% 50% at 100% 100%, rgba(216, 182, 92, 0.05) 0%, var(--fade) 60%),
        var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

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

button {
    font-family: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

input,
select,
textarea {
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    padding: 13px 14px;
    width: 100%;
    outline: none;
    transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
    appearance: none;
}

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

input:focus,
select:focus,
textarea:focus {
    border-color: var(--line-strong);
    background: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(216, 182, 92, 0.10);
}

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

select {
    background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%),
        linear-gradient(135deg, var(--gold) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 13px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 34px;
}

.is-hidden {
    display: none !important;
}

/* ------------------------------ Splash ------------------------------ */

.splash {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    background:
        radial-gradient(70% 50% at 50% 30%, rgba(216, 182, 92, 0.13), var(--fade) 70%),
        var(--bg);
    transition: opacity 0.45s ease, visibility 0.45s ease;
}

.splash.is-out {
    opacity: 0;
    visibility: hidden;
}

.splash-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.splash-name {
    font-family: var(--font-brand);
    letter-spacing: 0.32em;
    text-transform: uppercase;
    font-size: 13px;
    color: var(--gold-soft);
    margin: 0;
}

.splash-loader {
    width: 34px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
}

/* ------------------------------ Logo ------------------------------ */

.logo-ring {
    position: relative;
    display: grid;
    place-items: center;
    border-radius: 50%;
    padding: 3px;
    background: conic-gradient(from 210deg, #8a6a1f, #f4dd9c, #b8912f, #6f5417, #f4dd9c, #8a6a1f);
    box-shadow: 0 0 0 1px rgba(216, 182, 92, 0.25), 0 12px 30px var(--shadow-1);
}

.logo-ring img {
    border-radius: 50%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #0c0c10;
}

.logo-ring::after {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 1px solid rgba(216, 182, 92, 0.18);
    pointer-events: none;
}

.logo-ring--lg {
    width: 96px;
    height: 96px;
}

.logo-ring--xl {
    width: 124px;
    height: 124px;
    padding: 4px;
}

/* ------------------------------ Login ------------------------------ */

.login {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(28px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom));
    overflow-y: auto;
}

.login-glow {
    position: absolute;
    top: -18%;
    left: 50%;
    width: 130%;
    aspect-ratio: 1;
    transform: translateX(-50%);
    background: radial-gradient(circle at 50% 50%, rgba(216, 182, 92, 0.16), rgba(216, 182, 92, 0.03) 42%, var(--fade) 66%);
    pointer-events: none;
}

.login::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(216, 182, 92, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(216, 182, 92, 0.035) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: radial-gradient(60% 45% at 50% 25%, #000 0%, transparent 100%);
    -webkit-mask-image: radial-gradient(60% 45% at 50% 25%, #000 0%, transparent 100%);
    pointer-events: none;
}

.login-inner {
    position: relative;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    animation: rise 0.6s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.login-company {
    font-family: var(--font-brand);
    font-size: 30px;
    line-height: 1.1;
    letter-spacing: 0.02em;
    margin: 6px 0 0;
    color: var(--text);
    background: linear-gradient(180deg, var(--text) 0%, var(--gold) 90%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-tagline {
    margin: 0;
    font-size: 12px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 22px 20px 24px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, var(--surface-a), var(--surface-b));
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-label {
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}

.field-password {
    position: relative;
    display: block;
}

.field-password input {
    padding-right: 48px;
}

.field-eye {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: var(--muted);
}

.field-eye svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    opacity: 0.85;
}

.form-error {
    margin: 0;
    min-height: 18px;
    font-size: 13px;
    color: var(--danger);
}

.login-foot {
    margin: 0;
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ------------------------------ Botones ------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 48px;
    padding: 12px 20px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.06em;
    border: 1px solid transparent;
    transition: transform 0.14s ease, filter 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.btn:active {
    transform: scale(0.985);
}

.btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.btn-gold {
    background: linear-gradient(160deg, #f3dda1 0%, #d8b65c 42%, #b8912f 100%);
    color: #17130a;
    box-shadow: 0 12px 26px rgba(190, 152, 55, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.btn-gold:hover {
    filter: brightness(1.05);
}

.btn-ghost {
    background: var(--fill-1);
    border-color: var(--line-3);
    color: var(--text-soft);
}

.btn-outline-gold {
    background: rgba(216, 182, 92, 0.08);
    border-color: var(--line-strong);
    color: var(--gold-soft);
}

.btn-danger {
    background: rgba(226, 104, 95, 0.12);
    border-color: rgba(226, 104, 95, 0.38);
    color: var(--danger);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    min-height: 38px;
    padding: 8px 14px;
    font-size: 12.5px;
    border-radius: 11px;
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.icon-btn {
    position: relative;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    color: var(--gold-soft);
    background: var(--fill-1);
    border: 1px solid var(--line-2);
    transition: background 0.18s ease, border-color 0.18s ease;
}

.icon-btn:active {
    background: rgba(216, 182, 92, 0.14);
    border-color: var(--line-strong);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(160deg, #f3dda1, #c69c36);
    color: #191307;
    font-size: 10.5px;
    font-weight: 700;
    border: 2px solid var(--badge-ring);
}

/* ------------------------------ App shell ------------------------------ */

.app {
    min-height: 100vh;
    padding-bottom: calc(var(--nav-h) + 26px + env(safe-area-inset-bottom));
    animation: fade 0.3s ease both;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: calc(16px + env(safe-area-inset-top)) 20px 14px;
    background: linear-gradient(180deg, var(--header-a) 55%, var(--header-b) 100%);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line-1);
}

.app-header-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.app-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-eyebrow {
    margin: 0 0 3px;
    font-size: 10.5px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gold);
    opacity: 0.85;
}

.app-title {
    margin: 0;
    font-family: var(--font-brand);
    font-size: 23px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text);
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 9px;
}

.app-main {
    padding: 18px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 720px;
    margin: 0 auto;
}

/* ------------------------------ Bottom nav ------------------------------ */

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding: 0 6px env(safe-area-inset-bottom);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    background: linear-gradient(180deg, rgba(16, 16, 22, 0.94), rgba(9, 9, 13, 0.99));
    border-top: 1px solid rgba(216, 182, 92, 0.16);
    backdrop-filter: blur(20px);
    box-shadow: 0 -14px 34px rgba(0, 0, 0, 0.5);
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 100%;
    color: #77725f;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: color 0.2s ease;
}

.nav-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    opacity: 0.9;
}

.nav-btn.is-active {
    color: var(--gold-on-dark);
}

.nav-btn.is-active svg {
    filter: drop-shadow(0 0 10px rgba(216, 182, 92, 0.45));
}

.nav-logo {
    justify-self: center;
    align-self: start;
    margin-top: -30px;
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 30%, rgba(216, 182, 92, 0.28), rgba(10, 10, 14, 0.98) 70%);
    box-shadow: 0 0 0 1px rgba(216, 182, 92, 0.45), 0 14px 28px rgba(0, 0, 0, 0.6), inset 0 0 18px rgba(216, 182, 92, 0.18);
}

.nav-logo:active .nav-logo-ring {
    transform: scale(0.95);
}

.nav-logo-ring {
    width: 56px;
    height: 56px;
    padding: 2px;
    border-radius: 50%;
    display: block;
    background: conic-gradient(from 210deg, #8a6a1f, #f4dd9c, #b8912f, #6f5417, #f4dd9c, #8a6a1f);
    transition: transform 0.15s ease;
}

.nav-logo-ring img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #0c0c10;
}

/* ------------------------------ Tarjetas ------------------------------ */

.card {
    border-radius: var(--radius-lg);
    background: linear-gradient(175deg, var(--surface-a), var(--surface-b));
    border: 1px solid var(--line-1);
    box-shadow: 0 12px 30px var(--shadow-4);
}

.card-pad {
    padding: 18px;
}

.card-gold {
    border-color: var(--line);
    background:
        radial-gradient(120% 90% at 0% 0%, rgba(216, 182, 92, 0.13), var(--fade) 60%),
        linear-gradient(175deg, var(--surface-a), var(--surface-b));
}

.hero {
    position: relative;
    overflow: hidden;
    padding: 22px 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background:
        radial-gradient(110% 100% at 100% 0%, rgba(216, 182, 92, 0.18), var(--fade) 62%),
        linear-gradient(170deg, var(--hero-a), var(--hero-b));
}

.hero::after {
    content: "";
    position: absolute;
    right: -40px;
    bottom: -70px;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    border: 1px solid rgba(216, 182, 92, 0.16);
    pointer-events: none;
}

.hero-label {
    margin: 0 0 6px;
    font-size: 10.5px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gold);
}

.hero-title {
    margin: 0;
    font-family: var(--font-brand);
    font-size: 25px;
    line-height: 1.2;
    color: var(--text);
}

.hero-sub {
    margin: 8px 0 0;
    font-size: 13px;
    color: var(--muted);
}

.hero-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 18px;
}

.hero-figure {
    display: flex;
    flex-direction: column;
}

.hero-figure strong {
    font-size: 34px;
    line-height: 1;
    font-family: var(--font-brand);
    color: var(--gold-soft);
}

.hero-figure span {
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 6px;
}

/* ------------------------------ KPIs ------------------------------ */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 11px;
}

.kpi {
    padding: 15px 15px 13px;
    border-radius: var(--radius);
    background: linear-gradient(170deg, var(--surface-a), var(--surface-b));
    border: 1px solid var(--line-1);
}

.kpi-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

.kpi-value {
    margin-top: 8px;
    font-family: var(--font-brand);
    font-size: 27px;
    line-height: 1;
    color: var(--text);
}

.kpi-value.is-gold {
    color: var(--gold-soft);
}

/* ------------------------------ Secciones ------------------------------ */

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 2px -4px;
}

.section-title {
    margin: 0;
    font-size: 12px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.section-link {
    font-size: 12px;
    color: var(--gold);
    letter-spacing: 0.04em;
}

/* ------------------------------ Lista de partes ------------------------------ */

.parte-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.parte-card {
    position: relative;
    display: flex;
    gap: 13px;
    width: 100%;
    text-align: left;
    padding: 15px 16px;
    border-radius: var(--radius);
    background: linear-gradient(170deg, var(--surface-a), var(--surface-b));
    border: 1px solid var(--line-1);
    transition: border-color 0.2s ease, transform 0.14s ease, background 0.2s ease;
}

.parte-card:active {
    transform: scale(0.992);
}

.parte-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 3px;
    background: var(--gold);
    opacity: 0.75;
}

.parte-card[data-estado="FINALIZADO"]::before {
    background: var(--ok);
}

.parte-card[data-estado="EN CURSO"]::before {
    background: var(--info);
}

.parte-card[data-estado="HAY QUE VOLVER"]::before {
    background: var(--warn);
}

.parte-card[data-estado="ANULADO"]::before {
    background: var(--danger);
    opacity: 0.6;
}

.parte-time {
    flex: 0 0 auto;
    min-width: 52px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding-top: 2px;
}

.parte-time strong {
    font-size: 14px;
    color: var(--gold-soft);
    font-variant-numeric: tabular-nums;
}

.parte-time span {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.parte-body {
    flex: 1 1 auto;
    min-width: 0;
}

.parte-title {
    margin: 0;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.parte-meta {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
}

.parte-meta span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.parte-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 9px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 10.5px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    border: 1px solid var(--line-3);
    color: var(--text-soft);
    background: var(--fill-1);
    white-space: nowrap;
}

.chip-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.chip[data-tone="gold"] {
    color: var(--gold-soft);
    border-color: var(--line-strong);
    background: rgba(216, 182, 92, 0.10);
}

.chip[data-tone="ok"] {
    color: var(--ok);
    border-color: var(--tone-ok-line);
    background: var(--tone-ok-bg);
}

.chip[data-tone="info"] {
    color: var(--info);
    border-color: var(--tone-info-line);
    background: var(--tone-info-bg);
}

.chip[data-tone="warn"] {
    color: var(--warn);
    border-color: var(--tone-warn-line);
    background: var(--tone-warn-bg);
}

.chip[data-tone="danger"] {
    color: var(--danger);
    border-color: var(--tone-danger-line);
    background: var(--tone-danger-bg);
}

/* ------------------------------ Toolbar / filtros ------------------------------ */

.toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.segmented {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 14px;
    background: var(--fill-1);
    border: 1px solid var(--line-1);
    overflow-x: auto;
    scrollbar-width: none;
}

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

.segmented button {
    flex: 1 0 auto;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 12px;
    letter-spacing: 0.05em;
    color: var(--muted);
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
}

.segmented button.is-active {
    background: linear-gradient(160deg, rgba(216, 182, 92, 0.22), rgba(216, 182, 92, 0.08));
    color: var(--gold-soft);
    box-shadow: inset 0 0 0 1px rgba(216, 182, 92, 0.28);
}

.date-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--fill-1);
    border: 1px solid var(--line-1);
}

.date-bar button {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: var(--gold-soft);
    background: rgba(216, 182, 92, 0.08);
    border: 1px solid rgba(216, 182, 92, 0.18);
}

.date-bar button svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.date-bar-center {
    text-align: center;
    flex: 1 1 auto;
}

.date-bar-center strong {
    display: block;
    font-size: 14px;
    color: var(--text);
    text-transform: capitalize;
}

.date-bar-center span {
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

.week-strip {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.week-day {
    padding: 9px 2px 8px;
    border-radius: 12px;
    text-align: center;
    background: var(--fill-1);
    border: 1px solid var(--line-1);
    color: var(--text-soft);
    transition: background 0.18s ease, border-color 0.18s ease;
}

.week-day small {
    display: block;
    font-size: 9px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.week-day strong {
    display: block;
    margin-top: 3px;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.week-day em {
    display: block;
    margin-top: 3px;
    font-size: 9px;
    font-style: normal;
    color: var(--gold);
    min-height: 12px;
}

.week-day.is-today {
    border-color: rgba(216, 182, 92, 0.35);
}

.week-day.is-active {
    background: linear-gradient(165deg, rgba(216, 182, 92, 0.28), rgba(216, 182, 92, 0.10));
    border-color: rgba(216, 182, 92, 0.5);
    color: #1a1508;
}

.week-day.is-active small,
.week-day.is-active em {
    color: rgba(23, 18, 8, 0.72);
}

.search-box {
    position: relative;
}

.search-box svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    fill: var(--muted);
    pointer-events: none;
}

.search-box input {
    padding-left: 40px;
}

.inline-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
}

.inline-filters::-webkit-scrollbar {
    display: none;
}

/* ------------------------------ Ficha de parte ------------------------------ */

.detail-head {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-title {
    margin: 0;
    font-family: var(--font-brand);
    font-size: 21px;
    line-height: 1.25;
}

.detail-sub {
    margin: 0;
    font-size: 12.5px;
    color: var(--muted);
}

.detail-rows {
    display: flex;
    flex-direction: column;
}

.detail-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line-1);
}

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

.detail-row dt {
    margin: 0;
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    flex: 0 0 42%;
}

.detail-row dd {
    margin: 0;
    font-size: 13.5px;
    text-align: right;
    color: var(--text);
    word-break: break-word;
}

.detail-row dd a {
    color: var(--gold-soft);
    text-decoration: none;
}

.detail-note {
    margin: 0;
    padding: 14px 15px;
    border-radius: var(--radius-sm);
    background: var(--fill-1);
    border: 1px solid var(--line-1);
    font-size: 13.5px;
    color: var(--text-soft);
    white-space: pre-wrap;
    word-break: break-word;
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 9px;
}

.actions-grid .btn {
    min-height: 44px;
    font-size: 12.5px;
}

/* ------------------------------ Timeline ------------------------------ */

.timeline {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-left: 18px;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: linear-gradient(180deg, rgba(216, 182, 92, 0.4), rgba(216, 182, 92, 0.05));
}

.timeline-item {
    position: relative;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -18px;
    top: 5px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 0 3px rgba(216, 182, 92, 0.12);
}

.timeline-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.timeline-head strong {
    font-size: 12.5px;
    color: var(--text-soft);
}

.timeline-head span {
    font-size: 10.5px;
    color: var(--muted);
    letter-spacing: 0.06em;
}

.timeline-item p {
    margin: 5px 0 0;
    font-size: 13.5px;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ------------------------------ Clientes ------------------------------ */

.cliente-card {
    display: flex;
    align-items: center;
    gap: 13px;
    width: 100%;
    text-align: left;
    padding: 14px 15px;
    border-radius: var(--radius);
    background: linear-gradient(170deg, var(--surface-a), var(--surface-b));
    border: 1px solid var(--line-1);
    transition: border-color 0.2s ease, transform 0.14s ease;
}

.cliente-card:active {
    transform: scale(0.992);
    border-color: var(--line);
}

.avatar {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-family: var(--font-brand);
    font-size: 17px;
    color: #1a1508;
    background: linear-gradient(160deg, #f0d99b, #c19a37);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.cliente-info {
    min-width: 0;
    flex: 1 1 auto;
}

.cliente-info strong {
    display: block;
    font-size: 14.5px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cliente-info span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cliente-count {
    flex: 0 0 auto;
    text-align: right;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

.cliente-count b {
    display: block;
    font-size: 16px;
    color: var(--gold-soft);
    font-family: var(--font-brand);
}

.tabs {
    display: flex;
    gap: 6px;
    padding: 4px;
    border-radius: 14px;
    background: var(--fill-1);
    border: 1px solid var(--line-1);
}

.tabs button {
    flex: 1;
    padding: 9px 8px;
    border-radius: 10px;
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.tabs button.is-active {
    background: rgba(216, 182, 92, 0.14);
    color: var(--gold-soft);
    box-shadow: inset 0 0 0 1px rgba(216, 182, 92, 0.26);
}

.nota-card {
    padding: 14px 15px;
    border-radius: var(--radius);
    background: linear-gradient(170deg, var(--surface-a), var(--surface-b));
    border: 1px solid var(--line-1);
}

.nota-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.nota-head strong {
    font-size: 13.5px;
    color: var(--gold-soft);
}

.nota-head span {
    font-size: 10.5px;
    color: var(--muted);
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.nota-card p {
    margin: 0;
    font-size: 13.5px;
    color: var(--text-soft);
    white-space: pre-wrap;
    word-break: break-word;
}

/* ------------------------------ Perfil ------------------------------ */

.profile-head {
    display: flex;
    align-items: center;
    gap: 15px;
}

.profile-avatar {
    width: 62px;
    height: 62px;
    font-size: 24px;
    border-radius: 20px;
}

.profile-name {
    margin: 0;
    font-family: var(--font-brand);
    font-size: 20px;
    color: var(--text);
}

.profile-role {
    margin: 3px 0 0;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold);
}

.profile-email {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--muted);
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.form-actions {
    display: flex;
    gap: 9px;
}

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

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line-1);
}

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

.switch-row p {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--muted);
}

.switch-row strong {
    font-size: 13.5px;
    color: var(--text);
}

.switch {
    position: relative;
    flex: 0 0 auto;
    width: 50px;
    height: 29px;
    border-radius: 999px;
    background: var(--line-3);
    border: 1px solid var(--line-3);
    transition: background 0.2s ease;
}

.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background: var(--switch-knob);
    transition: transform 0.2s ease, background 0.2s ease;
}

.switch.is-on {
    background: linear-gradient(160deg, rgba(216, 182, 92, 0.85), rgba(184, 145, 47, 0.9));
    border-color: rgba(216, 182, 92, 0.6);
}

.switch.is-on::after {
    transform: translateX(21px);
    background: #1a1508;
}

/* ------------------------------ Estados vacíos / carga ------------------------------ */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 34px 22px;
    border-radius: var(--radius);
    border: 1px dashed var(--line);
    background: var(--fill-tiny);
    text-align: center;
}

.empty svg {
    width: 34px;
    height: 34px;
    fill: rgba(216, 182, 92, 0.5);
}

.empty strong {
    font-size: 14px;
    color: var(--text-soft);
}

.empty span {
    font-size: 12.5px;
    color: var(--muted);
    max-width: 280px;
}

.skeleton {
    border-radius: var(--radius);
    min-height: 78px;
    background: linear-gradient(100deg, var(--fill-1) 25%, var(--line-2) 45%, var(--fill-1) 65%);
    background-size: 260% 100%;
    animation: shimmer 1.5s linear infinite;
    border: 1px solid var(--fill-3);
}

.app-loader {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-items: center;
    background: var(--loader);
    backdrop-filter: blur(3px);
}

.app-loader span {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid rgba(216, 182, 92, 0.22);
    border-top-color: var(--gold);
    animation: spin 0.8s linear infinite;
}

/* ------------------------------ Hojas modales ------------------------------ */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: var(--backdrop);
    backdrop-filter: blur(4px);
    animation: fade 0.2s ease both;
}

.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 61;
    max-height: 92vh;
    overflow-y: auto;
    padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
    border-radius: 26px 26px 0 0;
    background: linear-gradient(180deg, var(--sheet-a), var(--bg-soft) 70%);
    border-top: 1px solid rgba(216, 182, 92, 0.3);
    box-shadow: 0 -22px 50px var(--shadow-2);
    animation: sheetUp 0.28s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

.sheet-grab {
    width: 42px;
    height: 4px;
    border-radius: 2px;
    background: var(--grab);
    margin: 0 auto 14px;
}

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

.sheet-head h3 {
    margin: 0;
    font-family: var(--font-brand);
    font-size: 19px;
    color: var(--text);
}

.sheet-head p {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--muted);
}

.sheet-close {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: var(--muted);
    background: var(--fill-3);
    border: 1px solid var(--line-2);
    font-size: 18px;
}

.sheet-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sheet-actions {
    display: flex;
    gap: 9px;
    margin-top: 6px;
}

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

/* ------------------------------ Firma ------------------------------ */

.signature-wrap {
    position: relative;
    border-radius: var(--radius);
    background: var(--signature);
    border: 1px dashed var(--line-strong);
    overflow: hidden;
    touch-action: none;
}

.signature-wrap canvas {
    display: block;
    width: 100%;
    height: 210px;
    touch-action: none;
}

.signature-hint {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 12.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    pointer-events: none;
}

.signature-hint.is-hidden {
    display: none;
}

/* ------------------------------ Toast ------------------------------ */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 80;
    max-width: calc(100% - 40px);
    padding: 12px 18px;
    border-radius: 14px;
    background: var(--toast-bg);
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 13px;
    box-shadow: var(--shadow);
    animation: rise 0.25s ease both;
}

.toast[data-tone="error"] {
    border-color: var(--tone-danger-line);
    color: var(--danger);
}

.toast[data-tone="ok"] {
    border-color: var(--tone-ok-line);
    color: var(--ok);
}

/* ------------------------------ Utilidades ------------------------------ */

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

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

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

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

.gold {
    color: var(--gold-soft);
}

.small {
    font-size: 12px;
}

.center {
    text-align: center;
}

.mt-2 {
    margin-top: 8px;
}

.mt-4 {
    margin-top: 16px;
}

/* ------------------- Instalación PWA y permiso de push ------------------- */

.install-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(216, 182, 92, 0.07);
}

.install-brand img {
    width: 56px;
    height: 56px;
    flex: 0 0 auto;
    border-radius: 16px;
    border: 1px solid var(--line-strong);
    background: var(--bg-soft);
    object-fit: cover;
}

.install-brand>div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.install-brand strong {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.install-brand span {
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.install-list,
.install-steps {
    margin: 0 0 4px;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.install-list li,
.install-steps li {
    position: relative;
    padding-left: 26px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-soft);
}

.install-list li::before {
    content: "";
    position: absolute;
    left: 3px;
    top: 6px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--gold-soft), var(--gold-deep));
}

.install-steps {
    counter-reset: paso;
}

.install-steps li {
    padding-left: 30px;
    counter-increment: paso;
}

.install-steps li::before {
    content: counter(paso);
    position: absolute;
    left: 0;
    top: 1px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    color: var(--gold-soft);
    background: rgba(216, 182, 92, 0.12);
    border: 1px solid var(--line-strong);
}

.install-list strong,
.install-steps strong {
    color: var(--text);
    font-weight: 600;
}

.install-note {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-left: 2px solid var(--line-strong);
    border-radius: 0 10px 10px 0;
    background: var(--fill-1);
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--muted);
}

.push-estado {
    margin: 10px 0 0;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--muted);
}

.push-estado.is-ok {
    color: var(--ok);
}

.push-estado.is-error {
    color: var(--danger);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes sheetUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (min-width: 640px) {
    .app-main {
        padding: 22px 24px 10px;
    }

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

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

    .sheet {
        left: 50%;
        right: auto;
        bottom: 24px;
        width: 520px;
        transform: translateX(-50%);
        border-radius: 26px;
        border: 1px solid rgba(216, 182, 92, 0.3);
        animation: rise 0.25s ease both;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

/* ============================================================
   Modo oscuro (negro + oro)
   Se activa con html[data-tema="oscuro"] desde Mi perfil.
   La barra inferior y el aro del logo siguen siendo oscuros.
   ============================================================ */

html[data-tema="oscuro"] {
    color-scheme: dark;

    /* Superficies */
    --bg: #07070a;
    --bg-soft: #0b0b10;
    --surface: #101016;
    --surface-2: #16161e;
    --surface-3: #1d1d27;
    --surface-a: rgba(24, 24, 32, 0.95);
    --surface-b: rgba(13, 13, 18, 0.96);
    --sheet-a: #16161d;
    --hero-a: #17171f;
    --hero-b: #0c0c11;
    --signature: #0e0e13;
    --input-focus: #191922;
    --toast-bg: rgba(22, 22, 30, 0.97);
    --header-a: rgba(7, 7, 10, 0.96);
    --header-b: rgba(7, 7, 10, 0.72);
    --loader: rgba(5, 5, 8, 0.55);
    --backdrop: rgba(4, 4, 7, 0.72);
    --fade: rgba(7, 7, 10, 0);

    /* Líneas y rellenos */
    --line: rgba(216, 182, 92, 0.16);
    --line-strong: rgba(216, 182, 92, 0.38);
    --line-1: rgba(255, 255, 255, 0.055);
    --line-2: rgba(255, 255, 255, 0.07);
    --line-3: rgba(255, 255, 255, 0.09);
    --fill-1: rgba(255, 255, 255, 0.03);
    --fill-2: rgba(255, 255, 255, 0.07);
    --fill-3: rgba(255, 255, 255, 0.04);
    --fill-tiny: rgba(255, 255, 255, 0.015);
    --grab: rgba(255, 255, 255, 0.16);

    /* Dorado y tipografía */
    --gold: #d8b65c;
    --gold-soft: #ebd08a;
    --gold-deep: #b8912f;
    --gold-on-dark: #ebd08a;
    --text: #f4f1e8;
    --text-soft: #cfc9ba;
    --muted: #8f8a7c;

    /* Estados */
    --danger: #e2685f;
    --ok: #5fbf8f;
    --warn: #e0a94b;
    --info: #6aa7d8;
    --tone-ok-line: rgba(95, 191, 143, 0.40);
    --tone-ok-bg: rgba(95, 191, 143, 0.10);
    --tone-info-line: rgba(106, 167, 216, 0.40);
    --tone-info-bg: rgba(106, 167, 216, 0.10);
    --tone-warn-line: rgba(224, 169, 75, 0.40);
    --tone-warn-bg: rgba(224, 169, 75, 0.10);
    --tone-danger-line: rgba(226, 104, 95, 0.45);
    --tone-danger-bg: rgba(226, 104, 95, 0.10);

    /* Controles */
    --switch-knob: #cfc9ba;
    --badge-ring: #0a0a0e;

    /* Sombras */
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
    --shadow-1: rgba(0, 0, 0, 0.55);
    --shadow-2: rgba(0, 0, 0, 0.6);
    --shadow-3: rgba(0, 0, 0, 0.5);
    --shadow-4: rgba(0, 0, 0, 0.35);
}

html[data-tema="oscuro"] body {
    background:
        radial-gradient(120% 70% at 50% -10%, rgba(216, 182, 92, 0.10) 0%, rgba(7, 7, 10, 0) 55%),
        radial-gradient(90% 50% at 100% 100%, rgba(216, 182, 92, 0.05) 0%, rgba(7, 7, 10, 0) 60%),
        var(--bg);
}

html[data-tema="oscuro"] .logo-ring img,
html[data-tema="oscuro"] .nav-logo-ring img {
    background: #0c0c10;
}

html[data-tema="oscuro"] .login-form {
    backdrop-filter: blur(14px);
}