:root {
  --black: #0d0d0d;
  --ink: #1d1d1f;
  --muted: #71717a;
  --line: #e7e5e4;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --gold: #c8a947;
  --orange: #ff6900;
  --green: #1b8a5a;
  --red: #c43d33;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 105, 0, 0.08), transparent 38%),
    linear-gradient(180deg, #fff, var(--paper) 320px);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 48px);
  color: #fff;
  background: var(--black);
  border-bottom: 4px solid var(--gold);
}

.brand {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.brand img {
  width: 168px;
  max-width: 34vw;
  height: auto;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 3vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sheet-link,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
  font-weight: 700;
}

.sheet-link {
  padding: 0 14px;
  border-radius: 6px;
}

.icon-button {
  width: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.25rem;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 38px) 42px;
}

.control-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(15, 15, 15, 0.08);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

select {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #d7d3cf;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-size: 0.96rem;
  font-weight: 650;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 14px 2px 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-row p {
  margin-bottom: 0;
}

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

.kpi {
  position: relative;
  min-height: 118px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kpi strong {
  display: block;
  padding-right: 28px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.kpi-help {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--muted);
  background: #f3f0ea;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 850;
  cursor: help;
}

.kpi-help::after {
  position: absolute;
  right: -2px;
  bottom: calc(100% + 10px);
  z-index: 5;
  width: min(260px, 72vw);
  padding: 11px 12px;
  color: var(--ink);
  background: #fffdfa;
  border: 1px solid var(--gold);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(13, 13, 13, 0.16);
  content: attr(data-tooltip);
  font-size: 0.82rem;
  font-style: normal;
  font-weight: 650;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  transform: translateY(4px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.kpi-help::before {
  position: absolute;
  right: 6px;
  bottom: calc(100% + 5px);
  z-index: 6;
  width: 10px;
  height: 10px;
  background: #fffdfa;
  border-right: 1px solid var(--gold);
  border-bottom: 1px solid var(--gold);
  content: "";
  opacity: 0;
  pointer-events: none;
  transform: rotate(45deg) translateY(4px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.kpi-help:hover::after,
.kpi-help:hover::before,
.kpi-help:focus-visible::after,
.kpi-help:focus-visible::before {
  opacity: 1;
  transform: translateY(0);
}

.kpi span {
  display: block;
  color: var(--black);
  font-size: clamp(1.28rem, 1.9vw, 1.82rem);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.kpi small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.panel {
  min-width: 0;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel-wide {
  grid-column: span 2;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 1.04rem;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 150px) 1fr minmax(52px, auto);
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 700;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  background: #eee9df;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--orange));
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.total-row td {
  color: var(--black);
  background: #fff8e8;
  border-top: 2px solid var(--gold);
  font-weight: 850;
}

.insights-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.insight-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  background: #fffdfa;
}

.insight-item > strong {
  color: var(--gold);
  font-size: 1.05rem;
  line-height: 1;
}

.insight-item h3 {
  margin: 0 0 5px;
  font-size: 0.98rem;
}

.insight-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.is-hidden {
  display: none;
}

@media (max-width: 1050px) {
  .control-bar,
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .panel-wide {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .app-header,
  .brand,
  .status-row,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .control-bar,
  .kpi-grid,
  .insights-list {
    grid-template-columns: 1fr;
  }
}
