/* ==========================================================================
   Design tokens — modern SaaS look (docs/identidade-visual.md, version 2)
   ========================================================================== */
:root {
    --bg: #F5F6F8;
    --surface: #FFFFFF;
    --surface-2: #F9FAFB;
    --surface-3: #F2F4F7;
    --border: #E6E8EC;
    --border-strong: #D0D5DD;

    --text: #101828;
    --text-2: #344054;
    --text-3: #667085;

    --primary: #15803D;
    --primary-hover: #166534;
    --primary-500: #22C55E;
    --primary-600: #16A34A;
    --primary-soft: #ECFDF3;
    --primary-soft-2: #DCFCE7;
    --primary-ink: #166534;
    --primary-ring: rgba(34, 197, 94, 0.22);

    --danger: #D92D20;
    --danger-soft: #FEF3F2;
    --warning: #B54708;
    --warning-soft: #FFFAEB;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 999px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 8px 20px -6px rgba(16, 24, 40, 0.12), 0 2px 6px -2px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, 0.22);

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --sidebar-width: 260px;
    --tabbar-height: 64px;
    --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1:focus { outline: none; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--primary-600); outline-offset: 2px; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.muted { color: var(--text-3); }
.caption { color: var(--text-3); font-size: 13px; line-height: 1.4; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-error { margin-top: 6px; font-size: 12px; color: var(--danger); }

.desktop-only { display: none !important; }
@media (min-width: 900px) {
    .desktop-only { display: inline-flex !important; }
    .mobile-only { display: none !important; }
}

/* ==========================================================================
   App shell: top bar + tab bar on mobile, sidebar on desktop
   ========================================================================== */
.app { min-height: 100vh; min-height: 100dvh; }

.sidebar { display: none; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.86);
    border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
}

.content {
    padding: 20px 16px calc(var(--tabbar-height) + 96px + env(safe-area-inset-bottom));
}

.content-inner { max-width: 1160px; margin: 0 auto; }

.tabbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, 0.92);
    border-top: 1px solid var(--border);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
}

.tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.tab-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 28px;
    border-radius: var(--radius-full);
    transition: background 0.2s var(--ease);
}

.tabbar a.active { color: var(--primary); }
.tabbar a.active .tab-icon { background: var(--primary-soft-2); }

@media (min-width: 900px) {
    .app {
        display: grid;
        grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    }

    .sidebar {
        position: sticky;
        top: 0;
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        padding: 20px 16px;
        background: var(--surface);
        border-right: 1px solid var(--border);
    }

    .topbar, .tabbar { display: none; }

    .content { padding: 36px 40px 56px; }
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    flex: none;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary));
    color: #FFFFFF;
    box-shadow: 0 4px 10px -2px rgba(21, 128, 61, 0.45);
}

.brand-mark svg { width: 18px; height: 18px; }

.nav { display: grid; gap: 2px; margin-top: 28px; }

.nav-label {
    margin: 20px 12px 6px;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    color: var(--text-2);
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.nav a .mud-icon-root { font-size: 20px; }

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12px;
    line-height: 1.4;
}

.live-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-500);
    box-shadow: 0 0 0 4px var(--primary-ring);
}

.topbar .live-dot { box-shadow: 0 0 0 3px var(--primary-ring); }

/* ==========================================================================
   Page header
   ========================================================================== */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header-main { display: flex; flex: 1 1 auto; align-items: center; gap: 12px; min-width: 0; }
.page-header-text { min-width: 0; }

.page-title {
    overflow: hidden;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-subtitle { margin: 4px 0 0; color: var(--text-3); font-size: 14px; }
.page-actions { display: flex; flex: none; align-items: center; gap: 8px; }

.back-button {
    display: grid;
    flex: none;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-2);
    box-shadow: var(--shadow-xs);
    text-decoration: none;
    transition: background 0.15s var(--ease);
}

.back-button:hover { background: var(--surface-2); }

