/* ==========================================================================
   Nutritec · Identidad tomada del logotipo
   Verde bosque #0F4722 · Verde profundo #0A361B · Amarillo #FCE704 · Verde hoja #8CC63F
   ========================================================================== */
:root {
  --brand: #0F4722;
  --brand-700: #0A361B;
  --brand-600: #13572A;
  --brand-500: #1C6B36;
  --brand-100: #E4EFE6;
  --brand-50: #F2F7F3;
  --leaf: #8CC63F;
  --leaf-100: #EEF6E2;
  --sun: #FCE704;
  --sun-600: #D9C400;
  --sun-100: #FFF9C7;

  --ink: #14211A;
  --ink-2: #44534A;
  --muted: #6F7D74;
  --line: #E3E8E4;
  --surface: #FFFFFF;
  --bg: #F5F7F4;

  --success: #2E8B4A;
  --warning: #C98A00;
  --danger: #C8372D;
  --info: #1F6FA8;
  --orange: #D96A12;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 71, 34, .06), 0 1px 1px rgba(15, 71, 34, .04);
  --shadow: 0 6px 24px -12px rgba(10, 54, 27, .25);
  --sidebar-w: 256px;

  --bs-primary: var(--brand);
  --bs-primary-rgb: 15, 71, 34;
  --bs-body-font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--bg);
  --bs-border-color: var(--line);
  --bs-link-color: var(--brand-500);
  --bs-link-hover-color: var(--brand);
  --bs-border-radius: var(--radius-sm);
}

* { -webkit-tap-highlight-color: transparent; }
body { background: var(--bg); color: var(--ink); font-size: .9rem; }
a { text-decoration: none; }
.icon { width: 18px; height: 18px; stroke-width: 2; vertical-align: -3px; flex-shrink: 0; }
.tabular, td.num, .num { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--brand-700); color: #CFE0D3;
  position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 1040;
  transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
