*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #4CAF50;
  --green-light: #E8F5E9;
  --green-dark: #388E3C;
  --blue: #2196F3;
  --orange: #FF9800;
  --red: #F44336;
  --purple: #9C27B0;
  --teal: #009688;
  --grey-100: #F5F5F5;
  --grey-200: #EEEEEE;
  --grey-300: #E0E0E0;
  --grey-500: #9E9E9E;
  --grey-700: #616161;
  --grey-900: #333333;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --sidebar-w: 200px;
  --right-w: 260px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--grey-100);
  color: var(--grey-900);
  font-size: 14px;
  line-height: 1.5;
}

.text-green { color: var(--green); }

/* App shell */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: #fff;
  border-bottom: 1px solid var(--grey-300);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.slogan {
  font-size: .75rem;
  color: var(--grey-700);
  margin-top: 2px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name { font-weight: 600; font-size: .875rem; }
.user-role { font-size: .75rem; color: var(--grey-500); }

.dropdown-btn {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--grey-500);
  cursor: pointer;
  padding: 4px 8px;
}

/* Layout */
.layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--grey-300);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
  flex-shrink: 0;
}

.nav-list { list-style: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--grey-700);
  text-decoration: none;
  font-size: .8125rem;
  transition: background .15s, color .15s;
}

.nav-link:hover { background: var(--grey-100); color: var(--grey-900); }

.nav-link.active {
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 600;
  border-right: 3px solid var(--green);
}

.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-help {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--grey-200);
  text-align: center;
}

.sidebar-help p {
  font-size: .75rem;
  color: var(--grey-500);
  margin-bottom: 8px;
}

.btn-chat {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: .8125rem;
  transition: background .15s;
}

.btn-chat:hover { background: var(--grey-100); }

/* Main */
.main-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  min-width: 0;
}

.view { display: none; animation: fadeIn .25s ease; }
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
  background: #fff;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: .9375rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--grey-900);
}