@media (min-width: 900px) {
    .page-header { margin-bottom: 28px; }
    .page-title { font-size: 28px; }
}

/* ==========================================================================
   Surfaces
   ========================================================================== */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.card-interactive {
    transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease), border-color 0.2s var(--ease);
}

@media (hover: hover) {
    .card-interactive:hover {
        border-color: var(--border-strong);
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
    }
}

.icon-tile {
    display: grid;
    flex: none;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--primary-soft);
    color: var(--primary);
}

.icon-tile.neutral { background: var(--surface-3); color: var(--text-2); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { border-color: #ABEFC6; background: var(--primary-soft); color: var(--primary-ink); }
.badge-warning { border-color: #FEDF89; background: var(--warning-soft); color: var(--warning); }

.progress {
    height: 8px;
    overflow: hidden;
    border-radius: var(--radius-full);
    background: var(--surface-3);
}

.progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary-500), var(--primary-600));
    transition: width 0.4s var(--ease);
}

.banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-2);
    box-shadow: var(--shadow-xs);
}

.banner .mud-icon-root { flex: none; color: var(--text-3); }

/* Segmented control (tabs) */
.segmented {
    display: inline-flex;
    gap: 4px;
    margin-bottom: 20px;
    padding: 4px;
    border-radius: var(--radius-md);
    background: #EAECF0;
}

.segmented a {
    padding: 6px 16px;
    border-radius: 9px;
    color: var(--text-3);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.segmented a.selected { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Empty state */
.empty-state {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 48px 24px;
    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-bottom: 8px;
    border-radius: var(--radius-lg);
    background: var(--primary-soft);
    color: var(--primary);
    box-shadow: inset 0 0 0 1px #ABEFC6;
}

.empty-state h3 { font-size: 16px; font-weight: 600; }
.empty-state p { max-width: 380px; margin: 0 0 12px; color: var(--text-3); }

/* Loading skeletons */
.skeleton-stack { display: grid; gap: 12px; }

.skeleton {
    height: 72px;
    border-radius: var(--radius-lg);
    background: linear-gradient(90deg, #ECEEF2 0%, #F6F7F9 50%, #ECEEF2 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton:nth-child(2) { opacity: 0.8; }
.skeleton:nth-child(3) { opacity: 0.6; }

@keyframes shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* ==========================================================================
   Lists overview
   ========================================================================== */
.list-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.list-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 18px;
    color: inherit;
    text-decoration: none;
}

.list-card-top { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.list-card-heading { flex: 1; min-width: 0; }
.list-card-title { font-size: 15px; font-weight: 600; }

.meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: var(--text-3); font-size: 13px; }
.meta .mud-icon-root { font-size: 16px; }

.list-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    color: var(--text-3);
    font-size: 13px;
}

.list-card-footer strong { color: var(--text); font-weight: 600; }

.add-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 150px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text-3);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s var(--ease), color 0.15s var(--ease), background 0.15s var(--ease);
}

.add-card:hover { border-color: var(--primary-600); background: var(--primary-soft); color: var(--primary); }

/* Phones: the header button already creates lists; tabs span the full width */
@media (max-width: 899px) {
    .add-card { display: none; }
    .segmented { display: flex; }
    .segmented a { flex: 1; text-align: center; }
    .item-actions .mud-icon-button, .row-actions .mud-icon-button, .product-actions .mud-icon-button { width: 40px; height: 40px; }
}

/* ==========================================================================
   List detail
   ========================================================================== */
.detail-layout { display: grid; gap: 20px; }
.detail-main { min-width: 0; }
.detail-aside { order: -1; }

@media (min-width: 1100px) {
    .detail-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; gap: 28px; }
    .detail-aside { position: sticky; top: 36px; order: 0; }
}

