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

:root {
  --navy: #1a1a2e;
  --blue: #4ca8b0;
  --green: #2ec4b6;
  --red: #e71d36;
  --orange: #ff9f1c;
  --bg: #f0f2f5;
  --card: #fff;
  --text: #1a1a2e;
  --muted: #888;
  --border: #e8eaf0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.4;
}

/* LOGIN */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--navy);
}
.login-card {
  background: var(--card);
  border-radius: 16px;
  padding: 40px 32px;
  width: 90%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.login-logo {
  width: 100%;
  max-width: 300px;
  margin-bottom: 16px;
  background: var(--navy);
  border-radius: 12px;
  padding: 20px 24px;
}
.login-card h1 {
  font-size: 1.6rem;
  color: var(--navy);
  margin-bottom: 4px;
}
.login-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 24px;
}
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 12px;
  outline: none;
}
.login-card input:focus { border-color: var(--blue); }
.login-card button {
  width: 100%;
  padding: 12px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.login-card button:hover { opacity: 0.9; }
.error-msg { color: var(--red); font-size: 0.75rem; margin-top: 8px; min-height: 1em; }

/* DASHBOARD LAYOUT */
.container { max-width: 700px; margin: 0 auto; padding: 12px; }

header {
  background: var(--navy);
  color: #fff;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-logo { height: 44px; width: auto; }
header h1 { font-size: 1.1rem; font-weight: 700; }
header .logout-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
}
header .logout-btn:hover { background: rgba(255,255,255,0.25); }

/* CONTROLS */
.controls {
  background: var(--card);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}
.controls-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.controls label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: block;
  margin-bottom: 2px;
}
.controls input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  flex: 1;
  min-width: 120px;
}
.controls input[type="date"]:focus { border-color: var(--blue); outline: none; }
.compare-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  margin-top: 10px;
}
.compare-toggle input { width: 16px; height: 16px; accent-color: var(--blue); }
.run-btn {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.run-btn:hover { opacity: 0.9; }
.run-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* SECTION TITLES */
.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
  margin: 20px 0 10px;
  padding-left: 4px;
}

