:root {
    color-scheme: light;
    --bg: #f3f0f2;
    --bg-soft: #faf8fa;
    --surface: #ffffff;
    --surface-soft: #f6f3f6;
    --surface-sunken: #efeaee;
    --text: #26202b;
    --text-strong: #171219;
    --muted: #746c7a;
    --faint: #9b93a2;
    --line: rgba(38, 32, 43, 0.08);
    --line-strong: rgba(38, 32, 43, 0.16);
    --accent: #7e5f86;
    --accent-strong: #684a71;
    --accent-soft: #f1eaf4;
    --accent-rgb: 126, 95, 134;
    --danger: #b23c2c;
    --danger-soft: #fcefec;
    --warning: #a06a12;
    --warning-soft: #fdf3e2;
    --ok: #2f7d5a;
    --ok-soft: #e9f6ef;
    --owner-me: rgba(126, 95, 134, 0.1);
    --owner-partner: rgba(214, 118, 152, 0.1);
    --owner-joint: rgba(140, 120, 140, 0.08);
    --shadow-card:
        0 1px 2px rgba(40, 26, 48, 0.05),
        0 4px 14px rgba(40, 26, 48, 0.05);
    --shadow-panel:
        0 1px 2px rgba(40, 26, 48, 0.04),
        0 14px 34px rgba(40, 26, 48, 0.08);
    --shadow-float:
        0 4px 12px rgba(40, 26, 48, 0.1),
        0 24px 56px rgba(40, 26, 48, 0.18);
    --shadow-sm: var(--shadow-card);
    --shadow-md: var(--shadow-panel);
    --radius-sm: 9px;
    --radius-md: 13px;
    --radius-lg: 17px;
    --radius-xl: 22px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --sidebar-width: 258px;
    --mobile-header-h: 116px;
    --mobile-nav-h: 74px;
    --android-safe-top: 0px;
    --desktop-windowbar-h: 42px;
    --ring: 0 0 0 3px rgba(var(--accent-rgb), 0.24);
}

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

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

.hidden {
    display: none !important;
}

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

html {
    overflow: hidden;
}

body {
    margin: 0;
    color: var(--text);
    font-family:
        "Plus Jakarta Sans", "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif;
    font-size: 14.5px;
    line-height: 1.5;
    background:
        radial-gradient(1200px 500px at 85% -10%, rgba(126, 95, 134, 0.07), transparent 60%),
        radial-gradient(900px 420px at -10% 110%, rgba(214, 118, 152, 0.05), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
}

::selection {
    background: rgba(var(--accent-rgb), 0.24);
}

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(38, 32, 43, 0.22) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(38, 32, 43, 0.18);
}

*::-webkit-scrollbar-track {
    background: transparent;
}

/* ===== Buttons & inputs ===== */

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

button {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    border-radius: 10px;
    min-height: 40px;
    padding: 8px 15px;
    font-weight: 650;
    line-height: 1.2;
    cursor: pointer;
    transition:
        background-color 0.16s ease,
        border-color 0.16s ease,
        color 0.16s ease,
        box-shadow 0.16s ease,
        transform 0.1s ease;
}

button:hover {
    border-color: rgba(var(--accent-rgb), 0.55);
    background: var(--surface-soft);
}

button:active {
    transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    padding: 8px 12px;
    background: var(--surface);
    transition:
        border-color 0.16s ease,
        box-shadow 0.16s ease;
}

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

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}

select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 34px;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 16px) calc(50% - 2px),
        calc(100% - 11px) calc(50% - 2px);
    background-size:
        5px 5px,
        5px 5px;
    background-repeat: no-repeat;
}

select option {
    color: var(--text);
    background: var(--surface);
}

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

/* Primary buttons: bare buttons inside action containers, zero-specificity
   wrapper keeps .ghost / .danger free to override. */
:where(
        .toolbar,
        .setup-form,
        .settings-form,
        .modal-form,
        .modal-head,
        .modal-extra,
        .inline-form,
        .system-dialog-actions,
        .empty-state,
        .stocktake-foot,
        .auth-form
    )
    button:where(
        :not(.app-select-trigger):not(.app-select-option):not(
                .filament-color-clear
            ):not(.filament-color-swatch):not(.entity-action-btn):not(
                .small-btn
            ):not(.app-icon-btn):not(.ghost):not(.danger)
    ) {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

:where(
        .toolbar,
        .setup-form,
        .settings-form,
        .modal-form,
        .modal-head,
        .modal-extra,
        .inline-form,
        .system-dialog-actions,
        .empty-state,
        .stocktake-foot,
        .auth-form
    )
    button:where(
        :not(.app-select-trigger):not(.app-select-option):not(
                .filament-color-clear
            ):not(.filament-color-swatch):not(.entity-action-btn):not(
                .small-btn
            ):not(.app-icon-btn):not(.ghost):not(.danger)
    ):hover {
    border-color: var(--accent-strong);
    background: var(--accent-strong);
}

.ghost {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--text);
    font-weight: 650;
}

.ghost:hover {
    background: var(--surface-soft);
    border-color: rgba(var(--accent-rgb), 0.55);
    color: var(--accent-strong);
}

.small-btn {
    min-height: 30px;
    padding: 5px 11px;
    font-size: 12px;
    border-radius: 8px;
}

.danger-btn,
.modal-extra .danger {
    background: var(--danger-soft);
    border-color: rgba(178, 60, 44, 0.32);
    color: var(--danger);
}

.danger-btn:hover,
.modal-extra .danger:hover {
    background: #fae4df;
    border-color: rgba(178, 60, 44, 0.48);
    color: #93301f;
}

/* ===== Desktop window bar ===== */

.desktop-windowbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1200;
    height: var(--desktop-windowbar-h);
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: saturate(150%) blur(14px);
}

.desktop-windowbar-drag {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    padding: 0 14px;
    user-select: none;
    cursor: move;
}

.desktop-windowbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--text-strong);
}

.desktop-windowbar-brand-icon {
    width: 19px;
    height: 19px;
    border-radius: 6px;
    object-fit: cover;
    flex: 0 0 auto;
}

.desktop-windowbar-actions {
    display: inline-flex;
    align-items: stretch;
}

button.desktop-windowbar-btn {
    width: 44px;
    min-width: 44px;
    min-height: var(--desktop-windowbar-h);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
}

button.desktop-windowbar-btn span {
    display: block;
    line-height: 1;
    pointer-events: none;
}

#desktop-win-max-label {
    font-size: 12px;
}

button.desktop-windowbar-btn:hover {
    background: rgba(var(--accent-rgb), 0.12);
    border-color: transparent;
}

button.desktop-windowbar-btn:active {
    transform: none;
    background: rgba(var(--accent-rgb), 0.2);
}

button.desktop-windowbar-btn.is-close:hover {
    background: #dd4b4b;
    color: #fff;
    border-color: transparent;
}

/* ===== App shell ===== */

.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    max-width: 1800px;
    margin: 0 auto;
    overflow: hidden;
}

body.moeyes-desktop-shell .app-shell {
    margin-top: var(--desktop-windowbar-h);
    min-height: calc(100vh - var(--desktop-windowbar-h));
    min-height: calc(100dvh - var(--desktop-windowbar-h));
    height: calc(100vh - var(--desktop-windowbar-h));
    height: calc(100dvh - var(--desktop-windowbar-h));
}

body.moeyes-desktop-shell .sidebar {
    top: calc(12px + var(--desktop-windowbar-h));
    height: calc(100vh - var(--desktop-windowbar-h) - 24px);
    height: calc(100dvh - var(--desktop-windowbar-h) - 24px);
}

body.moeyes-desktop-shell .sidebar .brand {
    display: none;
}

body.moeyes-desktop-shell .main {
    height: calc(100vh - var(--desktop-windowbar-h) - 24px);
    height: calc(100dvh - var(--desktop-windowbar-h) - 24px);
}

/* ===== Sidebar ===== */

.sidebar {
    position: sticky;
    top: 12px;
    height: calc(100vh - 24px);
    overflow-y: auto;
    padding: var(--space-5) var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.88);
    box-shadow: var(--shadow-card);
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 2px 0 12px;
    margin-bottom: var(--space-4);
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.brand-mark {
    display: none;
}

.brand-copy {
    display: none;
}

.brand-sub {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: var(--text-strong);
    font-size: 25px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.02;
}

.brand-sub-icon {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    object-fit: cover;
    flex: 0 0 auto;
    box-shadow: var(--shadow-sm);
}

.brand-household {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 650;
    letter-spacing: 0.02em;
}

.brand strong {
    display: none;
}

.menu {
    display: grid;
    gap: 3px;
}

.menu button {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--muted);
    border-radius: 11px;
    min-height: 44px;
    padding: 9px 13px;
    text-align: left;
    cursor: pointer;
    transition:
        background-color 0.16s ease,
        color 0.16s ease;
}

.menu button i {
    font-size: 19px;
    line-height: 1;
    width: 22px;
    text-align: center;
}

.menu button span {
    font-weight: 700;
    letter-spacing: 0.01em;
    font-size: 14.5px;
}

.menu button:hover {
    background: var(--surface-sunken);
    color: var(--text);
    border-color: transparent;
}

.menu button.active {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.menu button.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 999px;
    background: var(--accent);
}

