/* Jember–Banyuwangi Performance — editorial trade desk */

:root {
  --bg: #ece7de;
  --paper: #f7f4ee;
  --ink: #1c1915;
  --muted: #6d675f;
  --line: #d5cfc4;
  --line-strong: #b9b1a4;
  --head: #1c1915;
  --head-text: #f4efe6;
  --chip: #fffdf8;
  --accent: #8f2a32;
  --forest: #2c4a3e;
  --pos: #1f6b45;
  --neg: #b42318;
  --amber: #9a6b24;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  min-height: 100dvh;
  overflow: auto;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  z-index: 80;
}

[hidden] {
  display: none !important;
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.boot.is-error { color: var(--neg); }

.app {
  padding: 12px 16px 20px;
  padding-top: max(12px, var(--safe-t));
  padding-left: max(16px, var(--safe-l));
  padding-right: max(16px, var(--safe-r));
  padding-bottom: max(20px, var(--safe-b));
  max-width: 1760px;
  margin: 0 auto;
}

.head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  background: var(--head);
  color: var(--head-text);
  border-radius: 2px;
  padding: 12px 16px 11px;
  margin-bottom: 8px;
}
.head h1 {
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  font-weight: 650;
  line-height: 1.25;
  font-stretch: condensed;
}
.head-left { flex: 1; min-width: 200px; }

.timebox {
  display: flex;
  gap: 28px;
  text-align: right;
}
.timebox > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-end;
}
.timebox span {
  font-size: 0.62rem;
  font-weight: 650;
  color: #c4bdb2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.timebox b {
  font-size: 1.15rem;
  font-weight: 650;
  color: #f4efe6;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.filters {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px 10px;
  margin-bottom: 8px;
}
.filters > label,
.field-period {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
}
.filters > label,
.field-period > span {
  font-size: 0.64rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.period-btn,
.filters select,
.filters input[type="search"] {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--chip);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 8px 10px;
  outline: none;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
.filters select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% - 2px), calc(100% - 9px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 26px;
}
.filters select:focus,
.filters input:focus,
.period-btn:focus {
  border-color: var(--ink);
}
.field-dealer { position: relative; }
.field-period { position: relative; z-index: 40; }
.period-btn {
  text-align: left;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0;
}

.period-tree {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 50;
  min-width: 248px;
  max-height: min(70vh, 440px);
  overflow: auto;
  background: #fffdf8;
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: 0 0 8px;
  box-shadow: 4px 8px 0 rgba(28, 25, 21, 0.08);
  font-family: inherit;
}
.pt-head {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--muted);
  padding: 10px 12px 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.pt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  font-size: 0.84rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--ink);
  text-transform: none;
  cursor: pointer;
  user-select: none;
}
.pt-row:hover { background: #efeae1; }
.pt-all {
  font-weight: 650;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  padding: 8px 12px;
}
.pt-y { padding-left: 8px; }
.pt-q { padding-left: 22px; }
.pt-m { padding-left: 36px; }
.pt-twist {
  width: 16px;
  height: 16px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  font-size: 0.7rem;
  line-height: 16px;
  flex-shrink: 0;
}
.pt-sp {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: inline-block;
}
.pt-lab {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: inherit;
  font-size: inherit;
  margin: 0;
}
.period-tree input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  min-width: 13px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  box-sizing: border-box;
  border: 1px solid var(--ink);
  border-radius: 1px;
  background: #fff;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  vertical-align: middle;
}
.period-tree input[type="checkbox"]:checked {
  background: var(--ink);
  border-color: var(--ink);
}
.period-tree input[type="checkbox"]:checked::after {
  content: "";
  width: 7px;
  height: 4px;
  border: 1.5px solid #fff;
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg);
  margin-bottom: 2px;
}
.period-tree input[type="checkbox"]:indeterminate {
  background: var(--ink);
  border-color: var(--ink);
}
.period-tree input[type="checkbox"]:indeterminate::after {
  content: "";
  width: 8px;
  height: 2px;
  background: #fff;
  border: 0;
  transform: none;
  margin: 0;
}

.suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  background: #fffdf8;
  border: 1px solid var(--ink);
  border-radius: 2px;
  max-height: 220px;
  overflow: auto;
}
.suggest button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  padding: 8px 10px;
  cursor: pointer;
}
.suggest button:hover { background: #efeae1; }

.dash { display: flex; flex-direction: column; gap: 8px; }

.sales,
.block {
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  overflow: hidden;
}

.sales-head {
  padding: 0;
  text-align: left;
}
.sales-main {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.72fr);
  align-items: stretch;
  border-top: 1px solid var(--line);
}
.sales-kpis {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.mix-card {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fffdf8;
}
.sales h2,
.block h2 {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-align: left;
  padding: 12px 16px 8px;
  color: var(--ink);
  font-weight: 700;
  text-transform: uppercase;
}

.cmp-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  padding: 0;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.cmp-card {
  background: var(--paper);
  border: 0;
  border-radius: 0;
  padding: 16px 18px 14px;
}
.cmp-card.is-kpi {
  background: #fffdf8;
}
.cmp-card h3 {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 10px;
}
.cmp-sub {
  font-size: 0.68rem;
  color: var(--muted);
  margin: 2px 0 8px;
  font-weight: 600;
  line-height: 1.35;
}
.mtd-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 2px 0 0;
}
.mtd-pair .k {
  font-size: 0.64rem;
  color: var(--muted);
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.mtd-pair .v {
  font-size: 1.35rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-top: 2px;
}
.cmp-tbl {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.cmp-tbl th,
.cmp-tbl td {
  text-align: right;
  padding: 5px 0 5px 10px;
  font-size: 0.82rem;
}
.cmp-tbl th {
  font-size: 0.62rem;
  color: var(--muted);
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.cmp-tbl td {
  border-bottom: 1px solid #ebe6dc;
  font-weight: 600;
}
.cmp-tbl tr:last-child td { border-bottom: 0; }
.cmp-tbl td:first-child,
.cmp-tbl th:first-child {
  text-align: left;
  padding-left: 0;
  color: var(--muted);
  font-weight: 650;
}

.asps {
  display: grid;
  grid-template-columns: repeat(6, minmax(70px, 1fr));
}
.asp {
  padding: 12px 10px 14px;
  text-align: left;
  border-right: 1px solid var(--line);
}
.asp:last-child { border-right: 0; }
.asp .k {
  font-size: 0.58rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.asp .v {
  margin-top: 6px;
  font-weight: 650;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.charts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: stretch;
}
.chart-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 2px;
  flex-shrink: 0;
}
.chart-head h2 {
  padding: 0;
  margin: 0;
}
.chart {
  width: 100%;
  height: 176px;
  display: block;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  justify-content: flex-end;
  font-size: 0.7rem;
  font-weight: 650;
  color: var(--muted);
  padding: 0;
}
.legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 1px;
  margin-right: 5px;
  vertical-align: 1px;
}
.mix-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  flex: 1;
  padding: 4px 16px 12px;
  min-height: 0;
}
.mix-donut {
  width: 100px;
  height: 100px;
  display: block;
  margin: 0 auto;
  flex-shrink: 0;
}
.mix-list {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 8px;
  flex: 1;
}
.mix-row {
  display: grid;
  grid-template-columns: 70px 1fr 56px 48px 72px;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}
.mix-name {
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mix-name i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  vertical-align: 1px;
}
.mix-qty {
  text-align: right;
  color: var(--muted);
  font-weight: 650;
}
.mix-bar {
  height: 14px;
  background: #e7e0d4;
  overflow: hidden;
}
.mix-bar b {
  display: block;
  height: 100%;
  min-width: 2px;
}
.mix-pct {
  text-align: right;
  color: var(--muted);
  font-weight: 650;
}
.mix-val {
  text-align: right;
  font-weight: 700;
}

.pill {
  display: inline-block;
  min-width: 42px;
  padding: 0;
  border-radius: 0;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: transparent;
}
.pill.pos { color: var(--pos); }
.pill.neg { color: var(--neg); }
.pill.zero { color: var(--muted); }
.pill.amber { color: var(--amber); }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  min-width: 1100px;
}
table.grid th,
table.grid td {
  padding: 7px 8px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.grid th {
  background: #efeae1;
  color: var(--ink);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: center;
  border-bottom: 1px solid var(--ink);
}
table.grid th.g-mtd { box-shadow: inset 0 -2px 0 var(--ink); }
table.grid th.g-lm { box-shadow: inset 0 -2px 0 var(--forest); }
table.grid th.g-l3 { box-shadow: inset 0 -2px 0 var(--amber); }
table.grid th.g-ly { box-shadow: inset 0 -2px 0 var(--accent); }
table.grid th.g-est { box-shadow: inset 0 -2px 0 #3d4a6b; }
table.grid th:first-child,
table.grid td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--paper);
  font-weight: 700;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.grid thead th:first-child { background: #efeae1; z-index: 4; }
table.grid tbody tr:nth-child(even) td { background: #f3efe8; }
table.grid tbody tr:nth-child(even) td:first-child { background: #f3efe8; }
table.grid tbody tr:hover td { background: #e7e0d4; }
table.grid tbody tr:hover td:first-child { background: #e7e0d4; }
table.grid tr.total td {
  background: #1c1915;
  color: #f4efe6;
  font-weight: 700;
  border-bottom: 0;
}
table.grid tr.total td:first-child { background: #1c1915; color: #f4efe6; }

.foot {
  margin-top: 14px;
  font-size: 0.68rem;
  color: var(--muted);
  text-align: left;
  max-width: 90ch;
  line-height: 1.5;
}

.empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 1200px) {
  .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .cmp-grid { grid-template-columns: 1fr; }
  .sales-main { grid-template-columns: 1fr; }
  .mix-card { border-left: 0; border-top: 1px solid var(--line); }
  .charts { grid-template-columns: 1fr; }
  .chart { height: 200px; }
  .mix-body { min-height: 0; }
  .asps { grid-template-columns: repeat(3, minmax(80px, 1fr)); }
  .asp { border-bottom: 1px solid var(--line); }
}

@media (max-width: 640px) {
  .app { padding: 12px 12px 24px; }
  .head h1 { font-size: 0.92rem; letter-spacing: 0.01em; }
  .timebox { width: 100%; justify-content: flex-start; }
  .timebox > div { align-items: flex-start; }
  .asps { grid-template-columns: repeat(2, minmax(80px, 1fr)); }
  .mtd-pair .v { font-size: 1.2rem; }
}
