@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Sarabun:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #f1f5f9;
  --bg-deep: #e8eef5;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --ink: #0f172a;
  --ink-2: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #0d9488;
  --accent-strong: #0f766e;
  --accent-soft: #ccfbf1;
  --gold: #f59e0b;
  --indigo: #4f46e5;
  --rose: #e11d48;
  --gradient-brand: linear-gradient(135deg, #0d9488 0%, #0e7490 45%, #1e40af 100%);
  --gradient-warm: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  --gradient-glass: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.78) 100%);
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.12), 0 6px 18px rgba(15, 23, 42, 0.06);
  --shadow-xl: 0 30px 80px rgba(15, 23, 42, 0.18);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --ring: 0 0 0 3px rgba(13, 148, 136, 0.18);
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  font-family: "Inter", "Sarabun", "Segoe UI", Tahoma, sans-serif;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(1200px 600px at 0% -10%, rgba(13, 148, 136, 0.08), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(79, 70, 229, 0.06), transparent 65%),
    var(--bg);
  color: var(--ink);
  letter-spacing: -0.005em;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  letter-spacing: 0.01em;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.28);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.5);
}

/* ============================================================
   Login screen
   ============================================================ */
.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(800px 500px at 20% 20%, rgba(13, 148, 136, 0.22), transparent 60%),
    radial-gradient(700px 500px at 80% 80%, rgba(79, 70, 229, 0.18), transparent 60%),
    linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}

.login-card {
  position: relative;
  display: grid;
  width: min(440px, 100%);
  gap: 18px;
  padding: 36px;
  background: var(--gradient-glass);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.login-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: var(--radius-xl);
  padding: 1px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(13, 148, 136, 0.2));
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}

.login-card h1,
.login-card p {
  margin: 0;
}

.login-card h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-card p {
  color: var(--muted);
  font-size: 13px;
}

.login-card .brand-mark {
  width: 56px;
  height: 56px;
  font-size: 18px;
}

/* ============================================================
   App shell
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(248, 250, 252, 0.95) 100%);
  border-right: 1px solid var(--line);
  overflow: auto;
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 4px 4px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 14px;
  background: var(--gradient-brand);
  color: #fff;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 20px rgba(13, 148, 136, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.logo-mark {
  overflow: hidden;
  padding: 0;
  background: transparent;
}

.logo-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand h1,
.brand p,
.topbar h2,
.panel h2,
.bottom-dock h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.brand p {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.eyebrow,
.status-text,
.bottom-dock p,
label,
small {
  color: var(--muted);
}

.status-text,
.bottom-dock p,
small {
  font-size: 12px;
}

.panel {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), border-color var(--transition);
}

.panel:hover {
  box-shadow: var(--shadow-sm);
}

.upload-panel {
  display: grid;
  gap: 12px;
}

.file-drop {
  display: grid;
  position: relative;
  place-items: center;
  min-height: 132px;
  gap: 6px;
  padding: 14px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(13, 148, 136, 0.04), rgba(79, 70, 229, 0.04));
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
}

.file-drop:hover {
  border-color: var(--accent);
  background:
    linear-gradient(135deg, rgba(13, 148, 136, 0.08), rgba(79, 70, 229, 0.07));
  transform: translateY(-1px);
}

.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-drop strong {
  font-size: 13px;
  font-weight: 700;
}

.file-drop small {
  font-size: 11px;
}

.file-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, #0e7490 100%);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 6px 14px rgba(13, 148, 136, 0.35);
}

/* ============================================================
   Buttons
   ============================================================ */
.primary-btn,
.ghost-btn,
.icon-btn,
.segment,
.metric-segment {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  transition: all var(--transition);
}

.primary-btn {
  position: relative;
  border-color: transparent;
  background: var(--gradient-brand);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 20px rgba(13, 148, 136, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(13, 148, 136, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.primary-btn:active {
  transform: translateY(0);
}

.primary-btn:disabled {
  background: var(--muted-2);
  box-shadow: none;
  cursor: not-allowed;
}

.ghost-btn,
.icon-btn {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--line);
}

.ghost-btn:hover,
.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--ink);
}

.icon-btn {
  width: 40px;
  font-size: 16px;
  display: grid;
  place-items: center;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input::placeholder {
  color: var(--muted-2);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

input[type="color"] {
  padding: 4px;
  cursor: pointer;
}

/* Customer group multi-select */
.checkbox-list {
  display: grid;
  max-height: 160px;
  overflow: auto;
  gap: 2px;
  margin-top: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.checkbox-list:empty {
  display: none;
}

.checkbox-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 30px;
  margin: 0;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  transition: background var(--transition);
}

.checkbox-option:hover {
  background: rgba(13, 148, 136, 0.08);
}

.checkbox-option input {
  width: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.checkbox-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checkbox-option small {
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Segmented controls
   ============================================================ */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-top: 8px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.segment,
.metric-segment {
  min-height: 36px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  border-radius: 9px;
  letter-spacing: 0;
}

.segment:hover,
.metric-segment:hover {
  color: var(--ink-2);
}

.segment.active,
.metric-segment.active {
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1), inset 0 0 0 1px rgba(13, 148, 136, 0.15);
}

.field-label {
  margin-top: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============================================================
   Level editor
   ============================================================ */
.level-editor {
  display: grid;
  gap: 6px;
}

.level-row {
  display: grid;
  grid-template-columns: 40px 1fr 1fr 38px;
  gap: 6px;
  align-items: center;
  padding: 4px;
  border-radius: 8px;
  transition: background var(--transition);
}

.level-row:hover {
  background: var(--surface-2);
}

.level-row span {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-2);
  text-align: center;
  padding: 4px 0;
  background: var(--surface-2);
  border-radius: 6px;
}

.level-row input {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 12px;
}

.level-row input[type="color"] {
  padding: 2px;
  width: 100%;
  height: 34px;
  border-radius: 6px;
}

/* ============================================================
   Workspace
   ============================================================ */
.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  padding: 22px 26px 24px;
  gap: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "title userbar"
    "kpis kpis";
  align-items: center;
  gap: 14px 18px;
}

.topbar > :first-child {
  grid-area: title;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.topbar h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.userbar {
  grid-area: userbar;
  display: flex;
  align-items: center;
  gap: 10px;
}

.userbar span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 180px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
}

.userbar span::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.kpis {
  grid-area: kpis;
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
}

.kpis div {
  position: relative;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.kpis div::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.08), transparent 60%);
  pointer-events: none;
}

