:root {
  --ink: #172033;
  --muted: #5c6573;
  --paper: #f3f0e8;
  --card: #fffcf7;
  --line: #e2dbd0;
  --teal: #0c6e78;
  --teal-soft: #e5f3f4;
  --navy: #1b3a4b;
  --red: #a33b3b;
  --red-soft: #f8e8e6;
  --amber: #8a5a12;
  --amber-soft: #f8efd8;
  --green: #1d6b45;
  --green-soft: #e5f4ec;
  --shadow: 0 10px 30px rgba(23, 32, 51, 0.06);
  --sans: "Segoe UI", "Helvetica Neue", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}

button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }

.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.side {
  background: var(--navy);
  color: #f4f7f8;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.brand { padding: 0 8px 18px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand small { display: block; letter-spacing: .14em; text-transform: uppercase; font-size: 11px; opacity: .7; }
.brand strong { display: block; font-family: var(--serif); font-size: 26px; font-weight: 600; margin-top: 4px; }
.brand span { display: block; margin-top: 6px; font-size: 12px; line-height: 1.4; opacity: .8; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
.nav button {
  text-align: left;
  background: transparent;
  color: #e7eef0;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}
.nav button.active, .nav button:hover { background: rgba(255,255,255,.1); }

.main { padding: 22px 28px 64px; min-width: 0; }
.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.top h1 { font-family: var(--serif); font-weight: 600; font-size: 32px; margin: 0; }
.top p { margin: 6px 0 0; color: var(--muted); max-width: 640px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

.btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
}
.btn.primary { background: var(--teal); color: white; border-color: var(--teal); }
.btn.danger { background: var(--red-soft); color: var(--red); border-color: transparent; }
.btn.ghost { background: transparent; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.filters input, .filters select, .field input, .field select, .field textarea {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}
.filters input { min-width: 220px; }

.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.card h2, .card h3 { margin: 0 0 8px; font-size: 16px; }
.card .k { font-family: var(--serif); font-size: 34px; line-height: 1; margin: 8px 0; }
.card .sub { color: var(--muted); font-size: 13px; line-height: 1.45; }
.tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 99px;
  background: var(--teal-soft);
  color: var(--teal);
  margin-bottom: 8px;
}
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.ink { background: #eceae4; color: var(--ink); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr.paraguay { background: #f8e8e6; }
.bar {
  height: 8px;
  background: #ece7df;
  border-radius: 99px;
  overflow: hidden;
  min-width: 80px;
}
.bar span { display: block; height: 100%; background: var(--teal); }
.bar.red span { background: var(--red); }

.list { margin: 0; padding-left: 18px; }
.list li { margin: 6px 0; line-height: 1.4; }
.note {
  background: #f7f4ee;
  border-left: 3px solid var(--teal);
  padding: 10px 12px;
  font-size: 13px;
  color: #3d4654;
  line-height: 1.45;
}
.split { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.row-actions { display: flex; gap: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.modal-back {
  position: fixed; inset: 0;
  background: rgba(23, 32, 51, .45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 20;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--card);
  width: min(860px, 100%);
  border-radius: 16px;
  padding: 18px;
  max-height: calc(100vh - 80px);
  overflow: auto;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.field.full { grid-column: 1 / -1; }
.field textarea { min-height: 70px; resize: vertical; }

.toast {
  position: fixed; bottom: 16px; right: 16px;
  background: var(--navy); color: white;
  padding: 10px 14px; border-radius: 10px;
  display: none; z-index: 30;
}
.toast.show { display: block; }

.empty { padding: 18px; color: var(--muted); }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .side { position: relative; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .span-3, .span-4, .span-6, .span-8 { grid-column: span 12; }
  .top { flex-direction: column; align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
}
