:root {
  --bg: #eef5f3;
  --surface: #ffffff;
  --surface-soft: #f5fbf8;
  --line: #d8e7e3;
  --text: #163036;
  --muted: #5f767b;
  --nav: #003f49;
  --nav-active: #075861;
  --green: #55bb27;
  --green-dark: #1d8e38;
  --teal: #005963;
  --teal-dark: #003f49;
  --blue: #0a7885;
  --amber: #f6b73c;
  --orange: #ff7a45;
  --red: #e5484d;
  --shadow: 0 18px 45px rgba(0, 63, 73, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font-size: 1rem;
}

input,
select,
textarea {
  min-height: 42px;
}

.btn,
.nav-item {
  min-height: 42px;
}

button,
input,
select,
textarea,
a {
  touch-action: manipulation;
}

a {
  color: var(--teal);
  font-weight: 700;
  text-decoration: none;
}

a:hover {
  color: var(--green-dark);
}

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

.sidebar {
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: max(18px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom));
  background: var(--nav);
  color: #eef5f8;
  box-shadow: 10px 0 30px rgba(20, 26, 32, 0.16);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 14px;
  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
}

.brand:hover {
  color: #ffffff;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  background: #ffffff;
  padding: 3px;
}

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

.nav-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border-radius: 8px;
  color: #cdd8e1;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-item:hover,
.nav-item:focus {
  background: var(--nav-active);
  color: #ffffff;
  transform: translateX(2px);
}

.nav-item.disabled {
  opacity: 0.48;
  pointer-events: none;
}

.nav-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 800;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  color: #b6c3cd;
  font-size: 0.78rem;
}

.sidebar-footer span:first-child {
  color: #ffffff;
  font-weight: 800;
}

.content-shell {
  min-width: 0;
}

.topbar {
  min-height: 74px;
  padding: 16px max(24px, env(safe-area-inset-right)) 16px max(24px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 4;
}

.topbar strong {
  display: block;
  font-size: 1.1rem;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--green-dark);
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 800;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-chip {
  min-height: 42px;
  max-width: 180px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  background: var(--surface-soft);
  color: var(--teal-dark);
  font-size: 0.86rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-box {
  width: min(390px, 34vw);
  min-width: 240px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.main-content {
  width: min(1480px, 100%);
  margin-inline: auto;
  padding: 24px max(24px, env(safe-area-inset-right)) 24px max(24px, env(safe-area-inset-left));
}

.btn {
  border-radius: 8px;
  font-weight: 800;
}

.btn-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--teal), var(--green-dark));
  border-color: var(--teal);
  box-shadow: 0 12px 26px rgba(0, 89, 99, 0.22);
}

.btn-primary:hover,
.btn-primary:focus {
  background: linear-gradient(135deg, var(--teal-dark), var(--green-dark));
  border-color: var(--teal-dark);
}

.btn-outline-secondary {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}

.dashboard-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.dashboard-hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1;
  font-weight: 850;
}

.hero-copy {
  max-width: 720px;
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: end;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-strip.users-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card,
.panel,
.section-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 122px;
  padding: 1rem;
  display: grid;
  gap: 0.35rem;
  align-content: center;
}

.metric-card span,
.metric-card small,
.panel p,
.metric-row span {
  color: var(--muted);
}

.metric-card span {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  color: var(--text);
  font-size: 2.1rem;
  line-height: 1;
}

.metric-card.attention strong {
  color: var(--orange);
}

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

.panel {
  min-height: 280px;
  padding: 1rem;
  grid-column: span 3;
  overflow: hidden;
}

.panel.wide,
.chart-panel {
  grid-column: span 6;
}

.ideas-panel {
  grid-column: span 5;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel h2 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
  font-weight: 850;
}

.panel p {
  margin: 0;
  font-size: 0.82rem;
}

