:root {
  --atlas-blue: #0056ad;
  --atlas-blue-dark: #004484;
  --atlas-blue-soft: #eef6ff;
  --ink: #0f172a;
  --text: #243247;
  --muted: #667085;
  --line: #d9e0ea;
  --line-soft: #e8edf4;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #fbfcfe;
  --green: #18884f;
  --green-soft: #ddf6e8;
  --amber: #b76100;
  --amber-soft: #fff3dc;
  --teal: #087f8c;
  --teal-soft: #dcf7f7;
  --danger: #c43d12;
  --danger-dark: #9f310e;
  --danger-soft: #fff1eb;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.registration-link {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.registration-link a {
  color: var(--atlas-blue);
  font-weight: 800;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--atlas-blue);
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.login-view {
  min-height: 100vh;
  background: #f8fafc;
}

.login-shell {
  width: min(1440px, calc(100vw - 96px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(480px, 1fr) minmax(420px, 540px);
  gap: 76px;
  align-items: center;
  padding: 48px 0;
}

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

.hero-brand img {
  width: 240px;
}

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

.hero-brand p,
.login-card p,
.hero-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.hero-copy h1 {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 36px;
  line-height: 1.15;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 48px 54px;
}

.login-logo {
  width: 206px;
  margin: 0 auto 24px;
}

.login-card h2 {
  margin: 0 0 8px;
  color: var(--ink);
  text-align: center;
  font-size: 31px;
}

.login-card > p {
  margin-bottom: 30px;
  text-align: center;
}

.login-card form,
.admin-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 39px;
  border: 1px solid #cfd8e5;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--atlas-blue);
  box-shadow: 0 0 0 3px rgba(0, 86, 173, 0.12);
}

.field-shell {
  position: relative;
}

.field-shell input {
  padding-left: 42px;
}

.field-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  translate: 0 -50%;
  border: 2px solid #5b6678;
  border-radius: 4px;
}

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

.login-options,
.topbar,
.topbar-brand,
.topbar-actions,
.breadcrumbs,
.section-title-row,
.table-toolbar,
.form-actions,
.related-title {
  display: flex;
  align-items: center;
}

.login-options {
  justify-content: space-between;
  margin: 2px 0 10px;
}

.check-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 9px;
  font-weight: 500;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.primary-action,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-action {
  background: var(--atlas-blue);
  color: #fff;
  box-shadow: 0 8px 18px rgba(0, 86, 173, 0.18);
}

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

.ghost-button,
.icon-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

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

.danger-button:hover {
  background: var(--danger-dark);
}

.form-message {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.app-view {
  height: 100vh;
  overflow: hidden;
}

.topbar {
  height: 68px;
  justify-content: space-between;
  gap: 24px;
  padding: 0 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-brand {
  gap: 18px;
}

.topbar-brand img {
  width: 150px;
}

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

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

.topbar-actions {
  gap: 12px;
}

.session-pill {
  max-width: 310px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  font-size: 13px;
}

.admin-shell {
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  min-width: 0;
}

.side-nav {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 14px;
  padding: 22px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.side-nav nav {
  display: grid;
  align-content: start;
  gap: 5px;
  overflow: auto;
}

.side-nav a {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--text);
  font-weight: 650;
}

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

.nav-icon,
.metric-icon {
  position: relative;
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  border: 2px solid currentColor;
  border-radius: 5px;
  color: #475467;
}

.nav-icon.chat {
  border-radius: 50%;
}

.nav-icon.chat::after {
  content: "";
  position: absolute;
  left: 6px;
  bottom: -4px;
  width: 7px;
  height: 7px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: skewX(-25deg);
}

.nav-icon.chart::after {
  content: "K";
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 10px;
  font-weight: 850;
}

.nav-icon.mobile::after {
  content: "MV";
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 10px;
  font-weight: 850;
}

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

.db-status {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.db-status strong,
.version-note {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.db-status small {
  color: var(--green);
  font-weight: 700;
}

.content-area {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 22px 28px 28px;
}

.breadcrumbs {
  gap: 9px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumb-icon {
  width: 17px;
  height: 17px;
  border: 2px solid var(--muted);
  border-radius: 4px;
}

.admin-hero {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 22px;
  margin-bottom: 16px;
}

.admin-hero h1 {
  margin: 0 0 7px;
  color: var(--ink);
  font-size: 28px;
}

.admin-hero p {
  max-width: 800px;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.hero-status {
  min-width: 190px;
  display: grid;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--atlas-blue);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px 16px;
}

.hero-status small,
.metric-strip small,
.detail-summary small,
.related-title small {
  color: var(--muted);
  font-size: 12px;
}

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

.metric-strip > div {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 3px 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 13px 14px;
}

.metric-icon {
  grid-row: span 2;
  width: 40px;
  height: 40px;
  border: 0;
  background: var(--atlas-blue-soft);
}

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

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

.metric-icon.muted {
  background: var(--teal-soft);
}

.metric-strip strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  font-size: 25px;
}

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

.overview-grid.executive-overview {
  grid-template-columns: 1fr;
  align-items: start;
}

.executive-dashboard,
.report-section,
.module-access-section {
  display: grid;
  gap: 14px;
}

.report-badge {
  align-self: start;
  border: 1px solid var(--atlas-blue);
  border-radius: 999px;
  background: var(--atlas-blue-soft);
  color: var(--atlas-blue);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 850;
}

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

.executive-kpi,
.report-card,
.operation-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.executive-kpi {
  display: grid;
  gap: 7px;
  border-top: 4px solid var(--atlas-blue);
  padding: 14px;
}

.executive-kpi.success {
  border-top-color: var(--green);
}

.executive-kpi.warning {
  border-top-color: var(--amber);
}

.executive-kpi.danger {
  border-top-color: var(--danger);
}

.executive-kpi.muted {
  border-top-color: var(--teal);
}

.executive-kpi small,
.executive-kpi span {
  color: var(--muted);
  font-size: 12px;
}

.executive-kpi strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 24px;
}

.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 14px;
}

.report-card {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.report-card h2,
.report-section h2,
.module-access-section h2 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 20px;
}

.report-card p,
.report-section p,
.module-access-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.ghost-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--atlas-blue);
  padding: 7px 11px;
  font-weight: 800;
}