.summary-card { display: grid; gap: 14px; padding: 20px; }
.summary-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.summary-label { color: var(--text-3); font-size: 13px; font-weight: 500; }
.summary-percent { font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; }
.summary-text { color: var(--text-3); font-size: 13px; }
.summary-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.summary-actions > :only-child { grid-column: 1 / -1; }

@media (min-width: 1100px) {
    .summary-actions { grid-template-columns: 1fr; }
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    margin-bottom: 12px;
}

.section-card { margin-bottom: 16px; overflow: hidden; }

.section-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.section-title {
    color: var(--text-2);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.item-list { margin: 0; padding: 0; list-style: none; }

.item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 64px;
    padding: 8px 6px 8px 6px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s var(--ease);
}

.item-row:last-child { border-bottom: 0; }

@media (hover: hover) {
    .item-row:hover { background: var(--surface-2); }
}

.item-body { flex: 1; min-width: 0; }
.item-name { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }

.item-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    color: var(--text-3);
    font-size: 13px;
}

.quantity {
    padding: 1px 8px;
    border-radius: 6px;
    background: var(--surface-3);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
}

.item-row.purchased .item-name { color: var(--text-3); text-decoration: line-through; }
.item-row.purchased .photo-thumb, .item-row.purchased .quantity { opacity: 0.55; }

.item-actions { display: flex; flex: none; }
.item-actions .mud-icon-button { color: var(--text-3); }

@media (hover: hover) and (min-width: 900px) {
    .item-actions { opacity: 0; transition: opacity 0.15s var(--ease); }
    .item-row:hover .item-actions, .item-row:focus-within .item-actions { opacity: 1; }
}

/* Round check button (44px touch target around a 24px circle) */
.check {
    display: grid;
    flex: none;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.check-circle {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface);
    color: transparent;
    transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.15s var(--ease);
}

.check-circle svg { width: 14px; height: 14px; }
.check:hover .check-circle { border-color: var(--primary-600); }
.check:active .check-circle { transform: scale(0.9); }
.check[aria-checked="true"] .check-circle { border-color: var(--primary-600); background: var(--primary-600); color: #FFFFFF; }
.check:disabled { cursor: default; }
.check:disabled .check-circle { opacity: 0.6; }

/* Floating action button (mobile) */
.fab.mud-button-root {
    position: fixed;
    right: 16px;
    bottom: calc(var(--tabbar-height) + 16px + env(safe-area-inset-bottom));
    z-index: 55;
    height: 52px;
    padding: 0 22px;
    border-radius: var(--radius-full);
    box-shadow: 0 12px 24px -6px rgba(21, 128, 61, 0.55);
}

.celebrate {
    display: grid;
    justify-items: center;
    gap: 6px;
    margin-bottom: 20px;
    padding: 32px 20px;
    border: 1px solid #ABEFC6;
    border-radius: var(--radius-lg);
    background: radial-gradient(circle at 50% 0%, var(--primary-soft-2), var(--surface) 70%);
    text-align: center;
}

.celebrate-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin-bottom: 6px;
    border-radius: 50%;
    background: var(--primary-600);
    color: #FFFFFF;
    box-shadow: 0 10px 24px -6px rgba(22, 163, 74, 0.6);
}

.celebrate h2 { font-size: 20px; }
.celebrate p { max-width: 380px; margin: 0 0 12px; color: var(--text-3); }

/* ==========================================================================
   Catalog
   ========================================================================== */
.toolbar-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    margin-bottom: 8px;
    padding: 12px 16px;
}

.search-field { flex: 1 1 260px; }

.group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 28px 0 12px;
    color: var(--text-2);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.product-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.product-card { display: flex; align-items: center; gap: 12px; padding: 10px 6px 10px 10px; }
.product-card.archived { opacity: 0.6; }

.product-body { flex: 1; min-width: 0; }
.product-name { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.product-sub { color: var(--text-3); font-size: 13px; }
.product-actions { display: flex; flex: none; }
.product-actions .mud-icon-button { color: var(--text-3); }

/* ==========================================================================
   Simple row lists (sections, stores)
   ========================================================================== */
.row-list { overflow: hidden; }

.row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 10px 8px 10px 16px;
    border-bottom: 1px solid var(--border);
}

