:root {
  --ink: #10243d;
  --muted: #66778a;
  --paper: #e6e8ea;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --line: #d7e0e8;
  --navy: #0b3d75;
  --navy-deep: #082c55;
  --accent: #2fc7df;
  --accent-dark: #0b83a0;
  --danger: #e85b4f;
  --warning: #f0a629;
  --ok: #1fa978;
  --shadow: 0 12px 30px rgba(11, 61, 117, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(11, 61, 117, 0.1), transparent 300px),
    var(--paper);
  color: var(--ink);
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
}

button,
.primary-link {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  font-weight: 750;
}

button:hover,
.primary-link:hover {
  border-color: var(--accent);
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--ink);
  padding: 10px 12px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    #fbfdff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2310243d' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E")
    no-repeat right 12px center / 18px 18px;
  color: var(--ink);
  padding: 10px 40px 10px 12px;
  line-height: 1.2;
}

input[type="number"] {
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(47, 199, 223, 0.34);
  outline-offset: 2px;
}

.public-shell {
  display: grid;
  place-items: center;
}

.page {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.construction-shell {
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #ffffff 0, #eef3f7 58%, #dce5ec 100%);
}

.construction-shell .page {
  width: 100%;
  margin: 0;
  padding: 0;
}

.construction {
  display: grid;
  width: 100%;
  min-height: 100svh;
  place-items: center;
  overflow: hidden;
}

.construction-art {
  position: relative;
  width: min(91vw, 142vh, 1536px);
  aspect-ratio: 3 / 2;
}

.construction-art picture,
.construction-art img {
  display: block;
  width: 100%;
  height: 100%;
}

.construction-art img {
  object-fit: contain;
}

.construction-login-link {
  position: absolute;
  top: 42%;
  left: 87.2%;
  width: 11.8%;
  height: 27%;
  border-radius: 8px;
  cursor: default;
}

.construction-login-link:focus-visible {
  outline: 3px solid rgba(47, 199, 223, 0.9);
  outline-offset: 3px;
}

.auth-card h1,
.workspace-heading h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1;
}

.workspace-heading p,
.placeholder-panel p,
.helper-text {
  color: var(--muted);
  line-height: 1.5;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-card {
  width: min(430px, calc(100vw - 32px));
  margin: 10vh auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
  border-top: 64px solid var(--navy);
}

.auth-card.compact {
  width: min(360px, calc(100vw - 32px));
}

.auth-card.compact .helper-text {
  margin: 12px 0 0;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.pin-unlock-form {
  display: grid;
  gap: 22px;
  margin-top: 20px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 18px;
}

.pin-dots span {
  width: 16px;
  height: 16px;
  border: 2px solid var(--navy);
  border-radius: 50%;
  background: transparent;
  transition: background 120ms ease, transform 120ms ease;
}

.pin-dots span.filled {
  background: var(--accent);
  transform: scale(1.08);
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 68px);
  justify-content: center;
  gap: 12px 18px;
}

.pin-keypad button {
  width: 68px;
  min-height: 68px;
  border: 1px solid #cbd8e6;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--navy-deep);
  font-size: 1.65rem;
  font-weight: 800;
  box-shadow: 0 3px 9px rgba(11, 61, 117, 0.1);
}

.pin-keypad button:hover,
.pin-keypad button:focus-visible {
  border-color: var(--accent);
  background: #eafaff;
}

.pin-keypad button:active {
  transform: scale(0.94);
}

.pin-keypad .pin-delete {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  font-size: 1.35rem;
}

.password-fallback-form {
  margin-top: 14px;
  text-align: center;
}

.text-action {
  min-height: auto;
  border: 0;
  background: transparent;
  padding: 6px;
  color: var(--navy);
  font-weight: 800;
  text-decoration: underline;
}

.stacked-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.security-notice {
  display: grid;
  gap: 7px;
  margin-top: 18px;
  border: 1px solid rgba(240, 166, 41, 0.45);
  border-radius: 8px;
  background: rgba(240, 166, 41, 0.1);
  padding: 12px;
}

.security-notice p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.security-notice code {
  overflow-wrap: anywhere;
  color: var(--navy);
  font-weight: 750;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.primary-action,
.primary-link {
  display: inline-grid;
  place-items: center;
  border-color: var(--navy);
  background: var(--navy);
  color: #ffffff;
  font-weight: 800;
  padding: 0 16px;
}

.danger-action {
  border-color: var(--danger);
  background: var(--danger);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid rgba(8, 44, 85, 0.2);
  background: linear-gradient(180deg, var(--navy), var(--navy-deep));
  color: #ffffff;
  padding: 12px max(16px, calc((100vw - 1120px) / 2));
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 0 0 2px rgba(47, 199, 223, 0.18);
  overflow: hidden;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.main-nav {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.logout-form {
  display: flex;
}

.logout-form button {
  min-height: 38px;
  border-color: transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  padding: 0 12px;
}

.logout-form button:hover {
  border-color: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

.main-nav a,
.subnav a {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  text-decoration: none;
}

.main-nav a.active,
.subnav a.active {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.main-nav a {
  color: rgba(255, 255, 255, 0.78);
}

.main-nav a.active {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.icon-button {
  display: none;
  width: 44px;
  justify-self: end;
  padding: 9px;
}

.icon-button span {
  display: block;
  height: 2px;
  margin: 5px 0;
  border-radius: 99px;
  background: #ffffff;
}

.subnav {
  position: sticky;
  top: 67px;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 6px;
  box-shadow:
    0 0 0 6px var(--paper),
    0 8px 20px rgba(11, 61, 117, 0.08);
}

.subnav a {
  font-size: 1.04rem;
}

.workspace-heading {
  margin-bottom: 20px;
}

.workspace-heading p:last-child {
  max-width: 60ch;
  margin-bottom: 0;
}

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

.module-tile,
.placeholder-panel,
.budget-summary,
.expense-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.module-tile {
  display: grid;
  gap: 8px;
  min-height: 160px;
  align-content: center;
  padding: 22px;
  text-decoration: none;
}

.module-tile strong {
  font-size: 1.5rem;
}

.module-tile span:last-child {
  color: var(--muted);
}

.module-tile.disabled {
  opacity: 0.62;
}

.tile-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: rgba(47, 199, 223, 0.13);
  color: var(--navy);
  font-weight: 900;
}

.placeholder-panel {
  padding: 20px;
}

.placeholder-panel h2 {
  margin: 0 0 8px;
}

.period-list {
  display: grid;
  gap: 14px;
}

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

.period-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-top: 5px solid var(--navy);
}

.period-card.is-collapsible {
  display: block;
}

.period-overview {
  display: grid;
  gap: 14px;
}

.period-card.is-collapsible > .period-overview {
  cursor: pointer;
  list-style: none;
}

.period-card.is-collapsible > .period-overview::-webkit-details-marker {
  display: none;
}

.period-card-header,
.entry-row {
  display: grid;
  gap: 12px;
}

.period-card-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.period-card-header h2 {
  margin: 8px 0 0;
  font-size: 1.1rem;
}

.period-chevron {
  width: 13px;
  height: 13px;
  border-right: 3px solid var(--navy);
  border-bottom: 3px solid var(--navy);
  transform: rotate(45deg);
  transition: transform 160ms ease;
}

.period-card[open] .period-chevron {
  transform: rotate(225deg);
}

.period-details {
  margin-top: 14px;
}

.status-pill {
  display: inline-grid;
  min-height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 850;
}

.status-pill.active {
  border-color: rgba(47, 199, 223, 0.45);
  background: rgba(47, 199, 223, 0.14);
  color: var(--navy);
}

.entry-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.entry-row {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
  padding: 12px 14px;
}

.entry-edit-button {
  display: inline-grid;
  width: 34px;
  min-height: 34px;
  place-items: center;
  padding: 0;
  color: var(--navy);
  font-size: 1.15rem;
  line-height: 1;
}

.entry-edit-button span {
  transform: translateY(-2px);
}

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

.entry-row div span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.entry-category-icon,
.entry-category-fallback {
  width: 34px;
  height: 34px;
}

.entry-category-icon {
  display: block;
  object-fit: contain;
}

.entry-category-fallback {
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--navy);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 900;
}

.empty-panel {
  padding: 20px;
}

.empty-panel h2 {
  margin: 0 0 8px;
}

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

.budget-settings-screen {
  display: grid;
  gap: 16px;
}

.user-settings-screen {
  display: grid;
  gap: 16px;
}

.user-settings-screen h1 {
  margin: 0;
  font-size: 1.5rem;
}

.password-settings-form {
  max-width: 620px;
}

.password-settings-form .helper-text {
  margin: 0;
}

.device-settings-form {
  max-width: 620px;
}

.backup-download-form {
  max-width: 620px;
}

.restore-upload-form {
  max-width: 620px;
}

.user-create-form {
  max-width: 760px;
}

.user-identity-fields,
.user-password-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.user-account-list {
  display: grid;
  gap: 10px;
}

.user-account-row {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.user-account-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.user-account-heading h3,
.user-account-heading p {
  margin: 0;
}

.user-account-heading h3 {
  font-size: 1rem;
}

.user-account-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.user-account-statuses {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.user-account-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.65fr);
  gap: 12px;
  align-items: start;
}

.user-account-actions details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.user-account-actions summary {
  padding: 11px 12px;
  color: var(--navy);
  font-weight: 800;
  cursor: pointer;
}

.compact-user-form {
  border-top: 1px solid var(--line);
  padding: 12px;
}

.user-toggle-form {
  display: grid;
  gap: 10px;
}

.restore-confirmation {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--ink);
}

.restore-confirmation input {
  width: auto;
  min-height: auto;
  margin-top: 3px;
}

input[type="file"] {
  padding: 7px;
}

input[type="file"]::file-selector-button {
  min-height: 34px;
  margin-right: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--navy);
  padding: 5px 10px;
  font-weight: 800;
  cursor: pointer;
}

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

.empty-setting {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
}

.trusted-device-list {
  display: grid;
  gap: 8px;
}

.trusted-device-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 12px;
}

.trusted-device-row h3,
.trusted-device-row p {
  margin: 0;
}

.trusted-device-row h3 {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 1rem;
}

.trusted-device-row p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.current-device-badge {
  border-radius: 999px;
  background: rgba(47, 199, 223, 0.16);
  padding: 3px 7px;
  color: var(--navy);
  font-size: 0.7rem;
  font-weight: 850;
}

.danger-text-action {
  border-color: rgba(239, 89, 78, 0.45);
  color: #b62f27;
}

.settings-panel {
  display: grid;
  align-content: space-between;
  gap: 18px;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.settings-wide-panel {
  align-content: start;
  min-height: 0;
}

.settings-panel h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.15;
}

.setting-facts {
  display: grid;
  gap: 10px;
  margin: 0;
}

.setting-facts div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.setting-facts dt {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.setting-facts dd {
  margin: 0;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 850;
}

.settings-form,
.category-settings-form {
  display: grid;
  gap: 14px;
}

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

.settings-choice-group label,
.category-active-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.settings-choice-group input,
.category-active-toggle input {
  width: auto;
  min-height: auto;
}

.category-settings-list {
  display: grid;
  gap: 7px;
}

.category-settings-row {
  display: grid;
  grid-template-columns: 34px minmax(180px, 1fr) 70px 88px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 8px 10px;
}

.category-settings-row > .entry-category-icon,
.category-settings-row > .entry-category-fallback {
  align-self: center;
}

.category-settings-row input[type="color"] {
  min-height: 36px;
  padding: 3px;
}

.category-settings-row label {
  gap: 4px;
  font-size: 0.78rem;
}

.category-settings-row input[type="text"] {
  min-height: 38px;
  padding-top: 7px;
  padding-bottom: 7px;
}

.category-settings-row .category-active-toggle {
  align-self: center;
  font-size: 0.84rem;
}

.settings-form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.category-order-dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
}

.category-order-list {
  display: grid;
  gap: 7px;
  max-height: min(520px, calc(100vh - 250px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px;
}

.category-order-item {
  display: grid;
  grid-template-columns: 42px 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 6px 8px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.category-order-item.is-dragging {
  z-index: 1;
  border-color: var(--accent);
  box-shadow: 0 7px 18px rgba(11, 61, 117, 0.18);
}

.drag-handle {
  min-height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  font-size: 1.2rem;
  letter-spacing: 2px;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.category-order-buttons {
  display: flex;
  gap: 5px;
}

.category-order-buttons button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 1.05rem;
}

.budget-screen {
  display: grid;
  gap: 16px;
}

.budget-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  border-top: 5px solid var(--navy);
}

.budget-summary .progress-block {
  grid-column: 1 / -1;
}

.budget-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.budget-summary strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1;
}

.period-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  padding: 14px 0 0;
}

.period-summary .progress-block {
  grid-column: 1 / -1;
}

.progress-block {
  display: grid;
  align-content: center;
  gap: 8px;
}

.entry-progress-block {
  grid-template-columns: minmax(0, 1fr) auto;
}

.entry-progress-block .period-start {
  color: var(--ink);
}

.entry-progress-block .progress-percent {
  text-align: right;
}

.entry-progress-block .progress-track {
  grid-column: 1 / -1;
}

.progress-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce7ef;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--ok);
}

