:root {
    color-scheme: light;
    --cream-50: #fffdfc;
    --cream-100: #f8f1e4;
    --cream-200: #f0e4d2;
    --terracotta: #b55d3c;
    --terracotta-dark: #8f432b;
    --terracotta-soft: #f4ded4;
    --terracotta-border: #d9a28c;
    --sage: #536a4c;
    --sage-dark: #43573d;
    --sage-soft: #dde5d7;
    --ink: #2f2923;
    --muted: #776d63;
    --line: #e6d8c5;
    --white: #ffffff;
    --warning: #a66a1d;
    --danger: #a33e35;
    --shadow: 0 10px 30px rgba(78, 52, 37, .08);
    --radius: 24px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--cream-100); }

body {
    margin: 0;
    color: var(--ink);
    background: var(--cream-100);
    font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a { color: inherit; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(181, 93, 60, .34); outline-offset: 3px; }

h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: "Fraunces", Georgia, serif; }
h1 { margin-bottom: 8px; font-size: clamp(30px, 4vw, 43px); line-height: 1.08; }
h2 { margin-bottom: 18px; font-size: 23px; }
h3 { margin-bottom: 8px; font-size: 16px; }

.admin-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    width: 256px;
    padding: 30px 22px 22px;
    flex-direction: column;
    background: #343a31;
    color: #fdf8ed;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: block;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 1px solid rgba(217, 162, 140, .42);
    border-radius: 14px;
    background: var(--cream-100);
    box-shadow: 0 5px 15px rgba(38, 29, 23, .14);
    object-fit: cover;
}

