:root {
  /* Light only -- the palette below has no dark-mode variants. Claiming
     "light dark" makes the browser flip its system colors in dark mode,
     which turned buttons' default text white on their white background. */
  color-scheme: light;
  /* Three steps of light green -- page, raised surface, inner card. No
     white anywhere; depth comes from the ramp plus --border. */
  --bg: #dbe5c4;
  --surface: #e9efd9;
  --card: #f3f7ea;
  --border: #bfcda3;
  --muted: #566046;
  --ink: #232818;
  --accent: #5d1623;
  --accent-dark: #40101a;
  /* Orchid and gold are both too light for small text -- borders, focus
     rings and accents only. Hence the darker --profit-positive below. */
  --accent-alt: #d269e6;
  --gold: #c2b63a;
  --danger: #9d1b30;
  --profit-positive: #2f5d24;
  --profit-negative: #9d1b30;
}

* {
  box-sizing: border-box;
}

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

:focus-visible {
  outline: 2px solid var(--accent-alt);
  outline-offset: 2px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header h1 {
  font-size: 1.25rem;
  margin: 0;
}

nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

button {
  font: inherit;
  /* Always an explicit color -- never the UA's buttontext system color. */
  color: var(--accent);
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--card);
  padding: 0.5rem 0.9rem;
}

button.nav-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent-dark);
}

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

/* Solid variant for a destructive primary action, e.g. the confirm dialog. */
button.danger-solid {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

button[type="submit"] {
  background: var(--accent);
  color: white;
  border-color: var(--accent-dark);
}

/* Raised sheet on the page canvas -- one step up the green ramp, with the
   inner cards/inputs one step lighter again. */
main {
  max-width: 900px;
  margin: 1.5rem auto;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

#login-view {
  max-width: 320px;
  margin: 4rem auto;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

label {
  font-size: 0.85rem;
  color: var(--muted);
  display: block;
  margin-bottom: 0.25rem;
}

input {
  font: inherit;
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: inherit;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
}

th, td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.recipe-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.recipe-card:hover {
  border-color: var(--accent-alt);
}

.recipe-card .stats {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: right;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
}

.row {
  display: flex;
  gap: 1rem;
}

.row > div {
  flex: 1;
}

.totals {
  display: flex;
  gap: 2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

.totals div {
  display: flex;
  flex-direction: column;
}

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

.totals strong {
  font-size: 1.2rem;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog {
  background: var(--card);
  border-radius: 10px;
  padding: 1.25rem;
  width: 100%;
  max-width: 420px;
}

/* Dialog actions sit bottom-right; the inline form keeps its left-aligned
   row so the recipe editor's Save button stays where it was. */
.dialog .form-actions {
  justify-content: flex-end;
}

.profit-positive {
  color: var(--profit-positive);
}

.profit-negative {
  color: var(--profit-negative);
}

.icon-btn {
  border: none;
  background: none;
  color: var(--muted);
}

.icon-btn:hover {
  color: var(--danger);
}

[hidden] {
  display: none !important;
}
