:root {
  color-scheme: dark;
  --bg: #062f86;
  --bg-deep: #041743;
  --surface: #f5f9ff;
  --surface-strong: #ffffff;
  --text: #10243b;
  --muted: #5d7189;
  --line: #b8d0ec;
  --primary: rgb(11, 114, 255);
  --primary-strong: #0759c8;
  --primary-soft: #d8e9ff;
  --blue-warm: #4aa3ff;
  --medical-red: #e22435;
  --danger: #b43b34;
  --warning: #c98219;
  --ok: #2b7a6b;
  --shadow: 0 22px 52px rgba(3, 15, 45, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

body > *,
main,
main > * {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 7%, rgba(71, 169, 255, 0.70) 0 58px, transparent 150px),
    radial-gradient(circle at 74% 0%, rgba(11, 114, 255, 0.54) 0 80px, transparent 260px),
    radial-gradient(circle at 92% 18%, rgba(255, 255, 255, 0.18) 0 18px, transparent 90px),
    linear-gradient(145deg, #0b72ff 0%, #06358f 42%, var(--bg-deep) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px max(18px, env(safe-area-inset-left)) 14px max(18px, env(safe-area-inset-right));
  background: rgba(3, 19, 57, 0.74);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(12px);
}

.brand-cluster,
.brand {
  display: flex;
  align-items: center;
}

.brand-cluster {
  gap: 14px;
  min-width: 0;
  flex-wrap: wrap;
}

.brand {
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: 0 6px 18px rgba(11, 114, 255, 0.22);
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

.brand strong {
  color: white;
}

.brand small {
  color: #b9d9ff;
  font-size: 12px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  max-width: 260px;
  padding: 6px 10px 6px 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.user-chip small,
.user-chip strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip small {
  color: #b9d9ff;
  font-size: 11px;
}

.user-chip strong {
  font-size: 14px;
}

.user-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, var(--primary), var(--medical-red));
  color: white;
  font-weight: 850;
}

.top-actions,
.locale-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions {
  margin-left: auto;
}

.locale-switcher a {
  display: grid;
  min-width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #d4e7ff;
  font-size: 20px;
}

.locale-switcher a.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.shell {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 24px 18px 64px;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  gap: 30px;
  align-items: start;
  margin-top: 36px;
}

.auth-intro {
  position: relative;
  min-height: 420px;
  padding: 28px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 255, 255, 0.22), transparent 130px),
    linear-gradient(145deg, rgba(11, 114, 255, 0.82), rgba(4, 23, 67, 0.94));
  box-shadow: var(--shadow);
}

.auth-intro h1,
.auth-intro p {
  position: relative;
  z-index: 2;
  color: white;
}

.auth-intro p {
  color: #d5e8ff;
}

.auth-panel .auth-intro p {
  color: #ffffff;
}

.photo-strip {
  position: absolute;
  right: 26px;
  bottom: 34px;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 112px);
  gap: 12px;
  align-items: end;
}

.auth-medical-scene {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 34px;
  z-index: 2;
  display: grid;
  grid-template-columns: 78px 104px repeat(3, 112px);
  gap: 12px;
  align-items: end;
}

.scene-kit {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  border-radius: 8px;
  background: var(--medical-red);
  color: white;
  font-size: 48px;
  font-weight: 900;
  box-shadow: 0 18px 32px rgba(1, 10, 33, 0.28);
}

.scene-pill {
  position: absolute;
  width: 58px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffffff 0 49%, var(--medical-red) 50% 100%);
  box-shadow: 0 12px 20px rgba(1, 10, 33, 0.24);
}

.scene-pill-one {
  left: 100px;
  bottom: 19px;
  transform: rotate(-18deg);
}

.scene-pill-two {
  left: 145px;
  bottom: 35px;
  transform: rotate(-16deg);
}