.scope-block {
    margin-top: var(--space-6);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.scope-block small {
    color: var(--faint);
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.scope-switch {
    margin-top: var(--space-2);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
}

.scope-switch button {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    border-radius: 10px;
    min-height: 36px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition:
        background-color 0.16s ease,
        border-color 0.16s ease,
        color 0.16s ease;
}

.scope-switch button.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.nav-system {
    margin-top: var(--space-4);
    padding: var(--space-2) 2px 0;
    border: 0;
    border-top: 1px dashed var(--line);
    border-radius: 0;
    background: transparent;
    display: grid;
    gap: 6px;
}

.nav-system .status-pill {
    background: transparent;
    border: 0;
    color: var(--faint);
    min-height: 0;
    padding: 0 2px;
    font-weight: 700;
}

.nav-system .status-pill.is-online {
    color: var(--ok);
}

.nav-system-actions {
    grid-template-columns: 1fr;
}

.nav-system-actions .nav-sync-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    justify-content: flex-start;
    padding: 0 2px;
    min-height: 30px;
}

.nav-system-actions .nav-sync-btn:hover {
    background: transparent;
    color: var(--accent-strong);
}

#sidebar-system-slot:empty,
.topbar-system-slot:empty {
    display: none;
}

.topbar-system-slot {
    display: none;
}

.nav-system-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

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

.nav-system-actions .nav-sync-btn,
.nav-system-actions .db-indicator {
    min-height: 38px;
    min-width: 0;
    width: 100%;
    padding: 0 10px;
    border-radius: 10px;
}

.nav-system-actions .nav-sync-btn span,
.nav-system-actions .db-indicator span {
    font-size: 12px;
    font-weight: 700;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.status-pill.is-runtime {
    background: var(--accent-soft);
    border-color: rgba(var(--accent-rgb), 0.28);
    color: var(--accent-strong);
}

.status-pill.is-version {
    background: rgba(var(--accent-rgb), 0.12);
    border-color: rgba(var(--accent-rgb), 0.24);
    color: var(--accent-strong);
}

.status-pill.is-online {
    border-color: rgba(47, 125, 90, 0.32);
    background: var(--ok-soft);
    color: var(--ok);
}

.status-pill.is-offline {
    border-color: rgba(178, 60, 44, 0.32);
    background: var(--danger-soft);
    color: var(--danger);
}

/* ===== Main column ===== */

.main {
    min-width: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    height: calc(100vh - 24px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-5) var(--space-6) var(--space-7);
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transition: opacity 0.16s ease;
}

.main.is-loading {
    opacity: 0.85;
}

.topbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 10px;
    position: sticky;
    top: calc(var(--space-5) * -1);
    z-index: 8;
    min-height: 0;
    margin: calc(var(--space-5) * -1) calc(var(--space-6) * -1) var(--space-4);
    padding: var(--space-5) var(--space-6) 12px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: linear-gradient(to bottom, var(--bg) 78%, rgba(243, 240, 242, 0));
    box-shadow: none;
    backdrop-filter: none;
}

.topbar-title {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.topbar-badges {
    display: none;
}

.topbar h1 {
    margin: 0;
    font-size: clamp(24px, 2.2vw, 30px);
    line-height: 1.16;
    letter-spacing: -0.02em;
    font-weight: 800;
    color: var(--text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13.5px;
}

.household-label {
    font-size: 13px;
    display: none;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.app-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.app-icon-btn i {
    font-size: 16px;
    line-height: 1;
}

.app-icon-btn span {
    white-space: nowrap;
}

.topbar-actions button,
.topbar-actions .db-indicator {
    min-height: 40px;
    min-width: 92px;
    padding: 8px 13px;
    border-radius: 10px;
}

.db-indicator {
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
}

.db-indicator.is-ok {
    border-color: rgba(47, 125, 90, 0.32);
    background: var(--ok-soft);
    color: var(--ok);
}

.db-indicator.is-error {
    border-color: rgba(178, 60, 44, 0.32);
    background: var(--danger-soft);
    color: var(--danger);
}

.topbar-icon-btn:not(.db-indicator) {
    min-width: 40px;
    border-width: 1px;
    border-color: var(--line-strong);
    background: var(--surface);
    color: var(--muted);
    font-weight: 700;
}

.topbar-icon-btn:not(.db-indicator):hover {
    border-color: rgba(var(--accent-rgb), 0.55);
    background: var(--surface-soft);
    color: var(--accent-strong);
}

#db-indicator i {
    font-size: 11px;
}

.mobile-tabbar,
.mobile-sheet {
    display: none;
}

/* ===== Pages ===== */

.app-page {
    display: none;
}

.app-page.active {
    display: grid;
    gap: var(--space-4);
    align-content: start;
    animation: page-enter 0.22s cubic-bezier(0.2, 0.75, 0.2, 1);
}

@keyframes page-enter {
    from {
        opacity: 0.35;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-page.active {
        animation: none;
    }
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.toolbar-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    align-items: center;
    justify-content: end;
    gap: 9px;
    min-width: 0;
}

.toolbar-actions > * {
    flex: 0 0 auto;
    width: auto;
}

.toolbar-actions > .app-select,
.toolbar-actions > select,
.toolbar-actions > input {
    width: auto;
    min-width: 150px;
}

.toolbar-actions > button {
    min-width: 96px;
}

.inventory-toolbar {
    margin-bottom: 0;
}

.inventory-controls {
    display: grid;
    grid-template-columns: 150px minmax(200px, 1fr) 190px;
    gap: var(--space-2);
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.72);
}

/* ===== Dashboard ===== */

.home-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 4px 2px 0;
}

.home-hero-text h2 {
    margin: 0;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: var(--text-strong);
}

.home-hero-text p {
    margin: 3px 0 0;
    color: var(--faint);
    font-size: 12.5px;
}

.home-focus {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.home-focus-item {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
    transition:
        transform 0.16s ease,
        box-shadow 0.16s ease,
        border-color 0.16s ease;
}

@media (hover: hover) {
    .home-focus-item:hover {
        border-color: rgba(var(--accent-rgb), 0.45);
        box-shadow: var(--shadow-panel);
        transform: translateY(-1px);
    }
}

.home-focus-tag {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--surface-sunken);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.home-focus-tag.is-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.home-focus-tag.is-warn {
    background: var(--warning-soft);
    color: var(--warning);
}

.home-focus-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.home-focus-do {
    color: var(--accent-strong);
    font-size: 11.5px;
    font-weight: 800;
    white-space: nowrap;
}

.home-focus-empty {
    color: var(--faint);
    font-size: 13px;
    padding: 6px 2px;
}

.home-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 4px 2px 0;
}

.home-hero-text h2 {
    margin: 0;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: var(--text-strong);
}

.home-hero-text p {
    margin: 3px 0 0;
    color: var(--faint);
    font-size: 12.5px;
}

.home-focus {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.home-focus-item {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
    transition:
        transform 0.16s ease,
        box-shadow 0.16s ease,
        border-color 0.16s ease;
}

@media (hover: hover) {
    .home-focus-item:hover {
        border-color: rgba(var(--accent-rgb), 0.45);
        box-shadow: var(--shadow-panel);
        transform: translateY(-1px);
    }
}

.home-focus-tag {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--surface-sunken);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.home-focus-tag.is-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.home-focus-tag.is-warn {
    background: var(--warning-soft);
    color: var(--warning);
}

.home-focus-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.home-focus-do {
    color: var(--accent-strong);
    font-size: 11.5px;
    font-weight: 800;
    white-space: nowrap;
}

.home-focus-empty {
    color: var(--faint);
    font-size: 13px;
    padding: 6px 2px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    gap: var(--space-3);
    align-items: stretch;
}

.dashboard-main {
    align-items: start;
}

.dashboard-panel {
    padding: var(--space-4);
}

.dashboard-panel h3 {
    margin: 0 0 10px;
    font-size: 16.5px;
    font-weight: 750;
    color: var(--text-strong);
}

.dashboard-panel .list {
    gap: 4px;
}

.dashboard-panel .list .row {
    border: 0;
    border-radius: 10px;
    padding: 8px 10px;
    background: transparent;
}

.dashboard-panel .list .row strong {
    font-size: 13.5px;
}

.dashboard-panel .list .row p {
    margin-top: 2px;
    font-size: 12.5px;
}

.dashboard-panel .list .row.is-clickable {
    cursor: pointer;
    transition: background-color 0.14s ease;
}

.dashboard-panel .list .row.is-clickable:hover {
    background: var(--surface-soft);
}

.dashboard-modules {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-2);
}

.dashboard-modules button {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 13px;
}

.stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    min-height: 104px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    background: transparent;
    box-shadow: none;
    overflow: hidden;
    transition:
        background-color 0.18s ease,
        box-shadow 0.18s ease,
        border-color 0.18s ease;
}

@media (hover: hover) {
    .stat-card:not(.stat-card-key):hover {
        background: var(--surface);
        border-color: var(--line);
        box-shadow: var(--shadow-card);
    }
}

.stat-card span {
    display: block;
    color: var(--faint);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.stat-card strong {
    display: block;
    font-size: 24px;
    line-height: 1.08;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
}

.stat-card-key {
    border-color: transparent;
    background: linear-gradient(135deg, #8a6791 0%, #68496f 100%);
    box-shadow:
        0 10px 26px rgba(104, 73, 111, 0.38),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.stat-card-key span {
    color: rgba(255, 255, 255, 0.78);
}

.stat-card-key strong {
    color: #fff;
    font-size: 27px;
}

.stat-card-key::after {
    content: "";
    position: absolute;
    right: -34px;
    top: -34px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.09);
    pointer-events: none;
}

.stat-card-editable {
    cursor: default;
}

.stat-card.is-clickable {
    cursor: pointer;
}

@media (hover: hover) {
    .stat-card.is-clickable:hover {
        border-color: rgba(var(--accent-rgb), 0.45);
        box-shadow: var(--shadow-panel);
        transform: translateY(-1px);
    }
}

.stat-card-editable small {
    align-self: flex-start;
    margin-top: -6px;
    padding: 2px 9px;
    border: 0;
    border-radius: 999px;
    color: var(--muted);
    background: var(--surface-sunken);
    font-size: 11px;
    font-weight: 700;
}

.stat-card-editable:hover {
    background: var(--surface-soft);
    box-shadow: var(--shadow-panel);
}

.stat-card-sk {
    gap: 8px;
}

.stat-card-sk-display {
    cursor: pointer;
}

.stat-card-sk strong {
    font-size: 26px;
}

.stat-card-sk-inline-value {
    display: block;
    width: 100%;
    min-width: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    padding: 0;
    margin: 0;
    line-height: inherit;
    cursor: text;
    user-select: none;
    caret-color: var(--text);
}

.stat-card-sk-inline-value:focus {
    outline: none;
}

.stat-card-sk-inline-value[contenteditable="true"] {
    user-select: text;
}

.stat-card-sk-locked {
    cursor: default;
}

.stat-card-sk-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.stat-card-sk-auth {
    grid-template-columns: minmax(0, 1fr) auto auto;
}

.stat-card-sk-footer {
    grid-template-columns: 1fr auto;
}

.stat-card-sk-step {
    min-width: 52px;
}

.stat-card-sk-value,
.stat-card-sk-pin {
    width: 100%;
    min-width: 0;
    min-height: 34px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    padding: 7px 10px;
}

.stat-card-sk-value:disabled,
.stat-card-sk-pin:disabled,
.stat-card-sk-row button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.stat-card-sk-pin {
    letter-spacing: 0.08em;
}

.stat-card-sk.is-unlocked {
    background: var(--accent-soft);
    border-color: rgba(var(--accent-rgb), 0.3);
}

.stat-card-sk small[data-sk-status] {
    margin-top: -1px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
}

.stats-grid.is-sortable .stat-card.sortable {
    cursor: grab;
}

.stats-grid.is-sortable .stat-card.sortable:active {
    cursor: grabbing;
}

.stat-card.sortable.dragging {
    opacity: 0.7;
    transform: scale(0.985) rotate(0.2deg);
    box-shadow: var(--shadow-float);
}

.stats-grid.sorting .stat-card.sortable {
    transition:
        transform 0.12s ease,
        box-shadow 0.12s ease;
}

.stat-card.sortable.drag-chosen {
    box-shadow:
        0 0 0 2px rgba(var(--accent-rgb), 0.28),
        var(--shadow-panel);
}

.stat-card.sortable.drag-ghost {
    opacity: 0.35;
}

/* ===== Panels, lists, meta ===== */

.split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-3);
    align-items: start;
}

.setup-card,
.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-card);
}

