:root {
  color-scheme: light;
  --atlas-blue: #0057ad;
  --atlas-blue-dark: #003b78;
  --atlas-ink: #081a33;
  --atlas-muted: #53627a;
  --atlas-line: #d7e0ee;
  --atlas-soft: #f4f7fb;
  --atlas-card: #ffffff;
  --atlas-green: #16833a;
  --atlas-orange: #c65a00;
  --atlas-red: #b42318;
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--atlas-soft);
  color: var(--atlas-ink);
}

button,
input,
select {
  font: inherit;
}

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

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 520px);
  gap: 48px;
  align-items: center;
  padding: 48px 7vw;
}

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

.hero-brand img,
.topbar-brand img,
.login-logo {
  height: 56px;
  width: auto;
}

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

.hero-brand p {
  margin: 0;
  color: var(--atlas-muted);
  line-height: 1.35;
}

.hero-copy h1 {
  margin: 48px 0 16px;
  font-size: 42px;
  line-height: 1.1;
}

.hero-copy p {
  max-width: 540px;
  color: var(--atlas-muted);
  font-size: 18px;
  line-height: 1.55;
}

.login-card {
  background: var(--atlas-card);
  border: 1px solid var(--atlas-line);
  border-radius: 8px;
  box-shadow: 0 20px 48px rgba(8, 26, 51, 0.12);
  padding: 44px;
}

.login-card h2 {
  margin: 18px 0 8px;
  font-size: 30px;
}

.login-card p,
.form-message {
  color: var(--atlas-muted);
}

.login-card form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

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

.field-shell input,
.panel-tools input,
.panel-tools select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--atlas-line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--atlas-ink);
}

.primary-action,
.icon-button,
.ghost-button,
.panel-tools button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--atlas-blue);
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

.primary-action,
.icon-button {
  background: var(--atlas-blue);
  color: white;
}

.ghost-button,
.panel-tools button {
  background: white;
  color: var(--atlas-blue);
}

.topbar {
  height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  background: white;
  border-bottom: 1px solid var(--atlas-line);
}

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

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

.session-pill,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 12px;
  background: #eaf2ff;
  color: var(--atlas-blue-dark);
  font-weight: 800;
}

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

.side-nav,
.detail-panel {
  background: white;
  border-right: 1px solid var(--atlas-line);
  padding: 20px;
}

.detail-panel {
  border-right: 0;
  border-left: 1px solid var(--atlas-line);
}

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

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

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

.nav-icon {
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-radius: 5px;
  display: inline-block;
  position: relative;
  flex: 0 0 auto;
}

.nav-icon.chart::before,
.nav-icon.automation::before,
.nav-icon.bell::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

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

.version-note {
  display: block;
  margin-top: 12px;
  color: var(--atlas-muted);
}

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

.breadcrumbs {
  display: flex;
  gap: 8px;
  color: var(--atlas-muted);
  margin-bottom: 18px;
}

.automation-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  background: white;
  border: 1px solid var(--atlas-line);
  border-radius: 8px;
  padding: 22px;
}

.automation-hero h1 {
  margin: 0 0 8px;
  font-size: 30px;
}

.automation-hero p {
  margin: 0;
  color: var(--atlas-muted);
}

.hero-status {
  min-width: 180px;
  text-align: right;
}

