:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #17191d;
  --muted: #6c727f;
  --line: #dfe3e8;
  --primary: #20242b;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 8px 25px rgba(20, 25, 35, .08);
}
* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
.hidden { display: none !important; }
.loading-screen { display:grid; place-items:center; min-height:100vh; color:var(--muted); }
.login-page { min-height:100vh; display:grid; place-items:center; padding:24px; }
.login-card { width:min(420px,100%); background:var(--surface); border:1px solid var(--line); border-radius:20px; box-shadow:var(--shadow); padding:32px; }
.brand { font-weight:800; letter-spacing:-.03em; font-size:1.45rem; }
.brand small { display:block; color:var(--muted); font-size:.78rem; font-weight:600; margin-top:4px; }
.stack { display:grid; gap:14px; }
.field { display:grid; gap:6px; }
.field label { font-size:.86rem; font-weight:700; }
.field input, .field select, .field textarea { width:100%; border:1px solid var(--line); border-radius:10px; padding:10px 12px; background:#fff; color:var(--text); }
.field textarea { min-height:94px; resize:vertical; }
.btn { border:1px solid var(--line); background:var(--surface); color:var(--text); border-radius:10px; padding:9px 13px; font-weight:700; display:inline-flex; align-items:center; justify-content:center; gap:7px; }
.btn:hover { background:var(--surface-2); }
.btn.primary { background:var(--primary); color:#fff; border-color:var(--primary); }
.btn.danger { color:var(--danger); border-color:#f0b7b2; }
.btn.small { padding:6px 9px; font-size:.82rem; }
.btn.ghost { background:transparent; border-color:transparent; }
.topbar { position:sticky; top:0; z-index:20; display:flex; align-items:center; justify-content:space-between; gap:16px; padding:14px 22px; background:rgba(255,255,255,.94); border-bottom:1px solid var(--line); backdrop-filter:blur(12px); }
.topbar-actions { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.layout { display:grid; grid-template-columns:240px minmax(0,1fr); min-height:calc(100vh - 65px); }
.sidebar { border-right:1px solid var(--line); background:var(--surface); padding:18px 12px; }
.nav-btn { width:100%; border:0; background:transparent; text-align:left; border-radius:10px; padding:11px 12px; font-weight:750; color:#4a505b; margin-bottom:5px; }
.nav-btn.active, .nav-btn:hover { background:#eef0f3; color:var(--text); }
.main { padding:24px; min-width:0; }
.page-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin-bottom:20px; }
h1,h2,h3,h4,p { margin-top:0; }
h1 { font-size:1.65rem; margin-bottom:4px; }
.muted { color:var(--muted); }
.grid { display:grid; gap:16px; }
.cards { grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); }
.card { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); box-shadow:0 2px 10px rgba(20,25,35,.035); overflow:hidden; }
.card-body { padding:15px; }
.recipe-photo { width:100%; aspect-ratio:16/10; object-fit:cover; background:#e8eaed; display:block; }
.recipe-photo.placeholder { display:grid; place-items:center; color:#8a909b; font-weight:700; }
.card-title { font-size:1.05rem; font-weight:800; margin-bottom:6px; }
.card-actions { display:flex; gap:7px; flex-wrap:wrap; margin-top:12px; }
.table-wrap { overflow:auto; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); }
table { width:100%; border-collapse:collapse; min-width:720px; }
th,td { padding:11px 12px; border-bottom:1px solid var(--line); text-align:left; vertical-align:middle; }
th { background:var(--surface-2); font-size:.79rem; text-transform:uppercase; letter-spacing:.03em; color:var(--muted); }
tr:last-child td { border-bottom:0; }
.editor { display:grid; gap:18px; }
.panel { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:18px; }
.panel-head { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:14px; }
.form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.form-grid .wide { grid-column:1/-1; }
.group-box, .step-box { border:1px solid var(--line); border-radius:12px; padding:14px; margin-top:12px; background:var(--surface-2); }
.row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.row > .grow { flex:1 1 180px; }
.ingredient-row { display:grid; grid-template-columns:minmax(180px,2fr) 110px 100px minmax(160px,1fr) auto; gap:8px; align-items:end; padding:9px 0; border-top:1px dashed var(--line); }
.ingredient-row:first-of-type { border-top:0; }
.rich-toolbar { display:flex; gap:5px; flex-wrap:wrap; padding:7px; border:1px solid var(--line); border-bottom:0; border-radius:10px 10px 0 0; background:#fff; }
.rich-editor { min-height:110px; border:1px solid var(--line); border-radius:0 0 10px 10px; padding:10px; background:#fff; outline:none; }
.chips { display:flex; gap:6px; flex-wrap:wrap; }
.chip { border:1px solid var(--line); border-radius:999px; padding:4px 8px; font-size:.78rem; background:#fff; }
.switch-row { display:flex; align-items:center; gap:9px; }
.switch-row input { width:18px; height:18px; }
.preview-layout { display:grid; grid-template-columns:minmax(0,1.5fr) minmax(260px,.7fr); gap:20px; }
.hero { border-radius:18px; overflow:hidden; background:#e7e9ec; margin-bottom:18px; }
.hero img { width:100%; max-height:420px; object-fit:cover; display:block; }
.recipe-meta { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:18px; }
.meta-pill { background:#eceef1; border-radius:999px; padding:6px 10px; font-size:.84rem; font-weight:700; }
.preview-group { margin:18px 0; }
.preview-ingredient { display:grid; grid-template-columns:100px 60px minmax(0,1fr); gap:8px; align-items:center; padding:7px 0; border-bottom:1px solid #eceef1; }
.preview-ingredient input { width:100%; border:1px solid var(--line); border-radius:8px; padding:7px; }
.step-card { border-top:1px solid var(--line); padding:18px 0; }
.step-card img { max-height:320px; object-fit:cover; border-radius:12px; margin-top:10px; }
.cost-box { position:sticky; top:88px; }
.cost-total { font-size:1.65rem; font-weight:900; }
.alert { border:1px solid #f3ca8d; background:#fff8e9; padding:10px 12px; border-radius:10px; font-size:.86rem; }
.error { color:var(--danger); font-weight:700; }
.toast { position:fixed; right:20px; bottom:20px; z-index:100; background:#17191d; color:#fff; border-radius:10px; padding:11px 14px; opacity:0; transform:translateY(10px); pointer-events:none; transition:.2s; max-width:min(360px,calc(100vw - 40px)); }
.toast.show { opacity:1; transform:none; }
.modal-backdrop { position:fixed; inset:0; background:rgba(10,12,16,.55); z-index:50; display:grid; place-items:center; padding:18px; }
.modal { background:#fff; border-radius:16px; width:min(620px,100%); max-height:90vh; overflow:auto; padding:20px; box-shadow:var(--shadow); }
.public-page { max-width:1120px; margin:0 auto; padding:22px; }
.public-header { display:flex; justify-content:space-between; gap:14px; align-items:center; margin-bottom:20px; }
@media (max-width:900px) {
  .layout { grid-template-columns:1fr; }
  .sidebar { display:flex; overflow:auto; border-right:0; border-bottom:1px solid var(--line); padding:8px; }
  .nav-btn { width:auto; white-space:nowrap; margin:0 4px 0 0; }
  .preview-layout { grid-template-columns:1fr; }
  .cost-box { position:static; }
  .ingredient-row { grid-template-columns:1fr 100px 90px auto; }
  .ingredient-row .ingredient-note { grid-column:1/-2; }
}
@media (max-width:620px) {
  .topbar { padding:12px; }
  .main { padding:14px; }
  .form-grid { grid-template-columns:1fr; }
  .ingredient-row { grid-template-columns:1fr 1fr; }
  .ingredient-row > * { min-width:0; }
  .ingredient-row .ingredient-select, .ingredient-row .ingredient-note { grid-column:1/-1; }
}
@media print {
  body { background:#fff; }
  .no-print, .topbar, .sidebar, .toast { display:none !important; }
  .layout, .preview-layout { display:block; }
  .main, .public-page { padding:0; max-width:none; }
  .panel, .card { border:0; box-shadow:none; padding:0; }
}