.row:last-child { border-bottom: 0; }

.row-index {
    display: grid;
    flex: none;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 600;
}

.row-body { flex: 1; min-width: 0; }
.row-title { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--text-3); font-size: 13px; }
.row-actions { display: flex; flex: none; }
.row-actions .mud-icon-button { color: var(--text-3); }

.hint {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 4px 0;
    color: var(--text-3);
    font-size: 13px;
}

.hint .mud-icon-root { font-size: 18px; }

/* ==========================================================================
   Photos
   ========================================================================== */
.photo-thumb {
    display: grid;
    flex: none;
    place-items: center;
    width: var(--size, 44px);
    height: var(--size, 44px);
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-3);
    color: var(--text-3);
    cursor: pointer;
}

.photo-thumb:disabled { cursor: default; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .mud-icon-root { font-size: 20px; opacity: 0.7; }

.photo-full {
    display: block;
    width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-md);
    background: var(--surface-3);
    object-fit: contain;
}

.photo-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    padding: 8px 8px 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
}

.photo-picker-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;
    padding: 0 16px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-2);
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s var(--ease), background 0.15s var(--ease), color 0.15s var(--ease);
}

.photo-picker-button:hover { border-color: var(--primary-600); background: var(--primary-soft); color: var(--primary); }

.form-label { margin: 16px 0 8px; color: var(--text-2); font-size: 13px; font-weight: 600; }

/* ==========================================================================
   MudBlazor refinements
   ========================================================================== */
.mud-button-root { border-radius: 10px !important; letter-spacing: 0 !important; }
.mud-button-filled { box-shadow: var(--shadow-xs) !important; }
.mud-button-filled:hover { box-shadow: var(--shadow-sm) !important; }
.mud-button-outlined { background: var(--surface) !important; border-color: var(--border-strong) !important; color: var(--text-2) !important; }
.mud-button-outlined:hover { background: var(--surface-2) !important; }

.mud-input-outlined .mud-input-outlined-border { border-radius: 10px !important; border-color: var(--border-strong); }
.mud-input.mud-input-outlined { background: var(--surface); border-radius: 10px; }

/* Dialogs: centered modal on desktop, bottom sheet on phones */
.mud-overlay-dialog { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.mud-overlay-dialog .mud-overlay-scrim { background-color: rgba(16, 24, 40, 0.45) !important; }

.mud-dialog {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-lg) !important;
}

