/* LOGIN */
.login-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0039b3 0%, #005bff 60%, #0ea5e9 100%);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.login-screen.visible { display: flex; }

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.login-card .logo-wrap {
  text-align: center;
  margin-bottom: 28px;
}

.login-card .logo-wrap .icon {
  font-size: 40px;
  display: block;
  margin-bottom: 8px;
}

.login-card .logo-wrap h1 {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
}

.login-card .logo-wrap p {
  font-size: 13px;
  color: #6b7280;
  margin-top: 4px;
}

.login-field {
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.login-field input {
  width: 100%;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.login-field input:focus {
  border-color: #005bff;
  box-shadow: 0 0 0 3px rgba(0,91,255,.1);
}

.login-btn {
  width: 100%;
  background: #005bff;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background .15s;
}

.login-btn:hover { background: #0047cc; }
.login-btn:disabled { background: #93c5fd; cursor: not-allowed; }

.login-error {
  color: #dc2626;
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
  min-height: 18px;
}

/* LOGOUT BTN */
.logout-btn {
  margin-left: auto;
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s;
}
.logout-btn:hover { background: rgba(255,255,255,.25); }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  font-size: 14px;
}

/* NAV */
nav {
  background: #005bff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

nav .logo {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  margin-right: 24px;
  white-space: nowrap;
}

nav a {
  color: rgba(255,255,255,.75);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

nav a:hover, nav a.active {
  background: rgba(255,255,255,.2);
  color: #fff;
}

/* DATE BAR */
.date-bar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.date-bar label { font-size: 12px; color: #6b7280; font-weight: 500; }

.date-bar input {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}

.date-bar input:focus { border-color: #005bff; }

.date-bar .btn {
  background: #005bff;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}

.date-bar .btn:hover { background: #0047cc; }
.date-bar .btn.secondary { background: #f3f4f6; color: #374151; }
.date-bar .btn.secondary:hover { background: #e5e7eb; }

.date-bar .separator { color: #d1d5db; padding: 0 4px; }

/* MAIN */
main { padding: 24px; max-width: 1400px; margin: 0 auto; }

/* KPI CARDS */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.kpi-card .label { font-size: 12px; color: #6b7280; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.kpi-card .value { font-size: 28px; font-weight: 700; margin: 8px 0 4px; color: #111827; }
.kpi-card .delta { font-size: 13px; }
.kpi-card .delta.up { color: #16a34a; }
.kpi-card .delta.down { color: #dc2626; }
.kpi-card .delta.neutral { color: #6b7280; }

/* CHARTS & PANELS */
.panel {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  margin-bottom: 20px;
}

.panel h3 {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 16px;
}

.panel-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

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

.chart-wrap { position: relative; height: 280px; }
.chart-wrap-lg { position: relative; height: 360px; }

/* TABLE */
.tbl-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  background: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
  color: #6b7280;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

thead th:hover { background: #f0f2f5; }

tbody tr { border-bottom: 1px solid #f3f4f6; transition: background .1s; }
tbody tr:hover { background: #f9fafb; }
tbody td { padding: 10px 12px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-A { background: #dcfce7; color: #15803d; }
.badge-B { background: #fef9c3; color: #a16207; }
.badge-C { background: #fee2e2; color: #dc2626; }
.badge-critical { background: #fee2e2; color: #dc2626; }
.badge-warning { background: #fef9c3; color: #a16207; }
.badge-ok { background: #dcfce7; color: #15803d; }
.badge-no_sales { background: #f3f4f6; color: #6b7280; }

.delta-up { color: #16a34a; font-weight: 600; }
.delta-down { color: #dc2626; font-weight: 600; }

/* BAR FILL */
.bar-fill { height: 6px; border-radius: 3px; background: #005bff; display: inline-block; min-width: 2px; }

/* LOADING */
.loader {
  text-align: center;
  padding: 60px;
  color: #6b7280;
}

.spinner {
  display: inline-block;
  width: 32px; height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: #005bff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-bottom: 12px;
}

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

/* PAGE SECTIONS */
.page { display: none; }
.page.active { display: block; }

/* COMPARE DIFF */
.diff-table td:last-child { text-align: right; }