.scene-pill-three {
  left: 188px;
  bottom: 21px;
  background: linear-gradient(90deg, #ffffff 0 49%, var(--primary) 50% 100%);
  transform: rotate(18deg);
}

.scene-tile {
  position: relative;
  display: block;
  width: 112px;
  height: 112px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background:
    radial-gradient(circle at 64% 18%, rgba(255, 255, 255, 0.16), transparent 42px),
    rgba(255, 255, 255, 0.07);
  box-shadow: 0 18px 32px rgba(1, 10, 33, 0.30);
}

.scene-tile i,
.scene-tile::before {
  position: absolute;
  content: "";
  border-radius: 999px;
  background: linear-gradient(90deg, #ffffff 0 49%, var(--primary) 50% 100%);
  box-shadow: 0 10px 18px rgba(1, 10, 33, 0.20);
}

.scene-tile i {
  left: 25px;
  top: 44px;
  width: 68px;
  height: 25px;
  transform: rotate(28deg);
}

.scene-tile::before {
  left: 36px;
  top: 58px;
  width: 48px;
  height: 18px;
  background: linear-gradient(90deg, #ffffff 0 49%, var(--medical-red) 50% 100%);
  transform: rotate(-20deg);
}

.photo-card {
  position: relative;
  display: block;
  width: 112px;
  height: 112px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background-position: center;
  background-size: cover;
  box-shadow: 0 18px 32px rgba(1, 10, 33, 0.32);
}

.photo-card::before,
.photo-card::after {
  content: "";
  position: absolute;
  left: 24px;
  top: 44px;
  width: 64px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffffff 0 49%, var(--medical-red) 50% 100%);
  box-shadow: 0 12px 20px rgba(1, 10, 33, 0.25);
  transform: rotate(-24deg);
}

.photo-card::after {
  left: 44px;
  top: 34px;
  width: 48px;
  height: 18px;
  background: linear-gradient(90deg, #ffffff 0 49%, var(--primary) 50% 100%);
  transform: rotate(28deg);
}

.photo-medkit {
  background-image:
    linear-gradient(135deg, rgba(226, 36, 53, 0.88), rgba(154, 0, 22, 0.70)),
    url("../images/medkit-red.jpg");
}

.photo-lab {
  background-image:
    linear-gradient(135deg, rgba(11, 114, 255, 0.38), rgba(4, 23, 67, 0.62)),
    url("../images/lab-pills.jpg");
}

.photo-cabinet {
  background-image:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(4, 23, 67, 0.46)),
    url("../images/medicine-cabinet.jpg");
}

.medical-motif::before,
.medical-motif::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  transform: rotate(-28deg);
  opacity: 0.85;
}

.medical-motif::before,
.medical-motif::after,
.motif-row,
.photo-strip {
  display: none;
}

.medical-motif::before {
  right: 250px;
  bottom: 42px;
  width: 118px;
  height: 44px;
  background:
    linear-gradient(90deg, #ffffff 0 49%, rgba(11, 114, 255, 0.88) 50% 100%);
  border: 1px solid rgba(7, 89, 200, 0.18);
}

.medical-motif::after {
  right: 284px;
  bottom: 104px;
  width: 86px;
  height: 34px;
  background:
    linear-gradient(90deg, rgba(244, 92, 76, 0.92) 0 50%, #ffffff 51% 100%);
  border: 1px solid rgba(16, 36, 59, 0.12);
}

.motif-row {
  position: absolute;
  left: 28px;
  bottom: 34px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.motif-row span:first-child,
.empty-icon {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  border-radius: 8px;
  background: var(--medical-red);
  color: white;
  font-size: 48px;
  font-weight: 800;
}

.motif-row span:not(:first-child) {
  width: 42px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: inset 18px 0 0 rgba(244, 92, 76, 0.92);
  transform: rotate(-20deg);
}

h1 {
  margin: 0 0 6px;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.05;
}

.auth-panel p,
.page-head p,
.medicine-main p,
.form-note {
  margin: 0;
  color: var(--muted);
}

.notification-panel,
.catalog-update-panel {
  display: grid;
  gap: 6px;
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(229, 241, 255, 0.94);
  color: var(--text);
  box-shadow: var(--shadow);
}

.notification-panel p {
  margin: 0;
  font-weight: 750;
}

.catalog-update-panel {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.catalog-update-panel span {
  color: var(--muted);
}

.catalog-update-panel a {
  color: var(--primary);
  font-weight: 800;
}

.form-card,
.medicine-form,
.empty-state,
.medicine-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(231, 241, 255, 0.96)),
    var(--surface);
}

.form-card,
.medicine-form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  font-weight: 650;
}

.checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.checkbox-row input {
  width: 20px;
  min-height: 20px;
  margin: 0;
}

.push-permission-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(11, 114, 255, 0.28);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(11, 114, 255, 0.12), rgba(229, 241, 255, 0.92));
}