.progress-fill.warning {
  background: var(--warning);
}

.progress-fill.danger {
  background: var(--danger);
}

.stats-period-form,
.stats-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stats-period-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
}

.js-enabled .stats-submit-button {
  display: none;
}

.stats-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.stats-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.stats-panel-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.stats-panel-header span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  white-space: nowrap;
}

.stats-category-list {
  display: grid;
  gap: 10px;
}

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

.stats-category-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.stats-category-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.stats-category-label strong,
.stats-category-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-category-label span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.stats-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce7ef;
}

.stats-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.stats-percent {
  min-width: 54px;
  color: var(--navy);
  text-align: right;
}

.text-ok {
  color: var(--ok);
}

.text-danger {
  color: var(--danger);
}

.expense-form {
  display: grid;
  gap: 16px;
  padding: 16px;
}

fieldset {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

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

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.category-button {
  position: relative;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  place-items: center;
  padding: 8px;
  text-align: center;
}

.category-button input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.category-button:has(input:checked) {
  border-color: var(--accent-dark);
  background: linear-gradient(180deg, #e7fbff, #ffffff);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(47, 199, 223, 0.25);
}

.category-button span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: var(--navy);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 900;
}

.category-icon {
  display: block;
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.category-button:has(input:checked) span {
  background: var(--accent);
  color: var(--navy-deep);
}

.autocomplete {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  z-index: 4;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(11, 61, 117, 0.16);
}

.autocomplete-list button {
  display: block;
  width: 100%;
  min-height: 36px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 8px 12px;
  color: var(--ink);
  text-align: left;
  font-weight: 750;
}

.autocomplete-list button:last-child {
  border-bottom: 0;
}

.autocomplete-list button:hover,
.autocomplete-list button:focus-visible {
  background: rgba(47, 199, 223, 0.12);
}

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

.sticky-action {
  width: 100%;
}

.flash {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.flash {
  margin-bottom: 16px;
  padding: 12px 14px;
  font-weight: 750;
}

.flash.success {
  border-color: rgba(31, 169, 120, 0.35);
  color: var(--ok);
}

.flash.error {
  border-color: rgba(167, 71, 43, 0.35);
  color: var(--danger);
}

.confirm-dialog {
  width: min(430px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 0;
}

.confirm-dialog::backdrop {
  background: rgba(8, 44, 85, 0.48);
}

.confirm-dialog form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.confirm-dialog h2,
.confirm-dialog p {
  margin: 0;
}

.confirm-dialog h2 {
  font-size: 1.22rem;
  line-height: 1.2;
}

.confirm-dialog p {
  color: var(--muted);
  line-height: 1.45;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.edit-entry-dialog {
  width: min(520px, calc(100vw - 28px));
}

.delete-entry-form {
  display: none;
}

.edit-entry-save-button {
  width: 100%;
}

.edit-entry-secondary-actions .danger-action {
  color: #ffffff;
}

@media (orientation: portrait) {
  .construction-art {
    width: min(92vw, 73svh, 1024px);
    aspect-ratio: 1024 / 1323;
  }

  .construction-login-link {
    top: 54.5%;
    left: 82.5%;
    width: 16.5%;
    height: 17%;
  }
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: auto auto;
  }

  .icon-button {
    display: block;
  }

  .main-nav {
    display: none;
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .main-nav.open {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    padding-top: 8px;
  }

  .main-nav.open .logout-form,
  .main-nav.open .logout-form button {
    width: 100%;
  }

  .budget-summary,
  .module-grid,
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }

  .budget-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .period-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .progress-block {
    grid-column: 1 / -1;
  }

  .category-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .category-settings-row {
    grid-template-columns: 34px minmax(160px, 1fr) 66px 82px;
  }

  .category-active-toggle {
    grid-column: auto;
  }
}

@media (min-width: 700px) and (max-width: 1180px) and (max-height: 900px) {
  .page {
    width: min(100vw - 40px, 1120px);
    padding: 14px 0 18px;
  }

  .topbar {
    min-height: 58px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .main-nav a,
  .subnav a {
    min-height: 34px;
  }

  .subnav {
    top: 64px;
    margin-bottom: 8px;
    padding: 5px;
  }

  .subnav a {
    font-size: 0.94rem;
  }

  .period-card {
    gap: 12px;
    padding: 14px;
  }

  .budget-screen {
    gap: 8px;
  }

  .budget-summary {
    gap: 7px;
    padding: 10px 12px;
    border-top-width: 4px;
  }

  .budget-summary span {
    font-size: 0.78rem;
  }

  .budget-summary strong {
    margin-top: 4px;
    font-size: 1.5rem;
  }

  .progress-block {
    gap: 6px;
  }

  .progress-track {
    height: 11px;
  }

  .expense-form {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 10px 12px;
  }

  .expense-form fieldset:nth-of-type(1) {
    grid-column: auto;
  }

  .expense-form fieldset:nth-of-type(2) {
    grid-row: auto;
  }

  .expense-form > label,
  .sticky-action {
    grid-column: auto;
  }

  label {
    gap: 5px;
    font-size: 0.84rem;
  }

  legend {
    margin-bottom: 6px;
    font-size: 0.84rem;
  }

  input,
  select,
  button,
  .primary-link {
    min-height: 38px;
  }

  input,
  select {
    padding: 8px 10px;
  }

  select {
    height: 38px;
    padding-right: 36px;
    background-position: right 10px center;
  }

  .date-row {
    grid-template-columns: minmax(150px, 1fr) 56px 68px 104px;
    gap: 8px;
  }

  .category-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }

  .category-button {
    min-height: 44px;
    gap: 2px;
    padding: 3px 5px;
    font-size: 0.72rem;
    line-height: 1.08;
  }

  .category-button span {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    font-size: 0.62rem;
  }

  .category-icon {
    width: 28px;
    height: 28px;
  }

  .amount-row {
    grid-template-columns: minmax(0, 1fr) 70px 70px;
    gap: 7px;
  }

  .sticky-action {
    min-height: 38px;
  }

  .auth-card.compact {
    margin: 4vh auto;
    border-top-width: 44px;
    padding: 18px;
  }

  .auth-card.compact h1 {
    font-size: 2.25rem;
  }

  .auth-card.compact .helper-text {
    margin-top: 8px;
    line-height: 1.35;
  }

  .pin-unlock-form {
    gap: 12px;
    margin-top: 12px;
  }

  .pin-dots {
    gap: 14px;
  }

  .pin-dots span {
    width: 14px;
    height: 14px;
  }

  .pin-keypad {
    grid-template-columns: repeat(3, 56px);
    gap: 8px 14px;
  }

  .pin-keypad button {
    width: 56px;
    min-height: 56px;
    font-size: 1.4rem;
  }

  .password-fallback-form {
    margin-top: 8px;
  }
}

@media (min-width: 700px) and (max-width: 899px) and (min-height: 901px) {
  .page {
    width: min(100vw - 32px, 1120px);
    padding: 12px 0 16px;
  }

  .topbar {
    min-height: 58px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .icon-button {
    width: 42px;
    min-height: 42px;
    padding: 8px;
  }

  .icon-button span {
    background: var(--navy-deep);
  }

  .subnav {
    top: 64px;
    margin-bottom: 10px;
    padding: 5px;
  }

  .subnav a {
    font-size: 0.92rem;
  }

  .period-card {
    gap: 12px;
    padding: 14px;
  }

  .budget-screen {
    gap: 10px;
  }

  .budget-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 12px 14px;
    border-top-width: 4px;
  }

  .budget-summary span {
    font-size: 0.78rem;
  }

  .budget-summary strong {
    margin-top: 5px;
    font-size: 1.5rem;
  }

  .progress-block {
    grid-column: 1 / -1;
    gap: 5px;
  }

  .progress-track {
    height: 10px;
  }

  .expense-form {
    gap: 9px;
    padding: 14px;
  }

  label {
    gap: 5px;
    font-size: 0.84rem;
  }

  legend {
    margin-bottom: 6px;
    font-size: 0.84rem;
  }

  input,
  select,
  button,
  .primary-link {
    min-height: 38px;
  }

  input,
  select {
    padding: 8px 10px;
  }

  select {
    height: 38px;
    padding-right: 36px;
    background-position: right 10px center;
  }

  .date-row {
    grid-template-columns: minmax(150px, 1fr) 52px 58px 96px;
    gap: 7px;
  }

  .category-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .category-button {
    min-height: 51px;
    gap: 3px;
    padding: 5px;
    font-size: 0.78rem;
    line-height: 1.05;
  }

  .category-button span {
    width: 23px;
    height: 23px;
    border-radius: 7px;
    font-size: 0.6rem;
  }

  .category-icon {
    width: 31px;
    height: 31px;
  }

  .amount-row {
    grid-template-columns: minmax(0, 1fr) 58px 58px;
    gap: 7px;
  }

  .sticky-action {
    min-height: 42px;
  }

  .category-settings-row {
    grid-template-columns: 32px minmax(150px, 1fr) 62px 78px;
    gap: 7px;
    padding: 7px 8px;
  }

  .stats-panel {
    gap: 12px;
    padding: 14px;
  }

  .stats-category-row {
    gap: 10px;
    padding: 10px;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100vw - 20px, 1120px);
    padding: 6px 0 10px;
  }

  .topbar {
    min-height: 56px;
    padding-top: 8px;
    padding-bottom: 8px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .icon-button {
    width: 42px;
    min-height: 42px;
    padding: 8px;
  }

  .icon-button span {
    background: var(--navy-deep);
  }

  .brand span:last-child {
    display: none;
  }

  .module-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    gap: 14px;
    padding: 14px;
  }

  .category-settings-row {
    grid-template-columns: 30px minmax(0, 1fr) 58px;
    gap: 6px;
    align-items: center;
    padding: 8px;
  }

  .category-settings-row label:first-of-type {
    grid-column: 2;
  }

  .category-settings-row label:nth-of-type(2) {
    grid-column: 3;
  }

  .category-active-toggle {
    grid-column: 2 / -1;
    justify-self: start;
  }

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

  .pin-fields,
  .trusted-device-row,
  .user-identity-fields,
  .user-password-fields,
  .user-account-actions {
    grid-template-columns: 1fr;
  }

  .user-account-heading {
    display: grid;
  }

  .user-account-statuses {
    justify-content: flex-start;
  }

  .trusted-device-row form,
  .trusted-device-row button {
    width: 100%;
  }

  .category-order-dialog form {
    gap: 12px;
    padding: 16px;
  }

  .category-order-item {
    grid-template-columns: 34px 30px minmax(0, 1fr) auto;
    gap: 7px;
    min-height: 48px;
    padding: 5px;
  }

  .category-order-buttons button {
    width: 34px;
    min-height: 34px;
  }

  .period-card-header,
  .period-card-header {
    grid-template-columns: 1fr;
  }

  .period-card.is-collapsible .period-card-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .entry-row {
    grid-template-columns: 30px minmax(0, 1fr) auto 34px;
    align-items: center;
    gap: 8px;
    padding: 10px;
  }

  .entry-row > strong {
    grid-column: 3;
    justify-self: start;
    white-space: nowrap;
  }

  .entry-edit-button {
    grid-column: 4;
    justify-self: end;
  }

  .entry-category-icon,
  .entry-category-fallback {
    width: 30px;
    height: 30px;
  }

  .entry-row div strong,
  .entry-row div span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .subnav {
    background: var(--surface);
    top: 62px;
    gap: 4px;
    margin-bottom: 6px;
    padding: 4px;
  }

  .subnav a {
    min-height: 32px;
    padding: 0 4px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .budget-screen {
    gap: 6px;
  }

  .stats-period-form {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  .stats-period-form .primary-action {
    width: 100%;
  }

  .stats-panel {
    gap: 10px;
    padding: 10px;
  }

  .stats-panel-header h2 {
    font-size: 1.05rem;
  }

  .stats-category-row {
    grid-template-columns: 30px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
  }

  .stats-category-label {
    display: grid;
    gap: 2px;
  }

  .stats-percent {
    min-width: 44px;
    font-size: 0.92rem;
  }

  .budget-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 7px 8px;
    border-top-width: 4px;
  }

  .budget-summary span {
    font-size: 0.68rem;
    line-height: 1.15;
  }

  .budget-summary strong {
    margin-top: 4px;
    font-size: 1rem;
    white-space: nowrap;
  }

  .progress-block {
    grid-column: 1 / -1;
    gap: 5px;
  }

  .progress-track {
    height: 9px;
  }

  .expense-form {
    gap: 6px;
    padding: 8px 10px;
  }

  label {
    gap: 5px;
    font-size: 0.82rem;
  }

  legend {
    margin-bottom: 5px;
    font-size: 0.82rem;
  }

  input,
  select,
  button,
  .primary-link {
    min-height: 38px;
  }

  input,
  select {
    padding: 7px 9px;
  }

  select {
    height: 38px;
    padding-right: 34px;
    background-position: right 9px center;
  }

  .date-row {
    grid-template-columns: minmax(104px, 1fr) 44px 54px 82px;
    gap: 6px;
  }

  .date-row button,
  .amount-row button {
    padding: 0 6px;
    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
  }

  .category-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }

  .category-button {
    min-height: 44px;
    gap: 2px;
    padding: 3px 4px;
    font-size: 0.72rem;
    line-height: 1.05;
  }

  .category-button span {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: 0.58rem;
  }

  .category-icon {
    width: 28px;
    height: 28px;
  }

  .amount-row {
    grid-template-columns: minmax(96px, 1fr) 58px 58px;
    gap: 6px;
  }

  .sticky-action {
    min-height: 42px;
    font-size: 1rem;
  }

  .subnav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow-x: visible;
    flex-wrap: initial;
    padding-bottom: 4px;
  }

  .subnav a {
    min-width: 0;
    padding: 0 2px;
    font-size: 0.8rem;
    white-space: nowrap;
  }
}

/* Glycemia meal prototype */
.glycemia-screen {
  --glycemia-blue: #0d5b9f;
  --glycemia-soft: #eef7fb;
  display: grid;
  gap: 18px;
  max-width: 940px;
  margin: 0 auto;
}

.glycemia-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
}

.glycemia-heading h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.35rem);
  line-height: 1;
}

