/* Aabetahura brand — green & gold */
:root {
  --green: #205537;        /* exact logo background */
  --green-dark: #163d27;
  --green-deep: #0f2c1c;
  --green-tint: #eef4ef;
  --gold: #c9a24a;
  --gold-light: #ecd28b;
  --gold-dark: #9c7a2e;
  --gold-tint: #faf3df;
  --ivory: #f7f3e8;
  --card: #ffffff;
  --line: #e7dfc9;
  --ink: #1f2a22;
  --muted: #6b7a70;
  --red: #b23b2e;
  --red-tint: #fbecea;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Poppins", system-ui, sans-serif;
  color: var(--ink);
  background: var(--ivory);
}

/* ---------- Header ---------- */
.topbar {
  background: var(--green);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 6px 20px rgba(15, 44, 28, 0.25);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.logo {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
}

.welcome { flex: 1; min-width: 0; }

.welcome-eyebrow {
  margin: 0 0 2px;
  font-family: "Cinzel", serif;
  font-size: 0.72rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-light);
  opacity: 0.85;
}

.welcome h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 500;
  color: #fff;
}

.welcome h2 span {
  font-weight: 600;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.btn-logout {
  flex-shrink: 0;
  padding: 8px 22px;
  border-radius: 999px;
  border: 1.5px solid var(--gold);
  color: var(--gold-light);
  background: transparent;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-logout:hover,
.btn-logout:focus {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--green-deep);
}

/* ---------- Page ---------- */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 100px;
}

/* ---------- Summary cards ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 4px 14px rgba(32, 85, 55, 0.06);
}

.stat-label {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--green);
  line-height: 1.2;
}

.stat-value small {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.stat-wallet {
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  border: 1px solid var(--gold-dark);
}

.stat-wallet .stat-label { color: var(--gold-light); }
.stat-wallet .stat-value small { color: rgba(255, 255, 255, 0.7); }
.stat-wallet.wallet-positive .stat-value { color: #fff; }
.stat-wallet.wallet-negative .stat-value { color: #ffb4a8; }

/* ---------- Title ---------- */
.dashboard-title {
  margin: 0 0 16px;
  font-family: "Cinzel", serif;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--green);
}

.dashboard-title::after {
  content: "";
  display: block;
  width: 56px;
  height: 3px;
  margin-top: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
}

/* ---------- Month filter ---------- */
.month-filter {
  margin-bottom: 24px;
  padding: 16px 18px 18px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 100% 0%, rgba(236, 210, 139, 0.18), transparent 45%),
    linear-gradient(135deg, var(--green), var(--green-dark));
  border: 1px solid var(--gold-dark);
  box-shadow: 0 10px 26px rgba(15, 44, 28, 0.22);
}

.month-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  min-height: 28px;
}

.month-filter-label {
  font-family: "Cinzel", serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-light);
}

.clear-filter {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(236, 210, 139, 0.5);
  background: transparent;
  color: var(--gold-light);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.clear-filter:hover {
  background: var(--gold-light);
  color: var(--green-deep);
}

.month-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding: 4px 2px 6px;
  -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
  mask-image: linear-gradient(90deg, #000 92%, transparent);
}

.month-strip::-webkit-scrollbar { display: none; }

.month-tile {
  flex: 0 0 auto;
  min-width: 132px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(236, 210, 139, 0.25);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.month-tile:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(236, 210, 139, 0.6);
}

.month-tile:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(236, 210, 139, 0.55);
}

.mt-name {
  font-size: 0.98rem;
  font-weight: 600;
}

.mt-meta {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
}

.month-tile.active {
  background: linear-gradient(135deg, var(--gold-light), var(--gold) 60%, var(--gold-dark));
  border-color: var(--gold-light);
  color: var(--green-deep);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.month-tile.active .mt-meta { color: rgba(15, 44, 28, 0.75); }

/* ---------- Panels & tables ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(32, 85, 55, 0.06);
}

.panel-title {
  margin: 0;
  padding: 16px 20px;
  font-family: "Cinzel", serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--green);
  background: var(--gold-tint);
  border-bottom: 1px solid var(--line);
}

/* ---------- Bottles per month chart ---------- */
.bottle-chart {
  --bar: #2f7a4d;          /* brand green, validated for chart marks */
  --bar-hover: #205537;
  --plot: 150px;           /* height of the tallest bar */
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 14px;
}

.chart-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.chart-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.key-line {
  width: 18px;
  border-top: 1.5px dashed #b9a978;
}

.chart-note {
  margin: 8px 0 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
}

.chart {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

/* Average reference line */
.chart-avg {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(24px + var(--plot) * var(--avg));
  border-top: 1.5px dashed #b9a978;
  pointer-events: none;
  z-index: 0;
}

.bar-col {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  cursor: pointer;
  z-index: 1;
}

.bar-plot {
  height: calc(var(--plot) + 18px);
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}

.bar {
  display: block;
  width: 70%;
  max-width: 24px;
  height: max(3px, calc(var(--plot) * var(--r)));
  border-radius: 4px 4px 0 0;
  background: var(--bar);
  transition: background 0.15s ease, opacity 0.2s ease;
}

.bar-value {
  margin-bottom: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  visibility: hidden;
}

.bar-label {
  height: 24px;
  width: 100%;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

/* Label only the peak and latest month, plus the selected one */
.bar-col.labeled .bar-value,
.bar-col.selected .bar-value { visibility: visible; }
.bar-col.dim .bar-value { visibility: hidden; }

.bar-col:hover .bar,
.bar-col:focus-visible .bar { background: var(--bar-hover); }

.bar-col.dim .bar { opacity: 0.3; }
.bar-col.selected .bar { background: var(--bar-hover); }
.bar-col.selected .bar-label { color: var(--green); font-weight: 600; }

.bar-col:focus-visible { outline: none; }
.bar-col:focus-visible .bar-label { color: var(--green); font-weight: 600; }

/* Hover tooltip */
.bar-tip {
  position: absolute;
  bottom: calc(24px + var(--plot) * var(--r) + 26px);
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--gold-light);
  background: var(--green-deep);
  box-shadow: 0 4px 12px rgba(15, 44, 28, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 2;
}

.bar-col:hover .bar-tip,
.bar-col:focus-visible .bar-tip { opacity: 1; }

/* Keep edge tooltips inside the card */
.bar-col:first-of-type .bar-tip { left: 0; transform: none; }
.bar-col:last-of-type .bar-tip { left: auto; right: 0; transform: none; }

.table-responsive { margin: 0; }

.mobile-only { display: none; }

.table-scroll {
  max-height: 520px;
  overflow-y: auto;
}

.table {
  margin: 0;
  font-size: 0.92rem;
  text-align: center;
  vertical-align: middle;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--gold-light);
  background: var(--green);
  border: 0;
}

.table tbody td {
  padding: 11px 14px;
  color: var(--ink);
  border-color: #f0ead9;
  white-space: nowrap;
}

.table tbody tr:nth-child(even) td { background: #fbf9f3; }
.table tbody tr:hover td { background: var(--green-tint); }

.table-responsive::-webkit-scrollbar { width: 8px; height: 8px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 8px; }
.table-responsive::-webkit-scrollbar-track { background: var(--gold-tint); }

/* ---------- Delivery panel ---------- */
.delivery-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.sum-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fbf9f3;
  border: 1px solid #f0ead9;
}

.sum-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--green);
}

