:root {
  --bg: #f2f6f4;
  --surface: #ffffff;
  --surface-2: #f7faf8;
  --ink: #102a2a;
  --muted: #657a77;
  --line: #dfe8e4;
  --brand: #0f766e;
  --brand-2: #14b8a6;
  --brand-soft: #e6f5f1;
  --accent: #f59e0b;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --sidebar: #0a2424;
  --sidebar-2: #0f3331;
  --shadow-sm: 0 2px 8px rgba(16, 42, 42, .05);
  --shadow: 0 14px 40px rgba(16, 42, 42, .08);
  --shadow-lg: 0 24px 60px rgba(16, 42, 42, .14);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 90% -10%, rgba(20, 184, 166, .09), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(245, 158, 11, .07), transparent 55%),
    var(--bg);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: #0b5f59; }
h1, h2, h3, p { margin: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
code { background: var(--brand-soft); color: var(--brand); padding: 1px 6px; border-radius: 6px; font-size: .85em; }

/* ---------- Shell ---------- */

.app-shell { display: flex; min-height: 100vh; }

.nav-toggle { display: none; }

.sidebar {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  width: 264px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 20px 22px;
  color: #e8fffb;
  background:
    radial-gradient(400px 300px at 0% 0%, rgba(20, 184, 166, .22), transparent 70%),
    linear-gradient(180deg, var(--sidebar-2), var(--sidebar));
  border-right: 1px solid rgba(255, 255, 255, .06);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 2px 4px; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 13px;
  color: #053b36;
  background: linear-gradient(135deg, #5eead4, #2dd4bf 55%, #fbbf24);
  box-shadow: 0 8px 20px rgba(45, 212, 191, .28);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -.04em;
}
.brand-mark-lg { width: 54px; height: 54px; flex-basis: 54px; font-size: 1.6rem; border-radius: 16px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.2; }
.brand-copy strong { font-size: 1.05rem; letter-spacing: -.01em; }
.brand-copy small { color: rgba(232, 255, 251, .55); font-size: .76rem; }

.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-label {
  margin: 4px 10px 8px;
  color: rgba(232, 255, 251, .4);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  color: rgba(232, 255, 251, .72);
  border-radius: 11px;
  font-size: .92rem;
  font-weight: 600;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-link svg { width: 19px; height: 19px; opacity: .78; }
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, .07); transform: translateX(2px); }
.nav-link.is-active {
  color: #062e2a;
  background: linear-gradient(135deg, #7ff5e3, #2dd4bf);
  box-shadow: 0 10px 24px rgba(45, 212, 191, .22);
}
.nav-link.is-active svg { opacity: 1; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 13px;
  background: rgba(255, 255, 255, .05);
}
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5eead4, #0d9488);
  color: #042f2b;
  font-size: .9rem;
  font-weight: 800;
  text-transform: uppercase;
}
.avatar-soft { background: var(--brand-soft); color: var(--brand); }
.user-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-copy strong { font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-copy small { color: rgba(232, 255, 251, .5); font-size: .74rem; }

.main { display: flex; flex-direction: column; min-width: 0; flex: 1; margin-left: 264px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 66px;
  padding: 0 34px;
  border-bottom: 1px solid rgba(223, 232, 228, .75);
  background: rgba(242, 246, 244, .82);
  backdrop-filter: blur(14px);
}
.topbar-title { font-weight: 700; letter-spacing: -.01em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 38px;
  height: 38px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
.menu-btn span { display: block; height: 2px; border-radius: 2px; background: var(--ink); }

.content { width: 100%; max-width: 1260px; margin: 0 auto; padding: 34px; }

/* ---------- Typography helpers ---------- */

.eyebrow {
  margin-bottom: 6px;
  color: var(--brand);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.subtitle { margin-top: 6px; color: var(--muted); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .8rem; color: var(--muted); }
.count { color: var(--muted); font-size: .78rem; font-weight: 600; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}
.page-head h1 { font-size: clamp(1.6rem, 2.4vw, 2.15rem); line-height: 1.1; letter-spacing: -.035em; }
.head-actions, .head-badges { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.head-badges { margin-top: 14px; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
}
.back-link svg { width: 15px; height: 15px; }
.back-link:hover { color: var(--brand); }

/* ---------- Buttons, pills, badges ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: .88rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #0d9488);
  box-shadow: 0 10px 22px rgba(15, 118, 110, .22);
}
.btn-primary:hover { color: #fff; box-shadow: 0 14px 28px rgba(15, 118, 110, .28); transform: translateY(-1px); }
.btn-dark { color: #fff; background: var(--ink); }
.btn-dark:hover { color: #fff; background: #0a1f1f; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { border-color: #cbdad5; background: var(--surface-2); color: var(--ink); }
.btn-danger-ghost { background: var(--surface); border-color: #fecaca; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); color: #b91c1c; }
.btn-small { padding: 7px 11px; border-radius: 9px; font-size: .78rem; }
.btn-block { width: 100%; }

.pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}
.pill { background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.pill-soft { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.badge { background: var(--brand-soft); color: var(--brand); }
.badge-on-media { background: rgba(255, 255, 255, .9); color: var(--brand); backdrop-filter: blur(4px); }

/* ---------- Filter ---------- */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, .8);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}
.field { position: relative; display: flex; align-items: center; }
.field-search { flex: 1; min-width: 0; }
.field-search svg { position: absolute; left: 13px; width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.field-search input { padding-left: 39px; }
.field-select { width: 210px; }
.field input, .field select { width: 100%; }
.filter-bar input, .filter-bar select {
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .86rem;
}
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(20, 184, 166, .14); }

/* ---------- Recipe grid ---------- */

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(278px, 1fr));
  gap: 20px;
}
.recipe-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.recipe-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: #cfe1db; }
.recipe-card-media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 132px;
  overflow: hidden;
  background:
    radial-gradient(220px 150px at 80% 0%, rgba(255, 255, 255, .35), transparent 70%),
    linear-gradient(135deg, #0f766e, #14b8a6 60%, #5eead4);
}
.recipe-card:nth-child(3n+2) .recipe-card-media { background: linear-gradient(135deg, #134e4a, #0d9488 55%, #99f6e4); }
.recipe-card:nth-child(3n+3) .recipe-card-media { background: linear-gradient(135deg, #14532d, #0f766e 55%, #6ee7b7); }
.recipe-initial {
  color: rgba(255, 255, 255, .82);
  font-size: 3.6rem;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.recipe-card-media .badge { position: absolute; top: 12px; left: 12px; }
.recipe-card-body { display: flex; flex-direction: column; gap: 13px; padding: 17px 18px 18px; flex: 1; }
.recipe-card h2 { font-size: 1.08rem; letter-spacing: -.02em; line-height: 1.2; }
.recipe-card h2 a { color: var(--ink); }
.recipe-card h2 a:hover { color: var(--brand); }
.recipe-subtitle { margin-top: 4px; font-size: .8rem; }
.meta-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: auto; }
.meta {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 600;
}
.meta strong { color: var(--ink); font-size: .82rem; }
.meta-total { background: var(--brand-soft); color: var(--brand); }
.meta-total strong { color: var(--brand); }
.card-actions { display: flex; align-items: center; gap: 7px; padding-top: 12px; border-top: 1px solid var(--line); }
.card-actions form { margin-left: auto; }

/* ---------- Panels & tables ---------- */

.panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-head h2 { font-size: 1rem; letter-spacing: -.01em; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 0 14px 11px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-align: left;
  text-transform: uppercase;
}
.table td { padding: 13px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background .15s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table-primary { display: flex; align-items: center; gap: 11px; font-weight: 600; }
.cell-actions { width: 1%; white-space: nowrap; text-align: right; }
.row-actions { display: inline-flex; align-items: center; gap: 7px; }
.row-actions form { display: inline-flex; }

/* ---------- Empty state ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 72px 24px;
  border: 1px dashed #cbdad5;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .6);
  text-align: center;
}
.empty-state-inline { border: 0; background: transparent; padding: 52px 24px; }
.empty-icon { font-size: 2rem; }
.empty-state h2 { font-size: 1.1rem; }

/* ---------- Detail ---------- */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.7fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.stat-label { display: block; margin-bottom: 3px; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.stat-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; }
.stat-value small { margin-left: 3px; color: var(--muted); font-size: .72rem; font-weight: 600; }
.stat-text { display: block; padding-top: 4px; color: var(--ink); font-size: .9rem; }

.detail-layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.ingredient-list { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.ingredient-list li { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.ingredient-list li:last-child { border-bottom: 0; }
.ing-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--brand-2); box-shadow: 0 0 0 3px rgba(20, 184, 166, .14); }
.ing-name { min-width: 0; }
.ing-amount { margin-left: auto; padding-left: 10px; color: var(--muted); font-size: .78rem; font-weight: 600; text-align: right; }

.steps { counter-reset: step; display: flex; flex-direction: column; gap: 0; margin: 0; padding: 0; list-style: none; }
.steps li { position: relative; display: grid; grid-template-columns: 38px 1fr; gap: 12px; padding: 13px 0; color: var(--ink); }
.steps li::before {
  counter-increment: step;
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: .78rem;
  font-weight: 800;
}
.steps li + li { border-top: 1px solid var(--line); }

/* ---------- Forms ---------- */

.editor { display: flex; flex-direction: column; gap: 18px; max-width: 1000px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.form-field-wide { grid-column: 1 / -1; }
.form-field label { color: var(--ink); font-size: .78rem; font-weight: 700; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .9rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-field textarea { resize: vertical; line-height: 1.6; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, .14);
}
.form-hint { margin-top: -4px; color: var(--muted); font-size: .76rem; }

.ingredient-editor { display: flex; flex-direction: column; gap: 10px; }
.ing-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.ing-amount-field { min-width: 0; }
.editor-actions {
  position: sticky;
  bottom: 16px;
  z-index: 10;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

/* ---------- Auth ---------- */

.auth-shell {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px 18px;
  overflow: hidden;
  background:
    radial-gradient(700px 500px at 15% 0%, rgba(20, 184, 166, .18), transparent 60%),
    radial-gradient(700px 500px at 100% 100%, rgba(245, 158, 11, .12), transparent 60%),
    linear-gradient(180deg, #071e1e, #0b2b2a 55%, #0a2424);
}
.auth-glow { position: absolute; border-radius: 50%; filter: blur(10px); pointer-events: none; }
.auth-glow-one { width: 340px; height: 340px; top: -120px; left: -80px; background: rgba(45, 212, 191, .16); }
.auth-glow-two { width: 280px; height: 280px; right: -80px; bottom: -60px; background: rgba(245, 158, 11, .12); }
.auth-panel { position: relative; z-index: 1; width: min(440px, 100%); }
.auth-card {
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 24px;
  background: rgba(255, 255, 255, .97);
  box-shadow: var(--shadow-lg);
}
.auth-head { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 24px; }
.auth-head h1 { margin-top: 6px; font-size: 1.7rem; letter-spacing: -.04em; }
.auth-head .subtitle { margin-top: 0; font-size: .88rem; }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-note { color: var(--muted); font-size: .82rem; text-align: center; }
.alert { padding: 11px 13px; margin-bottom: 16px; border-radius: 10px; font-size: .84rem; }
.alert-error { color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; }

/* ---------- Responsive ---------- */

@media (max-width: 1050px) {
  .detail-layout { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-wide { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-102%); transition: transform .24s ease; box-shadow: var(--shadow-lg); }
  .nav-toggle:checked ~ .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn { display: flex; }
  .topbar { padding: 0 18px; }
  .content { padding: 24px 18px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .page-head { flex-direction: column; }
  .page-head > .btn, .page-head .head-actions { align-self: stretch; }
  .page-head > .btn { justify-content: center; }
  .filter-bar { flex-wrap: wrap; }
  .field-search { flex-basis: 100%; }
  .field-select { flex: 1; width: auto; }
  .recipe-grid { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .stat-wide { grid-column: 1 / -1; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .ing-row { grid-template-columns: 1fr; align-items: stretch; }
  .ing-row .btn { justify-self: start; }
  .editor-actions { position: static; flex-direction: column-reverse; }
  .editor-actions .btn { width: 100%; }
  .panel { padding: 17px; overflow-x: auto; }
  .auth-card { padding: 26px 22px; }
}