.sidebar-brand { padding: 18px 18px 14px; background: #fff; border-bottom: 3px solid var(--sun); }
.brand-logo { width: 100%; max-width: 190px; display: block; }
.brand-sub { display: block; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--brand); font-weight: 700; margin-top: 4px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 12px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.nav-group { font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(207, 224, 211, .55); padding: 14px 10px 6px; font-weight: 700; }
.sidebar .nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: #D6E5D9;
  font-weight: 500; transition: background .15s, color .15s;
}
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar .nav-link.active { background: var(--sun); color: var(--brand-700); font-weight: 700; }
.sidebar .nav-link.active .icon { color: var(--brand-700); }
.sidebar-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; font-size: .72rem; color: rgba(214, 229, 217, .7); border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1030; height: 64px; display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-weight: 700; font-size: 1.02rem; color: var(--brand-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.btn-icon { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; display: inline-grid; place-items: center; color: var(--ink-2); }
.btn-icon:hover { background: var(--brand-50); color: var(--brand); }
.dot-count { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .65rem; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; }
.user-chip { display: flex; align-items: center; gap: 10px; background: transparent; border: 0; padding: 4px 6px; border-radius: 10px; color: var(--ink); }
.user-chip:hover { background: var(--brand-50); }
.user-chip small { color: var(--muted); font-size: .72rem; }
.avatar { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: var(--sun); display: grid; place-items: center; font-weight: 800; font-size: .8rem; }
.content { padding: 24px; flex: 1; }

.dropdown-panel { width: min(380px, calc(100vw - 24px)); padding: 0; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel-body { max-height: 420px; overflow-y: auto; }
.alert-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--ink); }
.alert-item:hover { background: var(--brand-50); }
.alert-item .ai-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.alert-item.unread { background: #FFFDE8; }
.ai-warning { background: var(--sun-100); color: #8A6D00; }
.ai-danger { background: #FBE5E3; color: var(--danger); }
.ai-info { background: var(--brand-100); color: var(--brand); }
.alert-item small { color: var(--muted); display: block; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(10, 30, 18, .45); z-index: 1035; display: none; }
  .sidebar.open + .sidebar-backdrop { display: block; }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 1.35rem; font-weight: 800; color: var(--brand-700); margin: 0; letter-spacing: -.01em; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.page-actions .form-control { width: auto; }
@media (max-width: 575.98px) {
  .page-actions { width: 100%; }
  .page-actions > .btn, .page-actions > .form-control, .page-actions > form, .page-actions > .dropdown { flex: 1 1 auto; }
  .toolbar > * { flex: 1 1 100% !important; max-width: none !important; min-width: 0 !important; width: 100% !important; }
}

/* ---------- Buttons ---------- */
.btn { font-weight: 600; border-radius: 9px; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.btn:active { transform: scale(.98); }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600); --bs-btn-active-bg: var(--brand-700); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-accent { background: var(--sun); color: var(--brand-700); border: 1px solid var(--sun-600); }
.btn-accent:hover { background: #F3DD00; color: var(--brand-700); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: #BFD5C4; --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand-700); }
.btn-light { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.btn-light:hover { background: var(--brand-50); border-color: #CFDCD2; color: var(--brand); }
.btn-sm .icon { width: 15px; height: 15px; }

/* ---------- Cards / KPI ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--surface); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-header h2, .card-title { font-size: .95rem; font-weight: 700; margin: 0; color: var(--brand-700); }
.card-body { padding: 18px; }

.kpi { padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; height: 100%; }
.kpi-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--brand-100); color: var(--brand); }
.kpi-icon.sun { background: var(--sun-100); color: #7A6400; }
.kpi-icon.red { background: #FBE5E3; color: var(--danger); }
.kpi-icon.leaf { background: var(--leaf-100); color: #4F7C1B; }
.kpi-icon.blue { background: #E3EEF7; color: var(--info); }
.kpi-label { color: var(--muted); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.55rem; font-weight: 800; color: var(--ink); line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-foot { font-size: .75rem; color: var(--muted); }
.kpi-hero { background: var(--brand); color: #fff; border: 0; position: relative; overflow: hidden; }
.kpi-hero .kpi-label, .kpi-hero .kpi-foot { color: rgba(255,255,255,.75); }
.kpi-hero .kpi-value { color: #fff; }
.kpi-hero .kpi-icon { background: var(--sun); color: var(--brand-700); }
.kpi-hero::after { content: ""; position: absolute; right: -30px; bottom: -40px; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, rgba(140,198,63,.35), transparent 70%); }

/* ---------- Tables ---------- */
.table-card .card-body { padding: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.toolbar .search { position: relative; flex: 1 1 220px; max-width: 340px; }
.toolbar .search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search input { padding-left: 36px; }
.toolbar .form-select, .toolbar .form-control { width: auto; min-width: 150px; }
.table { margin: 0; --bs-table-hover-bg: var(--brand-50); }
.table thead th { background: #F7F9F7; color: var(--ink-2); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; border-bottom: 1px solid var(--line); white-space: nowrap; padding: 10px 14px; }
.table td { padding: 11px 14px; vertical-align: middle; border-color: var(--line); }
.table td.num, .table th.num { text-align: right; }
.table .cell-main { font-weight: 600; color: var(--ink); }
.table .cell-sub { font-size: .76rem; color: var(--muted); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions .btn { padding: 4px 8px; }
.empty-state { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty-state .icon { width: 40px; height: 40px; color: #B8C8BC; margin-bottom: 8px; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.pagination { margin: 0; --bs-pagination-active-bg: var(--brand); --bs-pagination-active-border-color: var(--brand); --bs-pagination-color: var(--brand); --bs-pagination-font-size: .8rem; }

/* ---------- Status badges ---------- */
.badge-status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.badge-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: #E2F2E6; color: #1E6B36; }
.badge-warning { background: #FFF5C2; color: #7A5D00; }
.badge-danger { background: #FBE2DF; color: #A42A21; }
.badge-info { background: #E1EDF7; color: #1A5C8C; }
.badge-primary { background: var(--brand-100); color: var(--brand); }
.badge-secondary { background: #ECEFEC; color: #56645B; }
.badge-orange { background: #FDEBDC; color: #A64F0B; }

/* ---------- Forms ---------- */
.form-control, .form-select { border-radius: 9px; border-color: #D6DED8; padding: .5rem .75rem; font-size: .88rem; }
.form-control:focus, .form-select:focus { border-color: var(--brand-500); box-shadow: 0 0 0 .2rem rgba(28, 107, 54, .15); }
.form-label { font-weight: 600; font-size: .8rem; color: var(--ink-2); margin-bottom: 5px; }
.req { color: var(--danger); }
.form-section { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 20px; margin-bottom: 16px; background: #fff; }
.form-section legend { float: none; width: auto; padding: 0 8px; margin: 0 0 4px -8px; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.calc-box { background: var(--brand-50); border: 1px dashed #BFD5C4; border-radius: 10px; padding: 12px 14px; }
.calc-box .val { font-size: 1.6rem; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }

/* ---------- Detail sheets ---------- */
.profile-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile-photo { width: 92px; height: 92px; border-radius: 14px; object-fit: cover; background: var(--brand-100); display: grid; place-items: center; color: var(--brand); border: 1px solid var(--line); flex-shrink: 0; }
.profile-photo .icon { width: 38px; height: 38px; }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px 20px; margin: 0; }
.dl-grid dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.dl-grid dd { margin: 2px 0 0; font-weight: 600; }
.nav-tabs { border-bottom: 1px solid var(--line); gap: 2px; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.nav-tabs .nav-link { border: 0; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; white-space: nowrap; padding: 10px 14px; }
.nav-tabs .nav-link.active { color: var(--brand); border-bottom-color: var(--sun); background: transparent; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--brand-500); }
.timeline li:last-child { border-left-color: transparent; }
.timeline small { color: var(--muted); }
.progress { height: 8px; background: #E9EEEA; border-radius: 99px; }
.progress-bar { background: var(--brand-500); }
.progress-bar.warn { background: var(--sun-600); }
.progress-bar.over { background: var(--danger); }
.stat-mini { display: flex; flex-direction: column; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.stat-mini span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.stat-mini strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.evid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.evid-grid a { display: block; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; color: var(--ink-2); font-size: .75rem; }
.evid-grid img { width: 100%; height: 96px; object-fit: cover; display: block; }
.evid-grid .doc { height: 96px; display: grid; place-items: center; background: var(--brand-50); }
.evid-grid .name { padding: 6px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.workflow { display: flex; flex-wrap: wrap; gap: 6px; }
.workflow .step { padding: 6px 12px; border-radius: 99px; font-size: .74rem; font-weight: 700; background: #EEF1EE; color: #7A877F; }
.workflow .step.done { background: var(--brand-100); color: var(--brand); }
.workflow .step.current { background: var(--sun); color: var(--brand-700); }

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: var(--brand-700); color: #E2EEE5; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art::before { content: ""; position: absolute; width: 520px; height: 520px; right: -180px; top: -160px; border-radius: 50%; background: radial-gradient(circle, rgba(140, 198, 63, .28), transparent 65%); }
.auth-art::after { content: ""; position: absolute; width: 380px; height: 380px; left: -120px; bottom: -160px; border-radius: 50%; background: radial-gradient(circle, rgba(252, 231, 4, .18), transparent 65%); }
.auth-art h2 { font-size: 2.1rem; font-weight: 800; color: #fff; letter-spacing: -.02em; max-width: 460px; position: relative; }
.auth-art h2 em { font-style: normal; color: var(--sun); }
.auth-art ul { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 10px; position: relative; }
.auth-art li { display: flex; gap: 10px; align-items: center; }
.auth-art li .icon { color: var(--leaf); }
.auth-form { display: grid; place-items: center; padding: 32px 20px; background: #fff; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card img { max-width: 220px; display: block; margin-bottom: 24px; }
@media (max-width: 899.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-art { display: none; } }

@media print {
  .sidebar, .topbar, .page-actions, .toolbar, .pager, .row-actions, .no-print { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