.panel {
    padding: var(--space-4);
}

.panel h3 {
    margin: 0 0 var(--space-3);
    font-size: clamp(17px, 1.1vw, 20px);
    line-height: 1.25;
    font-weight: 750;
    color: var(--text-strong);
}

.setup-card {
    max-width: 980px;
    margin: 0 auto;
    padding: var(--space-6);
    box-shadow: var(--shadow-panel);
}

.setup-card h2 {
    margin: 0 0 var(--space-2);
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-strong);
}

.setup-card > p {
    margin: 0;
    color: var(--muted);
}

.setup-form {
    margin-top: var(--space-4);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: var(--space-3);
}

.setup-form input {
    min-height: 44px;
}

.setup-form button {
    grid-column: 1 / -1;
}

.auth-card {
    max-width: 520px;
}

.auth-form {
    grid-template-columns: 1fr;
}

.auth-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    color: var(--muted);
}

.auth-remember input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 0;
    margin: 0;
    padding: 0;
    accent-color: var(--accent);
}

#auth-remember-text {
    font-size: 13px;
}

#auth-message {
    min-height: 18px;
}

.list {
    display: grid;
    gap: var(--space-2);
}

.list .row {
    border: 0;
    border-radius: 10px;
    padding: 8px 6px;
    background: transparent;
}

.list .row strong {
    display: block;
    font-size: 14px;
    line-height: 1.35;
    font-weight: 700;
}

.list .row p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.list.compact .row strong,
.list.compact .row p {
    font-size: 12.5px;
}

.meta-table {
    display: grid;
}

.meta-row {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    align-items: baseline;
    gap: var(--space-3);
    padding: 9px 0;
    border-bottom: 1px dashed var(--line);
}

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

.meta-row span {
    color: var(--muted);
    font-size: 13px;
}

.meta-row strong {
    font-size: 14.5px;
    line-height: 1.35;
    font-weight: 700;
    word-break: break-word;
}

@media (min-width: 1100px) {
    #modal-summary.meta-table,
    #modal-summary .meta-table {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 12px;
    }

    #modal-summary .meta-row {
        grid-template-columns: 1fr;
        align-items: start;
        gap: 4px;
        padding: 10px 12px;
        border: 0;
        border-radius: 10px;
        background: var(--surface-soft);
    }

    #modal-summary .meta-row span {
        font-size: 12px;
        line-height: 1.25;
    }

    #modal-summary .meta-row strong {
        font-size: 14px;
        line-height: 1.3;
    }
}

.hint {
    margin: var(--space-2) 0 0;
    font-size: 13px;
    color: var(--muted);
}

.hint-list {
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px dashed var(--line);
}

.hint-list p {
    margin: var(--space-2) 0 0;
    font-size: 13px;
    color: var(--muted);
}

/* ===== Card grids & entity cards ===== */

.card-grid,
.inventory-group-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
    gap: var(--space-3);
}

.inventory-group {
    display: grid;
    gap: var(--space-3);
}

.inventory-groups-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: var(--space-4);
    align-items: start;
}

.inventory-group + .inventory-group {
    margin-top: var(--space-4);
}

.inventory-group h4 {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin: 0;
    padding: 0 var(--space-1);
    color: var(--text);
    font-size: 14.5px;
    font-weight: 750;
}

.inventory-group h4 span {
    color: var(--faint);
    font-size: 12px;
    font-weight: 700;
}

.entity-card {
    position: relative;
    display: grid;
    align-content: start;
    gap: 7px;
    min-height: 150px;
    padding: 15px 16px;
    cursor: pointer;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    transition:
        box-shadow 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease,
        background-color 0.18s ease;
}

.entity-card:active {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-panel);
}

@media (hover: hover) {
    .entity-card:hover {
        border-color: rgba(var(--accent-rgb), 0.4);
        box-shadow: var(--shadow-panel);
        transform: translateY(-2px);
    }
}

.entity-card.owner-me {
    background:
        linear-gradient(155deg, var(--owner-me) 0%, rgba(255, 255, 255, 0) 46%),
        var(--surface);
}

.entity-card.owner-partner {
    background:
        linear-gradient(
            155deg,
            var(--owner-partner) 0%,
            rgba(255, 255, 255, 0) 46%
        ),
        var(--surface);
}

.entity-card.owner-joint {
    background:
        linear-gradient(
            155deg,
            var(--owner-joint) 0%,
            rgba(255, 255, 255, 0) 46%
        ),
        var(--surface);
}

.entity-card h4 {
    margin: 0;
    font-size: 15.5px;
    line-height: 1.35;
    font-weight: 750;
    color: var(--text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.entity-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
}

.entity-kpi {
    font-size: 14px;
    line-height: 1.25;
    font-weight: 800;
    color: var(--accent-strong);
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

button.entity-kpi-btn {
    border: 0;
    background: transparent;
    padding: 2px 6px;
    margin: -2px -6px;
    min-height: 0;
    border-radius: 8px;
    font: inherit;
    line-height: 1.25;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: normal;
    text-transform: none;
    color: var(--accent-strong);
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    transition:
        background-color 0.14s ease,
        color 0.14s ease;
}

button.entity-kpi-btn:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
    border-color: transparent;
}

button.entity-kpi-btn::after {
    content: "改";
    margin-left: 5px;
    font-size: 10px;
    font-weight: 800;
    color: var(--faint);
}

button.entity-kpi-btn:hover::after {
    color: var(--accent-strong);
}

.balance-delta {
    display: grid;
    gap: 3px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--surface-soft);
}

.balance-delta:empty {
    display: none;
}

.balance-delta-value {
    font-size: 19px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.balance-delta-value.is-up {
    color: var(--ok);
}

.balance-delta-value.is-down {
    color: var(--danger);
}

.balance-delta-flat {
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

.balance-delta small {
    color: var(--muted);
    font-size: 12px;
}

.entity-meta,
.entity-note {
    margin: 0;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.42;
}

.entity-note {
    color: var(--text);
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--surface-soft);
}

.plan-comment-preview {
    margin-top: 1px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.entity-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.entity-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
}

.entity-action-btn {
    min-height: 29px;
    min-width: 0;
    padding: 4px 11px;
    border-radius: 999px;
    background: var(--surface-soft);
    border-color: transparent;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.1;
}

.entity-action-btn:hover {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--accent-strong);
}

