/* ---------- Design tokens ---------- */
:root {
  /* Palette: white base, oat neutrals, blue for information, hot pink for action & selection.
     Text/control pairs are WCAG AA on white and oat-100. */
  --white: #ffffff;
  --oat-50: #fbf8f2;
  --oat-100: #f4eee3;
  --oat-200: #e9e0d0;
  --oat-300: #d9cdb8;
  --oat-600: #8a7d66; /* input borders, 4:1 on white */

  --blue-50: #e8edfb;
  --blue-600: #1f3fb8;
  --blue-700: #18328f;

  --pink-50: #fce7f1;
  --pink-400: #ff3d8b; /* decorative only */
  --pink-600: #d4146e;
  --pink-700: #b00f57;

  --text: #16192b;
  --text-2: #4a4f63;
  --text-muted: #62677a;
  --success: #1e7a46;
  --error: #b42318;

  --bg: var(--white);
  --surface: var(--white);
  --surface-sunken: var(--oat-100);
  --border: var(--oat-200);
  --divider: var(--oat-200);
  --accent: var(--pink-600);
  --accent-hover: var(--pink-700);
  --accent-soft: var(--pink-50);
  --info: var(--blue-600);
  --focus: var(--blue-600);

  /* Type */
  --font: 'Inter', 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Inter Display', 'Segoe UI Variable Display', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;

  /* Spacing (4px scale) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 28px;
  --s-8: 32px;
  --s-10: 40px;

  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgba(22, 25, 43, 0.04), 0 4px 16px rgba(22, 25, 43, 0.04);
  --container: 1160px;
  --gutter: clamp(16px, 4vw, 40px);
  --tap: 44px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-md) / 1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--info); text-underline-offset: 3px; }
a:hover { color: var(--blue-700); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--border); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-6);
  flex-wrap: wrap; padding-top: var(--s-4); padding-bottom: var(--s-4);
}
.brand-block { display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap; }
.brand {
  font: 800 var(--fs-2xl) / 1 var(--font-display); letter-spacing: -0.03em;
  color: var(--text); text-decoration: none;
}
.brand:hover { color: var(--text); }
.brand .dot { color: var(--pink-400); }
.tagline { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); }
.updated { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); display: flex; align-items: center; gap: var(--s-2); }
.updated .live { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; }
.updated .live.stale { background: var(--oat-600); }

/* ---------- Search panel ---------- */
.search-panel {
  margin: var(--s-6) 0 var(--s-5);
  padding: var(--s-5);
  background: var(--surface-sunken);
  border-radius: var(--radius-lg);
}
.search-field { position: relative; display: flex; align-items: center; }
.search-field .icon-search { position: absolute; left: 18px; width: 22px; height: 22px; color: var(--text-muted); pointer-events: none; }
.search-field input {
  width: 100%; min-height: 60px; padding: 0 56px 0 52px;
  font-size: var(--fs-lg); background: var(--white); color: var(--text);
  border: 1px solid var(--oat-600); border-radius: var(--radius-md);
  -webkit-appearance: none; appearance: none;
}
.search-field input::placeholder { color: var(--text-muted); }
.search-field input:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.search-field input::-webkit-search-cancel-button { display: none; }
.clear-search {
  position: absolute; right: 8px; width: var(--tap); height: var(--tap);
  display: grid; place-items: center; border: 0; background: transparent; border-radius: var(--radius-sm);
  color: var(--text-2); cursor: pointer;
}
.clear-search:hover { background: var(--oat-100); color: var(--text); }
.clear-search[hidden] { display: none; }

/* Toolbar: location, price, district, sort */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-top: var(--s-4); }
.control { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--text-2); }
.select {
  min-height: var(--tap); padding: 0 36px 0 var(--s-3);
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%234a4f63' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1px solid var(--oat-600); border-radius: var(--radius-sm);
  -webkit-appearance: none; appearance: none; cursor: pointer; color: var(--text);
}
.select:disabled { opacity: 0.55; cursor: not-allowed; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-4); border-radius: var(--radius-sm);
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer; text-decoration: none;
  border: 1px solid transparent; transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: var(--accent-hover); color: var(--white); }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-outline { background: var(--white); border-color: var(--oat-600); color: var(--text); }
.btn-outline:hover { border-color: var(--text); }
.btn-outline[aria-pressed='true'] { background: var(--blue-50); border-color: var(--info); color: var(--blue-700); }
.btn-ghost { background: transparent; color: var(--info); padding: 0 var(--s-2); }
.btn-ghost:hover { background: var(--blue-50); color: var(--blue-700); }
.toolbar .spacer { flex: 1; }
.geo-status { margin: var(--s-3) 0 0; font-size: var(--fs-sm); color: var(--text-2); }
.geo-status.error { color: var(--error); }
.geo-status:empty { display: none; }

