:root {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #080909;
  background: #F1F0EC;
  font-synthesis: none;

  --ink: #080909;
  --paper: #F1F0EC;
  --accent: #BC387C;
  --white: #FFFFFF;
  --muted: #706F6B;
  --line: rgba(8, 9, 9, 0.16);
  --line-strong: rgba(8, 9, 9, 0.34);
  --line-dark: rgba(255, 255, 255, 0.17);
  --good: #2A6A46;
  --warn: #8B5D0A;
  --danger: #9C3341;

  --display: "Montserrat", Arial, sans-serif;
  --technical: "Oswald", "Arial Narrow", Arial, sans-serif;
  --ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--ink);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--ui);
  text-rendering: optimizeLegibility;
}

button, input { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* Official supplied logo. The source asset is not redrawn or simplified. */
.brand-mark {
  width: 190px;
  height: 42px;
  flex: 0 0 auto;
  overflow: hidden;
  background-image: url("/assets/inkspira-logo-bicolor-white.png");
  background-repeat: no-repeat;
  background-position: left center;
  background-size: contain;
  color: transparent;
  font-size: 0;
  user-select: none;
}

.boot-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  gap: 34px;
  padding: clamp(34px, 6vw, 88px);
  color: var(--paper);
  background: var(--ink);
  text-align: left;
}

.boot-screen .brand-mark {
  width: clamp(170px, 20vw, 260px);
  height: 58px;
}

.boot-copy {
  max-width: 900px;
  margin: 10px 0 0;
  font-family: var(--display);
  font-size: clamp(34px, 5vw, 78px);
  font-weight: 700;
  line-height: .94;
  letter-spacing: -.05em;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-family: var(--technical);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .15em;
  text-transform: uppercase;
}

/* Sign in — editorial split, not a generic SaaS card. */
.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(390px, .82fr);
  padding: 0;
  background: var(--paper);
  text-align: left;
}

.auth-screen::before {
  content: "GOBIERNO\A ANTES DE\A AUTOMATIZACIÓN.";
  white-space: pre-line;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: flex-end;
  padding: clamp(36px, 6vw, 88px);
  color: var(--paper);
  background-color: var(--ink);
  border-right: 1px solid var(--accent);
  font-family: var(--display);
  font-size: clamp(50px, 7vw, 116px);
  font-weight: 800;
  letter-spacing: -.065em;
  line-height: .82;
}

.auth-card {
  width: min(100%, 520px);
  align-self: center;
  justify-self: center;
  padding: clamp(34px, 5vw, 72px);
  border: 0;
  background: transparent;
  box-shadow: none;
}

.auth-card::before {
  content: "IDENTITY / HUMAN";
  display: block;
  margin-bottom: 28px;
  color: var(--accent);
  font-family: var(--technical);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .15em;
}

.auth-card .brand-mark {
  width: 170px;
  height: 38px;
  margin-bottom: 58px;
  background-image: url("/assets/inkspira-logo-bicolor-white.png");
  background-color: var(--ink);
  background-size: 145px auto;
  background-position: center;
  padding: 24px 16px;
  box-sizing: content-box;
}

.auth-card h1 {
  margin: 0 0 14px;
  font-family: var(--display);
  font-size: clamp(36px, 4.5vw, 58px);
  font-weight: 700;
  letter-spacing: -.045em;
  line-height: .95;
}

.auth-card > p {
  max-width: 430px;
  margin: 0 0 32px;
  color: var(--muted);
  line-height: 1.65;
}

#clerk-sign-in {
  min-height: 24rem;
}

/* Auth fatal states keep the same Inkspira visual language. */
.auth-screen:has(#fatal-message)::before {
  content: "FAIL\A CLOSED.";
  color: var(--paper);
}

/* Control shell */
.control-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  background: var(--paper);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 86px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  margin: 0;
  padding: 18px clamp(22px, 4vw, 54px);
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: rgba(241, 240, 236, .97);
  box-shadow: none;
}

.brand-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 26px;
}

.brand-row .brand-mark {
  width: 142px;
  height: 34px;
  padding: 9px 10px;
  box-sizing: content-box;
  background-color: var(--ink);
  background-size: 126px auto;
  background-position: center;
}

.brand-copy { min-width: 0; }

.brand-copy strong {
  display: block;
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.025em;
}

.brand-copy span {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--technical);
  font-size: 11px;
  letter-spacing: .06em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

#user-button {
  min-width: 2rem;
  min-height: 2rem;
}

.layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 0;
}

.sidebar {
  position: sticky;
  top: 86px;
  align-self: start;
  min-height: calc(100vh - 86px);
  min-height: calc(100dvh - 86px);
  padding: 34px 24px 24px;
  border: 0;
  border-right: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
}

.sidebar nav {
  display: grid;
}

.nav-button {
  position: relative;
  width: 100%;
  padding: 13px 0;
  border: 0;
  border-bottom: 1px solid var(--line-dark);
  border-radius: 0;
  color: rgba(241, 240, 236, .58);
  background: transparent;
  font-family: var(--technical);
  font-size: 13px;
  letter-spacing: .07em;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .16s ease, padding-left .16s ease;
}

.nav-button:hover {
  color: var(--paper);
  background: transparent;
}

.nav-button[aria-current="page"] {
  padding-left: 18px;
  color: var(--paper);
  background: transparent;
}

.nav-button[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 7px;
  height: 7px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--accent);
}

