:root {
    --primary: #067fa5;
    --primary-dark: #075d78;
    --primary-soft: #e6f6fa;
    --aqua: #14b8a6;
    --aqua-soft: #e6faf6;
    --cyan: #0ea5c6;
    --amber: #e69b21;
    --violet: #7967d9;
    --success: #16845d;
    --danger: #c84255;
    --warning: #9b6813;
    --bg: #f2f7f9;
    --surface: #ffffff;
    --surface-2: #eaf2f5;
    --text: #102b38;
    --text-soft: #385663;
    --muted: #718792;
    --border: #d7e5e9;
    --shadow-sm: 0 1px 2px rgba(10, 47, 62, .06), 0 8px 26px rgba(10, 47, 62, .05);
    --shadow-md: 0 22px 70px rgba(10, 47, 62, .17);
    --radius: 18px;
    --radius-lg: 26px;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color-scheme: light;
}

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

html { min-width: 320px; min-height: 100%; background: var(--bg); }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body, button, input, textarea, select { font: inherit; }
button, input, textarea, select { color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, strong { letter-spacing: -.022em; }
h1 { margin-bottom: .45rem; font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.04; }
h2 { margin-bottom: .45rem; font-size: 1.45rem; line-height: 1.15; }
small { color: var(--muted); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(6, 127, 165, .28); outline-offset: 2px; }

.icon { width: 21px; height: 21px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.eyebrow { display: block; margin-bottom: .3rem; color: var(--primary); font-size: .72rem; font-weight: 850; letter-spacing: .095em; text-transform: uppercase; }

.app-shell { min-height: 100vh; }
.topbar {
    position: fixed;
    z-index: 100;
    inset: 0 0 auto;
    height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
    border-bottom: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
    background: rgba(255, 255, 255, .91);
    backdrop-filter: blur(18px);
}
.brand { min-width: 0; display: flex; align-items: center; }
.brand img { width: 154px; height: 46px; object-fit: contain; object-position: left center; }
.topbar-actions { flex: 0 0 auto; display: flex; align-items: center; gap: .55rem; }
.icon-button {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text-soft);
}
.icon-button:hover { border-color: #b9d4dc; color: var(--primary); }
.connection-pill {
    position: relative;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .55rem .78rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--success);
    font-size: .76rem;
    font-weight: 800;
}
.connection-pill.offline { background: #fff8ea; border-color: #f1dcae; color: var(--warning); }
.connection-pill b { min-width: 19px; height: 19px; display: grid; place-items: center; border-radius: 99px; background: currentColor; color: white; font-size: .65rem; }
.install-button { min-height: 40px; padding: .5rem .85rem; border: 0; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-size: .78rem; font-weight: 850; }

.app-main { width: min(1120px, 100%); margin: 0 auto; padding: 112px 24px 120px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.25rem; margin-bottom: 25px; }
.page-heading p { margin: 0; color: var(--muted); }
.page-heading > div { min-width: 0; }
.page-heading .heading-history, .page-heading .heading-refresh { flex: 0 0 auto; }

.button {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .72rem 1.05rem;
    border: 1px solid transparent;
    border-radius: 14px;
    font-weight: 820;
    line-height: 1;
}
.button.primary { background: var(--primary); color: #fff; box-shadow: 0 8px 22px rgba(6, 127, 165, .18); }
.button.primary:hover { background: var(--primary-dark); }
.button.soft { border-color: var(--border); background: var(--surface); color: var(--primary); }
.button.compact { min-height: 42px; padding: .62rem .8rem; font-size: .82rem; white-space: nowrap; }
.button:disabled { cursor: default; opacity: .58; box-shadow: none; }

.bottom-nav {
    position: fixed;
    z-index: 90;
    inset: auto 0 0;
    height: calc(72px + env(safe-area-inset-bottom));
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: clamp(1rem, 10vw, 7rem);
    padding: 5px max(12px, env(safe-area-inset-left)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-right));
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(18px);
}
.bottom-nav a { min-width: 86px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 15px; color: var(--muted); font-size: .68rem; font-weight: 780; }
.bottom-nav a.active { color: var(--primary); background: var(--primary-soft); }
.bottom-nav .icon { width: 22px; height: 22px; }

.status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.status-card {
    position: relative;
    min-width: 0;
    min-height: 205px;
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    align-items: start;
    gap: 1rem;
    padding: 22px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    text-align: left;
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.status-card:hover { transform: translateY(-2px); border-color: #b8d6df; box-shadow: 0 15px 35px rgba(10, 47, 62, .09); }
.status-card::after { content: ""; position: absolute; width: 160px; height: 160px; right: -70px; top: -78px; border-radius: 50%; background: var(--card-soft, var(--primary-soft)); opacity: .72; }
.status-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 17px; background: var(--card-soft, var(--primary-soft)); color: var(--card-color, var(--primary)); }
.status-icon .icon { width: 27px; height: 27px; }
.status-card-copy { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.status-card-copy > small { margin-bottom: .15rem; color: var(--card-color, var(--primary)); font-size: .66rem; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
.status-card-copy > strong { width: 100%; overflow: hidden; color: var(--text); font-size: 1.04rem; text-overflow: ellipsis; white-space: nowrap; }
.status-value { min-height: 39px; display: flex; align-items: center; margin: .65rem 0 .2rem; color: var(--text); font-size: 1.35rem; font-weight: 900; letter-spacing: -.035em; }
.status-meta { max-width: 100%; color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric-pair { display: flex; flex-wrap: wrap; gap: .45rem; }
.metric-pair b { padding: .25rem .5rem; border-radius: 9px; background: var(--card-soft); font-size: 1rem; }
.quick-add { position: absolute; z-index: 2; right: 17px; bottom: 15px; display: inline-flex; align-items: center; gap: .25rem; color: var(--card-color, var(--primary)); font-size: .72rem; font-weight: 850; }
.quick-add .icon { width: 16px; height: 16px; }
.pending-label { display: inline-block; margin-top: .45rem; padding: .2rem .42rem; border-radius: 7px; background: #fff4d8; color: var(--warning); font-size: .65rem; font-style: normal; font-weight: 800; }
.status-card.teal { --card-color: var(--aqua); --card-soft: var(--aqua-soft); }
.status-card.cyan { --card-color: var(--cyan); --card-soft: #e6f7fb; }
.status-card.amber { --card-color: var(--amber); --card-soft: #fff5df; }
.status-card.violet { --card-color: var(--violet); --card-soft: #f0edff; }
.status-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }

.offline-banner, .sync-banner {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    margin: 0 0 18px;
    padding: .78rem .9rem;
    border: 1px solid #edd9a7;
    border-radius: 14px;
    background: #fff9eb;
    color: #7c5718;
    font-size: .82rem;
}
.sync-banner { border-color: #bfe2ea; background: var(--primary-soft); color: var(--primary-dark); }
.offline-banner .icon { width: 19px; height: 19px; margin-top: 1px; }

.sheet-layer { position: fixed; z-index: 500; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding: 20px; background: rgba(5, 31, 42, .44); backdrop-filter: blur(5px); }
.quick-sheet { width: min(620px, 100%); max-height: min(90dvh, 820px); padding: 25px; overflow: auto; border: 1px solid rgba(255,255,255,.7); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow-md); animation: sheet-in .2s ease-out; }
.quick-sheet > header, .admin-create > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 18px; }
.quick-sheet > header h2, .admin-create > header h2 { margin: 0; }
.sheet-save { width: 100%; margin-top: .45rem; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px); } }

.field { display: grid; gap: .4rem; margin-bottom: 15px; }
.field > span { color: var(--text-soft); font-size: .76rem; font-weight: 800; }
.field > span small { font-weight: 600; }
.field input, .field textarea, .field select, input[type="datetime-local"], .filter-panel select, .filter-panel input {
    width: 100%;
    min-height: 50px;
    padding: .75rem .85rem;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: #fbfdfe;
    color: var(--text);
    outline: none;
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus, .filter-panel select:focus, .filter-panel input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(6, 127, 165, .11); }
.field .validation-message { color: var(--danger); font-size: .72rem; }
.established-datetime { min-width: 0; display: flex; align-items: center; gap: .35rem; color: var(--primary-dark); font-size: .72rem; font-weight: 780; }
.established-datetime .icon { width: 15px; height: 15px; flex: 0 0 15px; color: var(--aqua); }
.established-datetime span { overflow-wrap: anywhere; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 52px; }
.input-suffix i { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .78rem; font-style: normal; font-weight: 750; pointer-events: none; }
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.quantity { grid-template-columns: minmax(0, 1fr) 112px; }
.quick-values { display: flex; flex-wrap: wrap; gap: .45rem; margin: -6px 0 17px; }
.quick-values button { min-height: 38px; padding: .4rem .7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-soft); font-size: .75rem; font-weight: 780; }
.quick-values button.selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.date-values { margin-top: -8px; }
.form-error { margin-bottom: 15px; padding: .72rem .8rem; border: 1px solid #efc3ca; border-radius: 12px; background: #fff0f2; color: var(--danger); font-size: .8rem; }

.toast { position: fixed; z-index: 700; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: .55rem; transform: translateX(-50%); padding: .72rem 1rem; border-radius: 999px; background: #123b36; color: #fff; box-shadow: var(--shadow-md); font-size: .82rem; font-weight: 780; white-space: nowrap; animation: toast-in .2s ease-out; }
.toast .icon { width: 18px; height: 18px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
.spinner { width: 17px; height: 17px; display: inline-block; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.filter-panel { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.filter-panel label { flex: 1 1 145px; display: grid; gap: .3rem; }
.filter-panel label > span { color: var(--muted); font-size: .68rem; font-weight: 820; text-transform: uppercase; letter-spacing: .05em; }
.filter-panel select, .filter-panel input { min-height: 43px; padding: .55rem .65rem; background: var(--surface); font-size: .8rem; }
.clear-filters { min-height: 43px; padding: .55rem .7rem; border: 0; background: transparent; color: var(--primary); font-size: .76rem; font-weight: 820; }
.history-list { display: grid; gap: 10px; }
.history-item { display: grid; grid-template-columns: 45px minmax(0, 1fr); gap: .85rem; padding: 17px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.history-dot { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 14px; background: var(--primary-soft); color: var(--primary); }
.history-dot.teal { background: var(--aqua-soft); color: var(--aqua); }
.history-dot.cyan { background: #e6f7fb; color: var(--cyan); }
.history-dot.amber { background: #fff5df; color: var(--amber); }
.history-dot.violet { background: #f0edff; color: var(--violet); }
.history-main { min-width: 0; }
.history-main header { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; }
.history-main header div { min-width: 0; }
.history-main header strong, .history-main header span { display: block; }
.history-main header strong { overflow-wrap: anywhere; font-size: .96rem; }
.history-main header span { color: var(--muted); font-size: .72rem; }
.history-values { margin: .55rem 0 .45rem; color: var(--primary-dark); font-size: 1rem; font-weight: 850; }
.history-record-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .65rem; color: var(--muted); font-size: .72rem; }
.history-attribution { min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; }
.history-attribution > span:first-child::before { content: "●"; margin-right: .35rem; color: var(--aqua); font-size: .55rem; }
.history-notes { max-width: 100%; padding-left: .45rem; overflow-wrap: anywhere; border-left: 1px solid var(--border); color: var(--text-soft) !important; }
.history-actions { display: flex; align-items: center; justify-content: flex-end; gap: .4rem; }
.history-edit, .history-delete { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: .32rem; padding: .4rem .65rem; border: 1px solid #b9dce4; border-radius: 11px; background: var(--primary-soft); color: var(--primary); font-size: .72rem; font-weight: 850; }
.history-delete { border-color: #efc3ca; background: #fff0f2; color: var(--danger); }
.history-edit .icon, .history-delete .icon { width: 16px; height: 16px; }
.history-edit:disabled, .history-delete:disabled { opacity: .52; cursor: default; }
.confirm-sheet { width: min(480px, 100%); }
.danger-eyebrow { color: var(--danger); }
.delete-confirmation { display: grid; grid-template-columns: 45px minmax(0, 1fr); align-items: center; gap: .8rem; padding: .85rem; border: 1px solid var(--border); border-radius: 16px; background: #fbfdfe; }
.delete-confirmation div { min-width: 0; }
.delete-confirmation strong, .delete-confirmation span, .delete-confirmation em { display: block; overflow-wrap: anywhere; }
.delete-confirmation span { margin-top: .12rem; color: var(--muted); font-size: .74rem; }
.delete-confirmation em { margin-top: .35rem; color: var(--primary-dark); font-size: .82rem; font-style: normal; font-weight: 820; }
.delete-warning { margin: 1rem 0; color: var(--text-soft); font-size: .8rem; line-height: 1.5; }
.sheet-actions { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.35fr); gap: .65rem; margin-top: .4rem; }
.sheet-actions .button { width: 100%; }
.button.danger { border: 1px solid #d85b6d; background: var(--danger); color: #fff; }

.admin-create { margin-bottom: 18px; padding: 22px; border: 1px solid #b9dce4; border-radius: var(--radius-lg); background: var(--primary-soft); }
.admin-create .field input, .admin-create .field select { background: #fff; }
.user-list { display: grid; gap: 12px; }
.user-card { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.user-card > header { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: .75rem; margin-bottom: 18px; }
.avatar { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; background: linear-gradient(145deg, var(--primary), var(--aqua)); color: #fff; font-weight: 900; }
.user-card > header div { min-width: 0; }
.user-card > header strong, .user-card > header span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card > header span { color: var(--muted); font-size: .75rem; }
.user-card > header em { padding: .3rem .55rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .67rem; font-style: normal; font-weight: 820; }
.user-card > header em.inactive { background: #fff0f2; color: var(--danger); }
.user-fields { display: grid; grid-template-columns: minmax(0, 1fr) 180px 150px; align-items: end; gap: 12px; }
.toggle-field { min-height: 50px; display: flex; align-items: center; gap: .55rem; padding: .65rem .75rem; border: 1px solid var(--border); border-radius: 13px; font-size: .78rem; font-weight: 760; }
.toggle-field input { width: 20px; height: 20px; accent-color: var(--primary); }
.password-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; padding-top: 3px; border-top: 1px solid var(--border); }
.password-row .field { margin: 12px 0 0; }
.inline-message { margin-top: 10px; font-size: .77rem; font-weight: 760; }
.inline-message.success { color: var(--success); }
.inline-message.error { color: var(--danger); }

.empty-state { min-height: 48vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 35px 20px; text-align: center; }
.empty-state > img { width: 70px; margin-bottom: 1rem; }
.empty-state > .icon { width: 50px; height: 50px; margin-bottom: 1rem; padding: 11px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); }
.empty-state p { max-width: 480px; color: var(--muted); }
.compact-empty { min-height: 35vh; }
.loading-view { min-height: 45vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; color: var(--muted); }
.loading-view img { width: 58px; animation: float 1.6s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-5px); } }

.public-main { min-height: 100vh; }
.login-page { position: relative; min-height: 100dvh; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); overflow: hidden; background: linear-gradient(145deg, #eff9fb 0%, #f7fafb 50%, #e5f6f3 100%); }
.login-glow { position: absolute; width: min(760px, 130vw); height: min(760px, 130vw); left: -18%; top: -48%; border-radius: 50%; background: radial-gradient(circle, rgba(20,184,166,.18), rgba(6,127,165,.05) 45%, transparent 70%); }
.login-card { position: relative; width: min(440px, 100%); padding: clamp(25px, 5vw, 40px); border: 1px solid rgba(191, 217, 224, .9); border-radius: 30px; background: rgba(255, 255, 255, .94); box-shadow: 0 28px 90px rgba(10, 47, 62, .16); backdrop-filter: blur(15px); }
.login-logo { width: 166px; height: 52px; object-fit: contain; object-position: left center; }
.login-copy { margin: 1.7rem 0 1.5rem; }
.login-copy h1 { font-size: 2.15rem; }
.login-copy p { margin: 0; color: var(--muted); }
.login-submit { width: 100%; margin-top: .25rem; }
.login-footnote { display: block; margin-top: 1.25rem; text-align: center; font-size: .68rem; }

/* Arranque y actualización atómica de la PWA */
.boot-splash { min-height: 100dvh; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom)); background: var(--bg); }
.boot-card { width: min(390px, 92vw); display: grid; justify-items: center; gap: 17px; padding: 34px 28px 29px; border: 1px solid var(--border); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow-md); text-align: center; }
.boot-mark { width: 76px; height: 76px; filter: drop-shadow(0 13px 25px rgba(6,127,165,.22)); animation: float 1.7s ease-in-out infinite; }
.boot-copy { display: grid; gap: 2px; }
.boot-copy strong { font-size: 1.25rem; }
.boot-copy span { color: var(--muted); font-size: .86rem; }
.boot-skeleton { width: min(240px, 68vw); display: grid; gap: 8px; }
.boot-skeleton i { height: 8px; overflow: hidden; border-radius: 99px; background: var(--surface-2); }
.boot-skeleton i::after { content: ""; display: block; width: 40%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--aqua)); animation: boot-scan 1.2s ease-in-out infinite; }
.boot-skeleton i:nth-child(2) { width: 82%; }
.boot-skeleton i:nth-child(3) { width: 62%; }
@keyframes boot-scan { from { transform: translateX(-120%); } to { transform: translateX(350%); } }
#pwa-activation-ui { position: fixed; z-index: 10000; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(242,247,249,.94); backdrop-filter: blur(16px); }
#pwa-activation-ui[hidden] { display: none; }
.pwa-update-lock, .pwa-update-lock body { overflow: hidden; }
.pwa-activation-card { width: min(360px, 92vw); display: grid; justify-items: center; gap: 11px; padding: 31px; border: 1px solid var(--border); border-radius: 26px; background: var(--surface); box-shadow: var(--shadow-md); text-align: center; }
.pwa-activation-card img { width: 72px; height: 72px; }
.pwa-activation-card strong { font-size: 1.18rem; }
.pwa-activation-card span { color: var(--muted); }
.pwa-activation-bars { height: 28px; display: flex; align-items: end; gap: 5px; }
.pwa-activation-bars i { width: 7px; height: 9px; border-radius: 99px; background: var(--primary); animation: bars .9s ease-in-out infinite alternate; }
.pwa-activation-bars i:nth-child(2) { animation-delay: 100ms; }
.pwa-activation-bars i:nth-child(3) { animation-delay: 200ms; }
.pwa-activation-bars i:nth-child(4) { animation-delay: 300ms; }
@keyframes bars { to { height: 27px; background: var(--aqua); } }
#blazor-error-ui { position: fixed; z-index: 9999; right: 12px; bottom: 90px; left: 12px; display: none; padding: .8rem 3rem .8rem 1rem; border: 1px solid #efc3ca; border-radius: 12px; background: #fff0f2; color: var(--danger); box-shadow: var(--shadow-md); }
#blazor-error-ui .dismiss { position: absolute; right: 1rem; cursor: pointer; }

@media (max-width: 720px) {
    body { font-size: 14px; }
    .topbar { height: 66px; padding-inline: 12px; }
    .brand img { width: 130px; height: 42px; }
    .connection-pill { width: 43px; min-width: 43px; padding: 0; justify-content: center; border-radius: 14px; }
    .connection-pill > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
    .connection-pill b { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; margin: 0; font-size: .58rem; }
    .logout-button { width: 43px; height: 43px; }
    .install-button { display: none; }
    .app-main { padding: 91px 13px 102px; }
    .page-heading { align-items: start; gap: .75rem; margin-bottom: 20px; }
    .page-heading h1 { font-size: clamp(1.9rem, 9vw, 2.15rem); }
    .page-heading p { font-size: .82rem; }
    .page-heading .button.compact { width: 43px; min-width: 43px; flex-basis: 43px; padding: 0; overflow: visible; color: var(--primary); gap: 0; }
    .page-heading .button.compact > span { display: none; }
    .page-heading .button.compact .icon { color: var(--primary); }
    .bottom-nav { height: calc(70px + env(safe-area-inset-bottom)); justify-content: stretch; gap: 0; }
    .bottom-nav a { flex: 1; min-width: 0; }
    .status-grid { grid-template-columns: 1fr; gap: 10px; }
    .status-grid > :last-child:nth-child(odd) { grid-column: auto; }
    .status-card { min-height: 170px; grid-template-columns: 48px minmax(0, 1fr); gap: .8rem; padding: 18px; border-radius: 21px; }
    .status-icon { width: 48px; height: 48px; border-radius: 15px; }
    .status-icon .icon { width: 24px; height: 24px; }
    .status-value { min-height: 33px; margin-top: .5rem; font-size: 1.22rem; }
    .quick-add { right: 14px; bottom: 13px; }
    .sheet-layer { padding: 0; align-items: flex-end; }
    .quick-sheet { width: 100%; max-height: 93dvh; padding: 21px 16px calc(20px + env(safe-area-inset-bottom)); border-width: 1px 0 0; border-radius: 26px 26px 0 0; }
    .filter-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 11px; }
    .filter-panel label:first-child { grid-column: 1 / -1; }
    .filter-panel label { min-width: 0; }
    .filter-panel .clear-filters { grid-column: 1 / -1; }
    .history-item { grid-template-columns: 40px minmax(0, 1fr); gap: .7rem; padding: 14px 12px; }
    .history-dot { width: 40px; height: 40px; border-radius: 12px; }
    .history-main header { align-items: center; }
    .history-record-footer { align-items: end; gap: .45rem; }
    .history-notes { width: 100%; padding: .45rem 0 0 !important; border: 0; }
    .history-edit, .history-delete { min-width: 70px; padding-inline: .5rem; }
    .admin-create, .user-card { padding: 16px; border-radius: 18px; }
    .user-card > header { grid-template-columns: 44px minmax(0, 1fr); }
    .user-card > header em { grid-column: 2; justify-self: start; }
    .avatar { width: 44px; height: 44px; border-radius: 14px; }
    .user-fields, .password-row { grid-template-columns: 1fr; }
    .toggle-field { margin-bottom: 14px; }
    .password-row .button { width: 100%; }
    .form-grid.two { grid-template-columns: 1fr 1fr; }
    .login-card { border-radius: 25px; }
}

@media (max-width: 390px) {
    .brand img { width: 118px; }
    .topbar-actions { gap: .35rem; }
    .form-grid.two { grid-template-columns: 1fr; }
    .quick-values { gap: .3rem; }
    .quick-values button { padding-inline: .55rem; }
    .history-record-footer { grid-template-columns: minmax(0, 1fr); }
    .history-actions { max-width: 100%; justify-self: end; }
}

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