:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --line: #d8dee8;
  --accent: #0f62fe;
  --accent-dark: #063ea8;
  --ink: #0f172a;
  --ok: #117a55;
  --warn: #a16207;
  --danger: #b42318;
  --nav-h: 76px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

html,
body {
  min-height: 100%;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100svh;
}

.topbar {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.brand-mark img {
  max-width: 28px;
  max-height: 28px;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 2px;
}

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

.user-chip {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.88rem;
}

.workspace {
  min-height: calc(100svh - 62px);
}

.content {
  padding: 18px 14px calc(var(--nav-h) + 24px);
  min-width: 0;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

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

.page-kicker {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.page-title {
  font-size: clamp(1.5rem, 2vw, 2.15rem);
  line-height: 1.08;
  margin: 4px 0 0;
  font-weight: 750;
}

.mobile-hero {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 16px;
}

.module-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 1.55rem;
}

.mobile-hero h1 {
  font-size: 1.55rem;
  line-height: 1.05;
  margin: 2px 0 0;
  font-weight: 780;
}

.mobile-hero p {
  color: var(--muted);
  margin: 7px 0 0;
  line-height: 1.45;
}

.eyebrow {
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.notice-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  border-radius: 8px;
  color: #1e3a8a;
  font-size: 0.88rem;
}

.action-panel,
.task-list,
.status-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.action-panel {
  padding: 14px;
  margin-bottom: 14px;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.scan-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.scan-row .btn,
.scan-row .form-control {
  min-height: 52px;
  border-radius: 8px;
}

.helper-text {
  color: var(--muted);
  margin-top: 10px;
  font-size: 0.9rem;
}

.mobile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.status-tile {
  padding: 14px;
}

.status-tile strong,
.status-tile small,
.tile-label {
  display: block;
}

.tile-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-tile strong {
  margin-top: 6px;
  font-size: 1.05rem;
}

.status-tile small {
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.35;
}

.task-list {
  padding: 14px;
}

.task-list h2 {
  font-size: 1rem;
  margin: 0 0 10px;
}

.task-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.task-row span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eef4ff;
  color: var(--accent-dark);
  font-weight: 800;
}

.task-row p {
  margin: 4px 0 0;
  color: #334155;
}

.page-subtitle {
  color: var(--muted);
  margin: 8px 0 0;
  max-width: 680px;
}

.surface {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.metric {
  padding: 18px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-value {
  font-size: 1.75rem;
  line-height: 1;
  font-weight: 760;
  margin-top: 8px;
}

.section-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 18px;
}

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

.quick-action {
  min-height: 128px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  transition: transform 140ms ease, border-color 140ms ease;
}

.quick-action:active {
  transform: scale(0.985);
}

.quick-action i {
  font-size: 1.65rem;
  color: var(--accent);
}

.quick-action strong,
.quick-action small {
  display: block;
}

.quick-action small {
  color: var(--muted);
  margin-top: 4px;
}

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

.module-group {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.module-group summary {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
  touch-action: manipulation;
}

.module-group summary::-webkit-details-marker {
  display: none;
}

.module-group summary i {
  transition: transform 160ms ease;
}

.module-group[open] summary i {
  transform: rotate(180deg);
}

.module-links {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.module-link {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 18px;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 10px 14px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  text-decoration: none;
}

.module-link:last-child {
  border-bottom: 0;
}

.module-link i:first-child {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--accent-dark);
  font-size: 1.2rem;
}

.module-link strong,
.module-link small {
  display: block;
}

.module-link small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  min-height: var(--nav-h);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
}

.bottom-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.66rem;
  font-weight: 750;
}

.bottom-link i {
  font-size: 1.32rem;
}

.bottom-link.active {
  background: #eef4ff;
  color: var(--accent-dark);
}

.desktop-nav {
  display: none;
}

.table-wrap {
  overflow: auto;
}

.table {
  margin: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status.ok {
  color: var(--ok);
  background: #e8f6f1;
}

.status.warn {
  color: var(--warn);
  background: #fff4df;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
}

.login-page {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f3f5f8;
}

.login-panel {
  width: min(100%, 420px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

.login-panel h1 {
  font-size: 1.55rem;
  margin: 0;
}

.login-panel p {
  color: var(--muted);
  margin: 8px 0 22px;
}

.form-control:focus,
.btn:focus-visible,
.nav-link:focus-visible {
  box-shadow: 0 0 0 0.2rem rgba(23, 107, 255, 0.18);
}

.btn-primary {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent-dark);
  --bs-btn-hover-border-color: var(--accent-dark);
}

@media (max-width: 840px) {
  .topbar {
    padding: 0 16px;
  }

  .content {
    padding: 14px 12px calc(var(--nav-h) + 22px);
  }

  .topbar {
    min-height: 56px;
  }

  .brand {
    gap: 9px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand small {
    display: none;
  }

  .user-chip {
    display: none;
  }

  .page-head {
    display: block;
    margin-bottom: 14px;
  }

  .page-title {
    font-size: 1.35rem;
  }

  .page-subtitle {
    font-size: 0.92rem;
  }

  .metric-grid {
    display: none;
  }

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

  .quick-action {
    min-height: 118px;
  }

  .quick-action strong {
    font-size: 0.96rem;
  }

  .quick-action small {
    font-size: 0.8rem;
    line-height: 1.25;
  }

  .module-link small {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .section-row {
    grid-template-columns: 1fr;
  }

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

@media (min-width: 760px) {
  .content {
    padding: 26px 22px calc(var(--nav-h) + 28px);
  }

  .scan-row {
    grid-template-columns: 1fr auto;
  }

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

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

@media (min-width: 1080px) {
  .workspace {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 0;
  }

  .content {
    grid-column: 2;
    grid-row: 1;
    max-width: 1040px;
    padding-bottom: 40px;
    overflow: visible;
  }

  .bottom-nav {
    display: none;
  }

  .desktop-nav {
    display: block;
    grid-column: 1;
    grid-row: 1;
    position: sticky;
    top: 62px;
    background: #fff;
    border-right: 1px solid var(--line);
    height: calc(100svh - 62px);
    min-height: 0;
    padding: 18px 12px 28px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .desktop-nav::-webkit-scrollbar {
    width: 9px;
  }

  .desktop-nav::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
  }

  .desktop-nav-inner {
    display: grid;
    gap: 18px;
  }

  .desktop-group span {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 0 10px 7px;
  }

  .desktop-group a {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 36px;
    padding: 8px 10px;
    border-radius: 8px;
    color: #334155;
    text-decoration: none;
    font-size: 0.9rem;
  }

  .desktop-group a.active,
  .desktop-group a:hover {
    background: #eef4ff;
    color: var(--accent-dark);
  }

  .module-list {
    gap: 14px;
  }

  .module-group summary {
    cursor: default;
  }
}
