:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #fff;
  --surface-low: #f7f9fc;
  --line: #dce2eb;
  --line-soft: #edf0f5;
  --text: #17202a;
  --muted: #687386;
  --primary: #245ee9;
  --primary-dark: #1948c2;
  --primary-soft: #eaf0ff;
  --danger: #be3030;
  --danger-soft: #fff0f0;
  --shadow: 0 24px 80px rgba(24, 41, 75, .18);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-width: 900px; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }
.material-symbols-rounded { font-size: 21px; line-height: 1; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 80px; padding: 0 28px;
  display: grid; grid-template-columns: 220px minmax(300px, 520px) 1fr;
  align-items: center; gap: 28px;
  background: rgba(247, 249, 252, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  color: white; background: var(--primary); border-radius: 11px;
  box-shadow: 0 8px 18px rgba(36, 94, 233, .22);
}
.search { position: relative; display: flex; align-items: center; }
.search > span { position: absolute; left: 13px; color: #8791a2; }
.search input {
  width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 11px;
  padding: 0 54px 0 43px; outline: none; background: white; color: var(--text);
  transition: .2s ease;
}
.search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search kbd {
  position: absolute; right: 10px; padding: 3px 7px; color: #798498; background: var(--surface-low);
  border: 1px solid var(--line); border-radius: 6px; font: 11px Inter, sans-serif;
}
.toolbar { justify-self: end; display: flex; align-items: center; gap: 9px; }
.user-menu { margin-left: 7px; padding-left: 15px; border-left: 1px solid var(--line); display: flex; align-items: center; gap: 9px; }
.user-menu > img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.user-menu > span { color: var(--muted); font-size: 34px; }
.user-menu > div { max-width: 130px; display: flex; flex-direction: column; }
.user-menu strong, .user-menu small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu strong { font-size: 11px; }
.user-menu small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.logout-link { width: 31px; height: 31px; display: grid; place-items: center; color: var(--muted); border-radius: 8px; text-decoration: none; }
.logout-link:hover { color: var(--danger); background: var(--danger-soft); }
.button {
  height: 40px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  color: var(--text); background: white; font-weight: 600; font-size: 13px;
  transition: transform .15s, background .15s, border .15s, opacity .15s;
}
.button:not(:disabled):active { transform: scale(.97); }
.button:disabled { cursor: not-allowed; opacity: .38; }
.button-primary { color: white; background: var(--primary); box-shadow: 0 5px 13px rgba(36, 94, 233, .15); }
.button-primary:hover { background: var(--primary-dark); }
.button-outline { color: var(--primary); border-color: #97aff0; background: transparent; }
.button-outline:hover { background: var(--primary-soft); }
.button-danger { color: var(--danger); border-color: #f2c9c9; background: var(--danger-soft); }
.button-danger:hover { background: #ffe5e5; }
.button-backup { color: #47566c; border-color: var(--line); background: white; }
.button-backup:hover { color: var(--primary); border-color: #afbfeb; background: var(--primary-soft); }
.button-backup.is-loading { cursor: wait; }
.button-backup.is-loading .material-symbols-rounded { animation: backup-spin 1s linear infinite; }
@keyframes backup-spin { to { transform: rotate(360deg); } }
.button-ghost { border-color: var(--line); }
.button-ghost:hover { background: var(--surface-low); }

main { padding: 28px; }
.page-heading { max-width: 1500px; margin: 0 auto 19px; display: flex; align-items: end; justify-content: space-between; }
.eyebrow { margin: 0 0 5px; color: var(--primary); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: -.03em; }
h1 { font-size: 26px; }
.count {
  display: inline-grid; place-items: center; min-width: 28px; height: 25px; margin-left: 7px; padding: 0 8px;
  color: var(--primary); background: var(--primary-soft); border-radius: 20px; font-size: 12px; vertical-align: 4px;
}
.today { margin: 0; color: var(--muted); font-size: 13px; text-transform: capitalize; }
.table-card {
  max-width: 1500px; min-height: 360px; margin: auto; background: white;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 5px 20px rgba(40, 56, 83, .035);
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
thead { background: var(--surface-low); border-bottom: 1px solid var(--line); }
th {
  height: 48px; padding: 0 16px; color: #667185; text-align: left;
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
}
th:nth-child(2) { width: 31%; }
th:nth-child(3) { width: 25%; }
th:nth-child(4) { width: 26%; }
.photo-column { width: 82px; }
.select-column { width: 58px; text-align: center; }
tbody tr { height: 82px; border-bottom: 1px solid var(--line-soft); transition: background .15s; }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover, tbody tr.selected { background: #f8faff; }
td { padding: 14px 16px; vertical-align: middle; }
td:last-child { text-align: center; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  color: #24406c; background: linear-gradient(135deg, #dce7ff, #e9e0fa);
  border: 2px solid white; box-shadow: 0 0 0 1px var(--line); font-weight: 700;
}
.avatar-photo { display: block; object-fit: cover; }
.patient-link { padding: 0; border: 0; background: none; color: var(--primary); font-weight: 650; font-size: 15px; text-align: left; }
.patient-link:hover { text-decoration: underline; }
.contact { margin: 5px 0 0; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.measurement { color: #515d70; }
.prescriptions { display: flex; align-items: center; gap: 7px; }
.prescription {
  width: 42px; height: 42px; border-radius: 8px; border: 1px solid var(--line);
  background: linear-gradient(145deg, #eef2f9, #fff); display: grid; place-items: center; color: #738096;
}
.prescription-thumb { padding: 0; overflow: hidden; cursor: zoom-in; }
.prescription-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .2s; }
.prescription-thumb:hover img { transform: scale(1.07); }
.prescription-count { margin-left: 3px; color: var(--muted); font-size: 12px; }
.checkbox { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-state > span { font-size: 46px; color: #9aabc5; }
.empty-state h2 { margin-top: 10px; color: var(--text); font-size: 18px; }
.empty-state p { margin: 7px 0 0; }

.modal-layer { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.modal-layer[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; border: 0; background: rgba(20, 27, 40, .42); backdrop-filter: blur(5px); }
.modal {
  position: relative; z-index: 1; width: min(720px, 100%); max-height: calc(100vh - 48px);
  background: white; border: 1px solid rgba(255,255,255,.7); border-radius: 18px;
  box-shadow: var(--shadow); overflow: auto; animation: modal-in .18s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal-header { padding: 22px 24px; display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-header h2 { font-size: 22px; }
.icon-button {
  width: 38px; height: 38px; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-low); color: #536075;
}
.icon-button:hover { background: #edf1f7; }
.patient-modal { width: min(790px, 100%); }
.patient-content { padding: 24px; display: grid; grid-template-columns: 190px 1fr; gap: 26px; }
.profile-side { display: flex; flex-direction: column; gap: 14px; }
.profile-avatar {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 14px;
  color: #274575; background: linear-gradient(145deg, #dce7ff, #eee4fa); font-size: 48px; font-weight: 700;
}
.profile-photo { display: block; width: 100%; object-fit: cover; }
.visit-card { padding: 13px; background: var(--surface-low); border-radius: 10px; }
.label { display: block; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.visit-card strong { display: block; margin-top: 5px; font-size: 12px; }
.details { display: flex; flex-direction: column; gap: 22px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 19px; }
.detail-wide { grid-column: 1 / -1; }
.detail-value { margin: 5px 0 0; font-size: 14px; word-break: break-word; }
.detail-name { font-size: 17px; font-weight: 650; }
.measurement-box {
  margin-top: 7px; padding: 13px; display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface-low); font-weight: 600;
}
.measurement-box span { color: var(--primary); }
.recipe-section { padding-top: 20px; border-top: 1px solid var(--line); }
.visits-section { padding-top: 20px; border-top: 1px solid var(--line); }
.visits-heading { display: flex; align-items: center; justify-content: space-between; }
.visits-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.visit-item { position: relative; padding: 12px 38px 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-low); }
.visit-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.visit-top strong { font-size: 12px; }
.visit-date { color: var(--primary); font-size: 10px; font-weight: 700; white-space: nowrap; }
.visit-notes { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; white-space: pre-line; }
.visit-measurement { margin-top: 8px; padding: 7px 9px; display: flex; align-items: center; gap: 7px; color: #344156; background: white; border: 1px solid var(--line); border-radius: 7px; font-size: 11px; font-weight: 600; }
.visit-measurement span { color: var(--primary); font-size: 17px; }
.delete-visit { position: absolute; top: 8px; right: 7px; width: 27px; height: 27px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 7px; color: #8b95a5; background: transparent; }
.delete-visit:hover { color: var(--danger); background: var(--danger-soft); }
.delete-visit span { font-size: 17px; }
.no-visits { margin: 0; padding: 16px; color: var(--muted); background: var(--surface-low); border-radius: 9px; text-align: center; font-size: 12px; }
.recipe-grid { display: flex; gap: 9px; margin-top: 11px; }
.recipe-heading { display: flex; align-items: center; justify-content: space-between; }
.text-button { padding: 0; border: 0; color: var(--primary); background: none; font-size: 12px; font-weight: 600; }
.recipe-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.recipe-photo { position: relative; aspect-ratio: 4 / 3; margin: 0; }
.recipe-preview { width: 100%; height: 100%; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-low); }
.recipe-preview img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .2s; }
.recipe-preview:hover img { transform: scale(1.04); }
.remove-photo {
  position: absolute; top: 5px; right: 5px; width: 25px; height: 25px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 50%; color: white; background: rgba(25, 28, 34, .72);
}
.remove-photo span { font-size: 17px; }
.no-recipes { grid-column: 1 / -1; margin: 0; padding: 18px; color: var(--muted); background: var(--surface-low); border-radius: 9px; text-align: center; font-size: 12px; }
.recipe-large {
  width: 72px; height: 72px; display: grid; place-items: center; color: #7a879a;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-low);
}
.recipe-large span { font-size: 27px; }
.modal-footer {
  padding: 17px 24px; display: flex; justify-content: flex-end; gap: 10px;
  background: var(--surface-low); border-top: 1px solid var(--line);
}
.form-modal { width: min(600px, 100%); }
.form-grid { padding: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-wide { grid-column: 1 / -1; }
.field span { color: #4f5b6e; font-size: 12px; font-weight: 600; }
.field .optional-label { margin-left: 5px; color: #929baa; font-size: 9px; font-weight: 500; text-transform: uppercase; }
.field .field-hint { color: var(--muted); font-size: 10px; font-weight: 400; line-height: 1.45; }
.field input {
  width: 100%; height: 43px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 9px; outline: none; color: var(--text);
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field textarea { width: 100%; padding: 11px 12px; resize: vertical; border: 1px solid var(--line); border-radius: 9px; outline: none; color: var(--text); line-height: 1.5; }
.field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.visit-modal { width: min(520px, 100%); }
.upload-field input { height: auto; padding: 10px; background: var(--surface-low); }
.upload-field input::file-selector-button {
  margin-right: 12px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 7px;
  color: var(--primary); background: white; font-weight: 600; cursor: pointer;
}
.upload-field small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.loading { height: 160px; color: var(--muted); text-align: center; }
.error-text { color: var(--danger); }
.toast {
  position: fixed; z-index: 80; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  padding: 11px 16px; color: white; background: #263142; border-radius: 9px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transition: .2s ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

.lightbox { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 38px; }
.lightbox[hidden] { display: none; }
.lightbox-backdrop { position: absolute; inset: 0; border: 0; background: rgba(10, 15, 25, .82); backdrop-filter: blur(8px); }
.lightbox-content { position: relative; z-index: 1; max-width: min(1100px, 92vw); max-height: 88vh; animation: lightbox-in .18s ease-out; }
.lightbox-content img {
  display: block; max-width: 100%; max-height: 88vh; object-fit: contain;
  border-radius: 12px; background: white; box-shadow: 0 24px 90px rgba(0, 0, 0, .45);
}
.lightbox-close {
  position: absolute; top: -17px; right: -17px; width: 38px; height: 38px;
  padding: 0; display: grid; place-items: center; color: white; background: #273142;
  border: 2px solid rgba(255,255,255,.75); border-radius: 50%; box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.lightbox-close:hover { background: var(--primary); }
@keyframes lightbox-in { from { opacity: 0; transform: scale(.97); } }

@media (max-width: 1120px) {
  .topbar { grid-template-columns: 180px minmax(260px, 1fr) auto; gap: 16px; padding: 0 20px; }
  .toolbar .button { width: 40px; padding: 0; font-size: 0; }
  main { padding: 22px 20px; }
}

.login-page { min-width: 320px; overflow: hidden; }
.login-shell { min-height: 100vh; padding: 0; display: grid; grid-template-columns: minmax(440px, 1.08fr) minmax(430px, .92fr); }
.login-visual {
  position: relative; overflow: hidden; padding: 42px 52px; display: flex; flex-direction: column;
  color: white; background: linear-gradient(145deg, #143896 0%, #245ee9 56%, #5486ff 100%);
}
.login-visual::before, .login-visual::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; }
.login-visual::before { width: 540px; height: 540px; right: -180px; top: -200px; }
.login-visual::after { width: 380px; height: 380px; left: -180px; bottom: -170px; }
.login-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 11px; font-size: 16px; font-weight: 700; }
.login-brand .brand-mark { color: var(--primary); background: white; }
.visual-content { position: relative; z-index: 1; width: min(540px, 90%); margin: auto 0; }
.visual-content .eyebrow { color: #d9e4ff; }
.visual-content h1 { margin-top: 13px; font-size: clamp(38px, 4vw, 58px); line-height: 1.08; letter-spacing: -.055em; }
.visual-content > p:not(.eyebrow) { max-width: 470px; margin: 23px 0 0; color: #dce6ff; font-size: 16px; line-height: 1.65; }
.visual-card { width: fit-content; margin-top: 35px; padding: 15px 18px; display: flex; align-items: center; gap: 13px; background: rgba(255,255,255,.11); border: 1px solid rgba(255,255,255,.2); border-radius: 13px; backdrop-filter: blur(10px); }
.visual-card > span { font-size: 27px; }
.visual-card div { display: flex; flex-direction: column; gap: 4px; }
.visual-card strong { font-size: 12px; }
.visual-card small { color: #dbe5ff; font-size: 10px; }
.login-domain { position: relative; z-index: 1; margin: 0; color: #c7d7ff; font-size: 11px; letter-spacing: .05em; }
.login-panel { display: grid; place-items: center; padding: 40px; background: white; }
.login-form-card { width: min(380px, 100%); text-align: center; }
.login-icon { width: 52px; height: 52px; margin: 0 auto 25px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 15px; font-size: 26px; }
.login-form-card h2 { font-size: 29px; }
.login-description { margin: 12px auto 27px; color: var(--muted); line-height: 1.6; }
.google-button { min-height: 44px; display: flex; justify-content: center; }
.login-error { margin: 0 0 18px; padding: 11px 13px; color: var(--danger); background: var(--danger-soft); border: 1px solid #f2cece; border-radius: 9px; font-size: 12px; line-height: 1.5; }
.privacy-note { margin: 24px auto 0; display: flex; justify-content: center; align-items: center; gap: 6px; color: #8992a1; font-size: 10px; }
.privacy-note span { font-size: 16px; }
@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; padding: 28px; }
}

@media (max-width: 760px) {
  html, body { min-width: 0; }
  body { font-size: 13px; }

  .topbar {
    position: sticky; height: auto; min-height: 126px; padding: 12px 14px;
    grid-template-columns: 1fr auto; grid-template-areas: "brand toolbar" "search search";
    gap: 11px 12px;
  }
  .brand { grid-area: brand; font-size: 14px; }
  .brand-mark { width: 35px; height: 35px; border-radius: 10px; }
  .search { grid-area: search; }
  .search input { height: 42px; }
  .search kbd { display: none; }
  .toolbar { grid-area: toolbar; gap: 5px; }
  .toolbar .button {
    width: 35px; height: 35px; padding: 0; border-radius: 9px;
    font-size: 0; box-shadow: none;
  }
  .toolbar .button .material-symbols-rounded { font-size: 19px; }
  .user-menu { margin-left: 2px; padding-left: 7px; gap: 3px; }
  .user-menu > img { width: 31px; height: 31px; }
  .user-menu > span { font-size: 31px; }
  .user-menu > div { display: none; }
  .logout-link { width: 29px; height: 31px; }

  main { padding: 18px 12px 28px; }
  .page-heading { margin-bottom: 14px; align-items: center; }
  .page-heading h1 { font-size: 23px; }
  .today { display: none; }

  .table-card { min-height: 0; border: 0; background: transparent; box-shadow: none; overflow: visible; }
  .table-wrap { overflow: visible; }
  table, tbody { display: block; width: 100%; }
  thead { display: none; }
  tbody { display: flex; flex-direction: column; gap: 10px; }
  tbody tr {
    position: relative; width: 100%; min-height: 0; height: auto; padding: 15px;
    display: grid; grid-template-columns: 56px minmax(0, 1fr) 24px;
    grid-template-rows: auto auto auto; column-gap: 12px; row-gap: 12px;
    background: white; border: 1px solid var(--line); border-radius: 13px;
    box-shadow: 0 4px 14px rgba(40, 56, 83, .04);
  }
  tbody tr:last-child { border-bottom: 1px solid var(--line); }
  tbody tr.selected { border-color: #aabcf0; background: #f7f9ff; }
  td { padding: 0; min-width: 0; }
  td:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; }
  td:nth-child(2) { grid-column: 2; grid-row: 1; align-self: center; }
  td:nth-child(3) {
    grid-column: 2 / 4; grid-row: 2; padding-top: 9px;
    border-top: 1px solid var(--line-soft); font-size: 12px;
  }
  td:nth-child(3)::before {
    content: "Измерение"; display: block; margin-bottom: 4px;
    color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  }
  td:nth-child(4) { grid-column: 1 / 4; grid-row: 3; }
  td:nth-child(4)::before {
    content: "Рецепты"; display: block; margin-bottom: 7px;
    color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  }
  td:nth-child(5) { position: absolute; top: 15px; right: 14px; }
  .avatar { width: 52px; height: 52px; }
  .patient-link { max-width: calc(100% - 20px); font-size: 14px; }
  .contact { margin-top: 5px; padding-right: 7px; font-size: 10px; white-space: normal; line-height: 1.5; }
  .prescription { width: 48px; height: 48px; }
  .prescription-count { margin-left: 5px; }
  .empty-state { padding: 50px 15px; background: white; border: 1px solid var(--line); border-radius: 13px; }

  .modal-layer { align-items: end; padding: 0; }
  .modal {
    width: 100%; max-width: none; max-height: 94dvh; border-radius: 18px 18px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0;
  }
  .modal-header { position: sticky; top: 0; z-index: 3; padding: 17px 18px; background: white; }
  .modal-header h2 { font-size: 20px; }
  .patient-content { padding: 18px; grid-template-columns: 1fr; gap: 20px; }
  .profile-side { display: grid; grid-template-columns: 108px 1fr; align-items: stretch; gap: 12px; }
  .profile-avatar { width: 108px; height: 108px; font-size: 34px; }
  .visit-card { display: flex; flex-direction: column; justify-content: center; }
  .details { gap: 19px; }
  .detail-grid { gap: 16px 13px; }
  .detail-value { font-size: 12px; }
  .detail-name { font-size: 16px; }
  .measurement-box { padding: 11px; font-size: 12px; }
  .recipe-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-footer {
    position: sticky; bottom: 0; z-index: 3; padding: 13px 16px;
    padding-bottom: max(13px, env(safe-area-inset-bottom)); background: rgba(247,249,252,.96);
    backdrop-filter: blur(12px);
  }
  .modal-footer .button { min-width: 0; padding: 0 13px; }
  .form-grid { padding: 18px; grid-template-columns: 1fr; gap: 15px; }
  .field, .field-wide { grid-column: 1; }
  .field input { font-size: 16px; }
  .field textarea { font-size: 16px; }
  .visits-list { gap: 9px; }
  .visit-top { padding-right: 5px; flex-direction: column; align-items: flex-start; gap: 4px; }

  .lightbox { padding: 18px; }
  .lightbox-content { max-width: 100%; max-height: 86dvh; }
  .lightbox-content img { max-height: 86dvh; border-radius: 9px; }
  .lightbox-close { top: -12px; right: -8px; }
  .toast { width: max-content; max-width: calc(100vw - 28px); bottom: 18px; text-align: center; }
}

@media (max-width: 390px) {
  .brand > span:last-child { display: none; }
  .toolbar { gap: 4px; }
  .toolbar .button { width: 33px; height: 33px; }
  .user-menu { padding-left: 4px; }
  .modal-footer { flex-wrap: wrap; }
}
