:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --ink: #1f2523;
  --muted: #68736f;
  --line: #dfe5e1;
  --brand: #0d7c66;
  --brand-dark: #075d4d;
  --accent: #c98922;
  --danger: #b42318;
  --warn: #9a6700;
  --ok: #137333;
  --shadow: 0 14px 35px rgba(23, 31, 28, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  background: #202724;
  color: #f7faf8;
  padding: 24px 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
}

.nav {
  display: grid;
  gap: 6px;
  margin-top: 34px;
}

.nav a {
  display: block;
  padding: 11px 12px;
  border-radius: 8px;
  color: #cfd8d4;
  text-decoration: none;
}

.nav a:hover,
.nav a.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.main {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar h1,
.panel h2,
.login-panel h1 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 30px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.user-name {
  color: var(--muted);
}

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

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

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 18px;
}

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

.metric-card strong {
  align-self: end;
  font-size: 30px;
}

.panel {
  margin-bottom: 18px;
  padding: 18px;
}

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

.panel h2 {
  font-size: 19px;
}

.panel p {
  margin: 4px 0 0;
}

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

.split-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-light {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.link {
  color: var(--brand-dark);
  font-weight: 750;
}

.form-grid,
.form-stack,
.search-row {
  display: grid;
  gap: 14px;
}

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

.form-grid .btn,
.form-grid fieldset {
  grid-column: 1 / -1;
}

.search-row {
  grid-template-columns: minmax(220px, 1fr) minmax(120px, 180px) auto;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 11px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(13, 124, 102, 0.16);
}

textarea {
  min-height: 110px;
  padding-top: 10px;
  resize: vertical;
}

.full-span {
  grid-column: 1 / -1;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.radio-row {
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.radio-row legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.radio-row label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.radio-row input {
  min-height: auto;
  width: auto;
}

.full-field {
  display: none;
}

.download-form.is-full .manual-field {
  display: none;
}

.download-form.is-full .full-field {
  display: grid;
}

.progress {
  width: 160px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ede9;
}

.progress.large {
  width: 100%;
  height: 12px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--brand);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef2ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-completado,
.status-info {
  background: #e7f4ec;
  color: var(--ok);
}

.status-procesando {
  background: #e9f2ff;
  color: #195b9d;
}

.status-error {
  background: #fdebea;
  color: var(--danger);
}

.status-pendiente,
.status-warn {
  background: #fff5df;
  color: var(--warn);
}

.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #eef7f3;
  color: var(--brand-dark);
}

.alert-error {
  background: #fff1f0;
  color: var(--danger);
}

.alert-warn {
  background: #fff8e8;
  color: var(--warn);
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 420px);
  padding: 28px;
}

.login-brand {
  color: var(--ink);
  margin-bottom: 28px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0 0 22px;
}

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

.detail-grid dd {
  margin: 0;
}

.json-box {
  max-height: 360px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
}

.availability-note {
  display: inline-block;
  max-width: 280px;
  color: var(--brand-dark);
  font-weight: 750;
  line-height: 1.35;
}

.url-cell {
  max-width: 420px;
  overflow-wrap: anywhere;
}

code {
  padding: 6px 8px;
  border-radius: 6px;
  background: #eef2ef;
  color: var(--brand-dark);
}

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

  .sidebar {
    position: static;
    padding: 16px;
  }

  .nav {
    display: flex;
    flex-wrap: wrap;
    margin-top: 16px;
  }

  .cards-grid,
  .split-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .main {
    padding: 18px;
  }

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

  .cards-grid,
  .split-layout,
  .form-grid,
  .search-row {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 96px;
  }

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

  .progress {
    width: 120px;
  }
}