.sidebar-meta {
  margin-top: 46px;
  padding: 18px 0 0;
  border-top: 1px solid var(--line-dark);
  color: rgba(241, 240, 236, .48);
  font-family: var(--technical);
  font-size: 11px;
  line-height: 1.7;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.workspace {
  min-width: 0;
  min-height: calc(100vh - 86px);
  min-height: calc(100dvh - 86px);
  padding: clamp(34px, 5vw, 76px);
  border: 0;
  border-radius: 0;
  background: var(--paper);
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: clamp(34px, 5vw, 64px);
  padding-bottom: 26px;
  border-bottom: 1px solid var(--ink);
}

.page-head h1 {
  margin: 8px 0 0;
  font-family: var(--display);
  font-size: clamp(44px, 7vw, 104px);
  font-weight: 800;
  letter-spacing: -.065em;
  line-height: .84;
}

.page-head p {
  max-width: 660px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.btn {
  padding: 10px 14px;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  font-family: var(--technical);
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
}

.btn:hover {
  color: var(--paper);
  background: var(--ink);
}

.btn:disabled {
  opacity: .45;
  cursor: wait;
}

.grid { display: grid; gap: 0; }

.metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: clamp(30px, 4vw, 56px);
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.metric {
  min-height: 158px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 22px 22px 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.metric + .metric { padding-left: 22px; }
.metric:last-child { border-right: 0; }

.metric-label {
  color: var(--muted);
  font-family: var(--technical);
  font-size: 11px;
  letter-spacing: .075em;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 30px;
  font-family: var(--display);
  font-size: clamp(30px, 4vw, 56px);
  font-weight: 700;
  letter-spacing: -.05em;
  line-height: .92;
  overflow-wrap: anywhere;
}

.metric-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.panel {
  padding: clamp(20px, 3vw, 34px) 0;
  overflow: hidden;
  border: 0;
  border-top: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
}

.panel h2 {
  margin: 0 0 24px;
  font-family: var(--display);
  font-size: clamp(22px, 2.4vw, 34px);
  font-weight: 700;
  letter-spacing: -.035em;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(28px, 4vw, 60px);
}

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

.status-row:first-child,
.list-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.status-title {
  font-weight: 600;
  font-size: 13px;
}

.status-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px 4px;
  border: 1px solid currentColor;
  border-radius: 0;
  font-family: var(--technical);
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.good { color: var(--good); }
.badge.warn { color: var(--warn); }
.badge.danger { color: var(--accent); }
.badge.neutral { color: var(--muted); }

.table-wrap {
  overflow: auto;
  border: 0;
  border-top: 1px solid var(--ink);
  border-radius: 0;
}

table {
  width: 100%;
  min-width: 44rem;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px 14px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-family: var(--technical);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .075em;
  text-transform: uppercase;
}

td {
  font-size: 12px;
  line-height: 1.5;
}

tr:last-child td { border-bottom: 0; }

code {
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.empty,
.error-box {
  padding: 28px 0;
  border: 0;
  border-top: 1px solid var(--ink);
  border-radius: 0;
  color: var(--muted);
  text-align: left;
}

.error-box {
  color: var(--danger);
  border-color: var(--danger);
  background: transparent;
}

.progress {
  height: 4px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 0;
  background: rgba(8, 9, 9, .10);
}

.progress > span {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  border-radius: 0;
  background: var(--accent);
}

.kv {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  gap: 0;
  font-size: 12px;
}

.kv dt,
.kv dd {
  margin: 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.kv dt {
  color: var(--muted);
  font-family: var(--technical);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.kv dd {
  overflow-wrap: anywhere;
}

.mobile-tabs {
  display: none;
  overflow-x: auto;
  gap: 18px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--ink);
  background: var(--ink);
}

.mobile-tabs .nav-button {
  width: auto;
  flex: 0 0 auto;
  border-bottom: 0;
}

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

  .auth-screen::before {
    min-height: 42vh;
    padding: 30px 24px;
    border-right: 0;
    border-bottom: 1px solid var(--accent);
    font-size: clamp(48px, 12vw, 86px);
  }

  .auth-card {
    width: min(100%, 620px);
    padding: 42px 24px 64px;
  }

  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-tabs { display: flex; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line); }

  .topbar {
    position: relative;
  }
}

@media (max-width: 620px) {
  .boot-screen {
    grid-template-columns: 1fr;
    align-content: end;
    padding: 28px 20px max(32px, env(safe-area-inset-bottom));
  }

  .boot-screen .brand-mark {
    width: 170px;
    height: 40px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 14px 16px;
  }

  .brand-row { gap: 12px; }

  .brand-row .brand-mark {
    width: 96px;
    height: 24px;
    padding: 7px 8px;
    background-size: 88px auto;
  }

  .brand-copy strong { font-size: 13px; }
  .brand-copy span { max-width: 9rem; font-size: 9px; }

  .btn {
    padding: 9px 10px;
    font-size: 10px;
  }

  .workspace {
    padding: 32px 18px 50px;
    min-height: auto;
  }

  .page-head {
    align-items: start;
    flex-direction: column;
    margin-bottom: 34px;
  }

  .page-head h1 { font-size: clamp(44px, 17vw, 72px); }

  .metrics,
  .two-col {
    grid-template-columns: 1fr;
  }

  .metric,
  .metric + .metric {
    min-height: 128px;
    padding: 18px 0;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .metric:first-child { border-top: 0; }

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

  .kv dt {
    padding-bottom: 4px;
    border-top: 1px solid var(--line);
  }

  .kv dd {
    padding-top: 0;
    border-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