.mud-dialog .mud-dialog-title { padding: 20px 24px 4px; }
.mud-dialog .mud-dialog-title h6, .mud-dialog .mud-dialog-title .mud-typography { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.mud-dialog .mud-dialog-content { padding: 8px 24px 8px; }
.mud-dialog .mud-dialog-actions { gap: 8px; padding: 16px 24px 20px; }

@media (max-width: 599px) {
    .mud-dialog-container { align-items: flex-end !important; }

    .mud-dialog {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92dvh;
        margin: 0 !important;
        border-radius: 22px 22px 0 0 !important;
        padding-bottom: env(safe-area-inset-bottom);
        animation: sheet-up 0.28s var(--ease);
    }

    .mud-dialog::before {
        content: "";
        display: block;
        width: 40px;
        height: 4px;
        margin: 10px auto 0;
        border-radius: var(--radius-full);
        background: var(--border-strong);
    }

    .mud-dialog .mud-dialog-actions .mud-button-root { flex: 1; height: 44px; }
}

@keyframes sheet-up {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.mud-popover { border: 1px solid var(--border); border-radius: var(--radius-md) !important; box-shadow: var(--shadow-md) !important; }
.mud-list-item { border-radius: 8px; }

.mud-snackbar { border-radius: var(--radius-md) !important; box-shadow: var(--shadow-lg) !important; font-weight: 500; }

@media (max-width: 899px) {
    /* Above the tab bar and the floating "Adicionar item" button, so a toast never hides it. */
    .mud-snackbar-location-bottom-center { bottom: calc(var(--tabbar-height) + 84px + env(safe-area-inset-bottom)) !important; }
}

/* Unit chips: outlined pills, green when selected */
.mud-chipset { display: flex; flex-wrap: wrap; gap: 6px; }
.mud-chipset .mud-chip {
    margin: 0 !important;
    border: 1px solid var(--border) !important;
    background-color: var(--surface) !important;
    color: var(--text-2) !important;
    font-weight: 600;
}
.mud-chipset .mud-chip.mud-chip-selected {
    border-color: var(--primary-600) !important;
    background-color: var(--primary-soft) !important;
    color: var(--primary-ink) !important;
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.mud-switch .mud-typography { font-size: 13px; font-weight: 500; color: var(--text-2); }

.blazor-error-boundary {
    padding: 16px;
    border-radius: var(--radius-md);
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 600;
}

.blazor-error-boundary::after { content: "Ocorreu um erro inesperado. Recarregue a página."; }

/* ==========================================================================
   Drag and drop (SortableList.razor)
   ========================================================================== */
.drag-handle {
    display: grid;
    flex: none;
    place-items: center;
    width: 28px;
    height: 40px;
    margin-left: -6px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-3);
    cursor: grab;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.drag-handle svg { width: 18px; height: 18px; }
.drag-handle:hover { background: var(--surface-3); color: var(--text-2); }
.drag-handle:active { cursor: grabbing; }

.list-card .drag-handle { position: relative; z-index: 2; margin: -8px -10px 0 0; }

.sortable-active { user-select: none; -webkit-user-select: none; }
.sortable-active, .sortable-active * { cursor: grabbing !important; }

.sortable-dragging {
    position: relative;
    z-index: 20;
    box-shadow: var(--shadow-lg) !important;
}

.row.sortable-dragging { border-radius: var(--radius-md); background: var(--surface); }

/* Whole-card link: the title link covers the card, the drag handle stays above it. */
.stretched-link { color: inherit; text-decoration: none; }
.stretched-link::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.stretched-link:focus-visible { outline: none; }
.stretched-link:focus-visible::after { outline: 2px solid var(--primary-600); outline-offset: 2px; }
.list-card-title { display: block; }

/* ==========================================================================
   Sign-in and sign-out
   ========================================================================== */
.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px 16px;
    background: radial-gradient(circle at 50% 0%, var(--primary-soft-2), var(--bg) 55%);
}

.auth-card { width: 100%; max-width: 400px; padding: 32px 28px; box-shadow: var(--shadow-lg); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; font-size: 15px; font-weight: 700; }
.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.auth-subtitle { margin: 6px 0 20px; color: var(--text-3); }
.auth-form { display: grid; }
.auth-form .form-label { margin-top: 0; }

.auth-input {
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 16px;
}

.auth-input:focus { border-color: var(--primary-600); outline: none; box-shadow: 0 0 0 4px var(--primary-ring); }

.auth-submit {
    height: 44px;
    margin-top: 16px;
    border: 0;
    border-radius: 10px;
    background: var(--primary);
    color: #FFFFFF;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
}

.auth-submit:hover { background: var(--primary-hover); }

.auth-alert {
    margin-bottom: 16px;
    padding: 10px 12px;
    border: 1px solid #FECDCA;
    border-radius: 10px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13px;
    font-weight: 500;
}

.auth-hint { margin: 16px 0 0; color: var(--text-3); font-size: 12px; text-align: center; }

.signout-form { margin-top: 8px; }

.signout-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--text-2);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

.signout-button:hover { background: var(--surface-3); color: var(--text); }

.topbar-actions { display: flex; align-items: center; gap: 4px; }

.signout-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-right: -8px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--text-3);
    cursor: pointer;
}