.brand strong { display: block; font-family: "Fraunces", Georgia, serif; font-size: 24px; line-height: 1; }
.brand small { display: block; margin-top: 5px; color: #bcc5b2; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; }

.main-nav { display: grid; gap: 7px; margin-top: 44px; }
.main-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 13px;
    color: #dce2d6;
    font-weight: 600;
    text-decoration: none;
    transition: background .16s ease, color .16s ease;
}
.nav-icon { display: grid; width: 19px; flex: 0 0 19px; place-items: center; color: #aebca1; }
.nav-icon svg { width: 19px; height: 19px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-label-compact { display: none; }
.main-nav a:hover, .main-nav a.active { background: rgba(255, 255, 255, .09); color: white; }
.main-nav a.active .nav-icon { color: #f2a085; }

.sidebar-footer { margin-top: auto; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.11); }
.signed-user { display: flex; min-width: 0; align-items: center; gap: 10px; }
.signed-user > span:last-child { min-width: 0; }
.signed-user strong, .signed-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signed-user strong { font-size: 14px; }
.signed-user small { color: #abb5a2; font-size: 11px; }
.avatar { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border-radius: 50%; background: var(--terracotta); color: white; font-weight: 700; }
.logout-button { margin-top: 13px; padding: 5px 0; border: 0; background: transparent; color: #ccd3c6; cursor: pointer; font-size: 13px; }
.logout-button:hover { color: white; }

.workspace { min-height: 100vh; margin-left: 256px; }
.mobile-header { display: none; }
.page-content { width: min(1500px, 100%); margin: 0 auto; padding: 42px clamp(24px, 4vw, 64px) 72px; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-header p { margin-bottom: 0; color: var(--muted); }
.eyebrow { display: block; margin-bottom: 9px; color: var(--terracotta-dark); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }

.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { position: relative; overflow: hidden; min-height: 130px; padding: 21px; border: 1px solid rgba(217, 198, 179, .65); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.stat-card::after { position: absolute; right: -20px; bottom: -26px; width: 76px; height: 76px; border-radius: 50%; background: var(--terracotta-soft); content: ""; opacity: .55; }
.stat-card.sage::after { background: var(--sage-soft); }
.stat-label { display: block; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.stat-value { position: relative; z-index: 1; display: block; margin-top: 11px; font-family: "Fraunces", Georgia, serif; font-size: 34px; font-weight: 700; line-height: 1; }
.stat-note { position: relative; z-index: 1; display: block; margin-top: 10px; color: var(--muted); font-size: 12px; }

.grid-two { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .8fr); gap: 20px; margin-bottom: 20px; }
.grid-even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { padding: 25px; border: 1px solid rgba(217, 198, 179, .66); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-header h2 { margin-bottom: 0; }
.panel-link { color: var(--terracotta-dark); font-size: 13px; font-weight: 700; text-decoration: none; }

.activity-chart { display: grid; height: 220px; grid-template-columns: repeat(14, minmax(18px, 1fr)); align-items: end; gap: clamp(5px, 1vw, 11px); padding-top: 18px; }
.activity-day { display: flex; height: 100%; min-width: 0; flex-direction: column; justify-content: flex-end; gap: 8px; text-align: center; }
.activity-bar-wrap { display: flex; height: 170px; align-items: flex-end; justify-content: center; }
.activity-bar { width: min(24px, 80%); min-height: 4px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, #d77659, var(--terracotta)); }
.activity-day:nth-child(3n) .activity-bar { background: linear-gradient(180deg, #94a884, var(--sage)); }
.activity-day small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: clip; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 16px; color: var(--muted); font-size: 12px; }
.chart-legend span::before { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--terracotta); content: ""; }

.ai-summary { display: grid; gap: 14px; }
.ai-hero { padding: 22px; border-radius: 18px; background: var(--sage-soft); }
.ai-hero strong { display: block; font-family: "Fraunces", Georgia, serif; font-size: 30px; }
.ai-hero span { color: var(--sage-dark); font-size: 13px; }
.mini-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.mini-stat { padding: 14px; border-radius: 15px; background: var(--cream-100); }
.mini-stat strong, .mini-stat span { display: block; }
.mini-stat strong { font-size: 20px; }
.mini-stat span { color: var(--muted); font-size: 11px; }

.list-stack { display: grid; gap: 3px; }
.list-row { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 5px; border-bottom: 1px solid var(--line); text-decoration: none; }
.list-row:last-child { border-bottom: 0; }
.list-row:hover strong { color: var(--terracotta-dark); }
.list-row > span:first-child { min-width: 0; }
.list-row strong, .list-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.list-value { flex: 0 0 auto; color: var(--muted); font-size: 12px; text-align: right; }

.overview-list { display: grid; gap: 8px; }
.overview-item {
    display: grid;
    min-width: 0;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid transparent;
    border-radius: 17px;
    background: var(--cream-50);
    text-decoration: none;
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.overview-item:hover { border-color: var(--terracotta-border); background: #fff8f3; transform: translateY(-1px); }
.overview-copy, .overview-aside { min-width: 0; }
.overview-copy strong, .overview-copy small, .overview-aside strong, .overview-aside small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overview-copy small, .overview-aside small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.overview-aside { max-width: 180px; text-align: right; }
.overview-aside strong { color: var(--muted); font-size: 12px; }

.record-avatar {
    display: grid;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    place-items: center;
    border-radius: 16px;
    background: var(--terracotta-soft);
    color: var(--terracotta-dark);
    font-weight: 700;
}
.record-avatar.small { width: 40px; height: 40px; flex-basis: 40px; border-radius: 13px; }
.record-avatar.recipe { background: var(--sage-soft); color: var(--sage-dark); }
.record-chevron { color: var(--terracotta); font-size: 27px; font-weight: 500; line-height: 1; }

.record-list {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow);
}
.activity-card {
    display: grid;
    min-width: 0;
    grid-template-columns: auto minmax(0, 1fr) minmax(155px, auto) auto;
    align-items: center;
    gap: 15px;
    padding: 17px 20px;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    transition: background .16s ease;
}
.activity-card:hover { background: #fffaf4; }
.activity-person, .activity-time { min-width: 0; }
.activity-person strong, .activity-person small, .activity-time strong, .activity-time small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-person small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.activity-person small + small { color: var(--sage-dark); }
.activity-time { text-align: right; }
.activity-time .badge { margin-bottom: 5px; }
.activity-time strong { font-size: 13px; }
.activity-time small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.record-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.record-card { display: flex; min-width: 0; padding: 22px; flex-direction: column; border: 1px solid rgba(217, 198, 179, .66); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.record-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.record-card-header > div { min-width: 0; }
.record-card-header h2 { margin: 3px 0 0; font-family: "DM Sans", system-ui, sans-serif; font-size: 20px; line-height: 1.25; }
.record-card-header h2 a { text-decoration: none; }
.record-card-header h2 a:hover { color: var(--terracotta-dark); }
.record-kicker, .record-id { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.record-id { flex: 0 0 auto; padding-top: 4px; }
.record-owner { display: flex; min-width: 0; align-items: center; gap: 11px; margin-top: 20px; padding: 14px; border-radius: 17px; background: var(--cream-100); }
.record-owner > span:last-child { min-width: 0; }
.record-owner a, .record-owner small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-owner a { font-weight: 700; text-decoration: none; }
.record-owner a:hover { color: var(--terracotta-dark); }
.record-owner small { color: var(--muted); font-size: 11px; }
.record-context { display: flex; flex-wrap: wrap; gap: 5px 15px; margin-top: 15px; color: var(--muted); font-size: 12px; }
.record-context a { color: var(--ink); font-weight: 700; text-decoration: none; }
.record-context a:hover { color: var(--terracotta-dark); }
.record-stats { display: grid; margin: 18px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 17px; background: var(--cream-50); }
.record-stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.record-stats > div { min-width: 0; padding: 12px; text-align: center; }
.record-stats > div + div { border-left: 1px solid var(--line); }
.record-stats dt, .record-stats dd { margin: 0; }
.record-stats dt { overflow: hidden; color: var(--muted); font-size: 10px; font-weight: 700; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.record-stats dd { margin-top: 4px; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.record-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: auto; padding-top: 18px; color: var(--muted); font-size: 11px; }
.record-footer a { flex: 0 0 auto; color: var(--terracotta-dark); font-size: 12px; font-weight: 700; text-decoration: none; }
.pagination-card { margin-top: 17px; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--white); box-shadow: var(--shadow); }
.pagination-card:empty { display: none; }

.stats-grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.usage-list, .transaction-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.usage-card, .transaction-card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--cream-50); }
.usage-card header { display: grid; min-width: 0; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 11px; }
.usage-card header > span:nth-child(2) { min-width: 0; }
.usage-card header a, .usage-card header small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-card header a { font-weight: 700; text-decoration: none; }
.usage-card header a:hover { color: var(--terracotta-dark); }
.usage-card header small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.usage-card header > strong { color: var(--terracotta-dark); font-size: 16px; white-space: nowrap; }
.usage-card .record-stats { margin-top: 14px; }
.transaction-panel { margin-bottom: 0; }
.transaction-card { display: grid; gap: 14px; }
.transaction-card header, .transaction-card footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.transaction-card header > div { min-width: 0; }
.transaction-card header strong, .transaction-card header small { display: block; }
.transaction-card header small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.transaction-people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.transaction-people span { min-width: 0; padding: 10px 11px; border-radius: 13px; background: var(--white); }
.transaction-people small, .transaction-people a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transaction-people small { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.transaction-people a { margin-top: 2px; font-size: 12px; font-weight: 700; text-decoration: none; }
.transaction-card footer { padding-top: 11px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.transaction-card footer strong { color: var(--ink); font-size: 15px; }
.transaction-panel > .pagination { margin: 18px -25px -25px; }

.filter-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 11px; margin-bottom: 20px; padding: 17px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.74); }
.filter-field { display: grid; min-width: 160px; gap: 5px; }
.filter-field.grow { min-width: 230px; flex: 1 1 270px; }
.filter-field span, .form-stack label > span { color: var(--muted); font-size: 12px; font-weight: 700; }
input, select { width: 100%; min-height: 50px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 16px; outline: none; background: var(--cream-50); color: var(--ink); }
input:focus, select:focus { border-color: var(--terracotta); box-shadow: 0 0 0 3px rgba(198,95,66,.12); }

.button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; padding: 10px 18px; border: 1px solid transparent; border-radius: 16px; cursor: pointer; font-weight: 700; text-decoration: none; }
.button-primary { background: var(--terracotta); color: white; box-shadow: 0 7px 17px rgba(159,67,46,.16); }
.button-primary:hover { background: var(--terracotta-dark); }
.button-secondary { border-color: var(--terracotta-border); background: var(--terracotta-soft); color: var(--terracotta-dark); }
.button-full { width: 100%; }

.table-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 17px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #fffaf2; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fffdf9; }
td a { color: var(--ink); font-weight: 700; text-decoration: none; }
td a:hover { color: var(--terracotta-dark); }
.cell-title strong, .cell-title small { display: block; }
.cell-title small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.number-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 99px; background: var(--cream-200); color: #6f5e50; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-green { background: var(--sage-soft); color: var(--sage-dark); }
.badge-orange { background: var(--terracotta-soft); color: var(--terracotta-dark); }
.badge-red { background: #f4d9d5; color: var(--danger); }
.badge-gray { background: #ece9e5; color: #67615d; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pagination a { color: var(--terracotta-dark); font-weight: 700; text-decoration: none; }
.pagination-disabled { opacity: .48; }

.empty-state { padding: 48px 22px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--ink); font-family: "Fraunces", Georgia, serif; font-size: 21px; }

.detail-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.back-link { display: inline-block; margin-bottom: 11px; color: var(--terracotta-dark); font-size: 13px; font-weight: 700; text-decoration: none; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .7fr); gap: 20px; }
.definition-list { display: grid; grid-template-columns: minmax(120px, .65fr) 1.4fr; margin: 0; }
.definition-list dt, .definition-list dd { margin: 0; padding: 11px 0; border-bottom: 1px solid var(--line); }
.definition-list dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.definition-list dd { text-align: right; word-break: break-word; }
.definition-list a { color: var(--terracotta-dark); font-weight: 700; text-decoration: none; }
.content-copy { color: #544d48; white-space: pre-line; }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; }
.ingredient-list, .steps-list { margin: 0; padding: 0; list-style: none; }
.ingredient-list li { display: grid; grid-template-columns: minmax(90px, auto) 1fr; gap: 13px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.ingredient-list li:last-child, .steps-list li:last-child { border-bottom: 0; }
.ingredient-amount { color: var(--terracotta-dark); font-weight: 700; }
.steps-list { counter-reset: steps; }
.steps-list li { position: relative; min-height: 46px; padding: 11px 0 11px 50px; border-bottom: 1px solid var(--line); counter-increment: steps; }
.steps-list li::before { position: absolute; left: 0; top: 8px; display: grid; width: 32px; height: 32px; place-items: center; border-radius: 11px; background: var(--terracotta-soft); color: var(--terracotta-dark); content: counter(steps); font-weight: 700; }

.progress { overflow: hidden; height: 10px; border-radius: 99px; background: var(--cream-200); }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--terracotta); }
.budget-row { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 8px; font-size: 13px; }

.flash-message { margin-bottom: 20px; padding: 13px 16px; border: 1px solid #cbd8bf; border-radius: 14px; background: var(--sage-soft); color: var(--sage-dark); }
.field-error { margin: 0; color: var(--danger); font-size: 13px; }

.login-page { display: grid; min-height: 100vh; padding: 24px; place-items: center; background: radial-gradient(circle at 20% 20%, #f9dfd1 0, transparent 32%), radial-gradient(circle at 84% 78%, #dfe8d7 0, transparent 28%), var(--cream-100); }
.login-card { width: min(100%, 470px); padding: clamp(29px, 6vw, 48px); border: 1px solid rgba(217,198,179,.7); border-radius: 30px; background: rgba(255,255,255,.92); box-shadow: 0 24px 80px rgba(85,60,43,.14); }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand strong { font-family: "Fraunces", Georgia, serif; font-size: 24px; }
.login-brand small { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.login-copy { margin: 43px 0 27px; }
.login-copy p { margin-bottom: 0; color: var(--muted); }
.form-stack { display: grid; gap: 15px; }
.form-stack label { display: grid; gap: 6px; }
.login-note { margin: 22px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 1180px) {
    .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .stats-grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-two, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
    .sidebar {
        position: fixed;
        inset: auto 10px max(10px, env(safe-area-inset-bottom)) 10px;
        z-index: 40;
        width: auto;
        padding: 7px;
        border: 1px solid rgba(217, 162, 140, .36);
        border-radius: 25px;
        background: rgba(255, 253, 252, .88);
        box-shadow: 0 12px 34px rgba(78, 52, 37, .18);
        color: var(--muted);
        -webkit-backdrop-filter: saturate(180%) blur(22px);
        backdrop-filter: saturate(180%) blur(22px);
    }
    .sidebar > .brand, .sidebar-footer { display: none; }
    .main-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; margin: 0; }
    .main-nav a {
        min-width: 0;
        min-height: 57px;
        flex-direction: column;
        justify-content: center;
        gap: 3px;
        padding: 5px 2px 4px;
        border-radius: 18px;
        color: var(--muted);
        font-size: 10px;
        line-height: 1.1;
        text-align: center;
    }
    .main-nav a:hover, .main-nav a.active { background: rgba(244, 222, 212, .82); color: var(--terracotta-dark); }
    .main-nav a.active .nav-icon { color: var(--terracotta); }
    .nav-icon { width: 23px; height: 23px; flex-basis: 23px; color: currentColor; }
    .nav-icon svg { width: 22px; height: 22px; stroke-width: 1.9; }
    .nav-label { overflow: hidden; max-width: 100%; text-overflow: ellipsis; white-space: nowrap; }
    .nav-label-full { display: none; }
    .nav-label-compact { display: block; }
    .workspace { margin-left: 0; }
    .mobile-header {
        position: sticky;
        top: 0;
        z-index: 30;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: max(11px, env(safe-area-inset-top)) 16px 11px;
        border-bottom: 1px solid rgba(230, 216, 197, .82);
        background: rgba(248, 241, 228, .9);
        color: var(--ink);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        backdrop-filter: saturate(180%) blur(20px);
    }
    .mobile-header .brand-mark { width: 38px; height: 38px; flex-basis: 38px; border-radius: 13px; }
    .mobile-header .brand strong { font-size: 20px; }
    .mobile-header-actions { display: flex; align-items: center; gap: 10px; }
    .mobile-header-actions form { margin: 0; }
    .mobile-admin-label { padding: 4px 8px; border-radius: 99px; background: var(--sage-soft); color: var(--sage-dark); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
    .mobile-logout-button { min-height: 44px; padding: 8px 12px; border: 1px solid var(--terracotta-border); border-radius: 14px; background: var(--terracotta-soft); color: var(--terracotta-dark); cursor: pointer; font-size: 11px; font-weight: 700; }
    .mobile-logout-button:hover { background: #ecd0c3; }
    .page-content { padding: 25px 16px calc(104px + env(safe-area-inset-bottom)); }
    .page-header, .detail-header { align-items: flex-start; flex-direction: column; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-card { min-height: 118px; padding: 18px; }
    .stat-value { font-size: 29px; }
    .grid-even { grid-template-columns: 1fr; }
    .record-grid, .usage-list, .transaction-list { grid-template-columns: 1fr; }
    .panel { padding: 19px; }
    .activity-chart { gap: 4px; }
    .activity-day small { font-size: 8px; transform: rotate(-45deg); }
    .table-card { border-radius: 17px; }
    th, td { padding: 13px 14px; }
    .definition-list { grid-template-columns: 1fr; }
    .definition-list dt { padding-bottom: 0; border-bottom: 0; }
    .definition-list dd { padding-top: 3px; text-align: left; }
    .transaction-panel > .pagination { margin: 18px -19px -19px; }
}

@media (max-width: 480px) {
    h1 { font-size: 31px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
    .stats-grid .stat-card:last-child { grid-column: 1 / -1; }
    .stats-grid-two .stat-card:last-child { grid-column: auto; }
    .overview-item { grid-template-columns: auto minmax(0, 1fr) auto; }
    .overview-aside { grid-column: 2; max-width: none; text-align: left; }
    .overview-item .record-chevron { grid-column: 3; grid-row: 1 / span 2; }
    .activity-card { grid-template-columns: auto minmax(0, 1fr) auto; gap: 11px; padding: 15px; }
    .activity-time { grid-column: 2; text-align: left; }
    .activity-time .badge { margin-right: 6px; margin-bottom: 0; }
    .activity-time strong { display: inline; }
    .activity-time small { margin-top: 3px; }
    .activity-card .record-chevron { grid-column: 3; grid-row: 1 / span 2; }
    .record-card { padding: 18px; }
    .record-footer { align-items: flex-start; flex-direction: column; gap: 7px; }
    .usage-card { padding: 14px; }
    .usage-card header { grid-template-columns: auto minmax(0, 1fr); }
    .usage-card header > strong { grid-column: 2; }
    .transaction-people { grid-template-columns: 1fr; }
    .filter-field, .filter-field.grow { width: 100%; min-width: 0; flex-basis: 100%; }
    .filter-bar .button { flex: 1; }
    .pagination { font-size: 11px; }
    .pagination > span:nth-child(2) { display: none; }
    .ingredient-list li { grid-template-columns: 1fr; gap: 2px; }
}

@media (max-width: 370px) {
    .main-nav a { font-size: 9px; }
    .mobile-admin-label { display: none; }
}