.push-permission-box strong,
.push-permission-box p {
  margin: 0;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-row i {
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  height: 30px;
  border-radius: 999px;
  background: #8ea3bd;
  transition: background 0.18s ease;
}

.switch-row i::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s ease;
}

.switch-row input:checked + i {
  background: var(--primary);
}

.switch-row input:checked + i::after {
  transform: translateX(24px);
}

.push-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 11, 36, 0.62);
}

.push-modal[hidden] {
  display: none;
}

.push-modal-card {
  display: grid;
  gap: 12px;
  width: min(430px, 100%);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: linear-gradient(180deg, #f7fbff, #e5f1ff);
  box-shadow: var(--shadow);
  color: var(--text);
}

.push-modal-card h2,
.push-modal-card p {
  margin: 0;
}

.push-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(11, 114, 255, 0.22);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  white-space: normal;
  text-align: center;
}

.button.primary {
  background: var(--primary);
  color: white;
}

.button.primary:hover {
  background: var(--primary-strong);
}

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

.button.danger {
  background: #fff4f2;
  border-color: #f3c7c2;
  color: var(--danger);
}

.inline-link {
  justify-self: center;
  color: var(--primary);
  font-weight: 700;
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 700;
}

.alert.success {
  background: #cfe7ff;
  color: var(--primary-strong);
}

.alert.error {
  background: #fff0ee;
  color: var(--danger);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.medicine-hero {
  position: relative;
  min-height: 156px;
  padding: 24px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 8px;
  background:
    radial-gradient(circle at 78% 10%, rgba(255, 255, 255, 0.24), transparent 110px),
    linear-gradient(135deg, rgba(11, 114, 255, 0.94), rgba(4, 23, 67, 0.90));
  box-shadow: var(--shadow);
}

.medicine-hero h1,
.medicine-hero p {
  color: white;
}

.medicine-hero p {
  color: #cfe5ff;
}

.medicine-hero .button {
  position: relative;
  z-index: 2;
}

.medicine-hero .button.primary {
  background: white;
  color: var(--primary-strong);
}

.hero-medical-visual {
  position: absolute;
  right: 160px;
  bottom: 16px;
  width: 310px;
  height: 110px;
  pointer-events: none;
}

.hero-kit,
.hero-pill,
.hero-bottle {
  position: absolute;
  display: block;
}

.hero-kit {
  right: 0;
  bottom: 0;
  display: grid;
  width: 96px;
  height: 72px;
  place-items: center;
  border-radius: 8px;
  background: var(--medical-red);
  color: white;
  font-size: 52px;
  font-weight: 900;
  box-shadow: 0 18px 32px rgba(2, 12, 36, 0.34);
}

.hero-pill {
  left: 20px;
  bottom: 30px;
  width: 86px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffffff 0 49%, var(--medical-red) 50% 100%);
  transform: rotate(-22deg);
}

.hero-bottle {
  left: 138px;
  top: 2px;
  width: 42px;
  height: 82px;
  border-radius: 12px 12px 8px 8px;
  background: linear-gradient(180deg, #ffffff 0 22%, #dbeaff 23% 100%);
}

.hero-bottle::before {
  content: "";
  position: absolute;
  left: 10px;
  top: -13px;
  width: 22px;
  height: 16px;
  border-radius: 5px 5px 2px 2px;
  background: var(--primary);
}

.page-head h1 {
  font-size: 34px;
  color: white;
}

.page-head p {
  color: #cfe5ff;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 16px;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(201, 225, 255, 0.76)),
    var(--surface);
}

.medicine-list {
  display: grid;
  gap: 12px;
}

.medicine-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(245, 249, 255, 0.92);
  box-shadow: var(--shadow);
}

.medicine-icon {
  position: relative;
  width: 42px;
  height: 22px;
  border: 1px solid rgba(16, 36, 59, 0.12);
  border-radius: 999px;
  background:
    linear-gradient(90deg, #ffffff 0 49%, var(--primary) 50% 100%);
  box-shadow: 0 8px 18px rgba(11, 114, 255, 0.16);
  transform: rotate(-18deg);
}

.medicine-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  bottom: 2px;
  width: 1px;
  background: rgba(16, 36, 59, 0.16);
}

