* {
  box-sizing: border-box;
}

:root {
  --bg: #F7F8F6;
  --text: #1F2933;
  --muted: #5F6B76;
  --primary: #234B73;
  --primary-dark: #183653;
  --green: #3F6B57;
  --green-soft: #E8F1EC;
  --card: #FFFFFF;
  --border: #D9E0E6;
  --draft: #FFF4D6;
  --archived: #E5E7EB;
  --shadow: rgba(16, 24, 40, 0.06);
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px;
}

.narrow {
  max-width: 620px;
}

.search {
  display: flex;
  gap: 10px;
  margin-bottom: 26px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 1px 3px var(--shadow);
}

.search input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 10px;
}

.search input:focus {
  outline: 2px solid var(--green-soft);
  border-radius: 8px;
}

input,
textarea,
select {
  width: 100%;
  padding: 11px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 1rem;
  background: white;
  color: var(--text);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--green-soft);
  border-color: var(--green);
}

label {
  display: block;
  margin-bottom: 16px;
  font-weight: 700;
  color: var(--text);
}

button,
.button {
  display: inline-block;
  border: 0;
  padding: 11px 16px;
  border-radius: 9px;
  background: var(--primary);
  color: white;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

.admin-link {
  font-size: 0.9rem;
  color: var(--muted);
}

.bite,
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 5px solid var(--green);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: 0 2px 8px var(--shadow);
}

.bite h2 {
  margin: 8px 0 10px 0;
  font-size: 1.28rem;
  line-height: 1.3;
}

.bite h2 a {
  color: var(--primary-dark);
}

.meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.tags {
  display: inline-block;
  color: var(--green);
  background: var(--green-soft);
  font-size: 0.9rem;
  border-radius: 999px;
  padding: 5px 10px;
  margin-top: 10px;
}

.empty,
.notice {
  background: #FFF8DC;
  border: 1px solid #F3D27A;
  padding: 14px;
  border-radius: 9px;
}

.error {
  background: #FDECEA;
  border: 1px solid #F5B5AE;
  padding: 14px;
  border-radius: 9px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
}

.admin-table th {
  background: var(--primary-dark);
  color: white;
}

.admin-table th,
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--archived);
}

.status.published {
  background: var(--green-soft);
  color: var(--green);
}

.status.draft {
  background: var(--draft);
  color: #8A5A00;
}

.status.archived {
  background: var(--archived);
  color: #4B5563;
}

nav {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Inline rating controls ──────────────────────────── */

.inline-rate { display: inline; margin: 0; }
.rate-select {
  padding: 2px 4px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}
.rating-cell { color: #ffc107; }
.muted { opacity: 0.6; }

/* ── Card-grid navigation ─────────────────────────────── */

.main-nav {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 18px;
  display: block;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.nav-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 1px 3px var(--shadow);
  transition: box-shadow .15s, border-color .15s, background .15s;
}

.nav-card:hover {
  box-shadow: 0 3px 10px rgba(16,24,40,.10);
  background: #f4f7fa;
  text-decoration: none;
}

.nav-card.active {
  border-left-color: var(--green);
  background: var(--green-soft);
  box-shadow: 0 2px 8px rgba(63,107,87,.12);
}

.nav-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.nav-card.active .nav-card-icon {
  background: var(--green);
}

.nav-card--settings .nav-card-icon {
  background: var(--muted);
}

.nav-card--settings.active .nav-card-icon {
  background: var(--green);
}

.nav-card-label {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  color: var(--primary-dark);
}

.nav-card.active .nav-card-label {
  color: var(--green);
}

.nav-card--settings .nav-card-label {
  color: var(--muted);
}

.nav-card--settings.active .nav-card-label {
  color: var(--green);
}

.nav-card-desc {
  margin-top: 4px;
  font-size: 0.78rem;
  line-height: 1.3;
  color: var(--muted);
  max-width: 200px;
}

/* ── Layout: Fixed Sidebar + Content ───────────────────────────── */

.sidebar {
  position: fixed;
  left: 0;
  top: 48px;
  width: 240px;
  height: calc(100vh - 48px);
  background: #f8f9fa;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
  transition: left 0.25s ease;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  position: relative;
}

.sidebar-divider {
  border-top: 1px solid var(--border);
  margin: 8px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.sidebar-link:hover {
  background: var(--primary);
  color: white;
  text-decoration: none;
}

.sidebar-link:hover .sidebar-icon {
  color: white;
}

.sidebar-item.active .sidebar-link {
  background: var(--primary);
  color: white;
}

.sidebar-item.active .sidebar-link .sidebar-icon {
  color: white;
}

.sidebar-item.sidebar-settings .sidebar-link {
  color: var(--muted);
  font-size: 0.82rem;
}

.sidebar-item.sidebar-settings .sidebar-link:hover {
  background: var(--primary);
  color: white;
}

.sidebar-item.active.sidebar-settings .sidebar-link {
  background: var(--primary);
  color: white;
}

.sidebar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--muted);
  transition: color 0.15s;
}

.sidebar-label {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Compact Top Header ─────────────────────────────────── */

.topbar {
  height: 48px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 1px 3px var(--shadow);
}

.topbar-left {
  display: flex;
  align-items: center;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-user {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.topbar-link {
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.topbar-link:hover {
  background: var(--primary);
  color: white;
  text-decoration: none;
}

/* ── Layout adjustments ─────────────────────────────────── */

/* Account for fixed sidebar + topbar */
.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 24px 280px; /* left padding for sidebar */
}

.narrow {
  max-width: 620px;
}

/* Remove old card-grid nav styles */
.main-nav,
.nav-grid,
.nav-card,
.nav-card-icon,
.nav-card-label,
.nav-card-desc,
.nav-card--settings,
.nav-card--settings.active,
.nav-card--settings .nav-card-icon,
.nav-card--settings.active .nav-card-icon,
.nav-card.active,
.nav-card:hover,
.site-header,
.header-brand,
.header-actions {
  /* These are now handled by .sidebar and .topbar */
}

.site-header {
  display: none;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .container {
    padding-left: 220px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    width: 260px;
    height: 100vh;
    top: 0;
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
    transition: left 0.25s ease;
    z-index: 1000;
  }
  .sidebar.open {
    left: 0;
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
  }
  .sidebar-overlay.open {
    display: block;
  }
  .topbar {
    padding: 0 12px;
  }
  .topbar-title {
    font-size: 0.95rem;
  }
  .topbar-user {
    display: none;
  }
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* Mobile menu toggle button */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
}

@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ── Remove old card-grid nav styles ─────────────────────────────── */

.main-nav,
.nav-grid,
.nav-card,
.nav-card-icon,
.nav-card-label,
.nav-card-desc,
.nav-card--settings,
.nav-card--settings.active,
.nav-card--settings .nav-card-icon,
.nav-card--settings.active .nav-card-icon,
.nav-card.active,
.nav-card:hover,
.site-header,
.header-brand,
.header-actions {
  /* These are now handled by .sidebar and .topbar */
}

.site-header {
  display: none;
}