:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #0f766e;
  --primary-hover: #0d625b;
  --danger: #dc2626;
  --promo-bg: #ecfdf5;
  --promo-ink: #065f46;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  padding-bottom: 76px;
}

.topbar {
  background: #0f172a;
  color: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid #1e293b;
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand .subtitle {
  display: block;
  font-size: 12px;
  color: #94a3b8;
}

.desktop-nav {
  display: none;
  gap: 6px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 30;
}

.nav-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 6px;
  border-radius: 10px;
  cursor: pointer;
}

.desktop-nav .nav-btn {
  color: #cbd5e1;
  padding: 8px 14px;
}

.nav-btn.active {
  background: var(--primary);
  color: #ffffff;
}

@media (min-width: 760px) {
  body {
    padding-bottom: 24px;
  }
  .desktop-nav {
    display: flex;
  }
  .bottom-nav {
    display: none;
  }
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

h1, h2, h3 {
  margin: 0;
}

h2 {
  font-size: 1.15rem;
}

h3 {
  font-size: 1rem;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
  .grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--ink);
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.inline-form input[type="text"] {
  flex: 1 1 180px;
}

.input-qty {
  max-width: 80px;
}

.input-unit {
  max-width: 80px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.84rem;
}

.btn-xs {
  padding: 4px 10px;
  font-size: 0.9rem;
  min-width: 30px;
}

.qty-stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.product-in-list {
  gap: 6px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: #e2e8f0;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-promo {
  background: var(--promo-bg);
  color: var(--promo-ink);
}

.pill {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.verdict-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

@media (min-width: 560px) {
  .verdict-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  }
}

.store-score {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  position: relative;
}

.store-score.winner {
  border-color: var(--primary);
  background: #f0fdfa;
}

.store-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.store-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.store-total {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 6px 0 2px;
}

.check-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.check-item.checked {
  opacity: 0.55;
  text-decoration: line-through;
}

.check-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 200px;
  min-width: 0;
  cursor: pointer;
}

.check-main input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.check-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.item-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
}

.item-row-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.draft-row {
  display: grid;
  grid-template-columns: 2fr 1.5fr 0.8fr 0.7fr 0.9fr auto;
  gap: 6px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

@media (max-width: 680px) {
  .draft-row {
    grid-template-columns: 1fr 1fr;
  }
}

.upload-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-label {
  display: block;
  padding: 16px;
  border: 2px dashed #94a3b8;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  font-weight: 600;
}

.file-label input {
  display: block;
  margin: 0 auto 8px;
  max-width: 100%;
}

.row-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.table-scroll {
  overflow-x: auto;
  margin-top: 10px;
}

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

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

.details-summary {
  cursor: pointer;
  font-weight: 700;
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
}

.toast {
  position: fixed;
  top: 66px;
  right: 16px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
}

.toast.error {
  background: var(--danger);
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.alert-error {
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  background: #fef2f2;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 600;
}
