.top20-metric-label {
  font-weight: 500;
  font-size: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.top20-metric-select {
  font-size: 1rem;
  padding: 4px 16px 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff url('data:image/svg+xml;utf8,<svg fill="%235e6b7c" height="20" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M7 8l3 3 3-3"/></svg>') no-repeat right 8px center/16px 16px;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  transition: border-color 0.2s;
}
.top20-metric-select:focus {
  outline: none;
  border-color: var(--primary);
}
:root {
  --font-primary: "Inter", sans-serif;
  --bg: #f9f9f9;
  --panel-bg: #ffffff;
  --panel-soft: #f5f8fb;
  --border: #e0e6ee;
  --text: #141b2b;
  --text-muted: #5e6b7c;
  --primary: #006398;
  --primary-hover: #00476e;
  --accent: #3d8fb8;
  --accent-soft: #dceff7;
  --green: #4f9b79;
  --shadow: rgba(0, 0, 0, 0.05) 0 4px 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-primary);
  background: var(--bg);
  color: var(--text);
}

.dashboard-shell {
  min-height: 100vh;
}

.top-hub {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
}

.brand a {
  color: var(--primary);
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
}

.status {
  display: grid;
  gap: 6px;
  min-width: min(360px, 44vw);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.status-text {
  white-space: nowrap;
}

.status-progress {
  position: relative;
  display: block;
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.status-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--primary) 18%, var(--accent) 50%, var(--primary) 82%, transparent);
  animation: status-progress-indeterminate 1.15s ease-in-out infinite;
}

.status.error {
  color: #ba1a1a;
}

@keyframes status-progress-indeterminate {
  from {
    transform: translateX(-115%);
  }

  to {
    transform: translateX(255%);
  }
}

.dashboard-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: min(100%, 1680px);
  margin: 0 auto;
  padding: 20px;
}

.dashboard-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
}

.dashboard-tab {
  min-height: 36px;
  padding: 7px 14px;
  border: 0;
  border-radius: 6px;
  color: var(--text-muted);
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
}

.dashboard-tab:hover {
  background: var(--panel-soft);
  color: var(--primary);
}

.dashboard-tab.active {
  color: #fff;
  background: var(--primary);
}

.dashboard-tab-panel {
  display: none;
}

.dashboard-tab-panel.active {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.summary-card,
.wide-visual,
.details {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-card,
.wide-visual {
  padding: 16px;
}

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

.card-title h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
}

.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
}

.chart-box {
  position: relative;
  width: 100%;
  min-width: 0;
}

.chart-box-wide {
  height: 1272px;
  min-height: 900px;
}

canvas {
  display: block;
}

.table-container {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.summary-table-container {
  max-height: 250px;
}

.main-table-container {
  min-height: 440px;
  max-height: 62vh;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

th,
td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #20344a;
  background: #eef4f8;
  font-weight: 700;
}

th.sortable,
th.summary-sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover,
th.summary-sortable:hover {
  background: var(--accent-soft);
}

tbody tr {
  cursor: context-menu;
}

tbody tr:hover {
  background: var(--panel-soft);
}

.details {
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.table-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.filter-inputs,
.table-info-group,
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-info-group {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.table-controls input,
.table-controls select {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  font-family: var(--font-primary);
  font-size: 0.9rem;
}

.table-controls input {
  width: min(34vw, 340px);
}

.table-controls input:focus,
.table-controls select:focus {
  outline: 1px solid var(--primary);
  border-color: var(--primary);
}

.pagination {
  justify-content: flex-end;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.pagination button,
.row-context-menu button {
  font-family: inherit;
}

.pagination button {
  min-height: 34px;
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
}

.pagination button:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.pagination button:hover:not(:disabled) {
  background: var(--primary-hover);
}

.row-context-menu {
  position: fixed;
  z-index: 1000;
  display: none;
  min-width: 220px;
  padding: 8px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
}

.row-context-menu.open {
  display: flex;
  flex-direction: column;
}

.row-context-menu .node-context-title {
  margin: 0;
  padding: 4px 16px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.row-context-menu .node-context-node {
  margin: 0 0 8px;
  padding: 0 16px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  word-break: break-word;
}

.row-context-menu button {
  padding: 8px 16px;
  border: 0;
  color: var(--text);
  background: transparent;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.row-context-menu button:hover {
  background: var(--panel-soft);
}

@media (max-width: 1180px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .chart-box-wide {
    height: 1272px;
  }
}

@media (max-width: 760px) {
  .top-hub,
  .table-controls,
  .filter-inputs {
    align-items: stretch;
    flex-direction: column;
  }

  .top-hub {
    gap: 10px;
    padding: 12px;
  }

  .brand {
    flex-wrap: wrap;
    gap: 8px;
  }

  .status {
    min-width: 0;
    width: 100%;
    font-size: 0.82rem;
  }

  .status-text {
    white-space: normal;
  }

  .dashboard-content {
    padding: 12px;
    gap: 12px;
  }

  .dashboard-tabs {
    overflow-x: auto;
  }

  .dashboard-tab {
    flex: 1 0 auto;
  }

  .card-title {
    align-items: stretch;
    flex-direction: column;
  }

  .top20-metric-label {
    justify-content: space-between;
    width: 100%;
    font-size: 0.9rem;
  }

  .top20-metric-select {
    min-width: 0;
    width: 100%;
    font-size: 0.9rem;
  }

  .table-controls input {
    width: 100%;
  }

  .table-info-group,
  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .main-table-container {
    max-height: 68vh;
  }

  th,
  td {
    padding: 7px 9px;
    font-size: 0.78rem;
  }

  .chart-box-wide {
    min-height: 820px;
  }
}