.glycemia-heading p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
}

.prototype-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(11, 131, 160, 0.24);
  border-radius: 999px;
  background: rgba(47, 199, 223, 0.12);
  padding: 7px 11px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 850;
}

.glycemia-meal-form {
  display: grid;
  gap: 14px;
}

.glycemia-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 9px 24px rgba(11, 61, 117, 0.1);
}

.glycemia-card {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.glycemia-card-heading {
  display: flex;
  gap: 12px;
  align-items: center;
}

.glycemia-card-heading h2,
.pending-section-heading h2 {
  margin: 0;
  font-size: 1.24rem;
}

.glycemia-card-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.glycemia-step {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 10px;
  background: var(--navy);
  color: #ffffff;
  font-weight: 900;
}

.meal-basics-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.75fr 1.35fr 1.1fr;
  gap: 12px;
}

.glycemia-screen label,
.food-search > label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
}

.input-with-unit {
  position: relative;
  display: block;
}

.input-with-unit input {
  padding-right: 68px;
}

.input-with-unit > span {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  pointer-events: none;
}

.food-picker-card {
  position: relative;
}

.food-search {
  position: relative;
  z-index: 5;
}

.food-search-box {
  position: relative;
}

.food-search-box > span {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 13px;
  transform: translateY(-50%);
  color: var(--accent-dark);
  font-size: 1.45rem;
  line-height: 1;
  pointer-events: none;
}

