:root {
  --bg: #f7f2ec;
  --surface: #ffffff;
  --surface-2: #fff8ef;
  --text: #2d2118;
  --muted: #7a6b5f;
  --primary: #8b4a16;
  --primary-2: #c9792b;
  --border: #eadfd3;
  --danger: #b42318;
  --success: #15803d;
  --warning: #b7791f;
  --shadow: 0 10px 30px rgba(74, 45, 25, 0.08);
}

body.dark {
  --bg: #17120f;
  --surface: #241b16;
  --surface-2: #2c211a;
  --text: #fff7ef;
  --muted: #c7b8aa;
  --border: #4a382c;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: linear-gradient(180deg, #6f3710, #3d1f0d);
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.15);
  font-size: 25px;
}

.brand strong {
  display: block;
}

.brand span {
  display: block;
  opacity: 0.75;
  font-size: 12px;
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  padding: 12px 14px;
  border-radius: 12px;
  text-align: left;
  display: flex;
  gap: 10px;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.14);
  color: white;
}

.sidebar-footer {
  margin-top: auto;
}

.content {
  min-width: 0;
  padding: 20px 24px 50px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.topbar h1 {
  margin: 0;
  font-size: 27px;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

#installBtn {
  margin-left: auto;
}

.icon-btn {
  border: 0;
  background: var(--surface);
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

#menuToggle {
  display: none;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 17px;
  padding: 17px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  display: block;
  margin-bottom: 9px;
}

.metric strong {
  font-size: 21px;
}

.danger-soft {
  background: #fff1f0;
}

body.dark .danger-soft {
  background: #3a1d1c;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 17px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 17px;
  margin: 0;
}

.panel p {
  color: var(--muted);
}

.section-actions,
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.primary,
.danger,
.ghost,
.file-btn {
  border-radius: 11px;
  padding: 11px 15px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary {
  background: var(--primary);
  color: white;
}

.primary:hover {
  background: #713a12;
}

.danger {
  background: var(--danger);
  color: white;
}

.ghost,
.file-btn {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.full {
  width: 100%;
}

.compact {
  padding: 9px 12px;
}

.hidden {
  display: none !important;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px rgba(201, 121, 43, 0.15);
}

label {
  color: var(--muted);
  font-size: 12px;
  display: grid;
  gap: 6px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.full-span {
  grid-column: 1 / -1;
}

.cards-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.item-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 15px;
  padding: 15px;
  box-shadow: var(--shadow);
}

.item-card h3 {
  margin: 0 0 5px;
}

.item-card .muted {
  color: var(--muted);
  font-size: 12px;
}

.item-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  font-size: 13px;
}

.item-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.item-actions button {
  flex: 1;
  padding: 8px 10px;
}

.progress {
  height: 9px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 9px;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--success);
}

.progress.low > span {
  background: var(--danger);
}

.summary-list,
.history-list {
  display: grid;
  gap: 10px;
}

.summary-row,
.history-row,
.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.history-row small,
.summary-row small {
  color: var(--muted);
  display: block;
  margin-top: 3px;
}

.alert.warning {
  border-color: #f0c36d;
  background: #fff8e8;
}

.alert.danger {
  border-color: #f3a6a1;
  background: #fff1f0;
  color: var(--text);
}

body.dark .alert.warning {
  background: #3a2c10;
}

body.dark .alert.danger {
  background: #3a1d1c;
}

.preview {
  border: 1px dashed var(--primary-2);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 12px;
  color: var(--muted);
}

.preview strong {
  color: var(--text);
}

dialog {
  border: 0;
  padding: 0;
  border-radius: 18px;
  width: min(720px, calc(100% - 24px));
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.modal-form {
  padding: 20px;
}

.modal-form.wide {
  width: 100%;
}

.modal-head,
.modal-actions,
.subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head {
  margin-bottom: 16px;
}

.modal-head h2,
.subhead h3 {
  margin: 0;
}

.modal-actions {
  margin-top: 18px;
  justify-content: flex-end;
}

.recipe-item {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 9px;
  margin-top: 9px;
  align-items: end;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 25px;
  transform: translate(-50%, 120px);
  background: #17120f;
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  transition: 0.25s;
  z-index: 100;
  box-shadow: var(--shadow);
}

.toast.show {
  transform: translate(-50%, 0);
}

.bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 60px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 12px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--primary-2);
  border-radius: inherit;
}

@media (max-width: 1100px) {
  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .cards-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    transition: 0.25s;
    width: 260px;
  }

  .sidebar.open {
    left: 0;
  }

  .content {
    padding: 14px 12px 40px;
  }

  #menuToggle {
    display: inline-grid;
    place-items: center;
  }

  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .two-col,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .cards-list {
    grid-template-columns: 1fr;
  }

  .recipe-item {
    grid-template-columns: 1fr 1fr;
  }

  .recipe-item .remove-item {
    grid-column: 1 / -1;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .bar-row {
    grid-template-columns: 100px 1fr 48px;
  }
}

@media (max-width: 430px) {
  .cards-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .metric {
    padding: 14px;
  }

  .metric strong {
    font-size: 18px;
  }
}