/* KPIs */
.kpis-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.kpi-card {
  background: #fff;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  box-shadow: var(--shadow);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}

.kpi-icon { font-size: 1.75rem; }

.kpi-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.kpi-label {
  font-size: .75rem;
  color: var(--grey-500);
}

.kpi-blue .kpi-value { color: var(--blue); }
.kpi-orange .kpi-value { color: var(--orange); }
.kpi-green .kpi-value { color: var(--green); }
.kpi-purple .kpi-value { color: var(--purple); }

/* Workflow */
.workflow-card { margin-bottom: 16px; }

.workflow {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.workflow-step {
  flex: 1;
  min-width: 120px;
  text-align: center;
  padding: 12px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s;
}

.workflow-step:hover { background: var(--grey-100); }

.step-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin: 0 auto 8px;
}

.step-blue { background: #E3F2FD; }
.step-orange { background: #FFF3E0; }
.step-green { background: var(--green-light); }
.step-purple { background: #F3E5F5; }
.step-teal { background: #E0F2F1; }

.step-num {
  font-size: .6875rem;
  color: var(--grey-500);
  margin-bottom: 4px;
}

.workflow-step strong {
  display: block;
  font-size: .8125rem;
  margin-bottom: 4px;
}

.workflow-step span {
  font-size: .6875rem;
  color: var(--grey-500);
  display: block;
}

.workflow-arrow {
  color: var(--grey-300);
  font-size: 1.25rem;
  align-self: center;
  flex-shrink: 0;
  padding-top: 20px;
}

/* Bottom row */
.bottom-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

/* Risk matrix */
.matrix-container {
  position: relative;
  margin-bottom: 16px;
}

.matrix-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 2px;
  aspect-ratio: 1;
  max-width: 280px;
}

.matrix-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: .875rem;
  border-radius: 3px;
  cursor: pointer;
  transition: transform .1s;
}

.matrix-cell:hover { transform: scale(1.08); z-index: 1; }

.matrix-cell.green { background: #A5D6A7; }
.matrix-cell.yellow { background: #FFF176; }
.matrix-cell.orange { background: #FFCC80; }
.matrix-cell.red { background: #EF9A9A; }

.matrix-label-y {
  position: absolute;
  left: -8px;
  top: 50%;
  transform: rotate(-90deg) translateX(-50%);
  font-size: .6875rem;
  color: var(--grey-500);
  white-space: nowrap;
}

.matrix-label-x {
  text-align: center;
  font-size: .6875rem;
  color: var(--grey-500);
  margin-top: 6px;
  max-width: 280px;
}

.critical-risks h3 {
  font-size: .875rem;
  margin-bottom: 10px;
}

.critical-risks ul { list-style: none; margin-bottom: 12px; }

.critical-risks li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--grey-200);
  font-size: .8125rem;
}

.badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .6875rem;
  font-weight: 600;
}

.badge-high { background: #FFEBEE; color: var(--red); }
.badge-medium { background: #FFF3E0; color: var(--orange); }
.badge-low { background: var(--green-light); color: var(--green-dark); }

.btn-outline {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: .8125rem;
  transition: background .15s, border-color .15s;
}

.btn-outline:hover {
  background: var(--grey-100);
  border-color: var(--green);
  color: var(--green-dark);
}

/* Quick access */
.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: .8125rem;
  text-align: left;
  transition: background .15s, border-color .15s;
}

.quick-btn:hover {
  background: var(--green-light);
  border-color: var(--green);
}

.quick-icon { font-size: 1.25rem; }

/* Right sidebar */
.right-sidebar {
  width: var(--right-w);
  background: #fff;
  border-left: 1px solid var(--grey-300);
  padding: 16px;
  overflow-y: auto;
  flex-shrink: 0;
}

.widget {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--grey-200);
}

.widget:last-child { border-bottom: none; }

.widget h3 {
  font-size: .8125rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.alert-list, .task-list, .activity-list { list-style: none; }

.alert-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  font-size: .75rem;
  line-height: 1.4;
}

.alert-list .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.alert-red .dot { background: var(--red); }
.alert-orange .dot { background: var(--orange); }

.task-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  font-size: .75rem;
}

.task-list input { margin-top: 2px; accent-color: var(--green); }

.activity-list li {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  font-size: .75rem;
  border-bottom: 1px solid var(--grey-100);
}

.act-icon { font-size: 1rem; flex-shrink: 0; }

.activity-list strong { display: block; font-weight: 500; }
.activity-list small { color: var(--grey-500); }

.link-all {
  display: inline-block;
  margin-top: 8px;
  font-size: .75rem;
  color: var(--green);
  text-decoration: none;
}

.link-all:hover { text-decoration: underline; }

/* Footer */
.footer {
  text-align: center;
  padding: 12px;
  font-size: .75rem;
  color: var(--grey-700);
  background: #fff;
  border-top: 1px solid var(--grey-300);
}

/* Page views */
.page-header {
  margin-bottom: 20px;
}

.page-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--grey-500);
  font-size: .875rem;
}

.demo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8125rem;
}

.demo-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--grey-100);
  font-weight: 600;
  border-bottom: 1px solid var(--grey-300);
}

.demo-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--grey-200);
}

.demo-table tr:hover td { background: var(--grey-100); }

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
}

.btn-primary {
  background: var(--green);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .8125rem;
  font-weight: 500;
  transition: background .15s;
}

.btn-primary:hover { background: var(--green-dark); }

.btn-sm {
  padding: 4px 12px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  font-size: .75rem;
}

.btn-sm:hover { background: var(--grey-100); }

.search-input {
  padding: 8px 12px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  font-size: .8125rem;
  flex: 1;
  max-width: 280px;
}

.cards-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-num {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 4px;
}

.demo-list {
  list-style: none;
  padding-left: 0;
}

.demo-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--grey-200);
  font-size: .8125rem;
}

.progress-section { margin-bottom: 20px; }

.progress-section h3 {
  font-size: .875rem;
  margin-bottom: 8px;
}

.progress-bar {
  height: 8px;
  background: var(--grey-200);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width .5s ease;
}

.progress-text { font-size: .75rem; color: var(--grey-500); }

.evidence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.evidence-item {
  background: #fff;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: box-shadow .15s;
}

.evidence-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }

.evidence-thumb {
  font-size: 2.5rem;
  margin-bottom: 8px;
  background: var(--grey-100);
  border-radius: var(--radius);
  padding: 20px;
}

.evidence-item span { display: block; font-size: .8125rem; font-weight: 500; }
.evidence-item small { color: var(--grey-500); font-size: .6875rem; }

.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.report-card {
  background: #fff;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  padding: 24px;
  font-size: .9375rem;
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s;
}

