:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-soft: #f8f9ff;
  --navy: #0e1b33;
  --navy-2: #213145;
  --text: #0b1c30;
  --muted: #64748b;
  --line: #dbe4f0;
  --line-strong: #c5d2e4;
  --magenta: #dd1386;
  --magenta-soft: #fff0f9;
  --teal: #006b6b;
  --teal-soft: #e9fbfb;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --shadow: 0 20px 45px rgba(14, 27, 51, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(0, 1fr);
  background:
    linear-gradient(90deg, #f8f9ff 0%, #f8f9ff 38%, rgba(14,27,51,.96) 38%, rgba(14,27,51,.96) 100%);
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-card {
  width: min(100%, 440px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
  color: var(--text);
  font-size: 32px;
  line-height: 1.08;
  letter-spacing: 0;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.input {
  width: 100%;
  min-height: 44px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.input:focus {
  border-color: var(--magenta);
  box-shadow: 0 0 0 3px rgba(221,19,134,.12);
}

.login-note {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 4px;
}

.error-text {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}

.login-hero {
  min-width: 0;
  display: grid;
  place-items: center;
  padding: 48px;
  background:
    linear-gradient(135deg, rgba(14,27,51,.9), rgba(33,49,69,.86)),
    radial-gradient(circle at 78% 18%, rgba(221,19,134,.24), transparent 24rem);
}

.login-message {
  width: min(760px, 100%);
}

.login-message h2 {
  margin: 0;
  font-size: 44px;
  line-height: 1.04;
  letter-spacing: 0;
}

.login-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.login-kpis .metric {
  border-color: rgba(255,255,255,.16);
  background: rgba(255,255,255,.08);
  box-shadow: none;
}

.login-kpis .metric small,
.login-kpis .metric strong {
  color: #fff;
}

.login-kpis .metric span {
  color: #9ff1f0;
}

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

.sidebar-backdrop {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 18px;
  color: #eaf1ff;
  background: var(--navy);
}

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

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--magenta);
  font-weight: 900;
}

.brand strong { display: block; line-height: 1.1; }
.brand small { display: block; margin-top: 3px; color: #9fb0ce; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }

.nav {
  display: grid;
  gap: 5px;
  overflow-y: auto;
  padding-right: 4px;
}

.nav button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #bac6e6;
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.nav button:hover,
.nav button.active {
  color: #fff;
  background: rgba(221, 19, 134, .14);
  border-color: rgba(221, 19, 134, .32);
}

.nav i {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: rgba(255,255,255,.08);
  font-style: normal;
  font-size: 11px;
}

.side-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  background: rgba(255,255,255,.06);
}

.main { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 249, 255, .88);
  backdrop-filter: blur(16px);
}

.topbar-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title strong {
  display: block;
}

.menu-toggle {
  display: none;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  gap: 4px;
  padding: 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: var(--navy);
}

.search {
  width: min(430px, 42vw);
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  outline: none;
}

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

.content {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 32px 44px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--magenta);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.page-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.page-title h1,
.hero h1 {
  margin: 0;
  color: var(--text);
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}

.page-title p,
.hero p,
.muted {
  color: var(--muted);
  line-height: 1.5;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr);
  gap: 18px;
  margin-bottom: 18px;
}

.hero-panel {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.94), rgba(255,240,249,.72)),
    var(--surface);
  box-shadow: var(--shadow);
}

.hero-panel.dark {
  color: #fff;
  background:
    linear-gradient(135deg, rgba(14,27,51,.98), rgba(33,49,69,.94));
}

