:root {
  --bg: #f4f1eb;
  --panel: #fffaf2;
  --panel-2: #ffffff;
  --ink: #172033;
  --muted: #6c7280;
  --line: #e6ded1;
  --navy: #0a1b45;
  --orange: #ec4b13;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #d97706;
  --blue: #0284c7;
  --shadow: 0 24px 80px rgba(23, 32, 51, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, rgba(236,75,19,0.10), transparent 34rem), var(--bg);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.loading { padding: 4rem; color: var(--muted); }
.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: rgba(244, 241, 235, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .9rem; }
.logo {
  width: 3.1rem;
  height: 3.1rem;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, var(--navy), #102b6d);
  border-radius: 1rem;
  font-weight: 900;
  letter-spacing: -.05em;
  box-shadow: var(--shadow);
}
.brand h1 { margin: 0; font-size: 1.05rem; }
.brand p { margin: .15rem 0 0; color: var(--muted); font-size: .86rem; }
.top-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.btn, .ghost, .danger {
  border: 0;
  border-radius: .75rem;
  padding: .7rem .95rem;
  font-weight: 750;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}
.btn { background: var(--orange); color: white; box-shadow: 0 10px 28px rgba(236, 75, 19, .23); }
.ghost { background: rgba(255,255,255,.72); color: var(--navy); border: 1px solid var(--line); }
.danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.layout { display: grid; grid-template-columns: 16.5rem 1fr; gap: 1.2rem; padding: 1.2rem; }
.sidebar {
  position: sticky;
  top: 5.5rem;
  align-self: start;
  background: rgba(255, 250, 242, .82);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: .8rem;
  box-shadow: var(--shadow);
}
.nav-btn {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: .8rem .9rem;
  border-radius: .85rem;
  color: var(--muted);
  font-weight: 750;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-btn.active { background: var(--navy); color: white; }
.main { min-width: 0; }
.hero {
  background: linear-gradient(135deg, #fffaf2, #fff);
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  padding: 1.4rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.2rem;
}
.hero h2 { margin: 0; font-size: clamp(1.5rem, 4vw, 2.5rem); letter-spacing: -.04em; }
.hero p { color: var(--muted); max-width: 70rem; }
.meta-line { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.pill {
  display: inline-flex;
  gap: .35rem;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  border-radius: 999px;
  padding: .4rem .65rem;
  font-size: .82rem;
  font-weight: 750;
}
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: rgba(255,255,255,.9);
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  padding: 1rem;
  box-shadow: 0 10px 35px rgba(23,32,51,.06);
}
.card h3 { margin: 0 0 .8rem; color: var(--navy); }
.kpi { display: flex; flex-direction: column; gap: .35rem; }
.kpi span { color: var(--muted); font-size: .84rem; }
.kpi strong { font-size: 1.55rem; color: var(--navy); letter-spacing: -.04em; }
.section-title { display:flex; justify-content:space-between; align-items:center; gap:1rem; margin: 1.2rem 0 .8rem; }
.section-title h2 { margin: 0; color: var(--navy); letter-spacing: -.03em; }
.table-wrap { overflow: auto; border-radius: 1rem; border: 1px solid var(--line); background: white; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .72rem .8rem; border-bottom: 1px solid #eee7dd; vertical-align: top; text-align: left; }
th { background: #f6efe5; color: var(--navy); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
small, .muted { color: var(--muted); }
.progress { height: .55rem; width: 100%; min-width: 7rem; background: #eee7dd; border-radius: 999px; overflow: hidden; }
.progress > span { display:block; height:100%; background: linear-gradient(90deg, var(--orange), #f59e0b); }
.status { font-weight: 800; border-radius: 999px; padding: .2rem .5rem; font-size: .75rem; white-space: nowrap; }
.status.signed, .status.done, .status.issued, .status.closed { background:#dcfce7; color:#166534; }
.status.pending, .status.draft, .status.planned, .status.accepted_to_sign { background:#fef3c7; color:#92400e; }
.status.refused, .status.blocked { background:#fee2e2; color:#991b1b; }
.status.in_progress, .status.open { background:#e0f2fe; color:#075985; }
.form-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:.8rem; }
.form-grid .wide { grid-column: 1 / -1; }
label { display: grid; gap: .32rem; color: var(--muted); font-weight: 700; font-size: .82rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: .7rem;
  padding: .68rem .75rem;
  background: white;
  color: var(--ink);
}
textarea { min-height: 5.5rem; resize: vertical; }
.inline-actions { display:flex; gap:.5rem; flex-wrap: wrap; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display:grid;
  place-items:center;
  background: rgba(10, 27, 69, .42);
  padding: 1rem;
}
.modal {
  width: min(46rem, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel-2);
  border-radius: 1.25rem;
  border: 1px solid var(--line);
  padding: 1.1rem;
  box-shadow: var(--shadow);
}
.modal header { display:flex; justify-content:space-between; align-items:center; margin-bottom: 1rem; }
.modal h2 { margin:0; }
.photos { display:grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1rem; }
.photo { background:white; border:1px solid var(--line); border-radius:1rem; overflow:hidden; }
.photo img { width:100%; aspect-ratio: 4/3; object-fit: cover; display:block; background:#eee; }
.photo div { padding:.75rem; }
.report-card { display:flex; justify-content:space-between; align-items:center; gap:1rem; }
.report-card + .report-card { margin-top:.7rem; }
.timeline-list { display:grid; gap:.55rem; }
.timeline-item { display:grid; grid-template-columns: 12rem 1fr 5rem; gap:.8rem; align-items:center; }
.toast { position: fixed; bottom: 1rem; right: 1rem; background: var(--navy); color: white; padding: .85rem 1rem; border-radius: .8rem; box-shadow: var(--shadow); z-index: 80; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .form-grid { grid-template-columns: 1fr; }
  .timeline-item { grid-template-columns: 1fr; }
}
