:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #647086;
  --line: #dce3ef;
  --nav: #182235;
  --nav-soft: #25324a;
  --accent: #0f766e;
  --accent-2: #2563eb;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  min-width: 320px;
  overflow-x: hidden;
}

.mobile-header {
  align-items: center;
  background: var(--nav);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  display: none;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 14px;
  position: sticky;
  top: 0;
  z-index: 30;
}

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

.brand {
  margin-bottom: 22px;
  padding: 0 6px;
}

.brand-logo {
  display: block;
  height: auto;
  width: 100%;
}

.brand .brand-logo {
  max-width: 210px;
}

.mobile-brand .brand-logo {
  max-width: 168px;
}

.nav-toggle {
  align-items: center;
  background: var(--nav-soft);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  height: 38px;
  justify-content: center;
  padding: 0;
  width: 42px;
}

.nav-toggle span {
  background: #fff;
  border-radius: 999px;
  display: block;
  height: 2px;
  width: 18px;
}

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

.sidebar {
  background: var(--nav);
  color: #fff;
  height: 100vh;
  padding: 20px 14px;
  position: sticky;
  top: 0;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-list a {
  border-radius: 8px;
  color: #d7dfeb;
  font-weight: 600;
  min-height: 40px;
  padding: 10px 12px;
  text-decoration: none;
}

.nav-list a:hover,
.nav-list a.active {
  background: var(--nav-soft);
  color: #fff;
}

.main {
  min-width: 0;
  padding: 24px;
  width: 100%;
}

.topbar {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.topbar h1 {
  font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 760;
  margin: 0;
  overflow-wrap: anywhere;
}

.topbar p {
  color: var(--muted);
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  margin-bottom: 18px;
}

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

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-size: clamp(20px, 2.2vw, 25px);
  margin-top: 8px;
  overflow-wrap: anywhere;
}

.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 16px;
  min-width: 0;
}

.section-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 14px 16px;
}

.section-header h2 {
  font-size: 16px;
  font-weight: 760;
  margin: 0;
}

.section-header p {
  color: var(--muted);
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.section-body {
  padding: 16px;
}

.table-wrap {
  overflow-x: auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  margin: 0;
  white-space: nowrap;
}

.data-table th {
  color: #49566c;
  font-size: 12px;
  text-transform: uppercase;
}

.data-table td,
.data-table th {
  padding: 10px 12px;
  vertical-align: middle;
}

.data-table td.wrap {
  max-width: min(520px, 60vw);
  white-space: normal;
}

.status-pill {
  background: #eef4ff;
  border: 1px solid #cfe0ff;
  border-radius: 999px;
  color: #164eaa;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
}

.status-pill.ok {
  background: #eefaf6;
  border-color: #bce8d8;
  color: #08745f;
}

.filter-bar {
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(140px, 1fr)) minmax(96px, auto);
  margin-bottom: 16px;
  padding: 14px;
}

.filter-bar > * {
  min-width: 0;
}

.filter-bar.compact {
  grid-template-columns: minmax(240px, 1fr) minmax(96px, auto);
}

.form-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #0b5f59;
  border-color: #0b5f59;
}

.export-group {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.export-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-right: 2px;
  text-transform: uppercase;
}

.chart-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  margin-bottom: 16px;
}

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

.chart-card h2 {
  font-size: 16px;
  font-weight: 760;
  margin: 0 0 12px;
}

.chart-card .chart-holder {
  height: 280px;
  position: relative;
}

.link-quiet {
  color: var(--accent-2);
  font-weight: 700;
  text-decoration: none;
}

.link-quiet:hover {
  text-decoration: underline;
}

.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
}

.detail-item {
  border-bottom: 1px solid var(--line);
  min-width: 0;
  padding: 10px 0;
}

.detail-item span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-item strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.pagination {
  margin: 16px 0 0;
}

@media (min-width: 981px) {
  .sidebar.collapse {
    display: block !important;
    visibility: visible;
  }
}

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

@media (max-width: 980px) {
  .mobile-header {
    display: flex;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    height: auto;
    padding: 10px 14px 14px;
    position: static;
  }

  .sidebar:not(.show) {
    display: none;
  }

  .sidebar.collapsing {
    display: block;
  }

  .sidebar .brand {
    display: none;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-list a {
    text-align: center;
  }

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

  .topbar .btn {
    align-self: start;
  }

  .filter-bar.compact {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (max-width: 760px) {
  .table-wrap {
    overflow-x: visible;
  }

  .data-table {
    border-collapse: separate;
    border-spacing: 0 10px;
    display: block;
    white-space: normal;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody,
  .data-table tfoot,
  .data-table tr,
  .data-table td,
  .data-table th {
    display: block;
    width: 100%;
  }

  .data-table tbody tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
  }

  .data-table td {
    align-items: start;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(92px, 38%) minmax(0, 1fr);
    min-height: 42px;
    overflow-wrap: anywhere;
    padding: 9px 12px;
    white-space: normal;
  }

  .data-table td:last-child {
    border-bottom: 0;
  }

  .data-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 760;
    text-transform: uppercase;
  }

  .data-table td.wrap {
    max-width: none;
  }

  .data-table tfoot {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 10px;
    padding: 8px 12px;
  }

  .data-table tfoot tr,
  .data-table tfoot th {
    border: 0;
    display: block;
    padding: 4px 0;
    width: 100%;
  }

  .pagination {
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 14px;
  }

  .nav-list,
  .filter-bar,
  .filter-bar.compact {
    grid-template-columns: 1fr;
  }

  .nav-list a {
    text-align: left;
  }

  .section-header {
    align-items: stretch;
    flex-direction: column;
    padding: 12px 14px;
  }

  .section-header .btn,
  .filter-bar .btn {
    align-self: stretch;
  }

  .section-body {
    padding: 14px;
  }

  .metric {
    padding: 14px;
  }
}
