:root {
  --green-dark:  #0f5132;
  --green-mid:   #1a6b3c;
  --green-light: #2ecc71;
  --green-soft:  #d1f2dd;
  --blue-dark:   #0a2e5c;
  --blue-mid:    #1565C0;
  --blue-light:  #42a5f5;
  --orange:      #e67e22;
  --red:         #dc3545;
  --teal:        #00897B;
  --indigo:      #3949AB;
  --purple:      #7b2cbf;
  --amber:       #f39c12;
  --bg:          #f4f6fa;
  --surface:     #ffffff;
  --border:      #e6ebf2;
  --text:        #1a2332;
  --text-mute:   #6b7a8f;
  --radius:      14px;
  --radius-sm:   10px;
  --radius-lg:   18px;
  --shadow-sm:   0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow:      0 4px 14px rgba(16,24,40,.08);
  --shadow-lg:   0 10px 32px rgba(16,24,40,.12);
  --sidebar-w:   280px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Inter','Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 70px;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1,h2,h3,h4,h5,h6 { color: var(--text); font-weight: 700; letter-spacing: -.01em; }
a { color: var(--green-mid); }
a:hover { color: var(--green-dark); }
code { color: var(--blue-mid); background: #eef4ff; padding: 1px 6px; border-radius: 4px; font-size: .88em; }
.navbar-custom {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--blue-dark) 100%);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  min-height: 58px;
  backdrop-filter: blur(6px);
}
.logo-nav { border-radius: 8px; object-fit: contain; background: #fff; padding: 3px; }
.brand-text { font-weight: 800; font-size: 1.12rem; letter-spacing: .3px; }
.offcanvas-custom {
  width: var(--sidebar-w) !important;
  background: linear-gradient(180deg, #0b3e25 0%, var(--blue-dark) 100%);
}
.offcanvas-header { background: rgba(0,0,0,.25); padding: 1rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-nav .nav-link {
  color: rgba(255,255,255,.80);
  padding: .7rem 1.5rem;
  font-size: .92rem;
  display: flex; align-items: center; gap: .8rem;
  border-left: 3px solid transparent;
  transition: all .15s ease;
  font-weight: 500;
}
.sidebar-nav .nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-nav .nav-link.active {
  color: #fff;
  background: rgba(46,204,113,.15);
  border-left-color: var(--green-light);
  font-weight: 600;
}
.sidebar-nav .nav-link i { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-section {
  color: rgba(255,255,255,.38);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  padding: 1.1rem 1.5rem .3rem;
}
.offcanvas-footer { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.1); }
.main-content { padding: 1rem; max-width: 1280px; margin: 0 auto; }
@media (min-width: 768px) {
  body { padding-bottom: 0; font-size: 14.5px; }
  .main-content { padding: 1.5rem 1.75rem; }
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
  overflow: hidden;
  transition: box-shadow .15s ease;
}
.card:hover { box-shadow: var(--shadow); }
.card-header-green {
  background: linear-gradient(135deg, var(--green-dark), var(--green-mid));
  color: #fff;
  padding: .85rem 1.15rem;
  font-weight: 600;
  font-size: .92rem;
  letter-spacing: .2px;
  display: flex; align-items: center;
}
.card-header-blue {
  background: linear-gradient(135deg, var(--blue-dark), var(--blue-mid));
  color: #fff;
  padding: .85rem 1.15rem;
  font-weight: 600;
  font-size: .92rem;
  display: flex; align-items: center;
}
.card-header-light {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .85rem 1.15rem;
  font-weight: 700;
  color: var(--text);
  font-size: .95rem;
  display: flex; align-items: center;
}
.stat-card {
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  display: flex; align-items: center; gap: .9rem;
  color: #fff;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 100% 0%, rgba(255,255,255,.18) 0%, transparent 60%);
  pointer-events: none;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card .stat-icon { font-size: 2rem; opacity: .85; }
.stat-card .stat-num { font-size: 1.85rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat-card .stat-label { font-size: .72rem; opacity: .92; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; margin-top: 3px; }
.stat-green  { background: linear-gradient(135deg, #0f5132, #2ecc71); }
.stat-blue   { background: linear-gradient(135deg, #0a2e5c, #1565C0); }
.stat-orange { background: linear-gradient(135deg, #a93226, #e67e22); }
.stat-teal   { background: linear-gradient(135deg, #00695C, #00897B); }
.stat-indigo { background: linear-gradient(135deg, #283593, #3949AB); }
.stat-gray   { background: linear-gradient(135deg, #37474F, #607D8B); }
.stat-purple { background: linear-gradient(135deg, #4a148c, #7b2cbf); }
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  height: 128px;
  box-shadow: var(--shadow-sm);
  transition: all .15s ease;
  position: relative;
  overflow: hidden;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-card::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--green-mid);
  border-radius: var(--radius) 0 0 var(--radius);
}
.kpi-card.kpi-blue::after   { background: var(--blue-mid); }
.kpi-card.kpi-orange::after { background: var(--orange); }
.kpi-card.kpi-red::after    { background: var(--red); }
.kpi-card.kpi-purple::after { background: var(--purple); }
.kpi-card.kpi-teal::after   { background: var(--teal); }
.kpi-card.kpi-amber::after  { background: var(--amber); }
.kpi-head {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text-mute);
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  white-space: nowrap;
}
.kpi-head span { overflow: hidden; text-overflow: ellipsis; }
.kpi-head i { font-size: 1rem; color: var(--green-mid); flex-shrink: 0; }
.kpi-blue   .kpi-head i { color: var(--blue-mid); }
.kpi-orange .kpi-head i { color: var(--orange); }
.kpi-red    .kpi-head i { color: var(--red); }
.kpi-purple .kpi-head i { color: var(--purple); }
.kpi-teal   .kpi-head i { color: var(--teal); }
.kpi-amber  .kpi-head i { color: var(--amber); }
.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-sub {
  font-size: .74rem;
  color: var(--text-mute);
  display: flex;
  align-items: center;
  gap: .3rem;
  margin-top: auto;
  line-height: 1.3;
  flex-wrap: wrap;
}
.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .72rem;
}
.kpi-trend.up   { background: rgba(46,204,113,.13); color: #0f5132; }
.kpi-trend.down { background: rgba(220,53,69,.12); color: #b02a37; }
.kpi-trend.flat { background: #eef0f3; color: #6b7a8f; }
.spark-wrap {
  position: absolute;
  right: 8px; bottom: 8px;
  width: 90px; height: 32px;
  pointer-events: none;
  opacity: .75;
}
.spark-wrap canvas { width: 100% !important; height: 100% !important; }
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-sm);
  height: 100%;
  display: flex; flex-direction: column;
}
.chart-card .chart-title {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem;
  margin-bottom: .2rem;
}
.chart-card .chart-title h6 {
  margin: 0;
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
}
.chart-card .chart-title .chart-sub {
  font-size: .78rem;
  color: var(--text-mute);
}
.chart-card .chart-body { flex: 1; min-height: 0; position: relative; padding-top: .5rem; }
.chart-card .chart-body > canvas { max-height: 100%; }
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.filter-bar .filter-label {
  font-size: .72rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-mute);
  display: flex; align-items: center; gap: .35rem;
  margin-right: .4rem;
}
.filter-bar .form-select-sm,
.filter-bar .form-control-sm {
  padding: .3rem .7rem;
  font-size: .85rem;
  border-radius: 8px;
  min-height: 34px;
}
.segmented {
  display: inline-flex;
  background: #eef1f5;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  border: none;
  background: transparent;
  padding: .35rem .85rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-mute);
  border-radius: 7px;
  cursor: pointer;
  transition: all .15s;
}
.segmented button:hover { color: var(--text); }
.segmented button.active {
  background: var(--surface);
  color: var(--green-dark);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-header h1,
.page-header h5 { margin: 0; font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; }
.page-header .page-sub { color: var(--text-mute); font-size: .85rem; margin-top: .15rem; }
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: .88rem; transition: all .15s; }
.btn-sm { border-radius: 8px; padding: .35rem .75rem; font-size: .8rem; }
.btn-green { background: var(--green-mid); color: #fff; border: none; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.btn-green:hover { background: var(--green-dark); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-lg { padding: .8rem 1.5rem; font-size: 1rem; }
.btn-action { min-width: 44px; min-height: 44px; }
.btn-outline-secondary:hover { background: #f1f3f5; color: var(--text); }
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  padding: .6rem .95rem;
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
  background: var(--surface);
}
.form-control:focus, .form-select:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(26,107,60,.12);
}
label.form-label { font-weight: 600; font-size: .86rem; color: #3a4a5f; margin-bottom: .3rem; }
.photo-upload-area {
  border: 2.5px dashed #bac3cf;
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  background: #fafbfc;
}
.photo-upload-area:hover,
.photo-upload-area.drag-over {
  border-color: var(--green-mid);
  background: #f0fdf4;
}
.photo-upload-area i { font-size: 2.5rem; color: var(--green-mid); }
.photo-upload-area p { margin: .5rem 0 0; color: var(--text-mute); font-size: .9rem; }
.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: .5rem;
  margin-top: .75rem;
}
.photo-preview-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  background: #e2e8f0;
}
.photo-preview-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-preview-item .remove-photo {
  position: absolute; top: 4px; right: 4px;
  background: rgba(220,53,69,.9);
  color: #fff; border: none;
  border-radius: 50%;
  width: 24px; height: 24px;
  font-size: .75rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.table-custom { font-size: .9rem; }
.table-custom thead th {
  background: #f7f9fc;
  color: #3a4a5f;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: none;
  padding: .75rem 1rem;
  white-space: nowrap;
  font-weight: 700;
  border-bottom: 2px solid var(--border);
}
.table-custom tbody tr { transition: background .12s; border-bottom: 1px solid #f1f3f5; }
.table-custom tbody tr:hover { background: #f0fdf4; }
.table-custom tbody tr:last-child { border-bottom: none; }
.table-custom td { vertical-align: middle; padding: .7rem 1rem; border: none; }
.protocolo-badge {
  font-family: 'JetBrains Mono','Courier New', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--green-dark);
  background: var(--green-soft);
  padding: .25rem .7rem;
  border-radius: 8px;
  border: 1px solid #a5d6b7;
  letter-spacing: .5px;
}
.progress-cell {
  position: relative;
  background: #eef1f5;
  border-radius: 6px;
  height: 22px;
  overflow: hidden;
  min-width: 120px;
}
.progress-cell .progress-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--green-mid), var(--green-light));
  border-radius: 6px;
  transition: width .4s ease;
}
.progress-cell .progress-label {
  position: relative;
  z-index: 1;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text);
  padding: 0 .6rem;
  line-height: 22px;
  display: flex; justify-content: space-between; align-items: center;
}
.progress-cell.warn .progress-fill { background: linear-gradient(90deg, #e67e22, #f39c12); }
.progress-cell.danger .progress-fill { background: linear-gradient(90deg, #b02a37, #dc3545); }
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 62px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  box-shadow: 0 -2px 12px rgba(16,24,40,.08);
  z-index: 1000;
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px;
  color: var(--text-mute);
  text-decoration: none;
  font-size: .65rem;
  font-weight: 600;
  padding: .3rem .5rem;
  border-radius: 10px;
  transition: color .2s;
  min-width: 56px;
}
.bottom-nav-item i { font-size: 1.25rem; }
.bottom-nav-item:hover,
.bottom-nav-item.active { color: var(--green-dark); }
.btn-fab-wrap { position: relative; top: -14px; }
.btn-fab {
  width: 54px; height: 54px;
  background: linear-gradient(135deg, var(--green-dark), var(--green-mid));
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 18px rgba(26,107,60,.45);
}
.login-container {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(46,204,113,.25), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(21,101,192,.3), transparent 50%),
    linear-gradient(135deg, var(--green-dark) 0%, var(--blue-dark) 100%);
  padding: 1rem;
}
.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 70px rgba(0,0,0,.35);
}
.login-logo { max-height: 90px; max-width: 200px; object-fit: contain; }
.badge { font-weight: 600; padding: .35em .7em; border-radius: 6px; font-size: .74rem; letter-spacing: .2px; }
.bg-orange { background-color: var(--orange) !important; }
.bg-teal   { background-color: var(--teal) !important; }
.bg-indigo { background-color: var(--indigo) !important; }
.alert { border-radius: var(--radius-sm); border: 1px solid transparent; padding: .85rem 1rem; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.img-thumb {
  width: 80px; height: 80px;
  object-fit: cover;
  border-radius: 10px;
  cursor: pointer;
  border: 2px solid var(--border);
  transition: border-color .2s, transform .15s;
}
.img-thumb:hover { border-color: var(--green-mid); transform: scale(1.03); }
@media print {
  .navbar-custom, .bottom-nav, .offcanvas, .btn, .filter-bar { display: none !important; }
  body { background: #fff; padding: 0; }
  .main-content { max-width: 100%; padding: 0; }
  .card, .kpi-card, .chart-card { box-shadow: none; border-color: #ccc; }
}
.fw-extrabold { font-weight: 800; }
.text-mute { color: var(--text-mute) !important; }
.divider-v { width: 1px; height: 22px; background: var(--border); }
.bg-soft-green { background: #f0fdf4; }
.bg-soft-blue  { background: #eff6ff; }
.bg-soft-amber { background: #fffbeb; }
.bg-soft-red   { background: #fef2f2; }
.hover-row:hover { background: #f0fdf4; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.kpi-card, .chart-card, .card { animation: fadeInUp .25s ease both; }
