:root {
  --page: #f7f5ef;
  --panel: #ffffff;
  --panel-soft: #f3efe5;
  --line: #d8d2c3;
  --text: #28241f;
  --muted: #746f67;
  --accent: #2f6f73;
  --accent-dark: #214f52;
  --tomato: #b8422f;
  --gold: #b68a2c;
  --shadow: 0 16px 40px rgba(46, 39, 28, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--page);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 430px) 1fr;
  height: 100vh;
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-title {
  flex: 1 1 0;
  min-width: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-action {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--panel-soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.account-menu {
  position: relative;
  flex: 0 0 auto;
}

.account-toggle {
  min-width: 96px;
  cursor: pointer;
}

.account-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 10;
  display: grid;
  gap: 6px;
  width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.account-panel .brand-action,
.account-item {
  display: block;
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--panel-soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.account-panel .brand-action:hover,
.account-item:hover {
  background: #e9f0ec;
}

.chef-brand {
  display: grid;
  gap: 6px;
  justify-items: center;
  flex: 0 0 76px;
  margin: 0;
}

.chef-brand img {
  width: 64px;
  height: 64px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-soft);
}

.chef-brand figcaption {
  max-width: 82px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.login-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(40, 36, 31, 0.42);
}

.login-box {
  display: grid;
  gap: 14px;
  width: min(100%, 390px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-box h2 {
  margin: 0;
  font-size: 20px;
}

.login-box label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.login-box input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
}

#mensagemLogin {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

#mensagemLogin[data-tipo="erro"] {
  color: var(--tomato);
  font-weight: 700;
}

.filters {
  display: grid;
  gap: 8px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.filters label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.filters input,
.filters select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--text);
}

.filters input:focus,
.filters select:focus {
  outline: 3px solid rgba(47, 111, 115, 0.18);
  border-color: var(--accent);
}

.btn-buscar {
  width: 100%;
  height: 42px;
  margin-top: 4px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.btn-buscar:hover {
  background: var(--accent-dark);
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}

.list-header button {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

.recipe-list {
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.recipe-card {
  width: 100%;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 13px 18px;
  background: white;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.recipe-card:hover,
.recipe-card.active {
  background: #f2f6f4;
}

.thumb {
  width: 72px;
  height: 58px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-soft);
}

.card-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 700;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.tag {
  color: var(--accent-dark);
  font-weight: 700;
}

.recipe-detail {
  min-width: 0;
  height: 100vh;
  overflow: auto;
  overscroll-behavior: contain;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(280px, 460px) minmax(320px, 1fr);
  gap: 28px;
  align-items: stretch;
  padding: 30px;
}

.recipe-photo-block {
  min-width: 0;
}

.recipe-photo-frame {
  position: sticky;
  top: 24px;
}

.hero-image {
  width: 100%;
  min-height: 360px;
  max-height: 540px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: var(--shadow);
  background: var(--panel-soft);
}

.image-search-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  min-height: 36px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 22px rgba(46, 39, 28, 0.18);
}

.image-search-dialog {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(40, 36, 31, 0.46);
}

.image-search-panel {
  width: min(940px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.image-search-panel h3 {
  margin: 0;
  font-size: 20px;
}

.image-search-status {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.local-image-upload {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.local-image-label {
  cursor: pointer;
}

.local-image-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.remote-image-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
  flex: 1 1 420px;
  min-width: min(100%, 320px);
}

.remote-image-row input {
  min-width: 0;
}

.image-search-results {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.image-choice {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  background: var(--panel-soft);
  cursor: pointer;
}

.image-choice:hover {
  outline: 3px solid rgba(47, 111, 115, 0.18);
  border-color: var(--accent);
}

.image-choice img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-copy {
  align-self: center;
  border-top: 4px solid var(--accent);
  border-bottom: 1px solid var(--line);
  padding: 22px 0;
}

.category-line {
  margin: 0 0 12px;
  color: var(--tomato);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 13px;
}

.recipe-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.recipe-title-actions {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 8px;
}

.recipe-title-row h2 {
  margin: 0;
  max-width: 780px;
  font-size: 42px;
  line-height: 1.08;
}

.recipe-print,
.recipe-edit {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
}

.printer-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.action-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 12px;
  margin-top: 26px;
}

.stat {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #ffffff, #f8fbf9);
}

.stat strong {
  display: block;
  color: var(--accent-dark);
  font-size: 22px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.detail-content {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 28px;
  padding: 0 30px 34px;
}

.section-block {
  border-top: 3px solid var(--accent);
  padding-top: 14px;
  background: transparent;
}

.section-block h3 {
  margin: 0 0 14px;
  font-size: 18px;
}

.ingredients {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ingredients li {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 11px 0;
}

.amount {
  color: var(--gold);
  font-weight: 700;
}

.instructions {
  margin: 0;
  white-space: pre-line;
  line-height: 1.65;
  font-size: 16px;
}

.shopping-box {
  margin-top: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: #f8fbf9;
}

.shopping-box h3 {
  margin: 0 0 10px;
}

.shopping-controls {
  display: grid;
  grid-template-columns: minmax(110px, 150px) 44px;
  gap: 10px;
  align-items: end;
}

.shopping-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.shopping-controls input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.shopping-print {
  display: grid;
  place-items: center;
  width: 44px;
  height: 40px;
  min-height: 40px;
  padding: 0;
}

.empty-state,
.loading,
.error-state {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 40px;
  text-align: center;
}

.empty-state h2,
.error-state h2 {
  margin: 0;
  font-size: 30px;
}

.empty-state p,
.error-state p,
.loading {
  color: var(--muted);
}

.empty-image {
  width: 220px;
  height: 150px;
  margin: 0 auto 10px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(47, 111, 115, 0.18), rgba(184, 66, 47, 0.12)),
    var(--panel-soft);
}

@media (max-width: 920px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    height: auto;
    min-height: auto;
    border-right: 0;
    border-bottom: 2px solid var(--text);
  }

  .recipe-detail {
    height: auto;
    overflow: visible;
  }

  .recipe-list {
    max-height: 340px;
  }

  .detail-hero,
  .detail-content {
    grid-template-columns: 1fr;
    padding-left: 18px;
    padding-right: 18px;
  }

  .hero-image {
    aspect-ratio: 16 / 10;
    min-height: 0;
    max-height: none;
  }

  .recipe-photo-frame {
    position: relative;
    top: auto;
  }

  .image-search-results {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .recipe-title-row h2 {
    font-size: 32px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 520px) {
  body {
    background: var(--panel);
  }

  .brand {
    gap: 12px;
    padding-top: 18px;
    padding-bottom: 14px;
  }

  .chef-brand {
    flex-basis: 66px;
  }

  .chef-brand img {
    width: 54px;
    height: 54px;
  }

  .chef-brand figcaption {
    max-width: 70px;
    font-size: 10px;
  }

  .brand h1 {
    font-size: 28px;
  }

  .brand p {
    font-size: 13px;
  }

  .filters {
    gap: 7px;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .filters input,
  .filters select,
  .btn-buscar {
    height: 41px;
    font-size: 15px;
  }

  .list-header {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .recipe-list {
    max-height: 280px;
  }

  .recipe-card {
    grid-template-columns: 62px 1fr;
    gap: 10px;
    min-height: 72px;
    padding: 9px 14px;
  }

  .thumb {
    width: 62px;
    height: 54px;
  }

  .card-title {
    font-size: 14px;
    line-height: 1.2;
  }

  .card-meta {
    gap: 6px;
    margin-top: 7px;
    font-size: 11px;
  }

  .brand,
  .filters,
  .list-header {
    padding-left: 14px;
    padding-right: 14px;
  }

  .recipe-detail {
    overflow: visible;
  }

  .detail-hero {
    gap: 16px;
    padding: 20px 14px 18px;
  }

  .hero-image {
    aspect-ratio: 4 / 3;
    box-shadow: 0 10px 24px rgba(46, 39, 28, 0.13);
  }

  .image-search-results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .image-search-panel {
    padding: 14px;
  }

  .category-line {
    margin-bottom: 8px;
    font-size: 12px;
  }

  .recipe-title-row h2 {
    font-size: 29px;
    line-height: 1.08;
  }

  .stats {
    gap: 8px;
    margin-top: 16px;
  }

  .stat {
    min-height: 62px;
    padding: 10px;
  }

  .stat strong {
    font-size: 18px;
  }

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

  .detail-content {
    gap: 24px;
    padding: 0 14px 28px;
  }

  .section-block h3 {
    margin-bottom: 10px;
  }

  .ingredients li {
    grid-template-columns: minmax(78px, 96px) 1fr;
    gap: 8px;
    padding: 8px 0;
  }

  .instructions {
    line-height: 1.55;
    font-size: 15px;
  }

  .shopping-controls {
    grid-template-columns: 1fr 44px;
  }
}

@media (max-width: 360px) {
  .recipe-title-row h2 {
    font-size: 25px;
  }

  .stats,
  .ingredients li {
    grid-template-columns: 1fr;
  }

  .recipe-list {
    max-height: 260px;
  }
}

.form-page {
  height: auto;
  min-height: 100vh;
  overflow: auto;
}

.form-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.narrow-shell {
  width: min(720px, calc(100% - 32px));
}

.form-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.form-header h1 {
  margin: 0;
  font-size: 38px;
}

.back-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

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

.form-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
}

.form-section h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

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

.nutrition-grid {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.recipe-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.recipe-form input,
.recipe-form select,
.recipe-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  color: var(--text);
  font: inherit;
  font-weight: 400;
  text-transform: none;
}

.recipe-form textarea {
  resize: vertical;
}

.recipe-form input[readonly] {
  background: var(--panel-soft);
  color: var(--accent-dark);
  font-weight: 700;
}

.section-title-row,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.ingredients-editor {
  display: grid;
  gap: 10px;
}

.ingredient-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 130px 170px auto;
  gap: 10px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.ingredient-register {
  border-color: rgba(47, 111, 115, 0.45);
  background: #f8fbf9;
}

.field-hint {
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  border: 0;
  padding: 0 18px;
  background: var(--accent);
  color: white;
}

.secondary-button,
.icon-button {
  border: 1px solid var(--line);
  padding: 0 12px;
  background: var(--panel-soft);
  color: var(--text);
}

.image-field {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px;
  gap: 16px;
  align-items: start;
}

.image-preview {
  width: 220px;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-soft);
}

#mensagemFormulario {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
}

#mensagemFormulario[data-tipo="sucesso"] {
  color: var(--accent-dark);
  font-weight: 700;
}

#mensagemFormulario[data-tipo="erro"] {
  color: var(--tomato);
  font-weight: 700;
}

#mensagemCategoria {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
}

#mensagemCategoria[data-tipo="sucesso"] {
  color: var(--accent-dark);
  font-weight: 700;
}

#mensagemCategoria[data-tipo="erro"] {
  color: var(--tomato);
  font-weight: 700;
}

#mensagemUsuario {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
}

#mensagemUsuario[data-tipo="sucesso"] {
  color: var(--accent-dark);
  font-weight: 700;
}

