:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --text: #1d2520;
  --muted: #66736b;
  --line: #dce2dc;
  --accent: #2f6f5e;
  --accent-strong: #214f43;
  --warn: #a35b16;
  --danger: #a13333;
  --ok: #1e7a4f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  padding: 0.65rem 0.9rem;
}

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

button.secondary {
  background: #eef3ef;
  color: var(--accent-strong);
}

button.danger {
  background: var(--danger);
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  background: white;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.hidden {
  display: none !important;
}

.auth-panel {
  display: grid;
  gap: 24px;
  min-height: calc(100vh - 64px);
  align-content: center;
}

.auth-panel h1,
.topbar h1 {
  margin: 0;
  font-size: 2rem;
}

.auth-panel p,
.topbar p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

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

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

.panel {
  display: grid;
  gap: 14px;
}

.panel h2,
.section h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.topbar,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 18px;
}

.message {
  margin-bottom: 16px;
  border: 1px solid #e7c590;
  border-radius: 6px;
  background: #fff7e8;
  color: var(--warn);
  padding: 10px 12px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  padding: 8px 0;
  background: var(--bg);
  overflow-x: auto;
}

.tab {
  background: #e9efea;
  color: var(--accent-strong);
  white-space: nowrap;
}

.tab.active {
  background: var(--accent);
  color: white;
}

.section {
  margin-bottom: 16px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) 100px 80px 120px minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 0.45rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.cards {
  display: grid;
  gap: 10px;
}

.recipe-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.nutrition {
  color: var(--accent-strong);
  font-size: 0.84rem;
  font-weight: 700;
  margin-top: 4px;
}

.checkline {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.checkline input {
  width: auto;
  min-height: auto;
}

.ingredients {
  margin: 8px 0;
  padding-left: 18px;
}

.recipe-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.shopping {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.shopping h3 {
  margin: 0 0 8px;
}

.shopping-items {
  display: grid;
  gap: 8px;
}

.shopping-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.shopping-row.done {
  opacity: 0.58;
}

.shopping-row.done strong::after {
  content: " acquistato";
  color: var(--ok);
  font-weight: 700;
}

@media (max-width: 820px) {
  .auth-grid,
  .two-cols {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head {
    display: grid;
  }

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

  .recipe-actions,
  .shopping-row {
    display: grid;
    grid-template-columns: 1fr;
  }
}