.medicine-card.expired {
  border-left: 6px solid var(--danger);
  background:
    linear-gradient(135deg, rgba(255, 240, 238, 0.98), rgba(255, 214, 207, 0.92)),
    var(--surface);
}

.medicine-card.soon {
  border-left: 6px solid var(--warning);
  background:
    linear-gradient(135deg, rgba(255, 248, 232, 0.98), rgba(255, 231, 187, 0.90)),
    var(--surface);
}

.medicine-card.ok {
  border-left: 6px solid var(--ok);
  background:
    linear-gradient(135deg, rgba(239, 255, 250, 0.98), rgba(210, 240, 230, 0.88)),
    var(--surface);
}

.medicine-main h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.medicine-detail {
  margin-top: 4px !important;
  font-size: 13px;
}

.medicine-meta {
  display: grid;
  justify-items: end;
  gap: 4px;
  min-width: 120px;
}

.status-pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 750;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.card-actions form {
  margin: 0;
}

.consume-panel {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: minmax(160px, 260px) auto;
  gap: 10px;
  align-items: end;
  padding-top: 6px;
}

.consume-panel[hidden] {
  display: none !important;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.group-card {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 190px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(245, 249, 255, 0.97), rgba(209, 229, 255, 0.90)),
    var(--surface);
  box-shadow: var(--shadow);
}

.group-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 7px;
  border-radius: 8px 0 0 8px;
  background: var(--category-color, var(--primary));
}

.group-card::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--category-color, var(--primary));
  opacity: 0.18;
}

.group-card.active {
  border-color: white;
  outline: 3px solid rgba(255, 255, 255, 0.20);
}

.group-card strong {
  font-size: 20px;
}

.group-card span {
  color: var(--primary-strong);
  font-weight: 800;
}

.group-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.group-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 22px 0 12px;
}

.group-list-head h2 {
  margin: 0;
  color: white;
}

.medicine-form {
  max-width: 720px;
}

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

.account-grid .medicine-form {
  max-width: none;
}

.account-grid .medicine-form:last-child {
  grid-column: 1 / -1;
}

.avatar-preview {
  display: grid;
  width: 112px;
  height: 112px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--medical-red));
  color: white;
  font-size: 44px;
  font-weight: 850;
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.medicine-form h2 {
  margin: 0;
  color: var(--text);
  font-size: 22px;
}

.import-result {
  display: grid;
  gap: 8px;
  max-width: 720px;
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.import-result h2,
.import-result p {
  margin: 0;
}

.import-result ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.scan-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.expiry-scan {
  display: grid;
  gap: 8px;
  align-content: end;
}

.expiry-scan .form-note {
  font-size: 13px;
}

.scan-panel .form-note,
.scanner {
  grid-column: 1 / -1;
}

.scanner {
  overflow: hidden;
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101817;
}

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

.pwa-install-btn {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  display: grid;
  width: min(248px, calc(100vw - 32px));
  justify-items: center;
  border: 1px solid rgba(255, 255, 255, 0.20);
  border-radius: 8px;
  padding: 13px 16px;
  background: linear-gradient(135deg, var(--primary), #06358f);
  color: white;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

.pwa-install-btn[hidden] {
  display: none !important;
}

.pwa-install-btn span {
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 800;
}

.pwa-install-btn strong {
  font-size: 16px;
  line-height: 1.2;
}

.site-footer {
  margin-top: 42px;
  padding: 36px 18px 26px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  background:
    radial-gradient(circle at 18% 0%, rgba(74, 163, 255, 0.14), transparent 34%),
    rgba(3, 19, 57, 0.78);
}

.footer-container {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(320px, 1.7fr);
  gap: 28px;
  align-items: center;
  width: min(1180px, 100%);
  margin: 0 auto;
}

.footer-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-size: 22px;
  font-weight: 900;
}

.footer-logo img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: white;
  object-fit: contain;
}

.footer-brand p {
  max-width: 380px;
  margin: 12px 0 0;
  color: #b9d9ff;
}

.footer-apps-title {
  margin: 0 0 12px;
  color: #dcecff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.footer-apps-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.footer-app-link {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: white;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.footer-app-link:hover {
  transform: translateY(-2px);
  border-color: rgba(74, 163, 255, 0.46);
  background: rgba(74, 163, 255, 0.12);
}

.footer-app-link img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: white;
}

