/* Base styles & theme - improved contrast and cohesion */
:root {
  --bg: #0a0f1c;
  --bg-elev: #0f172a;
  --card: #0c1322;
  --text: #f3f4f6;
  --muted: #cbd5e1;
  --muted-dim: #94a3b8;
  --primary: #10B981;
  --primary-600: #059669;
  --ring: rgba(16,185,129,0.65);
  --border: #243041;
  --warn: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 4px 24px rgba(0,0,0,0.35);
}

html[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --muted-dim: #64748b;
  --border: #e2e8f0;
  --shadow: 0 2px 14px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 800px at 80% -10%, rgba(16,185,129,0.1), transparent 60%) , var(--bg);
  color: var(--text);
  line-height: 1.6;
  letter-spacing: .2px;
}

.container { width: min(1100px, 92%); margin: 0 auto; }

.site-header { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 16px 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; letter-spacing: 0.2px; }
.main-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.main-nav a { color: var(--muted-dim); text-decoration: none; padding: 8px 10px; border-radius: 10px; }
.main-nav a:hover, .main-nav a[aria-current="page"] { color: var(--text); background: rgba(255,255,255,0.03); }
.header-actions { display:flex; gap:10px; }

.site-footer { display:flex; justify-content: space-between; align-items:center; padding: 24px 0 40px; color: var(--muted-dim); }
.link { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; }
 h1 { font-size: clamp(1.7rem, 1.2rem + 1.4vw, 2.3rem); margin: 6px 0 18px; }
 h2 { font-size: 1.25rem; margin: 18px 0 12px; }
 p { margin: 8px 0 12px; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

.masonry { column-count: 3; column-gap: 16px; }
@media (max-width: 900px) { .masonry { column-count: 2; } }
@media (max-width: 640px) { .masonry { column-count: 1; } }
.masonry > * { break-inside: avoid; margin-bottom: 16px; }

.card { background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent), var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.card .content { padding: 16px; }

.btn { appearance: none; border: 1px solid var(--border); background: rgba(255,255,255,0.02); color: var(--text); padding: 10px 14px; border-radius: 12px; cursor: pointer; transition: transform .05s ease, background .2s ease, border-color .2s ease; }
.btn:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.12); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary-600); color: #052014; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.badge { font-size: .85rem; }

.input, select { background: rgba(255,255,255,0.02); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.label { color: var(--muted-dim); font-size: .9rem; }

.kpi { display:flex; gap: 12px; align-items: center; padding: 12px 16px; border:1px dashed var(--border); border-radius: 12px; background: linear-gradient(180deg, rgba(16,185,129,0.1), transparent 60%); }
.kpi .num { font-weight: 800; font-size: 1.2rem; color: var(--text); }

.row { display:flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.space { height: 10px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 30; backdrop-filter: blur(2px); }
.modal { width: min(720px, 92vw); background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.modal header { display:flex; justify-content: space-between; align-items:center; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--bg-elev); }
.modal .body { padding: 16px; }
.modal footer { padding: 14px 16px; border-top: 1px solid var(--border); background: var(--bg-elev); display:flex; gap: 10px; justify-content: flex-end; }
.modal-backdrop[open] { display: flex; }

/* Focus */
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 8px; }

/* Utilities */
.text-muted { color: var(--muted-dim); }
.badge { background: rgba(16,185,129,0.12); color: var(--primary); padding: 4px 8px; border-radius: 999px; border:1px solid rgba(16,185,129,0.25); }
.hr { height: 1px; background: var(--border); margin: 8px 0; }
.small { font-size: .9rem; }

/* Calendar */
.calendar { display: grid; gap: 10px; grid-template-columns: repeat(7, minmax(0,1fr)); }
.calendar .day { aspect-ratio: 1 / 1; display:flex; align-items:center; justify-content: center; border:1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--bg-elev); color: var(--text); position: relative; }
.calendar .day.done { background: linear-gradient(180deg, rgba(16,185,129,0.18), transparent 60%); border-color: rgba(16,185,129,0.4); }
.calendar .day .mark { position:absolute; right:6px; bottom:6px; font-size: 12px; color: var(--primary); }

/* Recipe card */
.recipe-card img { width: 100%; height: auto; display:block; }
.recipe-card .meta { display:flex; gap: 8px; align-items:center; color: var(--muted-dim); font-size: .9rem; }

/* Tables (shopping) */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { border-bottom: 1px solid var(--border); padding: 10px 8px; text-align: left; }
.table th { color: var(--muted-dim); font-weight: 600; }

/* Print */
@media print {
  header, footer, #themeToggle, .no-print { display:none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ddd; }
}