.trend-chart {
  height: 174px;
  padding: 18px 10px 4px;
  border: 1px solid #e8eef3;
  border-radius: 8px;
  background:
    linear-gradient(to top, transparent 31%, #e8eef3 32%, transparent 33%),
    linear-gradient(to top, transparent 65%, #e8eef3 66%, transparent 67%),
    var(--surface-soft);
  display: flex;
  align-items: end;
  justify-content: space-around;
  gap: 12px;
}

.trend-column {
  min-width: 42px;
  height: 136px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr auto;
  align-items: end;
  gap: 5px;
}

.trend-column small {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
}

.bar {
  width: 100%;
  min-height: 8px;
  border-radius: 6px 6px 2px 2px;
}

.bar.trif {
  background: var(--green);
}

.bar.ltif {
  background: var(--teal);
}

.chart-legend {
  display: flex;
  gap: 18px;
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.dot,
.swatch {
  display: inline-block;
  flex: 0 0 auto;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.green {
  background: var(--green);
}

.blue {
  background: var(--teal);
}

.amber {
  background: var(--amber);
}

.gauge {
  --angle: calc((var(--score) * 1.8deg) - 90deg);
  width: min(190px, 100%);
  aspect-ratio: 1;
  margin: 1rem auto 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 0 49%, transparent 50%),
    conic-gradient(from 225deg, var(--red) 0 20%, var(--amber) 20% 48%, var(--green) 48% 78%, #e8eef2 78% 100%);
  position: relative;
}

.gauge::after {
  content: "";
  position: absolute;
  inset: 16%;
  border: 1px solid #e2e9ef;
  border-radius: 50%;
}

.gauge-needle {
  width: 42%;
  height: 5px;
  border-radius: 99px;
  background: var(--orange);
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: left center;
  transform: rotate(var(--angle));
  z-index: 2;
}

.gauge-needle::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--orange);
  position: absolute;
  left: -7px;
  top: -4.5px;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  transform: translateY(24px);
}

.gauge-center strong {
  font-size: 1.35rem;
}

.gauge-center span {
  color: var(--muted);
  font-size: 0.74rem;
}

.donut-layout {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.donut {
  width: 138px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 0 51%, transparent 52%),
    conic-gradient(var(--amber) 0 var(--first), var(--green) var(--first) 100%);
}

.status-list {
  flex: 1;
  display: grid;
  gap: 0.75rem;
  font-size: 0.88rem;
}

.status-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

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

.task-list label {
  min-height: 40px;
  padding: 0 10px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: var(--surface-soft);
  border: 1px solid #e4ebf1;
  border-radius: 8px;
  font-size: 0.84rem;
}

.task-list span {
  color: var(--muted);
  font-size: 0.76rem;
}

input[type="checkbox"] {
  min-height: auto;
  accent-color: var(--green);
}

.modern-table,
.table {
  margin-bottom: 0;
}

.table-responsive {
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}

.modern-table {
  table-layout: fixed;
  min-width: 720px;
}

.modern-table th:nth-child(1),
.modern-table td:nth-child(1) {
  width: 18%;
}

.modern-table th:nth-child(2),
.modern-table td:nth-child(2) {
  width: 12%;
}

.modern-table th:nth-child(4),
.modern-table td:nth-child(4) {
  width: 22%;
}

.modern-table th:nth-child(5),
.modern-table td:nth-child(5) {
  width: 20%;
}

.modern-table thead th,
.table thead th {
  color: #526070;
  border-bottom: 1px solid #e8edf2;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.modern-table tbody td,
.table tbody td {
  border-color: #edf1f4;
  overflow-wrap: anywhere;
}

.status-pill,
.badge {
  display: inline-flex;
  max-width: 100%;
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  background: #eef4f7;
  color: #435262;
  font-weight: 800;
}

.metric-rows {
  display: grid;
  gap: 0.75rem;
}

.metric-row {
  min-height: 54px;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #edf1f4;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.metric-row:last-child {
  border-bottom: 0;
}

.metric-row div {
  display: grid;
  gap: 0.1rem;
}

.metric-row div:last-child {
  text-align: right;
}

.idea-list {
  counter-reset: ideas;
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.idea-list li {
  counter-increment: ideas;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid #e4ebf1;
  border-radius: 8px;
  background: var(--surface-soft);
}

.idea-list li::before {
  content: counter(ideas);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e2f4ec;
  color: var(--green-dark);
  font-weight: 850;
}

.idea-list strong,
.idea-list span {
  grid-column: 2;
}

.idea-list strong {
  line-height: 1.2;
}

.idea-list span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.section-panel {
  padding: 1.25rem;
}

.users-panel {
  grid-column: 1 / -1;
}

.users-table {
  table-layout: auto;
  min-width: 760px;
}

.investigations-table,
.reports-table {
  min-width: 820px;
}

.table-subtext {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  background: #e2f4ec;
  color: var(--green-dark);
  font-weight: 900;
}

.form-panel {
  max-width: 920px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

.empty-state {
  width: 100%;
  align-self: center;
  text-align: center;
  color: var(--muted);
}

.form-control,
.form-select {
  border-color: var(--line);
  border-radius: 8px;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 0.22rem rgba(85, 187, 39, 0.16);
}

.login-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 20%, rgba(85, 187, 39, 0.14), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(0, 89, 99, 0.15), transparent 26%),
    linear-gradient(135deg, #f6fbf8 0%, #e6f2ef 52%, #f7fbf8 100%);
}

.login-shell {
  min-height: 100vh;
  width: min(1180px, 100%);
  margin-inline: auto;
  padding: max(32px, env(safe-area-inset-top)) max(32px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(32px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 28px;
  align-items: center;
}

.login-overview,
.login-card {
  border: 1px solid rgba(0, 89, 99, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 24px 70px rgba(0, 63, 73, 0.14);
  backdrop-filter: blur(16px);
}

.login-overview {
  min-height: 680px;
  padding: clamp(24px, 4vw, 46px);
  display: grid;
  align-content: center;
  gap: 28px;
}

.login-logo {
  width: min(360px, 70%);
  max-height: 300px;
  object-fit: contain;
}

.login-overview h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.6rem);
  line-height: 0.98;
  font-weight: 900;
  color: var(--teal-dark);
}

.login-overview p {
  max-width: 760px;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

.login-overview .system-credit {
  margin-top: 0.85rem;
  color: var(--teal-dark);
  font-weight: 800;
}

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

.overview-grid article {
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  display: grid;
  gap: 8px;
}

.overview-grid strong {
  color: var(--teal-dark);
}

.overview-grid span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.login-card {
  padding: clamp(24px, 4vw, 34px);
  display: grid;
  gap: 22px;
}

.login-card-logo {
  width: 150px;
  height: 150px;
  object-fit: contain;
  justify-self: center;
}

.login-card h2 {
  margin: 0;
  color: var(--teal-dark);
  font-size: 2rem;
  font-weight: 900;
}

.login-card p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.remember-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.remember-row input {
  accent-color: var(--green);
}

.login-hint {
  padding: 12px;
  border-radius: 8px;
  background: #eef8eb;
  color: var(--teal-dark);
  display: grid;
  gap: 2px;
  font-size: 0.85rem;
}

.login-hint span {
  color: var(--muted);
  font-weight: 700;
}

.login-credit {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
}

.offline-shell {
  min-height: 100vh;
  width: min(520px, 100%);
  margin-inline: auto;
  padding: 24px;
  display: grid;
  place-items: center;
}

.offline-title {
  margin: 0;
  color: var(--teal-dark);
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  font-weight: 900;
}

@media (min-width: 1400px) {
  .metric-strip {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .dashboard-grid {
    gap: 16px;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 212px minmax(0, 1fr);
  }

  .sidebar {
    gap: 16px;
  }

  .brand {
    font-size: 1rem;
  }

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

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .search-box {
    width: min(100%, 520px);
  }
}

@media (max-width: 1220px) {
  .metric-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-strip.users-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .panel,
  .panel.wide,
  .chart-panel,
  .ideas-panel {
    grid-column: span 6;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 10px;
  }

  .brand {
    padding: 0 8px;
    flex: 0 0 auto;
  }

  .brand span:last-child,
  .nav-item span:last-child,
  .sidebar-footer {
    display: none;
  }

  .nav-stack {
    display: flex;
  }

  .nav-item {
    min-width: 42px;
    justify-content: center;
  }

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

  .topbar-actions {
    width: 100%;
  }

  .search-box {
    width: auto;
    flex: 1;
  }

  .main-content {
    padding: 18px;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-strip.users-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel,
  .panel.wide,
  .chart-panel,
  .ideas-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .metric-strip {
    grid-template-columns: 1fr;
  }

  .metric-strip.users-strip {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .hero-actions,
  .donut-layout {
    flex-direction: column;
    align-items: stretch;
  }

  .donut {
    align-self: center;
  }

  .trend-chart {
    overflow-x: auto;
    justify-content: start;
  }
}

@media (max-width: 980px) {
  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-overview {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .login-shell {
    padding: 16px;
  }

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

  .login-logo {
    width: 220px;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 12px;
  }

  .main-content {
    padding: 14px;
  }

  .dashboard-hero h1,
  .login-overview h1 {
    font-size: 2rem;
  }

  .hero-actions .btn,
  .topbar-actions .btn,
  .search-box {
    width: 100%;
  }

  .login-card,
  .login-overview {
    padding: 20px;
  }

  .login-card-logo {
    width: 118px;
    height: 118px;
  }

  .login-logo {
    width: 180px;
  }
}

@media print {
  .sidebar,
  .topbar,
  .hero-actions,
  .btn {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .main-content {
    padding: 0;
  }

  body {
    background: #ffffff;
  }

  .panel,
  .metric-card,
  .section-panel {
    box-shadow: none;
    break-inside: avoid;
  }
}
