@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Playfair+Display:wght@500;600&display=swap');

:root {
  --primary: #B70865;
  --primary-dark: #8F0650;
  --secondary: #BF963D;
  --secondary-light: #F7EEDC;
  --bg: #FFFFFF;
  --bg-alt: #F5F5F5;
  --surface: #FFFFFF;
  --text: #333333;
  --text-light: #666666;
  --text-faint: #999999;
  --border: #EAEAEA;
  --success: #2ecc71;
  --error: #e74c3c;
  --warning: #f39c12;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px -12px rgba(183,8,101,0.12);
  --sidebar-w: 220px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- App shell ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  align-items: start;
  align-content: start;
}

.app > * { min-width: 0; }

.sidebar {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-lockup {
  margin-bottom: 32px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  object-position: left center;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.55), 0 1px 4px rgba(0,0,0,0.15);
  margin-bottom: 10px;
  display: block;
}

.brand-logo-full {
  width: 100%;
  max-width: 280px;
  height: auto;
  display: block;
  margin: 0 auto 18px;
}

.brand-lockup .brand-text { line-height: 1.3; }

.brand {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

.brand-sub {
  font-size: 11px;
  opacity: 0.75;
  letter-spacing: 0.2px;
  font-style: italic;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: rgba(255,255,255,0.82);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-link.active {
  background: rgba(255,255,255,0.14);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--secondary);
}

.sidebar-footer {
  margin-top: auto;
  font-size: 11.5px;
  opacity: 0.6;
}

.logout-link {
  display: block;
  margin-top: 12px;
  font-size: 12.5px;
  opacity: 0.75;
  text-decoration: none;
  cursor: pointer;
}
.logout-link:hover { opacity: 1; text-decoration: underline; }

.credit-link {
  display: block;
  margin-top: 10px;
  font-size: 11px;
  opacity: 0.55;
  text-decoration: none;
  color: inherit;
}
.credit-link:hover { opacity: 0.9; text-decoration: underline; }

.login-footer {
  text-align: center;
  margin-top: 18px;
}
.login-footer .credit-link {
  opacity: 0.7;
  color: #fff;
  font-size: 12px;
}
.login-footer .credit-link:hover { opacity: 1; }

main {
  padding: 32px 40px 60px;
  max-width: 1160px;
}

.page-header { margin-bottom: 28px; }
.page-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  font-weight: 500;
  color: var(--text);
  position: relative;
  padding-bottom: 12px;
}
.page-header h1::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 40px;
  height: 3px;
  background: var(--secondary);
  border-radius: 2px;
}
.page-header p {
  color: var(--text-light);
  font-size: 13.5px;
  margin-top: 10px;
}

/* ---------- Stat cards ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  padding: 18px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: var(--secondary);
}

.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  font-weight: 600;
}

.stat-card .value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text);
}

.stat-card .value.success { color: var(--success); }
.stat-card .value.error { color: var(--error); }
.stat-card .value.warning { color: var(--warning); }

/* ---------- Upload ---------- */

.upload-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 28px;
  padding: 4px;
}

.drop-zone {
  border: 2px dashed #E3C6D6;
  border-radius: calc(var(--radius) - 2px);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.drop-zone.dragover { background: rgba(183,8,101,0.05); border-color: var(--primary); }
.drop-zone.processing { cursor: default; border-color: var(--secondary-light); }

.drop-zone .icon { font-size: 26px; margin-bottom: 8px; }
.drop-zone strong { font-size: 14.5px; }
.drop-zone p { color: var(--text-light); font-size: 12.5px; margin-top: 4px; }

.spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 3px solid var(--secondary-light);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn {
  border: none;
  padding: 10px 24px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: 0.9; }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover:not(:disabled) { opacity: 0.9; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }

.upload-status { padding: 12px 20px 18px; font-size: 13px; }

/* ---------- Cards / tables ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 22px 24px;
  margin-bottom: 22px;
}

.card h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1.5px solid var(--secondary-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2 .badge {
  background: var(--secondary-light);
  color: #8a6b26;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

#productsTableWrap, #changesTableWrap, #recentUpdatesWrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  padding: 9px 10px;
  color: #8a6b26;
  background: var(--secondary-light);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.table th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.table th:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.table td { padding: 10px 10px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.table .muted { color: var(--text-faint); font-size: 12.5px; }

.change-positive { color: var(--success); font-weight: 600; }
.change-negative { color: var(--error); font-weight: 600; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}
.status-pill.success { background: #E6F9EF; color: #1e9e5a; }
.status-pill.error { background: #FCEAEA; color: var(--error); }
.status-pill.partial { background: #FEF3E2; color: var(--warning); }

.empty-state {
  color: var(--text-faint);
  font-size: 13px;
  padding: 20px 0;
  text-align: center;
}

/* ---------- Alerts ---------- */

.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13px;
}
.alert:last-child { margin-bottom: 0; }
.alert-warning { background: #FEF7E8; border-left: 3px solid var(--warning); }
.alert-trend { background: #FDF1F6; border-left: 3px solid var(--primary); }
.alert strong { display: block; font-size: 13px; margin-bottom: 2px; }
.alert .muted { color: var(--text-light); font-size: 12px; }

/* ---------- Forms ---------- */

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.field .hint { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }

input[type="text"], input[type="email"], input[type="number"], input[type="password"], input[type="time"] {
  width: 100%;
  max-width: 320px;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}
input:focus { outline: none; border-color: var(--primary); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--primary); }
.checkbox-row label { font-size: 13.5px; color: var(--text); }

.search-bar { position: relative; margin-bottom: 20px; max-width: 360px; }
.search-bar input { max-width: 100%; padding-left: 34px; width: 100%; }
.search-bar .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 13px; }

.threshold-row { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 22px; }
.threshold-row .field { margin-bottom: 0; }
.threshold-row input { max-width: 100px; }

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 55%, #5c0435 100%);
}

.login-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.login-card { text-align: center; }
.login-card .brand {
  color: var(--primary);
  font-size: 22px;
  margin-bottom: 2px;
}
.login-card .brand-sub {
  color: var(--text-light);
  font-size: 12.5px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--secondary-light);
  opacity: 1;
}
.login-card form { text-align: left; }

.login-error {
  background: #FCEAEA;
  color: var(--error);
  font-size: 12.5px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  display: none;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; align-items: center; padding: 14px 18px; overflow-x: auto; }
  .sidebar .brand-text, .sidebar-footer { display: none; }
  .nav-link { white-space: nowrap; }
  main { padding: 24px 18px 40px; }
  .two-col { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