.entity-action-btn.danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.entity-action-btn.danger:hover {
    background: #fae4df;
    color: #93301f;
    border-color: transparent;
}

.tag {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 650;
    color: var(--muted);
    background: var(--surface-soft);
}

.tag.warn {
    color: var(--warning);
    border-color: rgba(160, 106, 18, 0.3);
    background: var(--warning-soft);
}

button.tag.tag-action {
    min-height: 0;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1.2;
    transition:
        border-color 0.14s ease,
        background-color 0.14s ease;
}

button.tag.tag-action:hover {
    border-color: rgba(var(--accent-rgb), 0.4);
    background: var(--accent-soft);
}

button.tag.tag-action.warn:hover {
    border-color: rgba(160, 106, 18, 0.45);
    background: var(--warning-soft);
}

.tag.plan-tag.status-idea {
    border-color: rgba(126, 95, 134, 0.24);
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.tag.plan-tag.status-todo {
    border-color: rgba(47, 125, 90, 0.24);
    background: var(--ok-soft);
    color: var(--ok);
}

.tag.plan-tag.status-doing {
    border-color: rgba(160, 106, 18, 0.28);
    background: var(--warning-soft);
    color: var(--warning);
}

.tag.plan-tag.status-done {
    border-color: var(--line);
    background: var(--surface-sunken);
    color: var(--muted);
}

/* ===== Plan timeline ===== */

.plan-timeline {
    display: grid;
    gap: 10px;
}

.plan-timeline-item {
    position: relative;
    padding: 12px 12px 12px 28px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-card);
}

.plan-timeline-item::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 17px;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--accent);
}

.plan-timeline-item h5 {
    margin: 3px 0 4px;
    font-size: 14.5px;
    line-height: 1.3;
    font-weight: 750;
}

.plan-timeline-item small {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 700;
}

.plan-timeline-item p {
    margin: 0;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.4;
}

.plan-timeline-note {
    margin-top: 4px !important;
    color: var(--text) !important;
}

.plan-timeline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

/* ===== Forms ===== */

.settings-form,
.modal-form,
.inline-form {
    display: grid;
    gap: var(--space-3);
}

.settings-form {
    margin-top: var(--space-2);
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-form {
    margin-top: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.inline-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
}

.inline-form button {
    width: fit-content;
}

.settings-form .full,
.modal-form .full,
.inline-form .full {
    grid-column: 1 / -1;
}

.field {
    display: grid;
    gap: 6px;
}

.field span,
.field small {
    font-size: 12.5px;
    color: var(--muted);
}

.field small {
    font-weight: 500;
}

.form-more {
    grid-column: 1 / -1;
    border: 1px dashed var(--line-strong);
    border-radius: 12px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.5);
}

.form-more > summary {
    cursor: pointer;
    padding: 10px 2px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 750;
    list-style: none;
}

.form-more > summary::-webkit-details-marker {
    display: none;
}

.form-more > summary::before {
    content: "B8  ";
    color: var(--faint);
}

.form-more[open] > summary::before {
    content: "BE  ";
}

.form-more[open] {
    padding-bottom: 12px;
}

.form-more[open] > summary {
    border-bottom: 1px dashed var(--line);
    margin-bottom: 4px;
}

.form-more .field {
    margin-top: 10px;
}

details.item-kind-panel > summary {
    cursor: pointer;
    font-size: 14px;
    font-weight: 750;
    color: var(--text-strong);
    list-style: none;
    margin: 0 0 var(--space-2);
}

details.item-kind-panel > summary::-webkit-details-marker {
    display: none;
}

details.item-kind-panel > summary::before {
    content: "B8  ";
    color: var(--faint);
}

details.item-kind-panel[open] > summary::before {
    content: "BE  ";
}

details.item-kind-panel[open] {
    padding-bottom: 10px;
}

.form-tip {
    grid-column: 1 / -1;
    border: 0;
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 12.5px;
    line-height: 1.5;
    margin: 0;
}

.settings-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
}

.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 48px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-core {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(38, 32, 43, 0.16);
    transition: background 0.2s ease;
}

.switch-core::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease;
}

.switch input:checked + .switch-core {
    background: var(--accent);
}

.switch input:checked + .switch-core::after {
    transform: translateX(20px);
}

.subpanel {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    background: var(--surface-soft);
}

.subpanel h4 {
    margin: 0 0 var(--space-3);
    font-size: 14px;
    font-weight: 750;
    color: var(--text-strong);
}

.asset-bin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
}

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

.asset-bin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
}

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

.asset-bin-row-main {
    min-width: 0;
}

.asset-bin-row-main strong {
    display: block;
    font-size: 13px;
    line-height: 1.35;
}

.asset-bin-row-main p {
    margin: 3px 0 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.35;
}

.asset-bin-jump {
    min-height: 34px;
    padding: 5px 11px;
    font-size: 12px;
}

.asset-link-block {
    padding: 6px 0;
}

.asset-link-block:last-child {
    border-bottom: 0;
}

.asset-link-block > strong {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
}

.asset-color-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 0;
}

.asset-color-chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    font-size: 11px;
}

.asset-color-chip-solid {
    width: 16px;
    min-width: 16px;
    height: 16px;
    min-height: 16px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid rgba(38, 32, 43, 0.22);
    background: var(--chip-color, #d1d5db);
}

.filament-slot-legend-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 0;
}

.filament-slot-legend {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 24px;
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    font-size: 11px;
}

.filament-slot-legend b {
    font-weight: 750;
}

.filament-slot-legend em {
    color: var(--muted);
    font-style: normal;
}

.filament-color-picker {
    display: grid;
    gap: 8px;
}

button.filament-color-clear {
    justify-self: start;
    min-height: 30px;
    padding: 4px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
}

button.filament-color-clear.is-active {
    border-color: var(--accent);
    color: var(--accent-strong);
    background: var(--accent-soft);
}

.filament-color-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(22px, 22px));
    gap: 8px;
    max-width: 100%;
}

button.filament-color-swatch {
    width: 22px;
    min-width: 22px;
    height: 22px;
    min-height: 22px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid rgba(38, 32, 43, 0.28);
    background: var(--chip-color, #d1d5db) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

button.filament-color-swatch.is-active {
    outline: 2px solid rgba(var(--accent-rgb), 0.75);
    outline-offset: 1px;
}

.filament-color-current {
    color: var(--muted);
    font-size: 12px;
}

/* ===== Enhanced selects ===== */

.app-select {
    position: relative;
    width: 100%;
}

.app-select.open {
    z-index: 18;
}

.modal .app-select.open {
    z-index: 38;
}

.app-select-native {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
}

.app-select-trigger {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    padding: 8px 34px 8px 12px;
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
}

.app-select-trigger::after {
    content: "";
    position: absolute;
    right: 13px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: translateY(-62%) rotate(45deg);
    transition: transform 0.14s ease;
}

.app-select.open .app-select-trigger {
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.app-select.open .app-select-trigger::after {
    transform: translateY(-34%) rotate(-135deg);
}

.app-select.is-disabled .app-select-trigger {
    opacity: 0.6;
    cursor: not-allowed;
}

.app-select-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    display: none;
    max-height: 268px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-float);
    padding: 5px;
    z-index: 5;
}

.app-select.open .app-select-menu {
    display: grid;
    gap: 2px;
}

.app-select-group {
    padding: 8px 10px 5px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--faint);
    text-transform: uppercase;
}

.app-select-option {
    border: 1px solid transparent;
    border-radius: 8px;
    min-height: 34px;
    padding: 6px 10px;
    background: transparent;
    color: var(--text);
    text-align: left;
    font-weight: 600;
}

.app-select-option:hover {
    border-color: transparent;
    background: var(--surface-sunken);
}

.app-select-option.is-selected {
    border-color: transparent;
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.app-select-option:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Modal ===== */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1240;
    display: grid;
    place-items: center;
    padding: var(--space-5);
    background: rgba(23, 16, 26, 0.44);
    backdrop-filter: blur(3px);
}

body.moeyes-desktop-shell .modal {
    align-items: start;
    padding-top: calc(var(--desktop-windowbar-h) + 16px);
}

body.moeyes-desktop-shell .modal-card {
    max-height: calc(100dvh - var(--desktop-windowbar-h) - 32px);
}

.modal.hidden {
    display: none;
}

.modal-card {
    width: min(880px, 100%);
    max-height: calc(100vh - 56px);
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(38, 32, 43, 0.06);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-float);
    padding: 0;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-3);
    position: sticky;
    top: 0;
    z-index: 6;
    margin: 0;
    padding: 16px 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(150%) blur(10px);
}

.modal-head h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-strong);
    min-width: 0;
    flex: 1 1 auto;
    line-height: 1.25;
}

.modal-head button {
    min-height: 36px;
    min-width: 76px;
    padding: 0 14px;
    border-radius: 10px;
    white-space: nowrap;
    flex: 0 0 auto;
}

.modal-form {
    padding: var(--space-4) 22px var(--space-2);
}

.modal-extra {
    margin-top: var(--space-2);
    padding: var(--space-3) 22px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    border-top: 1px solid var(--line);
}

.modal-extra:empty {
    display: none;
}

#modal-summary.subpanel {
    margin: 0 0 var(--space-3);
    background: var(--surface-soft);
}