.food-search-box input {
  min-height: 50px;
  border-width: 2px;
  border-color: #b8dce5;
  padding-left: 42px;
  font-size: 1rem;
}

.food-search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 16px 36px rgba(8, 44, 85, 0.2);
}

.food-search-results > button {
  display: grid;
  width: 100%;
  min-height: 58px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 9px 13px;
  text-align: left;
}

.food-search-results > button:last-child {
  border-bottom: 0;
}

.food-search-results > button:hover,
.food-search-results > button:focus-visible {
  background: var(--glycemia-soft);
}

.food-search-results button span {
  display: grid;
  gap: 2px;
}

.food-search-results button small,
.food-result-empty small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.food-search-results button b {
  color: var(--glycemia-blue);
  font-size: 0.88rem;
  white-space: nowrap;
}

.food-result-empty {
  display: grid;
  gap: 3px;
  padding: 14px;
}

.food-result-empty span {
  font-weight: 850;
}

.selected-foods {
  display: grid;
  gap: 8px;
}

.selected-foods-empty {
  display: grid;
  min-height: 92px;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 1px dashed #b9ccd9;
  border-radius: 12px;
  color: var(--muted);
}

.selected-foods-empty[hidden] {
  display: none;
}

.selected-foods-empty span {
  color: var(--accent-dark);
  font-size: 1.45rem;
}

.selected-foods-empty p {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 750;
}

.selected-food-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(260px, auto) 62px 36px;
  gap: 10px;
  align-items: center;
  border: 1px solid #dbe5ec;
  border-radius: 12px;
  background: #fbfdff;
  padding: 10px;
}

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

.selected-food-heading strong,
.selected-food-heading span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-food-heading span {
  color: var(--muted);
  font-size: 0.74rem;
}

.food-quantity-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  justify-content: flex-end;
}

