:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d9dee7;
  --line-strong: #b9c2d0;
  --brand: #0f766e;
  --accent: #2563eb;
  --green: #15803d;
  --red: #c2410c;
  --gold: #b7791f;
  --surface-soft: #eef7f5;
  --shadow: 0 16px 32px rgba(31, 41, 51, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef2f6 0, var(--bg) 260px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 16px;
  color: #e6edf3;
  background: #18212f;
  border-right: 1px solid #111827;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #2563eb);
  border-radius: 6px;
  font-weight: 800;
}

.brand span {
  display: block;
  color: #aab6c5;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 6px;
  padding: 18px 0;
}

.nav-item {
  min-height: 38px;
  padding: 9px 12px;
  color: #b7c2d1;
  border: 1px solid transparent;
  border-radius: 6px;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  font-weight: 800;
  box-shadow: inset 3px 0 0 #2dd4bf;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 82px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 12px;
  font-size: 20px;
}

h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.view {
  padding: 22px 28px 36px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

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

.panel {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  border-top: 3px solid var(--brand);
}

.panel.tight {
  padding: 12px;
}

.panel-title,
.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-gap {
  margin-top: 18px;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.small-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 800;
}

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

.ghost-btn,
.small-btn {
  color: var(--ink);
  background: #f8fafc;
  border-color: var(--line-strong);
}

.ghost-btn:hover,
.small-btn:hover {
  background: #eef2f7;
}

.danger-btn {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.small-btn {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 13px;
}

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

.field {
  display: grid;
  gap: 5px;
}

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
}

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

.table-wrap {
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

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

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

th {
  color: var(--muted);
  background: #f7f9fc;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.money {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.status,
.tag,
.priority {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status {
  color: var(--brand);
  background: var(--surface-soft);
}

.status.done {
  color: var(--green);
  background: #e8f4ec;
}

.status.warn {
  color: var(--gold);
  background: #fbf0d9;
}

.status.danger {
  color: var(--red);
  background: #f8e6e2;
}

.tag {
  color: #344054;
  background: #eef2f7;
}

.priority.Alta,
.priority.Urgente {
  color: var(--red);
  background: #f8e6e2;
}

.priority.Media {
  color: var(--gold);
  background: #fbf0d9;
}

.priority.Baja {
  color: var(--green);
  background: #e8f4ec;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.kanban-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 16px;
  align-items: start;
}

.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(235px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-column {
  min-height: 520px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.kanban-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.op-card {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: 0 8px 18px rgba(31, 41, 51, 0.06);
}

.op-card:hover,
.op-card.selected {
  border-color: var(--brand);
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.12);
}

.op-card.delayed {
  border-left-color: var(--red);
}

.op-code {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
}

.op-meta {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 13px;
}

.stage-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.stage-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 11px;
  font-weight: 800;
}

.stage-pill.ready {
  color: #1d4ed8;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.stage-pill.active {
  color: var(--gold);
  background: #fff7ed;
  border-color: #fed7aa;
}

.stage-pill.done {
  color: var(--green);
  background: #ecfdf3;
  border-color: #bbf7d0;
}

.stage-pill.blocked {
  color: #7b8794;
  background: #f1f5f9;
  border-color: #d8dee8;
}

.detail-panel {
  position: sticky;
  top: 104px;
}

.stage-board {
  display: grid;
  gap: 12px;
}

.stage-card {
  padding: 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stage-card.ready {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.stage-card.active {
  border-color: #fed7aa;
  background: #fffaf3;
}

.stage-card.done {
  border-color: #bbf7d0;
  background: #f6fef9;
}

.stage-card.blocked {
  background: #f8fafc;
}

.stage-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.stage-card-head div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-dot {
  width: 9px;
  height: 9px;
  background: var(--line-strong);
  border-radius: 999px;
}

.stage-card.ready .stage-dot {
  background: #1d4ed8;
}

.stage-card.active .stage-dot {
  background: var(--gold);
}

.stage-card.done .stage-dot {
  background: var(--green);
}

.stage-state {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stage-facts {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stage-facts li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.stage-facts strong {
  color: var(--ink);
  text-align: right;
}

.stage-note {
  margin-bottom: 0;
}

.timeline {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  padding: 9px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

.flash {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 6px;
  font-weight: 800;
}

.flash.success {
  color: var(--green);
  background: #e8f4ec;
}

.flash.error {
  color: var(--red);
  background: #f8e6e2;
}

.payment-order {
  max-width: 980px;
  margin: 18px auto 0;
  padding: 26px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.payment-order-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--ink);
}

.payment-order-info,
.payment-summary,
.signature-grid {
  display: grid;
  gap: 12px;
}

.payment-order-info {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 18px;
}

.payment-order-info div,
.payment-summary div {
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.payment-order-info span,
.payment-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.payment-summary .net {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.signature-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 64px;
}

.signature-grid span {
  display: block;
  height: 1px;
  margin-bottom: 8px;
  background: var(--ink);
}

.empty {
  display: grid;
  min-height: 100px;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  background: #fff;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

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

  .kanban-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .view {
    padding: 18px;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .flash,
  .print-toolbar {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .view {
    padding: 0;
  }

  .payment-order {
    margin: 0;
    max-width: none;
    border: 0;
    box-shadow: none;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
  }
}