/* ===== Item visual summary ===== */

#modal-summary .meta-table > .ivs {
    grid-column: 1 / -1;
    display: grid;
    gap: 14px;
}

.ivs-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ivs-chips .tag {
    gap: 5px;
}

.ivs-chips .tag .asset-color-chip-solid {
    width: 13px;
    min-width: 13px;
    height: 13px;
    min-height: 13px;
    margin: 0;
}

.ivs-stock {
    display: grid;
    gap: 8px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.ivs-stock-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ivs-stock-head > span:first-child {
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 700;
}

.ivs-stock-head strong {
    margin-left: auto;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
}

.ivs-stock-head strong.is-low {
    color: var(--warning);
}

.ivs-bar {
    position: relative;
    height: 8px;
    border-radius: 999px;
    background: var(--surface-sunken);
}

.ivs-bar > i {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #a687b0, var(--accent));
}

.ivs-bar > u {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    border-radius: 2px;
    background: var(--warning);
}

.ivs-stock > small {
    color: var(--muted);
    font-size: 11.5px;
}

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

.ivs-slots-head span {
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 700;
}

.ivs-slots-head small {
    color: var(--faint);
    font-size: 11.5px;
    font-weight: 700;
}

.ivs-slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
    gap: 8px;
}

.ivs-slot {
    display: grid;
    gap: 7px;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.ivs-slot.is-empty {
    opacity: 0.68;
}

.ivs-slot-head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.ivs-slot-chip {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(38, 32, 43, 0.22);
    background: var(--chip-color, #d1d5db);
    flex: 0 0 auto;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.ivs-slot-head b {
    font-size: 12.5px;
    font-weight: 800;
}

.ivs-slot-head span {
    font-size: 12px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ivs-slot-head em {
    margin-left: auto;
    font-style: normal;
    font-size: 12.5px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.ivs-slot small {
    color: var(--muted);
    font-size: 11.5px;
}

.ivs-slot-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ivs-slot-foot .small-btn {
    min-height: 26px;
    padding: 3px 10px;
    font-size: 11.5px;
    border-radius: 999px;
}

/* ===== Replace spool dialog ===== */

.spool-slot-chips,
.spool-color-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.spool-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 5px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1;
}

.spool-chip:hover {
    border-color: rgba(var(--accent-rgb), 0.5);
    background: var(--surface-soft);
}

.spool-chip.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.spool-chip i {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(38, 32, 43, 0.22);
    background: var(--chip-color, #d1d5db);
    flex: 0 0 auto;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.spool-chip span {
    white-space: nowrap;
}

.spool-color-row button.filament-color-swatch {
    width: 26px;
    min-width: 26px;
    height: 26px;
    min-height: 26px;
}

.ivs-spark {
    display: grid;
    gap: 4px;
    color: var(--accent);
}

.ivs-spark-svg {
    display: block;
    width: 100%;
    height: 44px;
}

.ivs-spark small {
    color: var(--faint);
    font-size: 11.5px;
}

.ivs-stock-head strong.is-down {
    color: var(--danger);
}

.ivs-note {
    margin: 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
}

/* ===== System dialog ===== */

.system-dialog {
    position: fixed;
    inset: 0;
    z-index: 1320;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(23, 16, 26, 0.44);
    backdrop-filter: blur(3px);
}

.system-dialog.hidden {
    display: none;
}

.system-dialog-card {
    width: min(500px, 100%);
    border: 1px solid rgba(38, 32, 43, 0.06);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-float);
    padding: 22px 22px 18px;
}

.system-dialog-card h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-strong);
    line-height: 1.25;
}

.system-dialog-card p {
    margin: 12px 0 0;
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.5;
    white-space: pre-line;
}

.system-dialog-input {
    margin-top: 14px;
}

.system-dialog-actions {
    margin-top: 18px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.system-dialog-actions button {
    min-height: 38px;
    min-width: 86px;
    padding: 0 15px;
}

/* ===== Toast ===== */

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    z-index: 1300;
    width: min(430px, calc(100vw - 32px));
    transform: translateX(-50%) translateY(12px);
    border-radius: 14px;
    padding: 13px 15px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(30, 24, 34, 0.94);
    color: #fff;
    box-shadow: var(--shadow-float);
    opacity: 0;
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
    pointer-events: none;
}

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

.toast-title {
    margin: 0;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.3;
}

.toast-body {
    margin: 6px 0 0;
    font-size: 13px;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.88);
}

.toast-hint {
    margin: 6px 0 0;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    line-height: 1.45;
}

.toast-foot {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.toast-close,
.toast-action {
    border: 0;
    min-height: 30px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.toast-close {
    width: 30px;
    min-width: 30px;
    padding: 0;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.toast-close:hover {
    background: rgba(255, 255, 255, 0.26);
}

.toast-close i {
    font-size: 12px;
}

.toast-action {
    padding: 0 13px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--text-strong);
}

.toast-action:hover {
    background: #fff;
}

.toast.is-error {
    background: rgba(140, 42, 30, 0.96);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* ===== Presence panel（彼此近况 · 小黑板） ===== */

.app-page .panel.presence-panel {
    display: grid;
    gap: var(--space-3);
    padding: 2px 2px 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.presence-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    padding: 0 var(--space-2);
}

.presence-heading {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.presence-names {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: var(--text-strong);
}

.presence-heart-beat {
    color: #d6678e;
    font-size: 18px;
    font-style: normal;
    animation: presence-heart-beat 1.8s ease-in-out infinite;
    transform-origin: center;
}

@keyframes presence-heart-beat {
    0%,
    100% {
        transform: scale(1);
    }
    12% {
        transform: scale(1.28);
    }
    24% {
        transform: scale(1);
    }
    36% {
        transform: scale(1.18);
    }
    48% {
        transform: scale(1);
    }
}

.presence-greeting {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.presence-hero {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--space-3);
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(
            380px 110px at 15% 0%,
            var(--owner-me),
            transparent 70%
        ),
        radial-gradient(
            380px 110px at 85% 100%,
            var(--owner-partner),
            transparent 70%
        ),
        var(--surface);
}

.presence-side {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.presence-side.is-partner {
    flex-direction: row-reverse;
}

.presence-side-role {
    color: var(--faint);
    font-size: 12px;
    font-weight: 700;
}

.presence-avatar {
    width: 54px;
    height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 46% 54% 52% 48% / 50% 44% 56% 50%;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 22px;
    font-weight: 800;
    flex: 0 0 auto;
    transform: rotate(-3deg);
    box-shadow: inset 0 0 0 2px rgba(var(--accent-rgb), 0.14);
    transition: transform 0.25s ease;
}

.presence-side.is-partner .presence-avatar {
    background: rgba(214, 118, 152, 0.16);
    color: #a04a68;
    box-shadow: inset 0 0 0 2px rgba(214, 118, 152, 0.2);
    transform: rotate(2.6deg);
    border-radius: 54% 46% 48% 52% / 46% 52% 48% 54%;
}

@media (hover: hover) {
    .presence-side.is-me:hover .presence-avatar {
        transform: rotate(2deg) scale(1.06);
    }

    .presence-side.is-partner:hover .presence-avatar {
        transform: rotate(-2deg) scale(1.06);
    }
}

.presence-link {
    display: grid;
    justify-items: center;
    gap: 6px;
    min-width: 160px;
}

.presence-streak {
    min-height: 18px;
    color: var(--accent-strong);
    font-size: 12.5px;
    font-weight: 750;
    white-space: nowrap;
    letter-spacing: 0.04em;
}

.presence-streak b {
    font-size: 14px;
}

.presence-link-line {
    position: relative;
    width: 100%;
    height: 0;
    border-top: 2px dashed rgba(var(--accent-rgb), 0.4);
}

.presence-link-heart {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translate(-50%, -52%);
    color: #d6678e;
    font-size: 14px;
    font-style: normal;
    line-height: 1;
    animation: presence-heart-beat 1.8s ease-in-out infinite;
}

.presence-fly {
    position: absolute;
    z-index: 6;
    font-size: 22px;
    line-height: 1;
    pointer-events: none;
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 4px 10px rgba(126, 95, 134, 0.4));
    transition:
        transform 0.85s cubic-bezier(0.2, 0.7, 0.3, 1),
        opacity 0.85s ease;
}

.presence-wall {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px 14px;
    padding: 6px 2px 2px;
}

.presence-wall-empty {
    grid-column: 1 / -1;
    padding: 18px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.55);
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.presence-anniv {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 2px;
}

.anniv-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1;
    transition:
        border-color 0.15s ease,
        background-color 0.15s ease;
}

.anniv-chip:hover {
    border-color: rgba(var(--accent-rgb), 0.5);
    background: var(--accent-soft);
}

.anniv-chip i {
    font-style: normal;
    font-size: 13px;
    color: #d6678e;
}

.anniv-chip b {
    color: var(--accent-strong);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.anniv-chip.is-today {
    border-color: #d6678e;
    background: rgba(214, 118, 152, 0.14);
}

.anniv-chip.is-past {
    opacity: 0.6;
}

.anniv-chip.anniv-add {
    border-style: dashed;
    color: var(--muted);
}

.anniv-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
}

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

.anniv-row i {
    font-style: normal;
    font-size: 15px;
    color: #d6678e;
}

.anniv-row-main {
    min-width: 0;
    flex: 1 1 auto;
}

.anniv-row-main strong {
    display: block;
    font-size: 13.5px;
    font-weight: 750;
    color: var(--text-strong);
}

.anniv-row-main small {
    color: var(--muted);
    font-size: 12px;
}

.presence-weekly {
    position: relative;
    display: grid;
    gap: 4px;
    align-content: center;
    min-height: 96px;
    padding: 13px 14px;
    border: 1px dashed rgba(var(--accent-rgb), 0.5);
    border-radius: 3px 12px 4px 11px;
    background: var(--accent-soft);
    transform: rotate(-0.6deg);
}

.presence-weekly-head {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.14em;
    color: var(--accent);
}

.presence-weekly strong {
    font-size: 14.5px;
    line-height: 1.35;
    font-weight: 800;
    color: var(--accent-strong);
}

.presence-weekly small {
    color: var(--muted);
    font-size: 11.5px;
}

.presence-sticky {
    position: relative;
    display: grid;
    gap: 5px;
    min-width: 0;
    margin-top: var(--dip, 0);
    padding: 15px 13px 12px;
    border: 0;
    border-radius: 2px 10px 3px 10px;
    background: linear-gradient(168deg, #f3ecf9 0%, #fdfbfe 78%);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.8) inset,
        0 8px 16px rgba(40, 26, 48, 0.09);
    transform: rotate(var(--tilt, 0deg));
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.presence-sticky:hover {
    transform: rotate(0deg) translateY(-3px) scale(1.01);
    box-shadow: var(--shadow-panel);
    z-index: 2;
}

.presence-sticky.is-theirs {
    background: linear-gradient(168deg, #fcecf3 0%, #fffbfd 78%);
}

.presence-sticky::before {
    content: "";
    position: absolute;
    top: -8px;
    left: 50%;
    width: 62px;
    height: 16px;
    transform: translateX(-50%) rotate(calc(var(--tilt, 0deg) * -1.6));
    border-radius: 2px;
    background: rgba(126, 95, 134, 0.16);
    border-left: 1px solid rgba(255, 255, 255, 0.55);
    border-right: 1px solid rgba(255, 255, 255, 0.55);
}

.presence-sticky.is-theirs::before {
    background: rgba(214, 118, 152, 0.18);
}

.presence-sticky.is-unread {
    box-shadow:
        0 0 0 3px rgba(var(--accent-rgb), 0.16),
        0 10px 20px rgba(40, 26, 48, 0.12);
}

.presence-sticky.is-unread::after {
    content: "新";
    position: absolute;
    top: -9px;
    right: 8px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50% 46% 52% 48%;
    background: #d6678e;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    transform: rotate(8deg);
    box-shadow: 0 4px 10px rgba(214, 103, 142, 0.4);
}

.presence-sticky-mark {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 27px;
    height: 27px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--accent-strong);
    font-size: 14px;
    font-weight: 800;
}

.presence-sticky strong {
    padding-right: 30px;
    font-size: 14.5px;
    line-height: 1.4;
    font-weight: 750;
    color: var(--text-strong);
    word-break: break-word;
}

.presence-sticky small {
    color: var(--faint);
    font-size: 11.5px;
}

.presence-sticky-read {
    justify-self: start;
    min-height: 26px;
    padding: 2px 10px;
    font-size: 11.5px;
    border-radius: 999px;
}

.presence-quickbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 0 var(--space-2);
}

.presence-quick-label {
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 750;
    flex: 0 0 auto;
}

.presence-mood-chip {
    min-height: 33px;
    padding: 4px 13px;
    border: 1px dashed rgba(var(--accent-rgb), 0.45);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--accent-strong);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1;
    transition:
        transform 0.15s ease,
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.presence-mood-chip:nth-child(odd) {
    transform: rotate(-1.2deg);
}

.presence-mood-chip:nth-child(even) {
    transform: rotate(1deg);
}

.presence-mood-chip:hover {
    border-style: solid;
    background: var(--accent-soft);
    color: var(--accent-strong);
    transform: rotate(0deg) translateY(-1px);
}

.presence-quickbar input {
    flex: 1 1 200px;
    min-width: 160px;
    min-height: 35px;
    padding: 5px 14px;
    border: 1px dashed var(--line-strong);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

.presence-quickbar input:focus {
    border-style: solid;
}

.presence-feed {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    padding: 0 var(--space-2);
}

.presence-feed-item {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    color: var(--muted);
    font-size: 12.5px;
}

.presence-feed-item::before {
    content: "·";
    color: var(--faint);
    font-weight: 800;
}

.presence-feed-item b {
    color: var(--text);
    font-weight: 750;
}

.presence-feed-item small {
    color: var(--faint);
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 980px) {
    .app-page .panel.presence-panel {
        padding: var(--space-4);
        border: 0;
        border-radius: var(--mobile-panel-radius);
        background: var(--mobile-panel-bg);
        box-shadow: 0 10px 20px rgba(40, 26, 48, 0.06);
    }

    .presence-hero {
        grid-template-columns: auto 1fr auto;
        padding: 12px;
    }

    .presence-link {
        min-width: 0;
    }

    .presence-wall {
        grid-template-columns: 1fr 1fr;
    }

    .presence-sticky {
        margin-top: 0;
    }

    .presence-quickbar input {
        flex-basis: 100%;
    }
}

@media (max-width: 420px) {
    .presence-wall {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .presence-fly {
        display: none;
    }

    .presence-sticky,
    .presence-mood-chip {
        transform: none;
    }

    .presence-heart-beat,
    .presence-link-heart {
        animation: none;
    }
}

/* ===== Empty states ===== */

.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 46px 24px 42px;
    text-align: center;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.55);
}

.empty-state-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin-bottom: 10px;
    border-radius: 18px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 24px;
}

.empty-state h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 750;
    color: var(--text-strong);
}

.empty-state p {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 13px;
}

.empty-state button {
    min-width: 128px;
}

/* ===== Stocktake ===== */

.stocktake-tip {
    margin: 0 0 2px;
}

.stocktake-meta {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 650;
}

.stocktake-meta strong {
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
}

.stocktake-list {
    grid-column: 1 / -1;
    display: grid;
    gap: 8px;
}

.stocktake-group {
    display: grid;
    gap: 8px;
}

.stocktake-group > h5 {
    margin: 4px 0 0;
    padding: 0 2px;
    color: var(--faint);
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stocktake-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.stocktake-row.is-diff {
    border-color: rgba(var(--accent-rgb), 0.42);
    background: var(--accent-soft);
}

.stocktake-row.is-disabled {
    opacity: 0.62;
    background: var(--surface-soft);
}

.stocktake-row-main {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.stocktake-row-main strong {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stocktake-row-main small {
    color: var(--muted);
    font-size: 12px;
}

.stocktake-diff {
    min-width: 58px;
    text-align: right;
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--faint);
    white-space: nowrap;
}

.stocktake-diff.is-plus {
    color: var(--ok);
}

.stocktake-diff.is-minus {
    color: var(--danger);
}

.stocktake-qty {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.stocktake-qty button {
    width: 30px;
    min-width: 30px;
    min-height: 30px;
    padding: 0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
    background: var(--surface-soft);
    border-color: var(--line);
    color: var(--muted);
}

.stocktake-qty button:hover:not(:disabled) {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.stocktake-qty input {
    width: 78px;
    min-width: 78px;
    min-height: 34px;
    padding: 5px 8px;
    text-align: center;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
}

.stocktake-foot {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 2px;
}

.stocktake-foot .stocktake-sumbit-hint {
    margin-right: auto;
    color: var(--muted);
    font-size: 12.5px;
}

/* ===== Drag & sort ===== */

.card-grid.is-sortable .entity-card.sortable,
#items-grid.is-sortable .entity-card.sortable {
    cursor: grab;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body.moeyes-mobile .card-grid.is-sortable .entity-card.sortable,
body.moeyes-mobile #items-grid.is-sortable .entity-card.sortable {
    touch-action: manipulation;
}

.card-grid.is-sortable .entity-card.sortable:active,
#items-grid.is-sortable .entity-card.sortable:active {
    cursor: grabbing;
}

.entity-card.sortable.dragging {
    opacity: 0.65;
    transform: scale(0.985) rotate(0.2deg);
    z-index: 4;
    box-shadow: var(--shadow-float);
}

.entity-card.sortable.drag-chosen {
    box-shadow:
        0 0 0 2px rgba(var(--accent-rgb), 0.28),
        var(--shadow-panel);
}

.card-grid.sorting .entity-card.sortable,
#items-grid.sorting .entity-card.sortable,
.inventory-group-grid.sorting .entity-card.sortable {
    transition:
        transform 0.12s ease,
        box-shadow 0.12s ease;
}

.entity-card.sortable.drag-ghost {
    opacity: 0.34;
}

.entity-card-focus {
    box-shadow:
        0 0 0 2px rgba(var(--accent-rgb), 0.28),
        var(--shadow-panel);
}

body.is-sorting {
    user-select: none;
    -webkit-user-select: none;
}

/* ===== Misc actions ===== */

.about-hero {
    display: grid;
    gap: 9px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background:
        radial-gradient(300px 90px at 12% 0%, var(--owner-me), transparent 70%),
        var(--surface-soft);
}

.about-family {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: var(--text-strong);
}

.about-line {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.about-hero small {
    color: var(--faint);
    font-size: 12px;
}

.about-tech {
    margin-top: 2px;
}

.about-tech summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 700;
    padding: 4px 0;
    list-style: none;
}

.about-tech summary::-webkit-details-marker {
    display: none;
}

.about-tech summary::before {
    content: "▸ ";
    color: var(--faint);
}

.about-tech[open] summary::before {
    content: "▾ ";
}

.about-tech .meta-table {
    margin-top: 6px;
}

.about-tech .meta-row strong {
    font-size: 13.5px;
}

#settings-refresh-status-btn {
    width: auto;
    min-height: 40px;
    padding: 8px 14px;
    margin-top: var(--space-3);
}

#auth-logout-btn {
    width: auto;
    min-height: 38px;
    padding: 6px 14px;
    margin-top: var(--space-3);
    margin-left: var(--space-2);
}

/* ===== Mobile: outside 980px ===== */

.scope-float {
    display: none;
}

/* ===== Mobile (<= 980px) ===== */

@media (max-width: 980px) {
    :root {
        --mobile-safe-top: env(safe-area-inset-top, 0px);
        --mobile-modal-top-pad: calc(env(safe-area-inset-top, 0px) + 12px);
        --mobile-content-pad: 12px;
        --mobile-panel-radius: 18px;
        --mobile-panel-bg: rgba(255, 255, 255, 0.92);
        --mobile-blur: saturate(150%) blur(14px);
    }

    html,
    body {
        width: 100%;
        height: 100dvh;
        min-height: 100dvh;
        overflow: hidden !important;
    }

    body {
        background: var(--bg);
    }

    .app-shell,
    #app.app-shell {
        max-width: none;
        margin: 0;
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-template-rows: auto minmax(0, 1fr) auto !important;
        gap: 0 !important;
        padding: 0 !important;
        height: 100dvh !important;
        min-height: 100dvh !important;
        overflow: hidden !important;
    }

    .sidebar,
    #app.app-shell > .sidebar {
        grid-row: 1;
        position: relative !important;
        top: auto !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        z-index: 14;
        padding: calc(var(--mobile-safe-top) + 8px) 12px 10px;
        border: 0;
        border-radius: 0;
        background: var(--mobile-panel-bg);
        backdrop-filter: var(--mobile-blur);
        box-shadow: 0 8px 20px rgba(40, 26, 48, 0.08);
        transition: none;
    }

    .brand,
    #app.app-shell > .sidebar .brand {
        margin: 0;
        padding: 0 0 6px;
        max-height: 48px;
        overflow: hidden;
    }

    .brand-sub {
        margin: 0;
        font-size: 22px;
        letter-spacing: 0.08em;
        line-height: 1.02;
        white-space: nowrap;
    }

    .brand-sub-icon {
        display: none;
    }

    .scope-block,
    #app.app-shell > .sidebar .scope-block {
        display: none !important;
    }

    .menu,
    #app.app-shell > .sidebar .menu {
        display: none !important;
    }

    .nav-system {
        margin-top: 8px;
        padding: 6px 8px;
        border-radius: 14px;
        border-color: var(--line);
        background: var(--surface-soft);
        box-shadow: none;
    }

    .nav-system-chips {
        gap: 5px;
    }

    .nav-system .status-pill {
        min-height: 20px;
        padding: 0 7px;
        font-size: 10px;
    }

    .nav-system-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .nav-system-actions .nav-sync-btn,
    .nav-system-actions .db-indicator {
        min-height: 34px;
        padding: 0 8px;
        border-radius: 10px;
    }

    .nav-system-actions .nav-sync-btn span,
    .nav-system-actions .db-indicator span {
        font-size: 11px;
    }

    .main,
    #app.app-shell > .main {
        grid-row: 2;
        width: 100%;
        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;
        margin: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 10px 12px
            calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 28px) !important;
        scroll-padding-bottom: calc(
            var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 22px
        );
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        touch-action: pan-y !important;
        scrollbar-width: none;
    }

    #app.app-shell > .main::-webkit-scrollbar {
        width: 0;
        height: 0;
    }

    .scope-float {
        display: block;
        position: sticky;
        top: 2px;
        z-index: 12;
        margin: 0 0 10px;
    }

    .scope-float-card {
        display: grid;
        gap: 7px;
        padding: 9px 10px;
        border: 0;
        border-radius: var(--mobile-panel-radius);
        background: rgba(255, 255, 255, 0.88);
        box-shadow: 0 8px 18px rgba(40, 26, 48, 0.1);
        backdrop-filter: var(--mobile-blur);
        contain: paint;
    }

    .scope-float-card small {
        color: var(--faint);
        font-size: 11px;
        font-weight: 800;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .scope-float-card .scope-switch {
        margin-top: 0;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        overflow: visible;
    }

    .scope-float-card .scope-switch button {
        min-width: 0;
        min-height: 34px;
        border-radius: 11px;
        font-size: 12px;
        font-weight: 800;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar,
    #app.app-shell > .main .topbar {
        position: static !important;
        top: auto !important;
        z-index: 1;
        margin: 0 0 10px;
        padding: 10px 12px 12px;
        border: 0;
        border-bottom: 0;
        border-radius: var(--mobile-panel-radius);
        background: var(--mobile-panel-bg);
        box-shadow: 0 8px 20px rgba(40, 26, 48, 0.07);
        backdrop-filter: blur(4px);
        grid-template-columns: 1fr;
        align-items: start;
        gap: 6px;
        overflow: hidden;
    }

    .topbar-system-slot {
        display: block;
        width: 100%;
    }

    .topbar-system-slot .nav-system {
        margin-top: 4px;
    }

    .topbar h1 {
        font-size: 19px;
        line-height: 1.12;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #page-desc {
        display: block;
        margin: 2px 0 0;
        font-size: 12.5px;
        line-height: 1.35;
    }

    .topbar-badges {
        margin-bottom: 3px;
        gap: 5px;
    }

    .status-pill {
        min-height: 21px;
        padding: 0 8px;
        font-size: 10px;
    }

    .household-label {
        display: none;
    }

    .topbar-actions {
        width: auto;
        display: flex;
        flex-wrap: nowrap;
        align-self: center;
        gap: 6px;
        padding: 3px;
    }

    .topbar-actions button,
    .topbar-actions .db-indicator {
        min-height: 36px;
        min-width: 36px;
        padding: 0;
        border-radius: 999px;
        font-size: 12px;
    }

    .topbar-actions .app-icon-btn span {
        display: none;
    }

    .topbar-actions #refresh-data-btn.app-icon-btn {
        width: 34px;
    }

    .topbar-actions #db-indicator.app-icon-btn {
        width: 34px;
        min-width: 34px;
    }

    #app-screen {
        min-height: min-content;
        overflow: visible;
    }

    .app-page.active {
        min-height: 0;
        gap: var(--space-3);
        animation: mobile-page-enter 0.2s cubic-bezier(0.2, 0.75, 0.2, 1);
    }

    @keyframes mobile-page-enter {
        from {
            opacity: 0.01;
            transform: translateY(6px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .toolbar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
        padding: 10px;
        min-height: 0;
        border: 0;
        border-radius: var(--mobile-panel-radius);
        background: var(--mobile-panel-bg);
        box-shadow: 0 8px 16px rgba(40, 26, 48, 0.06);
        backdrop-filter: blur(4px);
    }

    .toolbar-label {
        font-size: 12px;
        letter-spacing: 0.06em;
    }

    .toolbar-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        grid-auto-flow: row;
        grid-auto-columns: minmax(0, 1fr);
        justify-content: stretch;
        gap: var(--space-2);
    }

    .toolbar-actions > * {
        width: 100%;
        min-width: 0;
    }

    .toolbar-actions > .app-select,
    .toolbar-actions > select,
    .toolbar-actions > input,
    .toolbar-actions > button {
        width: 100%;
        min-width: 0;
    }

    .inventory-controls {
        border: 0;
        border-radius: var(--mobile-panel-radius);
        background: var(--mobile-panel-bg);
        box-shadow: 0 8px 16px rgba(40, 26, 48, 0.05);
        grid-template-columns: 1fr 1fr;
        padding: 10px;
    }

    .inventory-controls #inventory-keyword {
        grid-column: 1 / -1;
    }

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

    .stat-card {
        min-height: 104px;
        padding: 14px 15px;
        border-radius: var(--mobile-panel-radius);
        background: var(--mobile-panel-bg);
        box-shadow: 0 10px 22px rgba(40, 26, 48, 0.08);
    }

    .stat-card-key,
    .stat-card-key.stat-card {
        background: linear-gradient(135deg, #8a6791 0%, #68496f 100%);
        box-shadow:
            0 10px 26px rgba(104, 73, 111, 0.38),
            inset 0 1px 0 rgba(255, 255, 255, 0.18);
    }

    .stat-card strong {
        font-size: 22px;
    }

    .stat-card-key strong {
        font-size: 24px;
    }

    .stat-card-sk strong {
        font-size: 22px;
    }

    .stat-card-sk-auth {
        grid-template-columns: 1fr;
    }

    .stat-card-sk-auth button {
        width: 100%;
    }

    .stat-card-sk-footer {
        grid-template-columns: 1fr;
    }

    .stat-card-sk-footer button {
        width: 100%;
    }

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

    .split,
    .settings-form,
    .modal-form,
    .inline-form,
    .inventory-controls {
        grid-template-columns: 1fr;
    }

    .card-grid,
    .inventory-group-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .inventory-groups-layout {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .inventory-group + .inventory-group {
        margin-top: var(--space-3);
    }

    .panel {
        padding: var(--space-4);
        border: 0;
        border-radius: var(--mobile-panel-radius);
        background: var(--mobile-panel-bg);
        box-shadow: 0 10px 20px rgba(40, 26, 48, 0.06);
        backdrop-filter: blur(4px);
    }

    .entity-card {
        padding: 14px 15px;
        min-height: 0;
        gap: 9px;
        border: 0;
        border-radius: var(--mobile-panel-radius);
        background: var(--mobile-panel-bg);
        box-shadow: 0 10px 20px rgba(40, 26, 48, 0.07);
        backdrop-filter: blur(4px);
        transition:
            transform 0.14s ease,
            box-shadow 0.14s ease;
    }

    .entity-card:active {
        transform: scale(0.995);
        box-shadow: 0 6px 12px rgba(40, 26, 48, 0.08);
    }

    .entity-card h4 {
        font-size: 16px;
    }

    .entity-actions {
        margin-top: 2px;
    }

    .empty-state {
        border: 0;
        border-radius: var(--mobile-panel-radius);
        background: var(--mobile-panel-bg);
        box-shadow: 0 8px 16px rgba(40, 26, 48, 0.05);
    }

    .meta-row {
        grid-template-columns: 1fr;
        gap: var(--space-1);
    }

    .modal {
        display: block;
        place-items: stretch;
        align-items: stretch;
        padding: 0;
        background: rgba(23, 16, 26, 0.4);
    }

    body.moeyes-mobile.modal-open .toast {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    }

    .modal-card {
        width: 100%;
        height: 100dvh;
        min-height: 100dvh;
        max-height: 100dvh;
        overflow-x: hidden;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 0 12px calc(env(safe-area-inset-bottom, 0px) + 24px);
        background: var(--bg-soft);
    }

    .modal-head {
        position: sticky;
        top: 0;
        z-index: 4;
        margin: 0 -12px 12px;
        padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
        border-bottom: 1px solid var(--line);
        background: var(--bg-soft);
        backdrop-filter: none;
    }

    .modal-head h3 {
        font-size: 17px;
    }

    .modal-head button {
        min-height: 34px;
        min-width: 66px;
        padding: 0 11px;
        border-radius: 999px;
        font-size: 12px;
    }

    .modal-form {
        padding: 0;
        gap: 10px;
    }

    .modal-extra {
        margin-top: 12px;
        padding: 12px 0 0;
        gap: 8px;
        border-top: 1px solid var(--line);
    }

    .system-dialog {
        padding: 16px;
    }

    .system-dialog-card {
        width: min(560px, 100%);
        border-radius: 18px;
        padding: 18px 16px 14px;
    }

    .system-dialog-card h3 {
        font-size: 17px;
    }

    .system-dialog-card p {
        font-size: 14px;
        margin-top: 10px;
    }

    .system-dialog-actions button {
        min-height: 36px;
        min-width: 78px;
        border-radius: 10px;
    }

    .toast {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: calc(
            var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 14px
        );
        border-radius: 13px;
        padding: 11px 12px;
    }

    .toast.show {
        transform: translateX(0) translateY(0);
    }

    .stocktake-row {
        grid-template-columns: minmax(0, 1fr) auto;
        row-gap: 8px;
    }

    .stocktake-foot {
        position: sticky;
        bottom: 8px;
        margin: 4px -12px 0;
        padding: 10px 12px;
        background: var(--bg-soft);
        border-top: 1px solid var(--line);
    }

    .stocktake-row .stocktake-qty {
        grid-column: 2;
        grid-row: 1;
    }

    .stocktake-row .stocktake-diff {
        grid-column: 1;
        grid-row: 2;
        text-align: left;
    }

    #auth-logout-btn {
        margin-left: 0;
    }

    @supports (content-visibility: auto) {
        .panel,
        .entity-card {
            content-visibility: auto;
            contain-intrinsic-size: 300px;
        }
    }

    .mobile-tabbar {
        grid-row: 3;
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 28;
        height: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
        display: grid !important;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 4px;
        padding: 8px 10px calc(env(safe-area-inset-bottom, 0px) + 8px);
        border: 0;
        border-top: 1px solid var(--line);
        border-radius: 0;
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 -8px 24px rgba(40, 26, 48, 0.08);
        backdrop-filter: var(--mobile-blur);
    }

    .mobile-tabbar button {
        border: 0;
        border-radius: 12px;
        background: transparent;
        color: var(--muted);
        display: grid;
        justify-items: center;
        align-content: center;
        gap: 3px;
        min-width: 0;
        min-height: 0;
        cursor: pointer;
        transition:
            background-color 0.16s ease,
            color 0.16s ease,
            transform 0.12s ease;
    }

    .mobile-tabbar button:hover {
        background: transparent;
    }

    .mobile-tabbar button:active {
        transform: scale(0.95);
    }

    .mobile-tabbar button i {
        font-size: 18px;
        line-height: 1;
    }

    .mobile-tabbar button span {
        font-size: 10px;
        font-weight: 700;
        line-height: 1;
    }

    .mobile-tabbar button.active {
        background: var(--accent-soft);
        color: var(--accent-strong);
    }

    .mobile-sheet {
        position: fixed !important;
        inset: 0 !important;
        z-index: 32 !important;
        display: none;
        align-items: end;
        background: rgba(23, 16, 26, 0.44);
        padding: 16px 10px
            calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 10px);
        overflow: auto;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.18s ease;
    }

    .mobile-sheet.is-open {
        display: grid;
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-sheet-card {
        width: min(560px, 100%);
        margin: 0 auto;
        border: 0;
        border-radius: 22px;
        background: rgba(255, 255, 255, 0.97);
        backdrop-filter: blur(10px);
        box-shadow: var(--shadow-float);
        padding: 14px 14px 12px;
        display: grid;
        gap: 10px;
        transform: translateY(18px);
        transition: transform 0.2s cubic-bezier(0.2, 0.76, 0.2, 1);
    }

    .mobile-sheet.is-open .mobile-sheet-card {
        transform: translateY(0);
    }

    .mobile-sheet-card h4 {
        margin: 0 0 4px;
        font-size: 17px;
        letter-spacing: 0.01em;
        color: var(--text-strong);
    }

    .mobile-sheet-card button {
        border: 0;
        border-radius: 14px;
        min-height: 46px;
        background: var(--surface-soft);
        box-shadow: none;
        text-align: left;
        padding: 0 14px;
        font-weight: 700;
        cursor: pointer;
    }
}