.food-quantity-controls button {
  min-width: 38px;
  min-height: 34px;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.78rem;
}

.food-quantity-controls.unit span {
  min-width: 82px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 850;
}

.food-quantity-controls button.active {
  border-color: var(--navy);
  background: var(--navy);
  color: #ffffff;
}

.food-measure-custom {
  width: 78px;
  min-height: 34px;
  border-radius: 8px;
  padding: 4px 7px;
  text-align: right;
}

.selected-food-carbs {
  color: var(--glycemia-blue);
  text-align: right;
  white-space: nowrap;
}

.selected-food-remove {
  width: 34px;
  min-height: 34px;
  border: 0;
  background: transparent;
  color: #a94740;
  font-size: 1.3rem;
}

.meal-carb-total {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--navy-deep), var(--glycemia-blue));
  padding: 14px 16px;
  color: #ffffff;
}

.meal-carb-total > span {
  font-size: 0.84rem;
  font-weight: 750;
}

.meal-carb-total strong {
  grid-row: 1 / 3;
  grid-column: 2;
  font-size: 1.8rem;
  line-height: 1;
}

.meal-carb-total small {
  color: rgba(255, 255, 255, 0.74);
}

.insulin-card {
  border-top: 4px solid var(--accent);
}

.insulin-grid {
  display: grid;
  grid-template-columns: minmax(140px, 0.72fr) minmax(310px, 1.56fr) minmax(140px, 0.72fr);
  gap: 12px;
}

.insulin-grid > label {
  display: flex;
  flex-direction: column;
}

.insulin-grid > label > .input-with-unit {
  margin-top: auto;
}

.insulin-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--line);
}

.insulin-summary div {
  display: grid;
  gap: 4px;
  background: var(--surface-soft);
  padding: 11px 13px;
}

.insulin-summary div > span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
}

.insulin-summary strong {
  color: var(--navy);
  font-size: 1.05rem;
}

.inline-history-ratio {
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(0.68rem, 2.6vw, 0.8rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-calculated-dose {
  overflow: hidden;
  color: var(--muted);
  font-size: clamp(0.68rem, 2.6vw, 0.8rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meal-comment-card {
  gap: 12px;
}

.meal-comment-card textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
}

.glycemia-save-action {
  width: 100%;
  min-height: 52px;
  border-radius: 12px;
  font-size: 1.05rem;
}

.glycemia-delete-meal {
  display: flex;
  justify-content: center;
}

.glycemia-delete-meal button {
  min-height: 42px;
}

.glycemia-form-error {
  margin: 0;
  border-radius: 8px;
  background: rgba(232, 91, 79, 0.12);
  padding: 10px 12px;
  color: #9d2922;
  font-weight: 750;
}

.glycemia-form-success {
  margin: 0;
  border-radius: 8px;
  background: rgba(40, 151, 98, 0.12);
  padding: 10px 12px;
  color: #17643f;
  font-weight: 750;
}

.post-glucose-card {
  scroll-margin-top: 90px;
  border-left: 5px solid var(--warning);
}

.post-glucose-entry[hidden] {
  display: none;
}

.post-glucose-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.7fr) auto;
  gap: 10px 14px;
  align-items: end;
}

.post-glucose-meal,
.post-glucose-summary {
  grid-column: 1;
  margin: 0;
}

.post-glucose-meal {
  align-self: end;
  font-weight: 850;
}

.post-glucose-summary {
  align-self: start;
  color: var(--muted);
  font-size: 0.82rem;
}

.post-glucose-entry label {
  grid-row: 1 / 3;
  grid-column: 2;
}

.post-glucose-entry button {
  grid-row: 1 / 3;
  grid-column: 3;
  min-height: 44px;
}

.post-glucose-card.is-in-range {
  border-left-color: var(--ok);
}

.post-glucose-card.is-low {
  border-left-color: #2b7cc1;
}

.post-glucose-card.is-high {
  border-left-color: var(--danger);
}

.completed-glucose {
  display: grid;
  gap: 3px;
  margin: 0;
  text-align: right;
}

.completed-glucose strong {
  color: var(--navy);
  font-size: 1.25rem;
}

.completed-glucose span {
  color: var(--muted);
  font-size: 0.8rem;
}

/* Glycemia meal history prototype */
.glycemia-history-screen {
  --glycemia-blue: #0d5b9f;
  display: grid;
  gap: 18px;
  max-width: 940px;
  margin: 0 auto;
}

.glycemia-list-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.glycemia-list-heading h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.35rem);
  line-height: 1;
}

.glycemia-new-link {
  min-height: 44px;
  border-radius: 10px;
  text-decoration: none;
}

.secondary-link {
  display: inline-grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  padding: 0 14px;
  color: var(--navy);
  font-weight: 800;
  text-decoration: none;
}

.secondary-link:hover,
.secondary-link:focus-visible {
  border-color: var(--glycemia-blue);
  outline: none;
}

.food-picker-heading {
  justify-content: flex-start;
}

.food-picker-heading > button {
  flex: 0 0 auto;
  min-height: 40px;
  margin-left: auto;
  border-color: rgba(11, 131, 160, 0.35);
  padding: 0 13px;
  color: var(--glycemia-blue);
}

.meal-template-applied {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.meal-template-list {
  display: grid;
  gap: 7px;
}

.meal-template-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 40px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 10px 12px;
  box-shadow: 0 7px 18px rgba(11, 61, 117, 0.07);
}

.meal-template-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.meal-template-copy strong {
  overflow: hidden;
  color: var(--navy);
  font-size: 1.02rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meal-template-copy span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.meal-template-carbs {
  color: var(--glycemia-blue);
  font-size: 1.05rem;
  white-space: nowrap;
}

.meal-template-basics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(180px, 1fr);
  gap: 12px;
}

.meal-template-form-actions {
  display: grid;
  grid-template-columns: minmax(120px, 0.55fr) minmax(220px, 1.45fr);
  gap: 9px;
}

.meal-template-form-actions .primary-action,
.meal-template-form-actions .secondary-link {
  min-height: 50px;
}

.meal-template-picker-dialog {
  width: min(100%, 540px);
}

.meal-template-picker-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.meal-template-picker-heading h2,
.meal-template-picker-heading p {
  margin: 0;
}

.modal-close-button {
  width: 38px;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
}

.meal-template-picker-list {
  display: grid;
  gap: 7px;
  max-height: min(60vh, 500px);
  overflow-y: auto;
}

.meal-template-picker-list > button {
  display: grid;
  width: 100%;
  min-height: 60px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  text-align: left;
}

.meal-template-picker-list button span {
  display: grid;
  gap: 2px;
}

.meal-template-picker-list button strong {
  color: var(--navy);
}

.meal-template-picker-list button small {
  color: var(--muted);
}

.meal-template-picker-list button b {
  color: var(--glycemia-blue);
  white-space: nowrap;
}

.glycemia-meal-list {
  display: grid;
  gap: 8px;
}

.glycemia-empty-state {
  display: grid;
  justify-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 28px 18px;
  text-align: center;
}

.glycemia-empty-state p {
  margin: 0;
  color: var(--muted);
}

.glycemia-day-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 10px 3px 0;
  color: var(--navy);
  font-size: 1rem;
}

.glycemia-day-heading:first-child {
  margin-top: 0;
}

.glycemia-day-heading span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.glycemia-meal-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.7fr) minmax(0, 2.3fr) 40px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 5px solid var(--ok);
  border-radius: 13px;
  background: var(--surface);
  padding: 10px 12px;
  box-shadow: 0 7px 18px rgba(11, 61, 117, 0.08);
}

.glycemia-meal-edit {
  display: grid;
  width: 40px;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--navy);
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 1px;
  text-decoration: none;
}

