:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #d7dde6;
  --line-strong: #aab4c3;
  --text: #182230;
  --muted: #667085;
  --blue: #1769aa;
  --blue-dark: #0b4778;
  --green: #13795b;
  --amber: #a15c07;
  --red: #b42318;
  --cyan: #0e7490;
  --purple: #6d3f91;
  --focus: #2e90fa;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
}

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

button {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
  padding: 0 12px;
}

button:hover {
  border-color: var(--blue);
  color: var(--blue-dark);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(46, 144, 250, 0.25);
  border-color: var(--focus);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  color: #98a2b3;
  background: #f8fafc;
  border-color: #e4e7ec;
}

button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

button.primary:hover {
  background: var(--blue-dark);
  color: #fff;
}

button.danger {
  color: var(--red);
  border-color: #f3b7b2;
}

button.ghost {
  border-color: transparent;
  background: transparent;
}

button.icon {
  width: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

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

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  height: 42px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #0b4778 0 52%, transparent 52%),
    linear-gradient(135deg, transparent 0 48%, #13795b 48% 100%),
    #e8f2f8;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 15px;
  margin: 0;
  line-height: 1.2;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.role-box {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.role-meta {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.role-meta strong {
  color: var(--text);
}

.nav {
  padding: 10px;
  display: grid;
  gap: 4px;
}

.nav button {
  border-color: transparent;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 9px;
}

.nav button.active {
  background: #e8f2f8;
  border-color: #b9d7ed;
  color: var(--blue-dark);
  font-weight: 700;
}

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

.nav button.active .nav-dot {
  background: var(--blue);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

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

.topbar h2 {
  margin: 0;
  font-size: 18px;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.content {
  padding: 22px 24px 36px;
  display: grid;
  gap: 18px;
}

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

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 92px;
}

.metric strong {
  display: block;
  font-size: 27px;
  line-height: 1;
}

.metric span {
  display: block;
  color: var(--muted);
  margin-top: 7px;
  font-size: 12px;
  font-weight: 650;
}

.band {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.band-header {
  min-height: 54px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.band-header h3 {
  margin: 0;
  font-size: 15px;
}

.band-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.band-body {
  padding: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 0.65fr);
  gap: 16px;
}

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

.field-span-2 {
  grid-column: span 2;
}

.field-span-3 {
  grid-column: span 3;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  background: #f8fafc;
}

tr.selectable {
  cursor: pointer;
}

tr.selectable:hover {
  background: #f8fbff;
}

tr.selected {
  background: #e8f2f8;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: currentColor;
}

.status.borrador,
.status.enviado,
.status.firmas,
.status.supervisor,
.status.revision,
.status.aprobacion {
  color: var(--blue);
  border-color: #b9d7ed;
  background: #eef7ff;
}

.status.observado,
.status.vencido,
.status.cierre {
  color: var(--amber);
  border-color: #fedf89;
  background: #fffbeb;
}

.status.aprobado,
.status.activo,
.status.cerrado {
  color: var(--green);
  border-color: #a6e4c8;
  background: #ecfdf3;
}

.status.cancelado,
.status.rechazado {
  color: var(--red);
  border-color: #fecdca;
  background: #fff1f0;
}

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

.permit-list {
  max-height: calc(100vh - 178px);
  overflow: auto;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.filter-row button {
  min-height: 32px;
  padding: 0 10px;
  border-color: var(--line);
  color: var(--muted);
  background: #fff;
}

.filter-row button.active {
  border-color: #84caff;
  color: var(--blue-dark);
  background: #eef7ff;
  font-weight: 750;
}

.filter-row span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 4px;
  border-radius: 999px;
  background: #eef2f6;
  color: #475467;
  font-size: 11px;
  font-weight: 800;
}

.filter-row button.active span {
  background: #d1e9ff;
  color: var(--blue-dark);
}

.table-empty {
  margin: 14px;
}

.flow-guide {
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 0.4fr);
  gap: 12px;
  background: #f8fafc;
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(112px, 1fr));
  gap: 8px;
  overflow-x: auto;
}

.flow-step {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  column-gap: 8px;
  align-content: start;
  background: #fff;
  color: var(--muted);
}

.flow-step span {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  background: #eef2f6;
  color: #475467;
}

.flow-step strong,
.flow-step small {
  min-width: 0;
}

.flow-step strong {
  color: var(--ink);
  font-size: 12px;
}

.flow-step small {
  grid-column: 2;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.25;
}

.flow-step.done span {
  background: #dcfae6;
  color: var(--green);
}

.flow-step.done {
  border-color: #a6e4c8;
}

.flow-step.active {
  border-color: #84caff;
  box-shadow: 0 0 0 2px rgba(23, 105, 170, 0.08);
}

.flow-step.active span {
  background: #d1e9ff;
  color: var(--blue-dark);
}

.flow-step.stopped {
  border-color: #fecdca;
  background: #fff1f0;
}

.flow-step.stopped span {
  background: #fee4e2;
  color: var(--red);
}

.next-action {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  display: grid;
  gap: 6px;
  align-content: start;
}

.next-action strong {
  font-size: 12px;
  color: var(--blue-dark);
}

.next-action p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.next-action button {
  justify-self: start;
  min-height: 32px;
  padding: 0 10px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  overflow-x: auto;
}

.tabs button {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  min-height: 44px;
  white-space: nowrap;
}

.tabs button.active {
  color: var(--blue-dark);
  border-bottom-color: var(--blue);
  font-weight: 750;
}

.section-title {
  margin: 0 0 10px;
  font-size: 14px;
}

.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.checklist {
  display: grid;
  gap: 10px;
}

.check-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 12px;
  align-items: start;
}

.check-row strong {
  font-size: 13px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-right: 1px solid var(--line-strong);
  border-radius: 0;
  min-height: 32px;
  padding: 0 10px;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--blue);
  color: #fff;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}

.check-chip {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.check-chip input {
  width: 16px;
  min-height: 16px;
  padding: 0;
  margin-top: 1px;
}

.worker-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 110px minmax(110px, 1fr) auto;
  gap: 8px;
  align-items: end;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.signature-thumb {
  width: 96px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  object-fit: contain;
}

.timeline {
  display: grid;
  gap: 10px;
}

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

.event-dot {
  width: 10px;
  height: 10px;
  background: var(--blue);
  border-radius: 99px;
  margin-top: 4px;
}

.event strong {
  display: block;
  font-size: 13px;
}

.event span {
  color: var(--muted);
  font-size: 12px;
}

.alert-list {
  display: grid;
  gap: 8px;
}

.alert {
  border-left: 4px solid var(--amber);
  background: #fffbeb;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
}

.alert.red {
  border-left-color: var(--red);
  background: #fff1f0;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 10;
}

.modal {
  width: min(720px, 100%);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.25);
  border: 1px solid var(--line);
}

.modal-header,
.modal-footer {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.modal-footer {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.modal h3 {
  margin: 0;
  font-size: 16px;
}

.signature-pad {
  width: 100%;
  height: 230px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}

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

.muted {
  color: var(--muted);
  font-size: 12px;
}

.role-notice {
  border: 1px solid #b9d7ed;
  border-left: 4px solid var(--blue);
  background: #eef7ff;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--blue-dark);
  font-size: 13px;
  margin-bottom: 12px;
}

.terminal-strip {
  height: 82px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(23, 105, 170, 0.08) 0 40%, transparent 40%),
    repeating-linear-gradient(90deg, #e2e8f0 0 2px, transparent 2px 34px),
    linear-gradient(180deg, #fff, #f8fafc);
  position: relative;
  overflow: hidden;
}

.terminal-strip::before {
  content: "SVTI";
  position: absolute;
  left: 18px;
  top: 20px;
  font-weight: 800;
  color: var(--blue-dark);
}

.terminal-strip::after {
  content: "";
  position: absolute;
  right: 22px;
  top: 18px;
  width: 150px;
  height: 42px;
  border-radius: 5px;
  background:
    repeating-linear-gradient(90deg, #13795b 0 14px, #eaf7f2 14px 20px);
  border: 1px solid #b7decf;
}

.hidden {
  display: none !important;
}

.home-shell {
  min-height: 100vh;
  padding: 28px;
  display: grid;
  gap: 22px;
  align-content: start;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

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

.home-brand h1,
.home-copy h2 {
  margin: 0;
}

.home-brand p,
.home-copy p {
  margin: 6px 0 0;
  color: var(--muted);
}

.home-copy h2 {
  font-size: 22px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}

.profile-card {
  min-height: 168px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
  align-content: start;
  text-align: left;
  padding: 16px;
}

.profile-card:hover {
  transform: translateY(-1px);
  border-color: var(--blue);
}

.profile-card strong {
  font-size: 17px;
  color: var(--text);
}

.profile-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.profile-card em {
  margin-top: 8px;
  font-style: normal;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 750;
}

.profile-kicker {
  color: var(--green) !important;
  font-size: 11px !important;
  font-weight: 800;
  text-transform: uppercase;
}

.home-note {
  background: #eef7ff;
  border: 1px solid #b9d7ed;
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--blue-dark);
  font-size: 13px;
}

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

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

  .nav {
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    overflow-x: auto;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .home-hero,
  .home-grid {
    grid-template-columns: 1fr;
  }

  .grid-2,
  .permit-layout {
    grid-template-columns: 1fr;
  }

  .permit-layout > .band:not(.permit-list) {
    order: -1;
  }

  .flow-guide {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .content {
    padding: 14px;
  }

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

  .field-span-2,
  .field-span-3 {
    grid-column: auto;
  }

  .check-row,
  .worker-row {
    grid-template-columns: 1fr;
  }

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

  .home-shell {
    padding: 14px;
  }

  .home-hero {
    padding: 16px;
  }

  .flow-guide {
    padding: 10px;
  }

  .flow-steps {
    grid-template-columns: repeat(5, 136px);
  }
}