/* CARD GRID */
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.card {
  background: var(--card);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card.full { grid-column: 1 / -1; }
.card.dark { background: var(--navy); color: #fff; }
.card.dark .card-label { color: rgba(255,255,255,0.6); }
.card-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.card-value { font-size: 1.2rem; font-weight: 700; margin-top: 2px; }
.card-sub { font-size: 0.7rem; margin-top: 2px; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral { color: var(--blue); }

/* COMPARATIVES */
.card-compare {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 2px;
}
.card-compare .yoy { font-weight: 600; }

/* BAR CHART */
.bar-chart { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-label {
  font-size: 0.7rem;
  width: 32px;
  text-align: right;
  flex-shrink: 0;
  color: #666;
}
.bar-track {
  flex: 1;
  background: var(--border);
  border-radius: 4px;
  height: 22px;
  position: relative;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--blue), #3a8f96);
  display: flex;
  align-items: center;
  padding-left: 6px;
  min-width: 2px;
  transition: width 0.4s ease;
}
.bar-fill.green { background: linear-gradient(90deg, var(--green), #20a89c); }
.bar-fill.red { background: linear-gradient(90deg, var(--red), #c4162d); }
.bar-fill.orange { background: linear-gradient(90deg, var(--orange), #e08a18); }
.bar-val {
  font-size: 0.65rem;
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}
.bar-val-outside {
  font-size: 0.65rem;
  color: #666;
  font-weight: 600;
  white-space: nowrap;
  margin-left: 4px;
  flex-shrink: 0;
}
/* Prior year ghost bar */
.bar-track-prior {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(0,0,0,0.08);
  border-radius: 4px;
}

/* HORIZONTAL LIST */
.h-list { display: flex; flex-direction: column; gap: 0; }
.h-item {
  display: flex;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}
.h-item:last-child { border-bottom: none; }
.h-item-rank { font-size: 0.7rem; color: #aaa; width: 22px; flex-shrink: 0; }
.h-item-name { font-size: 0.8rem; flex: 1; padding-right: 8px; }
.h-item-val { font-size: 0.85rem; font-weight: 700; white-space: nowrap; }
.h-item-prior { font-size: 0.65rem; color: var(--muted); white-space: nowrap; margin-left: 4px; }

/* AGING BAR */
.aging-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  text-align: center;
}
.aging-label { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; }
.aging-value { font-weight: 700; font-size: 0.8rem; margin-top: 2px; }

/* LOADING */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 0.85rem;
}
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* FOOTER */
.footer {
  text-align: center;
  font-size: 0.65rem;
  color: #aaa;
  margin: 24px 0 12px;
}

/* CATEGORY GRID */
.cat-grid-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  margin: 24px 0 4px;
}
.cat-grid-sub {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 24px;
}
.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
.cat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 18px;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
}
.cat-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  border-color: var(--blue);
  transform: translateY(-2px);
}
.cat-card-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}
.cat-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.cat-card-desc {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
}
@media (max-width: 500px) {
  .cat-grid {
    grid-template-columns: 1fr;
  }
}

/* MENU TITLE */
.menu-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  margin: 16px 0 14px 2px;
}

/* REPORT CARDS MENU */
.report-card {
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 14px;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.report-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border-color: #ddd;
}
.report-card-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.report-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.report-card-icon.green { background: #e8faf5; color: #2ec4b6; }
.report-card-icon.blue { background: #eaf0ff; color: #4361ee; }
.report-card-icon.teal { background: #e6f5f5; color: #4ca8b0; }
.report-card-icon.purple { background: #f0eaff; color: #7c5cfc; }
.report-card-icon.orange { background: #fff3e6; color: #ff9f1c; }
.report-card-icon.red { background: #ffeaed; color: #e71d36; }
.report-card-info { flex: 1; }
.report-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.report-card-desc {
  font-size: 0.8rem;
  color: #999;
  margin-top: 4px;
  line-height: 1.5;
}

/* Expandable controls — hidden by default */
.report-card-controls {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.report-card.expanded .report-card-controls {
  max-height: 200px;
}
.report-card-dates {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.report-card-date-field {
  flex: 1;
}
.report-card-date-field label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: block;
  margin-bottom: 3px;
}
.report-card-date-field input[type="date"] {
  width: 100%;
  padding: 8px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8rem;
  outline: none;
  background: #fff;
}
.report-card-date-field input[type="date"]:focus {
  border-color: var(--blue);
}
.report-card-compare {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 10px;
  cursor: pointer;
}
.report-card-compare input {
  width: 15px;
  height: 15px;
  accent-color: var(--blue);
}
.report-card-run {
  margin-top: 12px;
}

/* AUTOCOMPLETE */
.ac-dropdown {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
  margin-top: 2px;
}
.ac-item {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid #f5f5f5;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.ac-active {
  background: #f0f7ff;
}
.ac-item-code {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
}
.ac-item-desc {
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-empty {
  padding: 12px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* BACK BUTTON */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e0e2e6;
  border: none;
  color: #555;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  margin-bottom: 8px;
}
.back-btn:hover {
  background: #d0d3d8;
  color: var(--text);
}

/* ── Drill-down ── */
[data-drill-metric] { cursor: pointer; position: relative; }
.card[data-drill-metric]:hover { box-shadow: 0 0 0 2px var(--blue, #4361ee); }
.card[data-drill-metric]::after {
  content: '⤢'; position: absolute; top: 8px; right: 10px;
  font-size: 0.7rem; color: var(--muted); opacity: 0.6;
}
.bar-row[data-drill-metric]:hover { background: rgba(67,97,238,0.06); border-radius: 6px; }
.lrow[data-drill-metric]:hover { background: rgba(67,97,238,0.06); }

.drill-panel {
  background: #fafbfd; border: 1px solid var(--border, #e8eaf0);
  border-radius: 8px; margin: 6px 0 12px; padding: 4px 0;
  max-height: 340px; overflow-y: auto; grid-column: 1 / -1;
}
.drill-loading, .drill-empty { padding: 12px; text-align: center; color: var(--muted); font-size: 0.78rem; }
.drill-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; font-size: 0.78rem; border-bottom: 1px solid #eef0f4;
}
.drill-row:last-child { border-bottom: none; }
.drill-branch { cursor: pointer; }
.drill-branch:hover { background: rgba(67,97,238,0.06); }
.drill-branch.drill-open { background: rgba(67,97,238,0.10); font-weight: 600; }
.drill-caret { width: 12px; color: var(--blue, #4361ee); flex-shrink: 0; transition: transform 0.15s; }
.drill-branch.drill-open .drill-caret { transform: rotate(90deg); }
.drill-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drill-date { width: 78px; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.drill-ref { flex: 1; color: #555; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drill-amt { margin-left: auto; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.drill-leaf .drill-amt { color: #333; }
/* Nested panels indent slightly */
.drill-panel .drill-panel { margin-left: 16px; }

/* drill-down: product-lookup table rows */
tr.drill-tr { cursor: pointer; }
tr.drill-tr:hover { background: rgba(67,97,238,0.06); }
tr.drill-tr.drill-open { background: rgba(67,97,238,0.10); }
.drill-qty { width: 56px; text-align: right; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* ── Date presets ── */
.date-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.preset-btn {
  padding: 6px 12px; font-size: 0.75rem; border: 1px solid var(--border, #e8eaf0);
  background: #fff; border-radius: 16px; cursor: pointer; color: #555;
  transition: all 0.12s;
}
.preset-btn:hover { border-color: var(--blue, #4361ee); color: var(--blue, #4361ee); }
.preset-btn.active { background: var(--blue, #4361ee); border-color: var(--blue, #4361ee); color: #fff; font-weight: 600; }

/* ── Report screen header + on-screen date controls ── */
.report-header-row {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 4px;
}
.report-date-range {
  font-size: 0.78rem; color: var(--blue, #4361ee); font-weight: 600;
  white-space: nowrap;
}
.report-controls {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  margin: 8px 0 18px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border, #e8eaf0);
}
.report-custom-dates { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.report-custom-dates .run-btn { padding: 8px 16px; font-size: 0.78rem; }
.report-compare { font-size: 0.78rem; color: #555; display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* ── Rep monthly: one full-width card per rep, stacked vertically ── */
.vbar-grid {
  display: flex; flex-direction: column; gap: 14px;
}
.vbar-card {
  background: #fff; border-radius: 12px; padding: 14px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.vbar-cardhead {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.vbar-title { font-size: 0.9rem; font-weight: 600; color: #1a1a2e; }
.vbar-total { font-size: 0.8rem; color: var(--blue, #4361ee); font-weight: 600; white-space: nowrap; }
.vbar-total span { color: var(--muted, #888); font-weight: 400; }
.vbar-chart {
  display: flex; align-items: flex-end; justify-content: space-around;
  gap: 16px; height: 120px;
}
.vbar-col {
  flex: 1; max-width: 90px; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; height: 100%;
}
.vbar-fill {
  width: 100%; background: var(--teal, #2ec4b6); border-radius: 4px 4px 0 0;
  min-height: 0; transition: height 0.2s; position: relative;
}
.vbar-xlabel { font-size: 0.7rem; color: var(--muted, #888); margin-top: 5px; }
.vbar-vallabel { font-size: 0.62rem; color: #555; margin-bottom: 3px; white-space: nowrap; }

/* Header actions: change-password link + logout */
.header-actions { display: flex; align-items: center; gap: 14px; }
.header-link { font-size: 0.8rem; color: var(--blue, #4361ee); text-decoration: none; }
.header-link:hover { text-decoration: underline; }