.hero-panel.dark h1,
.hero-panel.dark h2,
.hero-panel.dark strong { color: #fff; }
.hero-panel.dark p { color: #cbd6ea; }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.dashboard-grid { grid-template-columns: minmax(0, 1.35fr) 380px; }

.card,
.metric,
.table-wrap {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(14, 27, 51, .04);
}

.card { padding: 22px; }
.card.ai { border-color: rgba(221, 19, 134, .32); background: var(--magenta-soft); }
.card.fiscal { border-color: rgba(0, 107, 107, .24); background: var(--teal-soft); }
.card h3 { margin: 0 0 10px; font-size: 18px; }

.metric {
  padding: 18px;
}

.metric small,
.label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 27px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric span { display: block; margin-top: 8px; color: var(--green); font-size: 13px; font-weight: 800; }

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  background: var(--navy);
  font-size: 13px;
  font-weight: 900;
}

.btn.ai { background: var(--magenta); }
.btn.fiscal { background: var(--teal); }
.btn.secondary { color: var(--navy); background: #fff; border-color: var(--line-strong); }
.btn.ghost { color: var(--magenta); background: transparent; border-color: transparent; }
.btn:hover { transform: translateY(-1px); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chip.ok { color: var(--green); border-color: rgba(22,163,74,.24); background: #f0fdf4; }
.chip.warn { color: var(--amber); border-color: rgba(217,119,6,.24); background: #fffbeb; }
.chip.risk { color: var(--red); border-color: rgba(220,38,38,.22); background: #fff1f2; }
.chip.ai { color: var(--magenta); border-color: rgba(221,19,134,.25); background: var(--magenta-soft); }
.chip.teal { color: var(--teal); border-color: rgba(0,107,107,.25); background: var(--teal-soft); }

.split {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row,
.activity-item,
.timeline-step {
  display: grid;
  gap: 6px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.activity {
  display: grid;
  gap: 10px;
  max-height: 650px;
  overflow: auto;
}

.activity-item {
  border-left: 4px solid var(--magenta);
}

.activity-item p { margin: 0; font-size: 13px; line-height: 1.45; }
.activity-item span { color: var(--muted); font-size: 11px; }

.agent-card {
  min-height: 246px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  border-top: 3px solid var(--magenta);
}

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

.progress div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--magenta), var(--teal));
  transition: width .35s ease;
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 13px; }
th { color: var(--muted); background: var(--surface-soft); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:nth-child(even) { background: #fbfdff; }

.workflow {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.timeline-step strong { color: var(--text); }
.timeline-step.active { border-color: var(--magenta); background: var(--magenta-soft); }
.timeline-step.done { border-color: rgba(0,107,107,.28); background: var(--teal-soft); }

.sim {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(221,19,134,.28);
  border-radius: 12px;
  background: #fff;
}

.sim ol {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.sim li {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.sim li b {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  color: #fff;
  background: var(--line-strong);
  font-size: 10px;
}

.sim li.active { color: var(--text); border-color: var(--magenta); background: var(--magenta-soft); }
.sim li.done b { background: var(--teal); }
.sim-output { margin-top: 12px; padding: 12px; border: 1px solid rgba(0,107,107,.28); border-radius: 8px; background: var(--teal-soft); }

.scan {
  height: 3px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf6;
}

.scan::after {
  content: "";
  display: block;
  width: 42%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--magenta), transparent);
  animation: scan 1s linear infinite;
}

@keyframes scan { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

.doc-list,
.portal-tabs,
.connector-grid {
  display: grid;
  gap: 10px;
}

.doc-card {
  width: 100%;
  color: var(--text);
  text-align: left;
}

.doc-card.selected {
  border-color: var(--magenta);
  background: var(--magenta-soft);
}

.doc-preview {
  display: grid;
  gap: 12px;
}

.doc-frame {
  width: 100%;
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.architecture {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 14px;
}

.architecture .lane {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.lane h3 { margin: 0 0 12px; }

.node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.portal-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 16px;
}

.portal-tabs button {
  width: 100%;
  justify-content: flex-start;
}

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

.map .card {
  min-height: 150px;
}

@media (max-width: 1180px) {
  .login-shell {
    grid-template-columns: 1fr;
    background: var(--bg);
  }
  .login-hero {
    padding: 24px;
  }
  .login-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .app { grid-template-columns: 1fr; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    border: 0;
    background: rgba(14, 27, 51, .48);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(86vw, 320px);
    max-width: 320px;
    height: 100dvh;
    transform: translateX(-104%);
    box-shadow: 22px 0 48px rgba(14, 27, 51, .22);
    transition: transform .22s ease;
  }
  .app.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .app.sidebar-open .sidebar-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
  .nav { grid-template-columns: 1fr; }
  .dashboard-grid, .hero, .cols-5, .cols-4, .cols-3, .cols-2, .architecture, .portal-shell, .map { grid-template-columns: 1fr; }
  .menu-toggle { display: grid; }
  .search { width: 100%; }
  .top-actions { width: 100%; align-items: stretch; }
  .topbar { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 680px) {
  .login-panel,
  .login-hero {
    padding: 18px;
  }
  .login-message h2 {
    font-size: 30px;
  }
  .login-kpis {
    grid-template-columns: 1fr;
  }
  .content, .topbar { padding: 16px; }
  .page-title { align-items: flex-start; flex-direction: column; }
  .topbar-title {
    width: 100%;
    align-items: flex-start;
  }
  .topbar-title strong {
    font-size: 15px;
    line-height: 1.25;
  }
  .top-actions {
    flex-direction: column;
  }
  .page-title h1,
  .hero h1 {
    font-size: 28px;
  }
  .hero-panel,
  .card {
    padding: 18px;
  }
  .doc-frame {
    min-height: 340px;
  }
  .split {
    align-items: flex-start;
    flex-direction: column;
  }
}