.glycemia-meal-edit:hover,
.glycemia-meal-edit:focus-visible {
  border-color: var(--glycemia-blue);
  outline: none;
}

.glycemia-meal-row.is-low {
  border-left-color: #2b7cc1;
}

.glycemia-meal-row.is-high {
  border-left-color: var(--danger);
}

.glycemia-meal-row.is-pending {
  border-left-color: var(--warning);
}

.glycemia-meal-identity {
  display: grid;
  gap: 2px;
}

.glycemia-meal-type {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.glycemia-meal-type img {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  object-fit: contain;
}

.glycemia-meal-identity strong {
  color: var(--navy);
  font-size: 1.05rem;
}

.glycemia-meal-identity span {
  color: var(--muted);
  font-weight: 750;
}

.glycemia-meal-values {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--line);
}

.glycemia-meal-values div {
  display: grid;
  gap: 2px;
  background: var(--surface-soft);
  padding: 7px 10px;
}

.glycemia-meal-values dt {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.glycemia-meal-values dd {
  margin: 0;
  color: var(--navy);
  font-size: 1rem;
  font-weight: 900;
}

.glycemia-meal-values dd small {
  font-size: 0.65rem;
}

.glycemia-before-value.is-in-range dd,
.is-in-range .glycemia-after-value dd {
  color: var(--ok);
}

.glycemia-before-value.is-low dd,
.is-low .glycemia-after-value dd {
  color: #2b7cc1;
}

.glycemia-before-value.is-high dd,
.is-high .glycemia-after-value dd {
  color: var(--danger);
}

.is-pending .glycemia-after-value dd {
  color: #805400;
  font-size: 0.8rem;
}

.glycemia-quick-after {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.glycemia-quick-after button {
  min-height: 44px;
}

.quick-after-success {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--ok);
  font-size: 0.82rem;
  font-weight: 800;
}

.prototype-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

.glycemia-food-library {
  display: grid;
  gap: 16px;
  max-width: 940px;
  margin: 0 auto;
}

body.food-editor-open {
  overflow: hidden;
}

.food-editor-modal {
  position: fixed;
  z-index: 70;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  background: rgba(5, 27, 55, 0.62);
  padding: 18px;
  backdrop-filter: blur(4px);
}

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

.glycemia-food-create {
  display: grid;
  width: min(680px, 100%);
  max-height: calc(100svh - 36px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  padding: 16px;
  box-shadow: 0 24px 60px rgba(5, 27, 55, 0.35);
}

.food-form-heading {
  display: flex;
  grid-column: 1 / -1;
  justify-content: space-between;
  align-items: center;
}

.food-form-heading h2 {
  margin: 0;
  color: var(--navy);
  font-size: 1.15rem;
}

.food-delete-action {
  min-height: 36px;
  padding: 5px 8px;
}

.food-mode-picker {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  border: 0;
  padding: 0;
}

.food-mode-picker legend {
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
}

.food-mode-picker label {
  position: relative;
}

.food-mode-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.food-mode-picker label > span {
  display: grid;
  min-height: 58px;
  align-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  padding: 8px 10px;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 850;
}

.food-mode-picker label > span small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
}

.food-mode-picker input:checked + span {
  border-color: var(--navy);
  background: var(--navy);
  color: #ffffff;
}

.food-mode-picker input:checked + span small {
  color: rgba(255, 255, 255, 0.75);
}

[data-reference-field] > small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
}

[data-reference-field] .input-with-unit:not(.has-suffix) input {
  padding-right: 12px;
}

.unit-suggestions {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: 0 10px 22px rgba(8, 44, 85, 0.16);
}

.unit-suggestions[hidden] {
  display: none;
}

.unit-suggestions button {
  min-height: 38px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 7px 11px;
  text-align: left;
}

.unit-suggestions button:last-child {
  border-bottom: 0;
}

.food-form-actions {
  grid-column: 1 / -1;
}

.food-form-actions {
  position: sticky;
  bottom: -16px;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  background: var(--surface);
  padding: 10px 0 16px;
}

.food-form-actions button {
  min-height: 48px;
}

.food-library-search input {
  min-height: 46px;
}

.food-library-filters {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(180px, 0.7fr);
  gap: 10px;
}

.food-library-list {
  display: grid;
  gap: 5px;
}

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

.food-library-row[hidden] {
  display: none;
}

.food-library-row > div {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.food-library-row strong {
  font-size: 1rem;
  line-height: 1.2;
}

.food-library-row strong,
.food-library-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.food-library-row span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.food-library-row b {
  color: var(--glycemia-blue, #0d5b9f);
  font-size: 1.08rem;
  white-space: nowrap;
}

.food-library-row button {
  width: 42px;
  min-height: 42px;
  padding: 0;
  font-size: 0.88rem;
  letter-spacing: 1px;
}

.food-library-empty {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

/* Glycemia settings prototype */
.glycemia-settings-screen {
  display: grid;
  gap: 14px;
  max-width: 940px;
  margin: 0 auto;
}

.glycemia-settings-card {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 18px;
  box-shadow: 0 9px 24px rgba(11, 61, 117, 0.1);
}

.settings-card-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.settings-card-heading h2 {
  margin: 0;
  color: var(--navy);
  font-size: 1.2rem;
}

.settings-card-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.settings-card-heading > button {
  flex: 0 0 auto;
  min-height: 40px;
}

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

.glycemia-target-preview,
.glycemia-setting-message,
.glycemia-target-form > button {
  grid-column: 1 / -1;
}

.glycemia-target-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--line);
}

.glycemia-target-preview div {
  display: grid;
  gap: 3px;
  background: var(--surface-soft);
  padding: 10px;
  text-align: center;
}

.glycemia-target-preview span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
}

.glycemia-target-preview strong {
  font-size: 1rem;
}

.glycemia-target-preview .is-low strong {
  color: #2b7cc1;
}

.glycemia-target-preview .is-in-range strong {
  color: var(--ok);
}

.glycemia-target-preview .is-high strong {
  color: var(--danger);
}

.glycemia-target-form > button,
.glycemia-categories-form > button {
  min-height: 46px;
}

.glycemia-setting-message {
  margin: 0;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 0.8rem;
  font-weight: 800;
}

.glycemia-setting-message.is-success {
  background: rgba(40, 151, 98, 0.12);
  color: #17643f;
}

.glycemia-setting-message.is-error {
  background: rgba(232, 91, 79, 0.12);
  color: #9d2922;
}

.glycemia-categories-form,
.glycemia-category-list {
  display: grid;
  gap: 8px;
}

.glycemia-categories-form {
  gap: 12px;
}

.glycemia-category-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  padding: 7px;
}

.glycemia-category-row > input {
  min-height: 38px;
  padding: 7px 9px;
}

.glycemia-category-actions {
  display: flex;
  gap: 4px;
}

