*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  background: #f4f5f7;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────── */
header {
  background: #1a1a2e;
  color: #fff;
  padding: 20px 24px 18px;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.subtitle {
  margin-top: 4px;
  font-size: 0.8rem;
  color: #aab;
}

.app-version {
  margin-top: 2px;
  font-size: 0.72rem;
  color: rgba(170, 170, 187, 0.5);
}

/* ── Main layout ─────────────────────────────────────────────────── */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ── Search ──────────────────────────────────────────────────────── */
.search-wrap {
  margin-bottom: 8px;
}

#search {
  width: 100%;
  padding: 13px 16px;
  font-size: 1rem;
  border: 2px solid #dde;
  border-radius: 8px;
  outline: none;
  background: #fff;
  transition: border-color 0.15s;
}

#search:focus {
  border-color: #4a6cf7;
}

.geo-status {
  margin-top: 6px;
  font-size: 0.78rem;
  color: #888;
  min-height: 18px;
}

.geo-ok  { color: #2d9e5f; }
.geo-warn { color: #b07d00; }

/* ── Status messages ─────────────────────────────────────────────── */
.loading, .no-results, .error {
  text-align: center;
  padding: 40px 16px;
  color: #888;
  font-size: 0.9rem;
}
.error { color: #c0392b; }

/* ── Product card ────────────────────────────────────────────────── */
.product-card {
  background: #fff;
  border-radius: 8px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  overflow: hidden;
}

.product-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  gap: 12px;
}

.product-header:hover {
  background: #f8f9ff;
}

.product-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.product-name {
  font-weight: 600;
  font-size: 0.97rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-meta {
  font-size: 0.78rem;
  color: #888;
}

.product-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

.badge-in  { background: #e6f9f0; color: #1a7a48; }
.badge-out { background: #fce8e8; color: #b03030; }

.chevron {
  font-size: 0.65rem;
  color: #bbb;
  transition: transform 0.2s;
}

.product-card.expanded .chevron {
  transform: rotate(180deg);
}

/* ── Store list ──────────────────────────────────────────────────── */
.store-list {
  display: none;
  border-top: 1px solid #eef;
  overflow-x: auto;
}

.product-card.expanded .store-list {
  display: block;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  text-align: left;
  padding: 8px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  background: #fafafa;
  border-bottom: 1px solid #eef;
}

tbody tr {
  border-bottom: 1px solid #f3f3f6;
}

tbody tr:last-child { border-bottom: none; }

tbody tr.out-of-stock { opacity: 0.45; }

tbody td {
  padding: 9px 12px;
  vertical-align: middle;
}

.store-name { font-weight: 500; }
.store-city { color: #666; }

.qty {
  display: inline-block;
  min-width: 28px;
  text-align: center;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.qty-ok   { background: #e6f9f0; color: #1a7a48; }
.qty-low  { background: #fff3e0; color: #b06000; }
.qty-zero { background: #f0f0f4; color: #aaa; }

.dist {
  font-size: 0.8rem;
  color: #555;
}

/* ── Tabs ────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid #eef;
  padding-bottom: 0;
}

.tab {
  background: none;
  border: none;
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: #444; }

.tab.active {
  color: #4a6cf7;
  border-bottom-color: #4a6cf7;
}

.tab-pane.hidden { display: none; }

/* ── Stores table ────────────────────────────────────────────────── */
.stores-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.stores-table thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  background: #fafafa;
  border-bottom: 1px solid #eef;
}

.stores-table tbody tr {
  border-bottom: 1px solid #f3f3f6;
}

.stores-table tbody tr:last-child { border-bottom: none; }

.stores-table tbody tr:hover { background: #f8f9ff; }

.stores-table tbody td {
  padding: 10px 14px;
  vertical-align: top;
}

.store-hours-cell { font-size: 0.78rem; color: #555; }
.store-hours-row { line-height: 1.6; }
.hours-day { font-weight: 600; color: #444; display: inline-block; min-width: 32px; }

/* ── Location form ───────────────────────────────────────────────── */
.set-location-btn {
  background: none;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 0.75rem;
  cursor: pointer;
  color: inherit;
}

.location-form {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.location-form.hidden { display: none; }

.location-form input {
  flex: 1;
  min-width: 200px;
  padding: 6px 10px;
  font-size: 0.82rem;
  border: 1px solid #dde;
  border-radius: 6px;
  outline: none;
  background: #fff;
}

.location-form input:focus { border-color: #4a6cf7; }

.location-form button {
  background: none;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  color: #4a6cf7;
}

.location-form .cancel-btn { color: #888; }

.location-msg {
  width: 100%;
  font-size: 0.78rem;
}

.location-msg-error { color: #c0392b; }