.bar-list,
.alert-feed,
.operation-stats {
  display: grid;
  gap: 10px;
}

.bar-row,
.mini-bar,
.alert-item {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.bar-row-head,
.mini-bar {
  display: grid;
  gap: 7px;
}

.bar-row-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.bar-row strong,
.mini-bar strong,
.alert-item strong {
  min-width: 0;
  color: var(--ink);
}

.bar-row small,
.mini-bar span,
.alert-item p {
  color: var(--muted);
  font-size: 12px;
}

.bar-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e7ec;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--atlas-blue), var(--green));
}

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

.operation-card {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
}

.operation-card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
}

.alert-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.alert-level {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  background: var(--atlas-blue-soft);
  color: var(--atlas-blue);
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 850;
}

.alert-level.advertencia {
  background: var(--amber-soft);
  color: #a15c05;
}

.alert-level.critica {
  background: var(--danger-soft);
  color: var(--danger-dark);
}

.alert-item {
  display: grid;
  gap: 6px;
}

.report-empty {
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 5px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 14px;
}

.report-empty strong {
  color: var(--ink);
}

.access-denied {
  border-color: var(--amber);
  background: var(--amber-soft);
}

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

.module-card {
  min-height: 176px;
  display: grid;
  align-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.module-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
}

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

.module-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.module-card strong {
  color: var(--atlas-blue);
  font-size: 26px;
}

.module-card a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  background: var(--atlas-blue);
  color: #fff;
  padding: 8px 12px;
  font-weight: 800;
}

.module-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.module-card-meta span {
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
}

.module-panel {
  display: grid;
  gap: 14px;
}

.entity-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.entity-tabs button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 12px;
  font-weight: 750;
}

.entity-tabs button.active {
  border-color: var(--atlas-blue);
  background: var(--atlas-blue);
  color: #fff;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 16px;
  align-items: start;
}

.table-panel,
.detail-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.table-panel {
  padding: 16px;
}

.detail-panel {
  display: grid;
  gap: 14px;
  padding: 15px;
}

.section-title-row {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-title-row h2,
.related-title h3 {
  margin: 0;
  color: var(--ink);
}

.section-title-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.table-toolbar {
  gap: 10px;
  margin-bottom: 12px;
}

.table-toolbar input {
  min-width: 260px;
}

.table-toolbar select {
  width: 136px;
}

.data-table-wrap {
  max-height: calc(100vh - 340px);
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.data-table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #344054;
  font-size: 12px;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover,
.data-table tbody tr.selected {
  background: var(--atlas-blue-soft);
}

.empty-row {
  color: var(--muted);
  text-align: center !important;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--line-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.state-pill.ok {
  background: var(--green-soft);
  color: var(--green);
}

.state-pill.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.state-pill.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.detail-summary,
.action-panel,
.related-panel {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 13px;
}

.detail-summary {
  display: grid;
  gap: 4px;
}

.detail-summary strong {
  color: var(--ink);
  font-size: 17px;
}

.detail-summary span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.action-panel {
  display: grid;
  gap: 10px;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-bar button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
}

.action-bar button:hover {
  border-color: var(--atlas-blue);
  color: var(--atlas-blue);
}

.action-bar button.primary {
  border-color: var(--atlas-blue);
  background: var(--atlas-blue);
  color: #fff;
}

.action-bar button.danger {
  border-color: #ffd8ca;
  color: var(--danger);
}

.action-bar-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

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

.form-grid label.wide {
  grid-column: 1 / -1;
}

.form-actions {
  justify-content: flex-end;
  gap: 9px;
}

.related-title {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.related-content {
  display: grid;
  gap: 10px;
}

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

.kv-item {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--surface);
  padding: 8px;
}

.kv-item small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}

.kv-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}

.mini-list {
  display: grid;
  gap: 6px;
}

.mini-row {
  display: grid;
  gap: 2px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--surface);
  padding: 8px;
}

.mini-row strong {
  color: var(--ink);
  font-size: 13px;
}

.mini-row small {
  color: var(--muted);
}

.read-only-note {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 14px;
  font-size: 13px;
  line-height: 1.4;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 420px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  padding: 13px 16px;
  font-weight: 700;
}

.toast.error {
  background: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.42);
  padding: 24px;
}

.action-modal {
  width: min(620px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  padding: 18px;
}

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

.action-modal h2 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 21px;
}

.action-modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

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

  .executive-kpis,
  .operation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-grid,
  .module-card-grid {
    grid-template-columns: 1fr;
  }

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

  .data-table-wrap {
    max-height: 520px;
  }
}

@media (max-width: 980px) {
  .login-shell {
    width: min(640px, calc(100vw - 36px));
    grid-template-columns: 1fr;
    gap: 28px;
  }

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

  .side-nav {
    grid-row: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

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

  .metric-strip,
  .overview-grid,
  .executive-kpis,
  .operation-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .content-area {
    padding: 18px;
  }
}