.hero-status small,
.detail-content small {
  color: var(--atlas-muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.summary-card,
.monitor-panel,
.detail-card {
  background: white;
  border: 1px solid var(--atlas-line);
  border-radius: 8px;
}

.summary-card {
  padding: 16px;
}

.summary-card small {
  color: var(--atlas-muted);
  font-weight: 700;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.tab-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.tab-bar button {
  border: 1px solid var(--atlas-line);
  background: white;
  border-radius: 999px;
  min-height: 38px;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

.tab-bar button.active {
  background: var(--atlas-blue);
  border-color: var(--atlas-blue);
  color: white;
}

.monitor-panel {
  padding: 16px;
  min-height: 420px;
}

.panel-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 10px;
  margin-bottom: 14px;
}

.timeline-list,
.card-list {
  display: grid;
  gap: 10px;
}

.timeline-item,
.list-card {
  border: 1px solid var(--atlas-line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  cursor: pointer;
}

.timeline-item:hover,
.list-card:hover {
  border-color: var(--atlas-blue);
}

.timeline-item header,
.list-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.timeline-item h3,
.list-card h3 {
  margin: 0;
  font-size: 16px;
}

.timeline-item p,
.list-card p,
.empty-state {
  color: var(--atlas-muted);
  margin: 8px 0 0;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  background: #eaf2ff;
  color: var(--atlas-blue-dark);
}

.badge.fallida,
.badge.critica {
  background: #fff0ed;
  color: var(--atlas-red);
}

.badge.ejecutada,
.badge.ok {
  background: #e8f7ee;
  color: var(--atlas-green);
}

.badge.omitida,
.badge.warning {
  background: #fff5e6;
  color: var(--atlas-orange);
}

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

.snapshot-summary .summary-card strong {
  font-size: 20px;
}

.detail-panel h2 {
  margin: 0 0 16px;
}

.detail-card {
  padding: 14px;
}

.detail-card dl {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.detail-card div {
  min-width: 0;
}

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

.detail-card dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--atlas-ink);
  color: white;
  box-shadow: 0 18px 36px rgba(8, 26, 51, 0.25);
}

.rules-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.4fr);
  gap: 18px;
  align-items: start;
}

.rules-list-panel,
.rule-form,
.simulation-card {
  min-width: 0;
  border: 1px solid var(--atlas-line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 12px 28px rgba(9, 32, 64, 0.06);
}

.rules-list-panel {
  padding: 14px;
}

.rule-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.rule-form header,
.builder-heading,
.action-bar,
.form-flags {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.rule-form h2,
.builder-heading h3 {
  margin: 0;
}

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

.rule-form label {
  display: grid;
  gap: 6px;
  color: var(--atlas-muted);
  font-weight: 800;
}

.rule-form input,
.rule-form select,
.rule-form textarea,
.json-editor {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--atlas-line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  color: var(--atlas-ink);
  background: #fff;
}

.builder-section {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--atlas-line);
  padding-top: 14px;
}

.builder-rows {
  display: grid;
  gap: 8px;
}

.builder-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(92px, 0.75fr) minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.action-row {
  grid-template-columns: minmax(130px, 0.85fr) minmax(130px, 0.85fr) minmax(130px, 1fr) minmax(130px, 1fr) minmax(105px, 0.7fr) minmax(105px, 0.7fr) minmax(100px, 0.7fr) minmax(90px, 0.6fr) minmax(90px, 0.6fr) auto;
  overflow-x: auto;
}

.builder-row button,
.ghost-button,
.danger-action {
  border: 1px solid var(--atlas-line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  color: var(--atlas-ink);
  font-weight: 800;
  cursor: pointer;
}

.danger-action {
  border-color: #f1b9a7;
  background: #fff4ef;
  color: #b73711;
}

.json-editor {
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}

.form-message {
  color: #b73711;
  font-weight: 800;
}

.simulation-result {
  min-width: 0;
}

.simulation-card {
  padding: 14px;
}

.simulation-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.simulation-card pre {
  max-height: 320px;
  overflow: auto;
  border-radius: 8px;
  padding: 12px;
  background: #f6f8fb;
  color: var(--atlas-ink);
}

.list-card.selected,
.timeline-item.selected {
  border-color: var(--atlas-blue);
  box-shadow: 0 0 0 2px rgba(0, 92, 185, 0.12);
}

[hidden] {
  display: none !important;
}

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

  .detail-panel {
    display: none;
  }

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

  .rules-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .builder-row,
  .action-row {
    grid-template-columns: 1fr;
  }
}

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

  .topbar,
  .automation-hero {
    flex-direction: column;
    height: auto;
    align-items: stretch;
  }

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

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

  .summary-grid,
  .snapshot-summary,
  .panel-tools {
    grid-template-columns: 1fr;
  }
}