.kpis div:nth-child(2)::before {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), transparent 60%);
}

.kpis div:nth-child(3)::before {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), transparent 60%);
}

.kpis div:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpis span {
  display: block;
  position: relative;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.kpis small {
  display: block;
  position: relative;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ============================================================
   Map stage
   ============================================================ */
.map-stage {
  position: relative;
  display: grid;
  min-height: 580px;
  overflow: hidden;
  background:
    radial-gradient(900px 600px at 30% 20%, rgba(255, 255, 255, 0.9), transparent 60%),
    radial-gradient(700px 500px at 80% 80%, rgba(13, 148, 136, 0.06), transparent 60%),
    linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

#mapSvg {
  width: 100%;
  height: 100%;
  min-height: 580px;
  filter: drop-shadow(0 4px 8px rgba(15, 23, 42, 0.08));
}

.map-area {
  stroke: #ffffff;
  stroke-width: 0.6;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 160ms ease, opacity 160ms ease, stroke 160ms ease, stroke-width 160ms ease;
}

.map-area:hover {
  opacity: 0.92;
  stroke: #0f172a;
  stroke-width: 1.4;
  filter: brightness(1.05);
}

/* Tooltip */
.tooltip {
  position: fixed;
  z-index: 30;
  min-width: 250px;
  padding: 14px 16px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  pointer-events: none;
  animation: tooltipIn 140ms ease;
}

@keyframes tooltipIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tooltip strong {
  display: block;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.tooltip div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.tooltip div b {
  color: var(--ink-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none;
}

/* Legend */
.legend {
  position: absolute;
  right: 20px;
  bottom: 20px;
  width: 210px;
  padding: 14px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
}

.legend-head {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.legend-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 4px 0;
  padding: 4px 0;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}

.legend-row b {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  background: var(--surface-2);
  border-radius: 4px;
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 3;
  background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  backdrop-filter: blur(4px);
}

.loading.hidden {
  display: none;
}

/* ============================================================
   Bottom dock — rankings
   ============================================================ */
.bottom-dock {
  display: grid;
  gap: 14px;
  align-items: start;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.app-footer {
  padding: 4px 2px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.rankings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rankings-head h3 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.015em;
}

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

.ranking-panel {
  min-width: 0;
}

.ranking-panel h3 {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.ranking-panel:nth-child(1) h3::before,
.ranking-panel:nth-child(2) h3::before,
.ranking-panel:nth-child(3) h3::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 2px;
  vertical-align: middle;
  background: #22c55e;
}

.ranking-panel:nth-child(2) h3::before {
  background: var(--rose);
}

.ranking-panel:nth-child(3) h3::before {
  background: var(--gold);
}

.ranking-list {
  display: grid;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.ranking-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  background: var(--surface);
  transition: background var(--transition), transform var(--transition);
}

.ranking-item:hover {
  background: var(--surface-2);
  transform: translateX(2px);
}

.ranking-item:last-child {
  border-bottom: 0;
}

.ranking-item b {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: var(--surface-2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ranking-item:nth-child(1) b {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #fff;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.35);
}

.ranking-item:nth-child(2) b {
  background: linear-gradient(135deg, #cbd5e1, #94a3b8);
  color: #fff;
}

.ranking-item:nth-child(3) b {
  background: linear-gradient(135deg, #fb923c, #ea580c);
  color: #fff;
}

.ranking-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.ranking-item span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 320px minmax(0, 1fr);
  }
  .kpis {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }
  .kpis span {
    font-size: 22px;
  }
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .workspace {
    padding: 18px;
  }
  .topbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "userbar"
      "kpis";
  }
  .userbar {
    justify-self: start;
  }
  .kpis,
  .rankings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .workspace {
    padding: 14px;
  }
  .topbar h2 {
    font-size: 20px;
  }
  .kpis,
  .rankings-grid {
    grid-template-columns: 1fr;
  }
  .kpis span {
    font-size: 22px;
  }
  .rankings-head {
    align-items: stretch;
    flex-direction: column;
  }
  .ranking-item {
    grid-template-columns: 32px minmax(0, 1fr);
  }
  .ranking-item span {
    grid-column: 2;
  }
  .legend {
    left: 14px;
    right: 14px;
    bottom: 14px;
    width: auto;
  }
}
