* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', sans-serif;
  background: #f8fafc;
  color: #2F3547;
  font-size: 14px;
}
a { color: #27ae60; text-decoration: none; }

/* ─── Login ─── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8faf2 0%, #f8fafc 100%);
}
.login-card {
  width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}
.login-card h1 { font-size: 22px; margin-bottom: 6px; color: #2F3547; }
.login-card .subtitle { color: #6D7280; margin-bottom: 28px; font-size: 13px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; color: #555; font-size: 13px; font-weight: 500; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus, .form-group textarea:focus {
  border-color: #27ae60;
  box-shadow: 0 0 0 3px rgba(39,174,96,0.12);
}
.form-group textarea { min-height: 80px; resize: vertical; font-family: monospace; font-size: 12px; }

/* ─── Buttons ─── */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.btn:active { transform: translateY(0); }
.btn-primary { background: #27ae60; color: #fff; }
.btn-primary:hover { background: #219a54; }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 6px; }
.btn-danger { background: #e53e3e; color: #fff; }
.btn-danger:hover { background: #c53030; }
.btn-secondary { background: #f1f5f9; color: #4a5568; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-link { background: none; color: #27ae60; padding: 4px 8px; }
.error-msg { color: #e53e3e; font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ─── Layout ─── */
.app-layout { display: flex; min-height: 100vh; }

/* ─── Sidebar (HowToCook style: light, clean) ─── */
.sidebar {
  width: 240px;
  background: #fff;
  color: #2F3547;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #eef0f4;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 28px 20px 20px;
  font-size: 20px;
  font-weight: 700;
  color: #27ae60;
  border-bottom: 1px solid #f1f5f9;
  letter-spacing: -0.5px;
}
.sidebar-brand span { color: #2F3547; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: #6D7280;
  cursor: pointer;
  border-left: 3px solid transparent;
  font-size: 14px;
  transition: all 0.15s;
}
.nav-item svg { flex-shrink: 0; opacity: 0.6; transition: opacity 0.15s; }
.nav-item:hover { background: #f8fafc; color: #2F3547; }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: #e8faf2;
  color: #27ae60;
  border-left-color: #27ae60;
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; }
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #f1f5f9;
  font-size: 12px;
  color: #6D7280;
}
.sidebar-footer strong { display: block; color: #2F3547; font-size: 13px; margin-bottom: 4px; }

/* ─── Main Content ─── */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: #fff;
  padding: 20px 32px;
  border-bottom: 1px solid #eef0f4;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar h2 { font-size: 20px; color: #2F3547; font-weight: 600; }
.page-body { padding: 28px 32px; flex: 1; }

/* ─── Stats Bar (HowToCook hero style) ─── */
.hero-bar {
  background: linear-gradient(135deg, #e8faf2 0%, #f0fdf4 100%);
  border: 1px solid #c3f0d8;
  border-radius: 14px;
  padding: 20px 28px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}
.hero-bar .hero-title {
  font-size: 18px;
  font-weight: 700;
  color: #2F3547;
  white-space: nowrap;
}
.hero-bar .hero-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.hero-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.hero-stat .hs-val { font-size: 22px; font-weight: 700; color: #27ae60; }
.hero-stat .hs-label { font-size: 11px; color: #6D7280; margin-top: 2px; }

/* ─── Stats Grid ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid #f1f5f9;
}
.stat-card .label { color: #6D7280; font-size: 12px; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 600; color: #2F3547; }

/* ─── Search Bar (HowToCook hero search style) ─── */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}
.search-bar input {
  flex: 1;
  padding: 11px 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  max-width: 360px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-bar input:focus {
  border-color: #27ae60;
  box-shadow: 0 0 0 3px rgba(39,174,96,0.12);
}
.search-bar select {
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  background: #fff;
  color: #4a5568;
  cursor: pointer;
  transition: border-color 0.2s;
}
.search-bar select:focus { border-color: #27ae60; }

/* ─── Recipe Card Grid ─── */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.recipe-card {
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #f1f5f9;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}
.recipe-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
}
.recipe-card-img {
  height: 110px;
  background: linear-gradient(135deg, #e8faf2 0%, #d0f0e0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.recipe-card-img .cuisine-emoji {
  font-size: 48px;
  opacity: 0.35;
}
.recipe-card-img .cuisine-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.9);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #27ae60;
  border: 1px solid #c3f0d8;
}
.no-video-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #a0aec0;
  white-space: nowrap;
}

/* Video card variant */
.recipe-card-video {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  cursor: pointer;
}
.recipe-card-video .video-play-icon {
  font-size: 36px;
  color: rgba(255,255,255,0.9);
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
  transition: transform 0.2s;
}
.recipe-card-video:hover .video-play-icon {
  transform: scale(1.15);
}
.recipe-card-video .video-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: #e53e3e;
  color: #fff;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.recipe-card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.recipe-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.recipe-card-stars { color: #f59e0b; font-size: 13px; letter-spacing: 1px; }
.recipe-card-calories { font-size: 12px; color: #6D7280; }
.recipe-card-title {
  font-size: 16px;
  font-weight: 600;
  color: #2F3547;
  margin-bottom: 6px;
  line-height: 1.4;
}
.recipe-card-desc {
  font-size: 13px;
  color: #6D7280;
  line-height: 1.6;
  margin-bottom: 12px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.recipe-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: #f0fdf4;
  color: #27ae60;
  border: 1px solid #c3f0d8;
}
.tag.tag-cuisine { background: #fff; }
.recipe-card-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}
.recipe-card-actions .btn { flex: 1; text-align: center; font-size: 12px; padding: 7px 0; border-radius: 8px; }

/* ─── Pagination ─── */
.pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 20px;
  color: #6D7280;
  font-size: 13px;
}
.pagination .page-info { margin: 0 auto; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 16px;
  width: 760px;
  max-width: 94vw;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px;
}
.modal h3 { margin-bottom: 20px; color: #2F3547; font-size: 18px; }
.modal-actions { margin-top: 24px; display: flex; gap: 10px; justify-content: flex-end; }
.hidden { display: none !important; }
.empty-hint { text-align: center; color: #a0aec0; padding: 60px 40px; font-size: 15px; }
.empty-hint .icon { font-size: 48px; display: block; margin-bottom: 16px; opacity: 0.4; }

/* ─── Info Banner ─── */
.info-banner {
  background: #ebf8ff;
  border: 1px solid #bee3f8;
  color: #2c5282;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.6;
  border-radius: 10px;
}
.info-banner code {
  background: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ─── Table (fallback) ─── */
.data-table {
  width: 100%;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border-collapse: collapse;
}
.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #edf2f7;
}
.data-table th { background: #f7fafc; color: #6D7280; font-weight: 500; font-size: 12px; }
.data-table tr:hover td { background: #fafbfc; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}
.badge-ok { background: #e8faf2; color: #2f855a; }
.badge-off { background: #fed7d7; color: #c53030; }

/* ─── Knowledge page tags ─── */
.tag-tips { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
.tag-learn { background: #e3f2fd; color: #1565c0; border-color: #bbdefb; }
.tag-advanced { background: #f3e5f5; color: #7b1fa2; border-color: #e1bee7; }
.tag-source { background: #fff3e0; color: #e65100; border-color: #ffe0b2; }
.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-right: 4px; }

/* ─── Recipe Detail Modal ─── */
.recipe-detail { min-width: 0; }
.detail-header {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  background: linear-gradient(135deg, #e8faf2 0%, #f0fdf4 100%);
  border-radius: 14px;
  overflow: hidden;
  margin: -28px -28px 24px;
  padding: 24px 28px;
  border-bottom: 1px solid #eef0f4;
}
.detail-img {
  width: 100px;
  height: 100px;
  background: rgba(39,174,96,0.12);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  border: 2px solid rgba(39,174,96,0.2);
}
.detail-emoji { font-size: 52px; }
.detail-badge {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.95);
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  color: #27ae60;
  white-space: nowrap;
}
.detail-meta { flex: 1; min-width: 0; }
.detail-title-wrap { margin-bottom: 8px; }
.detail-title-input {
  width: 100%;
  font-size: 22px;
  font-weight: 700;
  color: #2F3547;
  border: none;
  background: transparent;
  outline: none;
  border-bottom: 2px solid transparent;
  padding: 4px 0;
  transition: border-color 0.2s;
}
.detail-title-input:focus { border-bottom-color: #27ae60; }
.detail-submeta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.detail-stars { color: #f59e0b; font-size: 15px; letter-spacing: 2px; }
.detail-calories { font-size: 13px; color: #6D7280; font-weight: 500; }
.detail-time { font-size: 13px; color: #6D7280; }

.detail-desc-section {
  margin-bottom: 20px;
}
.detail-section-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #6D7280;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.detail-count {
  font-weight: 400;
  color: #27ae60;
  margin-left: 4px;
}
.detail-desc-input {
  width: 100%;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: #2F3547;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.detail-desc-input:focus {
  border-color: #27ae60;
  box-shadow: 0 0 0 3px rgba(39,174,96,0.12);
}

.detail-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 20px;
}
.detail-fields { display: flex; flex-direction: column; gap: 10px; }
.detail-field {
  display: flex;
  align-items: center;
  gap: 10px;
}
.detail-field label {
  font-size: 12px;
  color: #6D7280;
  min-width: 72px;
  flex-shrink: 0;
}
.detail-field input,
.detail-field select {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.detail-field input:focus,
.detail-field select:focus { border-color: #27ae60; }

.detail-tags-input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.detail-tags-input:focus { border-color: #27ae60; }

/* Ingredient list */
.ing-list, .step-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ing-item, .step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 13px;
  color: #2F3547;
}
.ing-item::before {
  content: '•';
  color: #27ae60;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}
.ing-amount { color: #6D7280; margin-left: 6px; font-size: 12px; }
.ing-empty, .step-empty { color: #a0aec0; font-size: 13px; padding: 8px; }

.step-num {
  width: 24px;
  height: 24px;
  background: #27ae60;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.step-text { flex: 1; line-height: 1.5; }

.detail-edit-hint {
  font-size: 11px;
  color: #a0aec0;
  margin-top: 6px;
}

.detail-json-section { margin-bottom: 20px; }
.detail-json-toggle {
  font-size: 13px;
  color: #6D7280;
  cursor: pointer;
  padding: 8px 0;
  user-select: none;
}
.detail-json-toggle:hover { color: #27ae60; }
.detail-json-body { padding-top: 12px; }
.detail-json-body .form-group label { font-size: 12px; color: #6D7280; }
.detail-json-body textarea {
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 12px;
}

.detail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #f1f5f9;
  padding-top: 16px;
}
.detail-verified {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #6D7280;
  cursor: pointer;
}
.detail-verified input { width: 16px; height: 16px; accent-color: #27ae60; }

.analytics-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.analytics-range {
  font-size: 13px;
  color: #6d7280;
}
.analytics-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}
.panel-card {
  background: #fff;
  border: 1px solid #e8ecf0;
  border-radius: 12px;
  padding: 18px 20px;
}
.panel-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #2f3547;
}
.analytics-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: #6d7280;
  line-height: 1.7;
}
.analytics-muted {
  margin: 0;
  font-size: 13px;
  color: #6d7280;
}
@media (max-width: 900px) {
  .analytics-panels { grid-template-columns: 1fr; }
}