:root {
  --atlas-blue: #0057ad;
  --atlas-blue-dark: #003f83;
  --atlas-blue-soft: #e8f2ff;
  --ink: #091a33;
  --muted: #56657c;
  --line: #d5deea;
  --panel: #ffffff;
  --bg: #f3f6fb;
  --green: #168243;
  --green-soft: #e6f6ec;
  --amber: #b26a00;
  --amber-soft: #fff3d8;
  --red: #bd3000;
  --red-soft: #fff0e8;
  --slate-soft: #eef2f7;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(135deg, rgba(0, 87, 173, 0.08), transparent 38%),
    var(--bg);
}

.login-shell {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 36px;
  align-items: center;
}

.login-hero {
  padding: 42px;
}

.hero-brand {
  display: flex;
  gap: 20px;
  align-items: center;
  margin-bottom: 42px;
}

.hero-brand img,
.topbar-brand img {
  width: 170px;
  height: auto;
}

.hero-brand span {
  width: 1px;
  height: 58px;
  background: var(--line);
}

.hero-brand p,
.hero-copy p,
.login-card p,
.audit-hero p,
.section-title-row p {
  color: var(--muted);
  line-height: 1.55;
}

.hero-copy h1,
.login-card h2,
.audit-hero h1 {
  margin: 0 0 12px;
  color: var(--ink);
}

.hero-copy h1 {
  font-size: 34px;
}

.login-card {
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(10, 38, 77, 0.1);
}

.login-logo {
  display: block;
  width: 185px;
  margin: 0 auto 18px;
}

.login-card h2,
.login-card p {
  text-align: center;
}

.login-card label {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted);
  font-weight: 700;
}

.field-shell {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
}

.field-icon {
  width: 18px;
  height: 18px;
  border: 2px solid #627085;
  border-radius: 4px;
}

.field-icon.mail {
  border-radius: 3px;
}

.field-icon.lock {
  border-radius: 10px 10px 4px 4px;
}

.field-shell input {
  min-width: 0;
  width: 100%;
  height: 52px;
  border: 0;
  outline: 0;
  color: var(--ink);
}

.primary-action,
.ghost-button,
.icon-button,
.danger-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
}

.primary-action {
  background: var(--atlas-blue);
  color: #fff;
  box-shadow: 0 10px 22px rgba(0, 87, 173, 0.2);
}

.primary-action:hover {
  background: var(--atlas-blue-dark);
}

.ghost-button,
.icon-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.danger-button {
  background: var(--red);
  color: #fff;
}

.login-submit {
  width: 100%;
  margin-top: 22px;
}

.form-message {
  display: block;
  min-height: 22px;
  margin-top: 12px;
  color: var(--red);
}

.app-view {
  min-height: 100vh;
}

.topbar {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar-brand,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-brand span {
  width: 1px;
  height: 34px;
  background: var(--line);
}

.topbar-brand button {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 900;
}

.session-pill {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--slate-soft);
  color: var(--muted);
  font-weight: 800;
}

.audit-shell {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  min-height: calc(100vh - 70px);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 16px;
  background: #fff;
  border-right: 1px solid var(--line);
}

.side-nav nav {
  display: grid;
  gap: 6px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 750;
}

.side-nav a.active,
.side-nav a:hover {
  background: var(--atlas-blue-soft);
  color: var(--atlas-blue);
}

.nav-icon,
.metric-icon,
.breadcrumb-icon {
  width: 19px;
  height: 19px;
  border-radius: 5px;
  display: inline-block;
  background: currentColor;
  opacity: 0.9;
}

.nav-icon.chart {
  display: inline-grid;
  place-items: center;
  color: var(--atlas-blue);
  background: #eef5ff;
  font-size: 10px;
  font-weight: 850;
}

.nav-icon.chart::before {
  content: "K";
}

.db-status {
  margin-top: auto;
  display: flex;
  gap: 12px;
  padding: 14px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

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

.version-note {
  color: var(--muted);
  padding-left: 12px;
}

.content-area {
  min-width: 0;
  padding: 24px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  margin-bottom: 18px;
}

.audit-hero,
.metric-strip > div,
.timeline-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.audit-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
  margin-bottom: 18px;
}

.audit-hero h1 {
  font-size: 30px;
}

.hero-status {
  min-width: 220px;
  align-self: stretch;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 16px;
  border-left: 4px solid var(--atlas-blue);
  background: var(--atlas-blue-soft);
}

.hero-status small,
.detail-summary small {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
}

.hero-status strong,
.detail-summary strong {
  overflow-wrap: anywhere;
}

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

.metric-strip > div {
  min-height: 86px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px;
}

.metric-strip small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.metric-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
}

.metric-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--atlas-blue-soft);
  color: var(--atlas-blue);
}

.metric-icon.sync {
  background: var(--amber-soft);
  color: var(--amber);
}

.metric-icon.review {
  background: var(--green-soft);
  color: var(--green);
}

.audit-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.timeline-panel,
.detail-panel {
  min-width: 0;
  padding: 18px;
}

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

.section-title-row h2,
.summary-panel h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.section-title-row p {
  margin: 0;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.filter-grid input,
.filter-grid select {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

.filter-grid button {
  grid-column: span 1;
}

.audit-timeline {
  display: grid;
  gap: 10px;
  max-height: 720px;
  overflow: auto;
  padding-right: 4px;
}

.timeline-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  text-align: left;
}

.timeline-item:hover,
.timeline-item.active {
  border-color: var(--atlas-blue);
  box-shadow: 0 10px 24px rgba(0, 87, 173, 0.1);
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.timeline-head strong,
.timeline-item p {
  overflow-wrap: anywhere;
}

.timeline-item p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.45;
}

.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 100%;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--slate-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.chip.origin-movil {
  background: var(--atlas-blue-soft);
  color: var(--atlas-blue);
}

.chip.origin-sync {
  background: var(--amber-soft);
  color: var(--amber);
}

.chip.origin-revision_web {
  background: var(--green-soft);
  color: var(--green);
}

.detail-panel {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 90px;
}

.detail-summary {
  display: grid;
  gap: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-summary span {
  color: var(--muted);
  line-height: 1.45;
}

.summary-groups {
  display: grid;
  gap: 10px;
}

.summary-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.summary-group h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  padding: 4px 0;
}

.audit-detail {
  display: grid;
  gap: 12px;
}

.detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.detail-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 8px 12px;
}

.detail-grid dt {
  color: var(--muted);
  font-weight: 800;
}

.detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.metadata-block {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #081626;
  color: #e6edf7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty-state,
.access-state {
  min-height: 130px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 8px;
  background: #091a33;
  color: #fff;
  box-shadow: 0 16px 38px rgba(9, 26, 51, 0.22);
}

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

  .side-nav a {
    justify-content: center;
    padding: 0;
  }

  .side-nav a:not(.active) {
    color: var(--muted);
  }

  .side-nav a {
    font-size: 0;
  }

  .nav-icon {
    margin: 0;
  }

  .db-status,
  .version-note {
    display: none;
  }

  .audit-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-panel {
    position: static;
  }
}

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

  .login-hero {
    display: none;
  }

  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 14px;
  }

  .audit-shell {
    display: block;
  }

  .side-nav {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }

  .side-nav nav {
    display: flex;
    min-width: max-content;
  }

  .side-nav a {
    font-size: 13px;
    padding: 0 12px;
  }

  .content-area {
    padding: 14px;
  }

  .audit-hero,
  .section-title-row {
    display: grid;
  }

  .hero-status {
    min-width: 0;
  }

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

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