#mensagemUsuario[data-tipo="erro"] {
  color: var(--tomato);
  font-weight: 700;
}

#mensagemImportacao {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
}

#mensagemImportacao[data-tipo="sucesso"] {
  color: var(--accent-dark);
  font-weight: 700;
}

#mensagemImportacao[data-tipo="erro"] {
  color: var(--tomato);
  font-weight: 700;
}

.web-results {
  display: grid;
  gap: 12px;
}

.web-result {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.web-result img,
.web-result-placeholder {
  width: 112px;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-soft);
}

.web-result h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.web-result p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.web-result a {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 620px) {
  .web-result {
    grid-template-columns: 88px 1fr;
  }

  .web-result img,
  .web-result-placeholder {
    width: 88px;
  }

  .web-result button {
    grid-column: 1 / -1;
  }
}

.category-create-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.unit-create-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

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

.category-row {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: white;
}

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

.category-row strong {
  color: var(--accent-dark);
}

.user-row {
  grid-template-columns: 110px minmax(160px, 1fr) 100px 90px auto;
  align-items: center;
}

.user-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.unit-row {
  grid-template-columns: 1fr;
}

@media (max-width: 760px) {
  .form-shell {
    width: calc(100% - 24px);
    padding-top: 18px;
  }

  .form-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-header h1 {
    font-size: 31px;
  }

  .form-grid,
  .nutrition-grid,
  .ingredient-row,
  .user-row,
  .image-field,
  .category-create-row,
  .unit-create-row {
    grid-template-columns: 1fr;
  }

  .image-preview {
    width: 100%;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .section-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-actions {
    justify-content: stretch;
  }

  .inline-actions button {
    flex: 1;
  }
}