.report-card:hover {
  background: var(--green-light);
  border-color: var(--green);
}

.settings-form label {
  display: block;
  margin-bottom: 16px;
  font-size: .8125rem;
  font-weight: 500;
}

.settings-form input[type="text"],
.settings-form input[type="number"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 12px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  font-size: .8125rem;
}

.help-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.help-card {
  background: #fff;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.help-card h3 { font-size: .9375rem; margin-bottom: 8px; }
.help-card p { font-size: .8125rem; color: var(--grey-500); margin-bottom: 12px; }

/* Toast & Modal */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--grey-900);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: .8125rem;
  z-index: 1000;
  transition: opacity .3s, transform .3s;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

.modal.hidden { display: none; }

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  max-width: 420px;
  width: 90%;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--grey-500);
}

.modal-content h3 { margin-bottom: 12px; font-size: 1.0625rem; }
.modal-content p { color: var(--grey-700); font-size: .875rem; margin-bottom: 20px; }

/* Responsive */
@media (max-width: 1200px) {
  .right-sidebar { display: none; }
  .bottom-row { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .kpis-row { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 60px; }
  .nav-link span:not(.nav-icon) { display: none; }
  .nav-link { justify-content: center; padding: 12px; }
  .sidebar-help { display: none; }
  .help-cards, .cards-grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .header-brand .slogan { display: none; }
  .kpis-row { grid-template-columns: 1fr; }
  .workflow { flex-direction: column; }
  .workflow-arrow { display: none; }
}

/* Toolbar extra */
.toolbar .btn-outline.btn-sm { white-space: nowrap; }

.empty-row {
  text-align: center;
  color: var(--grey-500);
  padding: 24px !important;
}

/* Side panels — formularios y reportes */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 1100;
}

.panel-backdrop.hidden { display: none; }

body.panel-open { overflow: hidden; }

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(480px, 100vw);
  height: 100vh;
  background: #fff;
  z-index: 1101;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,.12);
  animation: slideIn .25s ease;
}

.side-panel-wide { width: min(720px, 100vw); }

.side-panel.hidden { display: none; }

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--grey-300);
  flex-shrink: 0;
}

.side-panel-header h3 {
  font-size: 1.0625rem;
  font-weight: 600;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--grey-500);
  line-height: 1;
  padding: 4px 8px;
}

.side-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Formularios demo */
.demo-form label {
  display: block;
  margin-bottom: 14px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--grey-900);
}

.demo-form input[type="text"],
.demo-form input[type="number"],
.demo-form input[type="date"],
.demo-form select,
.demo-form textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: inherit;
  background: #fff;
}

.demo-form input:focus,
.demo-form select:focus,
.demo-form textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green-light);
}

.demo-form input:disabled {
  background: var(--grey-100);
  color: var(--grey-500);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-hint {
  font-size: .75rem;
  color: var(--grey-500);
  background: var(--grey-100);
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--grey-200);
}

/* Reportes en panel */
.report-doc h4 {
  font-size: .9375rem;
  margin: 16px 0 10px;
  color: var(--grey-900);
}

.report-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid var(--green);
  padding-bottom: 14px;
  margin-bottom: 8px;
}

.report-sub {
  font-size: .75rem;
  color: var(--grey-500);
  margin-top: 4px;
}

.report-badge-demo {
  background: var(--orange);
  color: #fff;
  font-size: .6875rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: .05em;
}

.report-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 8px;
}

.report-stats > div {
  background: var(--grey-100);
  border-radius: var(--radius);
  padding: 12px 20px;
  text-align: center;
  min-width: 100px;
  font-size: .75rem;
  color: var(--grey-700);
}

.report-stats span {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--green-dark);
  line-height: 1.2;
  margin-bottom: 4px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .8125rem;
  margin-bottom: 16px;
}

.report-table th {
  background: var(--grey-100);
  padding: 8px 10px;
  text-align: left;
  border: 1px solid var(--grey-300);
  font-weight: 600;
}

.report-table td {
  padding: 8px 10px;
  border: 1px solid var(--grey-200);
}

.report-footer-note {
  font-size: .75rem;
  color: var(--grey-500);
  font-style: italic;
  margin-top: 12px;
}

@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .search-input { max-width: 100%; flex: 1 1 100%; }
}