.glycemia-category-actions button {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.glycemia-category-actions .category-remove {
  border-color: rgba(232, 91, 79, 0.28);
  color: #a94740;
}

.category-delete-modal {
  position: fixed;
  z-index: 1200;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(16, 26, 48, 0.52);
  padding: 18px;
}

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

.category-delete-dialog {
  display: grid;
  gap: 16px;
  width: min(100%, 430px);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(16, 26, 48, 0.28);
  padding: 20px;
}

.category-delete-dialog h2,
.category-delete-dialog p {
  margin: 0;
}

.category-delete-dialog label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

.category-delete-actions {
  display: grid;
  grid-template-columns: 1fr 1.45fr;
  gap: 9px;
}

.category-delete-actions button {
  min-height: 44px;
}

.category-delete-actions .danger-action {
  border-color: #a94740;
  background: #a94740;
  color: #fff;
}

@media (max-width: 820px) {
  .inline-history-ratio,
  .inline-calculated-dose {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

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

  .selected-food-row {
    grid-template-columns: minmax(0, 1fr) auto 36px;
  }

  .food-quantity-controls {
    grid-row: 2;
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .selected-food-carbs {
    grid-column: 2;
  }

  .selected-food-remove {
    grid-column: 3;
  }

  .post-glucose-entry {
    grid-template-columns: 1fr 1fr;
  }

  .post-glucose-entry label {
    grid-row: 3;
    grid-column: 1;
  }

  .post-glucose-entry button {
    grid-row: 3;
    grid-column: 2;
  }

  .glycemia-meal-row {
    grid-template-columns: minmax(0, 1fr) 40px;
  }

  .glycemia-meal-values,
  .glycemia-quick-after {
    grid-column: 1 / -1;
  }

  .glycemia-meal-edit {
    grid-row: 1;
    grid-column: 2;
  }
}

@media (max-width: 560px) {
  .glycemia-screen {
    gap: 10px;
  }

  .glycemia-heading {
    align-items: start;
    padding: 8px 4px 2px;
  }

  .glycemia-heading h1 {
    font-size: 2rem;
  }

  .glycemia-heading p:last-child {
    margin-top: 6px;
    font-size: 0.82rem;
  }

  .glycemia-list-heading {
    align-items: center;
    padding: 5px 3px 0;
  }

  .glycemia-list-heading h1 {
    font-size: 2rem;
  }

  .glycemia-new-link {
    min-height: 40px;
    padding: 0 11px;
    font-size: 0.8rem;
  }

  .food-picker-heading > button {
    min-height: 38px;
    padding: 0 10px;
    font-size: 0.76rem;
  }

  .meal-template-basics-grid,
  .meal-template-form-actions {
    grid-template-columns: 1fr;
  }

  .meal-template-row {
    gap: 8px;
    padding: 9px;
  }

  .prototype-badge {
    padding: 5px 8px;
    font-size: 0.66rem;
  }

  .glycemia-meal-form {
    gap: 8px;
  }

  .glycemia-card {
    gap: 13px;
    border-radius: 11px;
    padding: 13px;
  }

  .glycemia-card-heading {
    gap: 9px;
  }

  .glycemia-card-heading h2 {
    font-size: 1.05rem;
  }

  .glycemia-card-heading p {
    font-size: 0.75rem;
  }

  .glycemia-step {
    width: 29px;
    height: 29px;
    flex-basis: 29px;
    border-radius: 8px;
    font-size: 0.82rem;
  }

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

  .meal-basics-grid label:nth-child(3),
  .meal-basics-grid .glucose-field {
    grid-column: 1 / -1;
  }

  .food-search-box input {
    min-height: 44px;
    padding-left: 38px;
  }

  .selected-food-row {
    gap: 7px;
    padding: 9px;
  }

  .food-quantity-controls {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .food-quantity-controls button {
    flex: 0 0 auto;
  }

  .meal-carb-total {
    padding: 11px 13px;
  }

  .meal-carb-total strong {
    font-size: 1.5rem;
  }

  .insulin-grid,
  .insulin-summary {
    grid-template-columns: 1fr;
  }

  .insulin-summary {
    gap: 1px;
  }

  .meal-comment-card {
    padding: 12px 14px;
  }

  .glycemia-save-action {
    min-height: 48px;
  }

  .post-glucose-entry {
    grid-template-columns: 1fr;
  }

  .post-glucose-entry label,
  .post-glucose-entry button {
    grid-row: auto;
    grid-column: 1;
  }

  .completed-glucose {
    text-align: left;
  }

  .glycemia-meal-list {
    gap: 6px;
  }

  .glycemia-meal-row {
    gap: 8px;
    border-radius: 11px;
    padding: 9px;
  }

  .glycemia-meal-identity {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }

  .glycemia-meal-values {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .glycemia-meal-values div {
    padding: 6px 5px;
  }

  .glycemia-meal-values dd {
    white-space: nowrap;
  }

  .glycemia-quick-after {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .glycemia-quick-after button {
    padding: 0 11px;
  }

  .glycemia-food-create {
    width: 100%;
    max-height: calc(100svh - 18px);
    grid-template-columns: 1fr;
    padding: 13px;
  }

  .food-form-actions {
    grid-column: 1;
  }

  .food-form-heading,
  .food-mode-picker {
    grid-column: 1;
  }

  .food-mode-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .food-mode-picker label > span {
    min-height: 62px;
    padding: 7px;
    font-size: 0.75rem;
  }

  .food-mode-picker label > span small {
    font-size: 0.61rem;
  }

  .food-editor-modal {
    align-items: end;
    padding: 9px;
  }

  .glycemia-food-create {
    border-radius: 14px 14px 10px 10px;
  }

  .food-form-actions {
    bottom: -13px;
    padding-bottom: 13px;
  }

  .food-library-filters {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .food-library-row {
    grid-template-columns: minmax(0, 1fr) auto 40px;
    gap: 8px;
    padding: 8px 9px;
  }

  .food-library-row button {
    width: 40px;
    min-height: 40px;
  }

  .glycemia-settings-screen {
    gap: 9px;
  }

  .glycemia-settings-card {
    gap: 13px;
    border-radius: 11px;
    padding: 13px;
  }

  .settings-card-heading h2 {
    font-size: 1.05rem;
  }

  .settings-card-heading .secondary-link {
    min-height: 40px;
    padding: 0 10px;
    font-size: 0.76rem;
    text-align: center;
  }

  .glycemia-target-form {
    gap: 8px;
  }

  .glycemia-target-preview div {
    padding: 8px 4px;
  }

  .glycemia-target-preview strong {
    font-size: 0.88rem;
  }

  .glycemia-category-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .glycemia-category-actions {
    justify-content: flex-end;
  }
}

/* Glycemia weekly report */
.glycemia-report-screen {
  display: grid;
  gap: 16px;
}

.report-kind-switch {
  display: inline-flex;
  width: fit-content;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  padding: 4px;
}

.report-kind-switch a {
  border-radius: 8px;
  padding: 8px 13px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration: none;
}

.report-kind-switch a.active {
  background: var(--navy);
  color: #ffffff;
}

.report-page-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
}

.report-page-heading h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(1.65rem, 4vw, 2.65rem);
  line-height: 1.08;
}

.report-page-heading p:last-child {
  margin: 7px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.report-print-action {
  flex: 0 0 auto;
  min-height: 44px;
}

.report-controls {
  display: grid;
  grid-template-columns: auto minmax(300px, 1fr) auto;
  gap: 9px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px;
}

.report-controls form {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.report-controls form button {
  min-height: 44px;
}

.weekly-report-days {
  display: grid;
  gap: 14px;
}

.weekly-report-day {
  display: grid;
  gap: 7px;
}

.weekly-report-day > h2 {
  margin: 0;
  border-left: 5px solid var(--glycemia-blue);
  border-radius: 7px;
  background: rgba(11, 131, 160, 0.08);
  padding: 8px 11px;
  color: var(--navy);
  font-size: 1.02rem;
}

.report-empty-day {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.report-table-scroll {
  overflow-x: auto;
}

.weekly-meals-table,
.monthly-meals-table,
.report-summary-table {
  width: 100%;
  border-spacing: 0;
  border-collapse: separate;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.weekly-meals-table {
  min-width: 980px;
  overflow: hidden;
  table-layout: fixed;
  font-size: 0.73rem;
}

.monthly-meals-table {
  width: 100%;
  min-width: 850px;
  overflow: hidden;
  table-layout: fixed;
  font-size: 0.72rem;
}

.monthly-meals-table th:first-child { width: 16%; }
.monthly-meals-table th:nth-child(2),
.monthly-meals-table th:nth-child(9) { width: 12%; }
.monthly-meals-table th:nth-child(3),
.monthly-meals-table th:nth-child(7),
.monthly-meals-table th:nth-child(8) { width: 10%; }
.monthly-meals-table th:nth-child(4),
.monthly-meals-table th:nth-child(5),
.monthly-meals-table th:nth-child(6) { width: 8%; }

.monthly-insulin-heading {
  white-space: nowrap;
}

.weekly-meals-table .report-col-meal { width: 10%; }
.weekly-meals-table .report-col-glucose { width: 9%; }
.weekly-meals-table .report-col-foods { width: 34%; }
.weekly-meals-table .report-col-carbs { width: 9%; }
.weekly-meals-table .report-col-insulin { width: 17%; }
.weekly-meals-table .report-col-ratio { width: 12%; }

.weekly-meals-table th,
.weekly-meals-table td,
.monthly-meals-table th,
.monthly-meals-table td,
.report-summary-table th,
.report-summary-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  vertical-align: top;
}

.weekly-meals-table tr > :last-child,
.monthly-meals-table tr > :last-child,
.report-summary-table tr > :last-child {
  border-right: 0;
}

.weekly-meals-table tbody:last-child tr:last-child > *,
.monthly-meals-table tbody:last-child tr:last-child > *,
.report-summary-table tbody tr:last-child > * {
  border-bottom: 0;
}

.weekly-meals-table thead th,
.monthly-meals-table thead th,
.report-summary-table thead th {
  background: #eef4f7;
  color: var(--navy);
  font-size: 0.67rem;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.report-summary-table thead th > small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.55rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: none;
}

.report-meal-identity {
  display: table-cell;
}

.report-meal-identity strong,
.report-meal-identity span {
  display: block;
}

.report-meal-identity strong {
  color: var(--navy);
}

.report-meal-identity span {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 750;
}

.report-foods-cell {
  padding-top: 4px !important;
  padding-bottom: 4px !important;
}

.report-food-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  padding: 4px 0;
}

.report-food-line + .report-food-line {
  border-top: 1px dotted #cbd8e0;
}

.report-food-line strong {
  color: var(--ink);
}

.report-food-line span {
  color: var(--navy);
  font-weight: 750;
  white-space: nowrap;
}

.report-food-line small {
  grid-column: 1 / -1;
  color: var(--muted);
  line-height: 1.25;
}

.report-number {
  color: var(--navy);
  text-align: right;
  white-space: nowrap;
}

.report-insulin-cell {
  display: grid;
  gap: 3px;
}

.report-insulin-cell span {
  color: var(--muted);
  white-space: nowrap;
}

.report-insulin-cell strong {
  border-top: 1px solid var(--line);
  padding-top: 3px;
  color: var(--navy);
}

.report-glucose {
  display: inline-block;
  border-radius: 6px;
  padding: 3px 5px;
  white-space: nowrap;
}

.report-glucose small {
  font-size: 0.58rem;
}

.report-glucose.is-low,
.report-summary-table .is-low {
  color: #2b7cc1;
}

.report-glucose.is-low {
  background: rgba(43, 124, 193, 0.1);
}

.report-glucose.is-in-range,
.report-summary-table .is-in-range {
  color: var(--ok);
}

.report-glucose.is-in-range {
  background: rgba(31, 169, 120, 0.1);
}

.report-glucose.is-high,
.report-summary-table .is-high {
  color: var(--danger);
}

.report-glucose.is-high {
  background: rgba(232, 91, 79, 0.1);
}

.report-missing-value {
  color: #805400;
  font-size: 0.68rem;
  font-weight: 750;
}

.report-comment-row td {
  background: #fafcfd;
  padding: 6px 9px;
  color: var(--muted);
  font-size: 0.7rem;
}

.report-comment-row strong {
  color: var(--navy);
}

.weekly-report-stats {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--glycemia-blue);
  border-radius: 13px;
  background: var(--surface);
  padding: 16px;
  box-shadow: 0 9px 24px rgba(11, 61, 117, 0.08);
}

.weekly-report-stats > h2,
.weekly-report-stats h3 {
  margin: 0;
  color: var(--navy);
}

.weekly-report-stats > h2 {
  font-size: 1.3rem;
}

.weekly-report-stats h3 {
  margin-bottom: 7px;
  font-size: 0.92rem;
}

.report-stat-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.report-stat-cards > div {
  display: grid;
  gap: 4px;
  border-radius: 9px;
  background: var(--surface-soft);
  padding: 10px;
}

.report-stat-cards span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
}

.report-stat-cards strong {
  color: var(--navy);
  font-size: 1.12rem;
}

.report-stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.report-summary-table {
  overflow: hidden;
  font-size: 0.7rem;
}

.report-summary-table tbody th {
  color: var(--navy);
  text-align: left;
}

.report-summary-table .report-global-summary > * {
  border-top: 2px solid #9fb5c5;
  background: #f1f6f8;
  font-weight: 850;
}

.report-summary-table .report-global-summary + .report-global-summary > * {
  border-top-width: 1px;
}

.report-summary-table td {
  text-align: right;
  white-space: nowrap;
}

.report-summary-table td small {
  font-size: 0.61rem;
}

.report-target-table thead tr:first-child th:not(:first-child) {
  border-bottom-color: #aebfcb;
  text-align: center;
}

.report-target-table thead tr:nth-child(2) th {
  font-size: 0.6rem;
  text-align: center;
}

.report-target-table tbody th {
  white-space: nowrap;
}

.report-target-table tbody td {
  padding-right: 5px;
  padding-left: 5px;
  text-align: center;
}

@media (max-width: 760px) {
  .report-page-heading {
    display: grid;
    align-items: start;
  }

  .report-print-action {
    width: 100%;
  }

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

  .report-controls form {
    grid-row: 1;
    grid-column: 1 / -1;
  }

  .report-controls > a {
    padding: 0 7px;
    text-align: center;
    font-size: 0.72rem;
  }

  .report-stat-cards,
  .report-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-stats-grid > section {
    grid-column: 1 / -1;
    overflow-x: auto;
  }

  .report-summary-table {
    min-width: 560px;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 9mm;
  }

  body {
    background: #ffffff;
    color: #10223a;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .topbar,
  .subnav,
  .flash,
  .report-kind-switch,
  .report-controls,
  .report-print-action {
    display: none !important;
  }

  .page {
    width: auto;
    margin: 0;
    padding: 0;
  }

  .glycemia-report-screen {
    gap: 4mm;
  }

  .report-page-heading h1 {
    font-size: 16pt;
  }

  .report-page-heading p {
    font-size: 8pt;
  }

  .weekly-report-days {
    gap: 3mm;
  }

  .weekly-report-day > h2 {
    break-after: avoid;
    padding: 1.5mm 2.5mm;
    font-size: 9pt;
  }

  .report-table-scroll {
    overflow: visible;
  }

  .weekly-meals-table {
    min-width: 0;
    font-size: 6.8pt;
  }

  .monthly-meals-table {
    min-width: 0;
    font-size: 6.5pt;
  }

  .weekly-meals-table thead,
  .monthly-meals-table thead {
    display: table-header-group;
  }

  .weekly-meal-block,
  .report-food-line,
  .report-empty-day {
    break-inside: avoid;
  }

  .weekly-meals-table th,
  .weekly-meals-table td,
  .monthly-meals-table th,
  .monthly-meals-table td {
    padding: 1.3mm 1.5mm;
  }

  .glycemia-monthly-report-screen .report-glucose {
    padding: 1mm;
  }

  .glycemia-monthly-report-screen .report-glucose small {
    display: block;
    margin-top: 0.4mm;
  }

  .weekly-report-stats {
    break-before: page;
    box-shadow: none;
    padding: 4mm;
  }

  .report-summary-table {
    font-size: 7pt;
  }
}
