/* === Reset & Base === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f7f4f0;
  color: #2d3436;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}
.hidden {
  display: none !important;
}

/* === Auth Gate === */
.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(145deg, #1e2d3b 0%, #2c3e50 100%);
}
.auth-card {
  width: 100%;
  max-width: 410px;
  background: #fff;
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.auth-logo {
  font-size: 2.5rem;
  margin-bottom: 0.25rem;
}
.auth-card h2 {
  font-size: 1.35rem;
  color: #1e2d3b;
}
.auth-subtitle {
  font-size: 0.85rem;
  color: #636e72;
  margin-bottom: 1.25rem;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  background: #f1ede8;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 1.25rem;
}
.auth-tab {
  border: none;
  background: transparent;
  padding: 0.55rem 0.5rem;
  border-radius: 9px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #636e72;
  cursor: pointer;
  transition: all 0.2s;
}
.auth-tab.active {
  background: #fff;
  color: #1e2d3b;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.auth-form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #2d3436;
}
.code-input {
  text-align: center;
  font-size: 1.4rem !important;
  letter-spacing: 0.35em;
  font-weight: 700;
}
.auth-msg {
  font-size: 0.82rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: #eef6ff;
  color: #1e40af;
}
.auth-msg.error {
  background: #fef2f2;
  color: #b91c1c;
}
.auth-hint {
  margin-top: 1rem;
  font-size: 0.75rem;
  color: #7f8c8d;
}

/* === Layout === */
#app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 240px;
  background: #1e2d3b;
  color: #e8e0d8;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}
.sidebar-header {
  padding: 1.4rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-header .logo {
  font-size: 1.5rem;
}
.sidebar-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f8fafc;
}
.nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.15s ease;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.nav-item.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  color: #94a3b8;
}
.user-badge {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #e2e8f0;
  margin-bottom: 0.35rem;
}
.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.link-btn {
  background: none;
  border: none;
  color: #fca5a5;
  font-size: 0.78rem;
  cursor: pointer;
  font-weight: 600;
}
.sidebar-backdrop {
  display: none;
}

/* === Main === */
.main {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  display: flex;
  align-items: center;
  padding: 0.95rem 1.75rem;
  background: rgba(247, 244, 240, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 50;
}
.menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  margin-right: 0.75rem;
}
.topbar h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e2d3b;
}
.topbar-spacer {
  flex: 1;
}
.pill-count {
  background: #1e2d3b;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
}
.content {
  flex: 1;
  padding: 1.5rem 1.75rem 3rem;
  max-width: 1140px;
  width: 100%;
}

/* === Cards & Forms === */
.card {
  background: #fff;
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 14px rgba(0, 0, 0, 0.03);
  margin-bottom: 1.25rem;
}
input[type="text"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid #e2ddd7;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.92rem;
  background: #fff;
  color: #2d3436;
  outline: none;
  transition: border-color 0.15s;
}
input:focus,
select:focus,
textarea:focus {
  border-color: #1e2d3b;
}
textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.5;
}
.form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}
.form-row > .grow {
  flex: 1;
  min-width: 200px;
}
.form-row > .fixed {
  width: 165px;
}
.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: #475569;
  cursor: pointer;
  user-select: none;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.15rem;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  background: #1e2d3b;
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: #2d4356;
}
.btn-secondary {
  background: #efeae4;
  color: #1e2d3b;
}
.btn-secondary:hover:not(:disabled) {
  background: #e4ddd5;
}
.btn-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  border-radius: 8px;
}
.btn-block {
  width: 100%;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

/* === Product Grid === */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 1rem;
}
.product-card {
  background: #fff;
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  border: 1px solid #f0ece6;
}
.product-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.store-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.store-sodimac {
  background: #dbeafe;
  color: #1d4ed8;
}
.store-easy {
  background: #fee2e2;
  color: #b91c1c;
}
.badge-mkt {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: 6px;
  background: #fef3c7;
  color: #92400e;
}
.badge-offer {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.18rem 0.5rem;
  border-radius: 6px;
  background: #dcfce7;
  color: #166534;
}
.product-img {
  width: 100%;
  height: 150px;
  object-fit: contain;
  background: #faf9f7;
  border-radius: 10px;
  padding: 0.4rem;
}
.product-brand {
  font-size: 0.74rem;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
}
.product-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e293b;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}
.product-name a {
  color: inherit;
  text-decoration: none;
}
.product-name a:hover {
  text-decoration: underline;
}
.price-block {
  margin-top: auto;
  padding-top: 0.35rem;
}
.price-main {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1e2d3b;
}
.price-list {
  font-size: 0.8rem;
  color: #94a3b8;
  text-decoration: line-through;
  margin-left: 0.4rem;
}
.price-card {
  font-size: 0.78rem;
  color: #0f766e;
  font-weight: 600;
}
.price-unit {
  font-size: 0.75rem;
  color: #64748b;
}
.product-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

/* === Tables & Summary === */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}
.summary-box {
  background: #fff;
  border-radius: 14px;
  padding: 1rem 1.2rem;
  border: 1px solid #ece7e0;
}
.summary-box.winner {
  border: 2px solid #16a34a;
  background: #f0fdf4;
}
.summary-label {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 600;
}
.summary-val {
  font-size: 1.45rem;
  font-weight: 700;
  color: #1e2d3b;
  margin-top: 0.2rem;
}
.summary-sub {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 0.15rem;
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
th,
td {
  padding: 0.75rem 0.8rem;
  border-bottom: 1px solid #eeeae4;
  text-align: left;
  vertical-align: top;
}
th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748b;
  background: #faf8f5;
}
.cell-winner {
  background: #f0fdf4;
}
.cell-prod-link {
  display: block;
  font-size: 0.76rem;
  color: #475569;
  text-decoration: none;
  margin-top: 0.2rem;
}
.cell-prod-link:hover {
  text-decoration: underline;
  color: #1e2d3b;
}
.star {
  color: #16a34a;
  font-weight: 700;
}
.muted {
  color: #94a3b8;
}
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #64748b;
}

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
  }
  .main {
    margin-left: 0;
  }
  .menu-btn {
    display: inline-flex;
  }
  .topbar {
    padding: 0.8rem 1rem;
  }
  .content {
    padding: 1rem;
  }
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }
  .form-row > .fixed,
  .form-row > .grow {
    width: 100%;
  }
}