/* ---------- Results ---------- */
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.result-count { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.result-count strong { color: var(--text); font-weight: 600; }
.results { display: grid; gap: var(--s-5); align-items: start; margin-bottom: var(--s-10); }
@media (min-width: 1024px) { .results { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Restaurant card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--s-6); box-shadow: var(--shadow-card); min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); }
.card-title { margin: 0; font: 700 var(--fs-xl) / 1.2 var(--font-display); letter-spacing: -0.015em; }
.card-meta { margin: var(--s-1) 0 0; font-size: var(--fs-sm); color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 2px var(--s-2); }
.card-meta a { color: var(--text-2); text-decoration: none; }
.card-meta a:hover { color: var(--info); text-decoration: underline; }
.distance { color: var(--info); font-weight: 600; }
.link-subtle {
  flex: none; display: inline-flex; align-items: center; gap: 4px; min-height: 32px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--info); text-decoration: none; white-space: nowrap;
}
.link-subtle:hover { text-decoration: underline; }
.link-subtle .icon { width: 14px; height: 14px; }
.badges { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  font-size: var(--fs-xs); font-weight: 500; border-radius: var(--radius-pill);
  background: var(--oat-100); color: var(--text-2);
}
.badge .icon { width: 14px; height: 14px; }

.menu-section { margin-top: var(--s-5); }
.section-label {
  margin: 0 0 var(--s-1); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
}
.menu-list { list-style: none; margin: 0; padding: 0; }

/* ---------- Menu item ---------- */
.menu-item { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-4); padding: var(--s-3) 0; }
.menu-item + .menu-item { border-top: 1px solid var(--divider); }
.mi-body { min-width: 0; flex: 1; }
.mi-name { margin: 0; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.mi-order {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; margin-right: 6px; padding: 0 4px;
  font-size: var(--fs-xs); font-weight: 700; border-radius: 6px; background: var(--blue-50); color: var(--blue-700);
  vertical-align: 1px;
}
.mi-desc { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.45; overflow-wrap: anywhere; }
.mi-meta { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 0 var(--s-2); }
.mi-meta .tip { color: var(--pink-700); font-weight: 600; }
.mi-price { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.mi-price.none { font-weight: 500; font-size: var(--fs-sm); color: var(--text-muted); }

.card-foot {
  margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--divider);
  font-size: var(--fs-sm); color: var(--text-muted);
}
.contacts { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); margin-bottom: var(--s-3); }
.contact {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px;
  color: var(--text-2); text-decoration: none; font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.contact:hover { color: var(--info); text-decoration: underline; }
.contact .icon { width: 16px; height: 16px; color: var(--text-muted); }
.foot-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s-2) var(--s-4); }
.card-foot .links { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }
.btn-sm { min-height: 40px; padding: 0 var(--s-4); }
.btn .icon { width: 16px; height: 16px; }

/* ---------- States ---------- */
.state {
  grid-column: 1 / -1; text-align: center; padding: var(--s-10) var(--s-5);
  border: 1px dashed var(--oat-300); border-radius: var(--radius-lg); background: var(--oat-50);
}
.state h2 { margin: 0 0 var(--s-2); font-size: var(--fs-lg); }
.state p { margin: 0 auto var(--s-4); max-width: 46ch; color: var(--text-2); }
.state.error h2 { color: var(--error); }

.skeleton { pointer-events: none; }
.sk { background: var(--oat-100); border-radius: 6px; height: 14px; margin: var(--s-3) 0; position: relative; overflow: hidden; }
.sk.title { height: 22px; width: 45%; }
.sk.short { width: 30%; }
.sk::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

.site-footer { border-top: 1px solid var(--border); padding: var(--s-6) 0 var(--s-8); font-size: var(--fs-sm); color: var(--text-muted); }
.site-footer p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .header-inner { padding-top: var(--s-3); padding-bottom: var(--s-3); }
  .brand { font-size: var(--fs-xl); }
  .tagline { display: none; }
  .search-panel { margin: var(--s-4) calc(var(--gutter) * -1) var(--s-4); padding: var(--s-4) var(--gutter); border-radius: 0; }
  .search-field input { min-height: 54px; font-size: var(--fs-md); }
  .toolbar .control { flex: 1 1 calc(50% - var(--s-2)); }
  .toolbar .control .select { width: 100%; }
  .toolbar .control .label { display: none; }
  .toolbar .spacer { display: none; }
  #locate { flex: 1 1 100%; }
  .card { padding: var(--s-4); border-radius: var(--radius-md); }
  .card-head { flex-direction: column; gap: var(--s-2); }
}

/* ---------- Admin ---------- */
.admin-main { padding-top: var(--s-6); padding-bottom: var(--s-10); }
.admin-form { display: flex; gap: var(--s-2); flex-wrap: wrap; margin: var(--s-4) 0; }
.admin-form input {
  flex: 1; min-width: 220px; min-height: var(--tap); padding: 0 var(--s-3);
  border-radius: var(--radius-sm); border: 1px solid var(--oat-600); background: var(--white);
}
.msg { min-height: 1.5em; color: var(--text-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--divider); font-size: var(--fs-sm); vertical-align: top; }
th { background: var(--oat-50); color: var(--text-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.status-ok { color: var(--success); font-weight: 600; }
.status-no-menu { color: var(--text-2); font-weight: 600; }
.status-error, .status-layout-changed, .status-parse-error { color: var(--error); font-weight: 600; }