.sum-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--gold-light);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sum-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sum-label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.sum-text strong {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--green);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sum-text small {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}

.row-in { animation: rowIn 0.35s ease both; }

@keyframes rowIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.no-results {
  margin: 0;
  padding: 28px 20px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---------- Status badges ---------- */
.status-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-paid { background: var(--green-tint); color: var(--green); }
.badge-unpaid { background: var(--red-tint); color: var(--red); }
.badge-neutral { background: var(--gold-tint); color: var(--gold-dark); }

.footer-note {
  margin: 36px 0 0;
  text-align: center;
  font-family: "Cinzel", serif;
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold-dark);
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  .topbar-inner { padding: 8px 14px; gap: 12px; }
  .logo { width: 64px; height: 64px; }
  .welcome-eyebrow { font-size: 0.62rem; letter-spacing: 0.2em; }
  .welcome h2 { font-size: 1.05rem; }
  .btn-logout { padding: 6px 14px; font-size: 0.85rem; }

  .page { padding: 18px 14px 100px; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-wallet { grid-column: 1 / -1; padding: 16px; }
  .stat-label { font-size: 0.68rem; letter-spacing: 0.02em; }
  .stat-value { font-size: 1.15rem; }
  .stat-wallet .stat-value { font-size: 1.6rem; }

  .dashboard-title { font-size: 1.5rem; }

  .month-filter { padding: 14px 12px 14px 14px; margin-left: -2px; margin-right: -2px; }
  .month-tile { min-width: 118px; padding: 10px 13px; }

  .delivery-summary { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 12px 14px; }
  .sum-tile { padding: 10px; gap: 9px; }
  .sum-icon { width: 34px; height: 34px; border-radius: 10px; }
  .sum-icon svg { width: 17px; height: 17px; }
  .sum-label { font-size: 0.64rem; }
  .sum-text strong { font-size: 1rem; }

  .bottle-chart { --plot: 120px; padding: 16px 14px 12px; }
  .bar-label { font-size: 0.62rem; }

  /* Tables become cards on phones */
  .desk-only { display: none; }
  .mobile-only { display: inline; }

  .table-responsive,
  .table-scroll {
    max-height: none;
    overflow: visible;
  }

  .table thead { display: none; }

  .table,
  .table tbody {
    display: block;
    width: 100%;
  }

  .table tbody {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: var(--ivory);
  }

  .table tbody tr {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px 8px;
    padding: 14px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--gold);
    border-radius: 14px;
    background: var(--card);
    box-shadow: 0 3px 10px rgba(32, 85, 55, 0.06);
  }

  .table tbody tr:nth-child(even) td,
  .table tbody tr:hover td { background: none; }

  .table tbody tr td {
    grid-column: span 2;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    white-space: normal;
    overflow-wrap: break-word;
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--green);
  }

  .table tbody td::before {
    content: attr(data-label);
    font-size: 0.64rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .table tbody td.cell-hide-mobile { display: none; }
  .table tbody td.cell-half { grid-column: span 3; }
  .table tbody td.cell-third { grid-column: span 2; }

  /* Card heading row: title on the left, time/status on the right */
  .table tbody td.cell-title {
    grid-column: 1 / span 4;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--line);
    font-family: "Cinzel", serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--green-dark);
  }

  .table tbody td.cell-time,
  .table tbody td.cell-status {
    grid-column: 5 / span 2;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--line);
    text-align: right;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--muted);
  }

  .table tbody td.cell-title::before,
  .table tbody td.cell-time::before,
  .table tbody td.cell-status::before { display: none; }

  .table tbody td.cell-wallet { color: var(--gold-dark); }

  /* Monthly report: month name across the full card */
  #monthlyReportTable tbody td.cell-title { grid-column: 1 / -1; }

  /* Customer report: name + status first */
  #reportTable tbody td.cell-name { order: -2; }
  #reportTable tbody td.cell-status { order: -1; }
  #reportTable tbody td:first-child { grid-column: span 1; }
  #reportTable tbody td:last-child { grid-column: span 3; white-space: nowrap; }
}