.footer-app-link span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.footer-app-link strong,
.footer-app-link small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer-app-link strong {
  font-size: 14px;
  line-height: 1.15;
}

.footer-app-link small {
  color: #b9d9ff;
  font-size: 11px;
}

.footer-bottom {
  width: min(1180px, 100%);
  margin: 28px auto 0;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  color: #b9d9ff;
  font-size: 13px;
  text-align: center;
}

.footer-legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 18px;
  margin-bottom: 12px;
  color: #e5f2ff;
  font-weight: 700;
}

.footer-legal-links a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal-doc {
  line-height: 1.65;
}

.legal-doc h2 {
  margin: 22px 0 8px;
  color: var(--text);
  font-size: 20px;
}

.legal-doc h2:first-child {
  margin-top: 0;
}

.legal-doc p {
  margin: 0 0 12px;
  color: #263b54;
}

.cookie-notice {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 860px;
  margin: 0 auto;
  padding: 14px 16px;
  background: rgba(245, 249, 255, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.cookie-notice p {
  margin: 0;
  color: var(--text);
}

.cookie-notice a {
  color: var(--primary-strong);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cookie-notice .button {
  flex: 0 0 auto;
}

@media (max-width: 760px) {
  *,
  *::before,
  *::after {
    max-width: 100%;
  }

  html {
    width: 100%;
    overflow-x: clip;
    overscroll-behavior-x: none;
  }

  body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
    touch-action: pan-y;
    overscroll-behavior-x: none;
  }

  body > *,
  main,
  main > *,
  section,
  form,
  article {
    max-width: calc(100vw - 24px);
  }

  .topbar {
    left: 0;
    right: 0;
    display: grid;
    align-items: flex-start;
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar,
  .site-footer {
    max-width: 100vw;
  }

  .brand-cluster {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    gap: 10px;
  }

  .brand {
    width: 100%;
    max-width: 100%;
  }

  .brand strong,
  .brand small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand span {
    min-width: 0;
  }

  .user-chip {
    width: min(100%, 260px);
    max-width: 100%;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    gap: 8px;
  }

  .top-actions .button {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding-left: 10px;
    padding-right: 10px;
    overflow-wrap: anywhere;
  }

  .locale-switcher {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 52px));
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    gap: 8px;
  }

  .locale-switcher a {
    width: 100%;
    min-width: 0;
  }

  .shell {
    width: 100%;
    max-width: 100%;
    padding-left: 12px;
    padding-right: 12px;
    overflow-x: clip;
    contain: inline-size;
  }

  .site-footer {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .cookie-notice {
    left: 12px;
    right: 12px;
    bottom: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .medicine-hero {
    max-width: 100%;
  }

  .page-head {
    min-width: 0;
  }

  .account-grid,
  .account-grid .medicine-form,
  .medicine-form,
  .form-card,
  .empty-state,
  .medicine-card,
  .catalog-update-panel,
  .notification-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  input[type="file"] {
    width: 100%;
    max-width: 100%;
    font-size: 15px;
  }

  .auth-panel,
  .account-grid,
  .form-grid,
  .scan-panel,
  .filter-panel {
    grid-template-columns: 1fr;
  }

  .catalog-update-panel {
    grid-template-columns: 1fr;
  }

  .account-grid .medicine-form:last-child {
    grid-column: auto;
  }

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

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-intro {
    min-height: 500px;
  }

  .auth-medical-scene {
    left: 24px;
    right: 24px;
    grid-template-columns: 76px 1fr 1fr;
  }

  .scene-pill-one,
  .scene-pill-two,
  .scene-pill-three {
    display: none;
  }

  .scene-tile {
    width: 100%;
  }

  .medical-motif::before,
  .medical-motif::after {
    display: none;
  }

  .hero-medical-visual {
    position: relative;
    right: auto;
    bottom: auto;
    width: 100%;
    margin-top: 8px;
  }

  .pwa-install-btn {
    right: 12px;
    bottom: 12px;
  }

  .medicine-meta {
    grid-column: 1 / -1;
    justify-items: start;
  }

  .card-actions {
    grid-column: 1 / -1;
    width: 100%;
  }

  .consume-panel {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
  }

  .card-actions .button,
  .card-actions form {
    flex: 1;
  }

  .footer-container,
  .footer-apps-list {
    grid-template-columns: 1fr;
  }
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  .pwa-install-btn {
    display: none !important;
  }
}