/* Mobile architecture: legacy body-class overrides kept for shell parity */

body.moeyes-mobile .app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    overflow: visible !important;
}

body.moeyes-mobile .menu {
    display: none;
}

body.moeyes-mobile .sidebar {
    position: relative !important;
    top: auto !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
}

body.moeyes-mobile .main {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

body.moeyes-mobile .topbar {
    position: static !important;
}

body.moeyes-mobile .mobile-tabbar {
    display: grid !important;
}

body.moeyes-mobile .mobile-sheet {
    display: none !important;
}

body.moeyes-mobile .mobile-sheet.is-open {
    display: grid !important;
}

body.moeyes-android {
    --android-safe-top: 26px;
    height: 100dvh;
    overflow: hidden !important;
}

body.moeyes-android .app-shell {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden !important;
}

body.moeyes-android .sidebar {
    flex: 0 0 auto;
}

body.moeyes-android .main {
    flex: 1 1 auto;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
}

body.moeyes-android .topbar,
body.moeyes-android .toolbar,
body.moeyes-android .panel,
body.moeyes-android .entity-card,
body.moeyes-android .scope-block,
body.moeyes-android .scope-float-card,
body.moeyes-android .mobile-sheet-card {
    backdrop-filter: none !important;
}

body.moeyes-android .panel,
body.moeyes-android .entity-card {
    content-visibility: visible !important;
    contain-intrinsic-size: auto !important;
}

@media (min-width: 1100px) {
    .app-page.active {
        gap: 12px;
    }

    .toolbar-actions > select,
    .toolbar-actions > .app-select,
    .toolbar-actions > input {
        min-width: 138px;
    }

    .entity-action-btn {
        min-height: 29px;
        padding: 4px 11px;
        font-size: 12px;
    }
}

@media (max-width: 1260px) {
    .main {
        padding: var(--space-4) var(--space-5) var(--space-6);
    }

    .topbar {
        margin: calc(var(--space-4) * -1) calc(var(--space-5) * -1)
            var(--space-4);
        padding: var(--space-4) var(--space-5) 12px;
    }

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

    .inventory-controls #inventory-keyword {
        grid-column: auto;
    }

    .asset-bin-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-modules {
        grid-template-columns: 1fr;
    }

    .toolbar-actions {
        grid-template-columns: 1fr;
    }

    .mobile-tabbar {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        padding: 6px 8px calc(env(safe-area-inset-bottom, 0px) + 6px);
    }

    .mobile-tabbar button span {
        font-size: 9px;
    }

    .mobile-sheet {
        padding-left: 8px;
        padding-right: 8px;
    }
}

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

@media (max-width: 980px) {
    .home-hero {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .home-focus {
        justify-content: flex-start;
    }

    .home-focus-title {
        max-width: none;
    }
}
