/* ==========================================================================
   Recovery Studio — Design system
   ========================================================================== */

:root {
  --navy: #0a2342;
  --navy-700: #0e2c52;
  --navy-600: #123f70;
  --blue: #0f4c81;
  --blue-600: #1468b8;
  --blue-50: #eaf2fb;
  --orange: #ff7a18;
  --orange-600: #ea6508;
  --orange-50: #fff3e8;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --border: #e3eaf3;
  --border-strong: #d3deeb;
  --text: #0e1c2e;
  --text-2: #33475f;
  --muted: #64748b;
  --muted-2: #8b9bb0;
  --success: #0e9f6e;
  --success-50: #e7f8f1;
  --warning: #d97706;
  --warning-50: #fff7e6;
  --danger: #dc2626;
  --danger-50: #fdecec;
  --info: #2563eb;
  --info-50: #eaf1ff;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-xs: 0 1px 2px rgba(15, 35, 65, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 35, 65, 0.04), 0 6px 16px -10px rgba(15, 35, 65, 0.14);
  --shadow-md: 0 18px 40px -20px rgba(15, 35, 65, 0.3);
  --shadow-lg: 0 30px 70px -30px rgba(10, 35, 66, 0.38);
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --sidebar-w: 264px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.modal-open {
  overflow: hidden;
}

h1, h2, h3, h4, p, ul, ol {
  margin: 0;
}

h1, h2, h3, h4 {
  letter-spacing: -0.022em;
  line-height: 1.2;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

img {
  max-width: 100%;
  display: block;
}

svg.icon {
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: -0.18em;
}

::selection {
  background: rgba(255, 122, 24, 0.24);
}

:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #c8d4e3;
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: #a9b9cd;
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12.5px;
}

.mono {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12.5px;
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.danger-text {
  color: var(--danger) !important;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.list-gap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack-tight {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* ------------------------------- boot screen ----------------------------- */

.boot-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(900px 520px at 50% -10%, #eaf2fb, transparent), var(--bg);
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.boot-logo {
  animation: floatIn 0.7s var(--ease);
  filter: drop-shadow(0 16px 26px rgba(10, 35, 66, 0.25));
}

.boot-spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid #dce7f4;
  border-top-color: var(--orange);
  animation: spin 0.8s linear infinite;
}

.boot-error {
  max-width: 560px;
  margin: 12vh auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.boot-error h1 {
  font-size: 22px;
  margin-bottom: 8px;
}

.boot-error pre {
  background: var(--surface-2);
  padding: 12px;
  border-radius: 8px;
  overflow: auto;
  font-size: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.36s var(--ease);
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ---------------------------------- logo --------------------------------- */

.logo-lockup {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  line-height: 1;
}

.logo-badge {
  display: inline-flex;
  border-radius: 13px;
  box-shadow: 0 5px 14px -6px rgba(10, 35, 66, 0.55);
  overflow: hidden;
}

.logo-mark-svg {
  display: block;
}

.logo-word {
  display: flex;
  flex-direction: column;
  color: var(--navy);
  font-size: 15px;
  letter-spacing: 0.13em;
}

.logo-word strong {
  font-weight: 800;
}

.logo-word span {
  margin-top: 3px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.44em;
  color: var(--orange);
}

.logo-lockup.is-light .logo-word {
  color: #fff;
}

.logo-lockup.is-light .logo-badge {
  box-shadow: 0 8px 22px -8px rgba(0, 0, 0, 0.5);
}

/* --------------------------------- avatares ------------------------------- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  flex: 0 0 auto;
  background: linear-gradient(135deg, #1468b8, #0a2342);
  user-select: none;
}

.av-1 { background: linear-gradient(135deg, #ff9a4d, #ea6508); }
.av-2 { background: linear-gradient(135deg, #2f7f6f, #0e5a4d); }
.av-3 { background: linear-gradient(135deg, #7c6bd6, #4c3ba8); }
.av-4 { background: linear-gradient(135deg, #d65b7c, #a52a4b); }
.av-5 { background: linear-gradient(135deg, #637a92, #2e4258); }

/* --------------------------------- botones -------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.16s, border-color 0.16s, color 0.16s, box-shadow 0.16s, transform 0.12s;
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 8px 18px -12px rgba(10, 35, 66, 0.75);
}

.btn-primary:hover:not(:disabled) {
  background: var(--navy-700);
}

.btn-accent {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 10px 22px -12px rgba(234, 101, 8, 0.8);
}

.btn-accent:hover:not(:disabled) {
  background: var(--orange-600);
}

.btn-outline {
  border-color: var(--border-strong);
  background: #fff;
  color: var(--navy);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--navy);
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: #eef3f9;
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 9px;
  gap: 6px;
}

.btn-lg {
  height: 50px;
  padding: 0 22px;
  font-size: 14.5px;
  border-radius: 12px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  transition: background 0.16s, color 0.16s, border-color 0.16s;
  flex: 0 0 auto;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--navy);
  border-color: var(--border);
}

.icon-btn.danger:hover {
  background: var(--danger-50);
  color: var(--danger);
  border-color: #f6c9c9;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--muted-2);
  transition: background 0.15s, color 0.15s;
}

.copy-btn:hover {
  background: var(--blue-50);
  color: var(--blue);
}

.link-btn {
  border: none;
  background: none;
  padding: 0;
  color: var(--blue-600);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--blue-600);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.link-arrow:hover {
  color: var(--navy);
}

/* -------------------------------- formularios ----------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field > label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}

.field-top {
  margin-top: 4px;
}

.input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  appearance: none;
}

textarea.input {
  height: auto;
  min-height: 76px;
  padding: 11px 13px;
  line-height: 1.5;
  resize: vertical;
}

select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.input:hover {
  border-color: #bccbdd;
}

.input:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(20, 104, 184, 0.12);
}

.input:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

.input-sm {
  height: 36px;
  font-size: 12.5px;
  border-radius: 9px;
}

.input-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon > svg {
  position: absolute;
  left: 13px;
  color: var(--muted-2);
  pointer-events: none;
}

.input-icon .input {
  padding-left: 40px;
}

.input-icon.has-action .input {
  padding-right: 42px;
}

.input-action {
  position: absolute;
  right: 6px;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.input-action:hover {
  background: var(--surface-2);
  color: var(--navy);
}

.input-search {
  width: 280px;
}

.input-search > svg {
  left: 12px;
}

.input-search .input {
  padding-left: 36px;
}

.input-search .input-sm {
  height: 38px;
}

.field-hint,
.form-hint {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
}

.form-hint svg {
  vertical-align: -0.2em;
}

.form-hint.is-error {
  color: var(--danger);
}

.field > .field-hint {
  margin-top: 1px;
}

.pin-field {
  letter-spacing: 0.45em;
  font-weight: 700;
  text-align: center;
  font-size: 16px;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.form-row.between {
  justify-content: space-between;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.form-actions.between {
  justify-content: space-between;
}

.form-actions.wrap,
.page-actions.wrap {
  flex-wrap: wrap;
}

.form-error {
  display: none;
  background: var(--danger-50);
  color: #b91c1c;
  border: 1px solid #f4c7c7;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.45;
  margin-bottom: 14px;
}

.form-error.show {
  display: block;
  animation: fadeUp 0.2s var(--ease);
}

.check {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.45;
  cursor: pointer;
}

.check input[type='checkbox'],
.check input[type='radio'] {
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: var(--blue);
  flex: 0 0 auto;
  cursor: pointer;
}

.check-top {
  margin: 2px 0 16px;
}

.check-boxed {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.gap-sm {
  gap: 12px;
}

.select-inline {
  display: inline-flex;
}

.select-inline .input {
  width: auto;
  min-width: 168px;
  background-color: #fff;
}

/* --------------------------------- tarjetas ------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-head {
  padding: 19px 22px;
  border-bottom: 1px solid var(--border);
}

.card-head:last-child {
  border-bottom: none;
}

.head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.card-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.card-body {
  padding: 22px;
}

.head-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------------------------------- pills --------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: #eef2f7;
  color: var(--muted);
}

.pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.pill-success { background: var(--success-50); color: #087a54; }
.pill-warning { background: var(--warning-50); color: #a86405; }
.pill-danger { background: var(--danger-50); color: #b91c1c; }
.pill-info { background: var(--info-50); color: #1d4ed8; }
.pill-neutral { background: #eef2f7; color: var(--muted); }

.tiny-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.tag-popular {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 20px;
  background: var(--orange);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tag-popular.inline {
  height: 18px;
  margin-left: 5px;
  vertical-align: 1px;
}

.tag-soft {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 7px;
  background: var(--blue-50);
  color: var(--blue);
  font-size: 10.5px;
  font-weight: 600;
  margin: 1px 0;
  white-space: nowrap;
}

.credit-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 25px;
  padding: 0 9px;
  border-radius: 8px;
  background: var(--orange-50);
  color: #b95405;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.delta {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

.delta.up { background: var(--success-50); color: #087a54; }
.delta.down { background: var(--danger-50); color: var(--danger); }

/* --------------------------------- layout --------------------------------- */

.app-root {
  min-height: 100vh;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(420px 240px at 0% 0%, rgba(20, 104, 184, 0.28), transparent 70%),
    linear-gradient(180deg, #0b2545 0%, #071b34 100%);
  color: #fff;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-brand {
  padding: 24px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.sidebar-mode {
  display: inline-flex;
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.55);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.side-nav {
  padding: 4px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.side-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-label {
  padding: 0 12px;
  margin-bottom: 6px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.32);
}

.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 8px 11px;
  border-radius: 9px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.side-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.side-link.active {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  font-weight: 600;
}

.side-link.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--orange);
}

.side-link-icon {
  display: inline-flex;
  color: rgba(255, 255, 255, 0.5);
  transition: color 0.15s;
}

.side-link.active .side-link-icon,
.side-link:hover .side-link-icon {
  color: var(--orange);
}

.side-link-label {
  flex: 1;
  white-space: nowrap;
}

.side-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 20px;
  background: var(--orange);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-help {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.15s;
}

.side-help:hover {
  background: rgba(255, 255, 255, 0.09);
}

.side-help-icon {
  display: inline-flex;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(255, 122, 24, 0.14);
  color: var(--orange);
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.side-help > span:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.side-help strong {
  font-size: 11.5px;
  font-weight: 600;
}

.side-help small {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.45);
}

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.side-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.side-user-info strong {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-user-info span {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.42);
}

.side-logout {
  color: rgba(255, 255, 255, 0.45);
}

.side-logout:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-color: transparent;
}

.sidebar-overlay {
  display: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 72px;
  padding: 0 30px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-menu {
  display: none;
}

.topbar-title {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.topbar-title span {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--muted-2);
}

.topbar-title strong {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.demo-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  margin-right: 6px;
}

.topbar-help {
  color: #1f9d61;
}

.topbar-bell {
  position: relative;
}

.bell-badge {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 10px;
  background: var(--orange);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-sizing: content-box;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 9px 4px 4px;
  border-radius: 10px;
  margin-left: 4px;
}

.topbar-user:hover {
  background: var(--surface-2);
}

.topbar-user > span {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.topbar-user strong {
  font-size: 12px;
  font-weight: 600;
}

.topbar-user small {
  font-size: 10px;
  color: var(--muted);
}

.topbar-logout {
  margin-left: 2px;
}

.page {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 30px 32px 52px;
}

.page-in {
  animation: fadeUp 0.28s var(--ease);
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 32px 24px;
  color: var(--muted-2);
  font-size: 10.5px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.45);
}

.app-footer span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ------------------------------- page header ------------------------------ */

.view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 7px;
}

.page-title {
  font-size: clamp(24px, 2.4vw, 32px);
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 9px;
}

.title-spark {
  color: var(--orange);
}

.page-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  max-width: 640px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
}

.section-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

/* ---------------------------------- stats --------------------------------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stats-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kpi {
  padding: 18px 19px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--blue-50);
  color: var(--blue);
  flex: 0 0 auto;
}

.tone-blue { background: var(--blue-50); color: var(--blue); }
.tone-orange { background: var(--orange-50); color: var(--orange-600); }
.tone-green { background: var(--success-50); color: #0b8a60; }
.tone-amber { background: var(--warning-50); color: #b45309; }
.tone-red { background: var(--danger-50); color: var(--danger); }

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
}

.kpi-trend.up { color: #087a54; background: var(--success-50); }
.kpi-trend.down { color: var(--danger); background: var(--danger-50); }

.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.kpi-value {
  font-size: clamp(21px, 2vw, 26px);
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi-helper {
  font-size: 11px;
  color: var(--muted-2);
  margin-top: 2px;
}

/* --------------------------------- vacío ---------------------------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 38px 22px;
  gap: 6px;
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted-2);
  margin-bottom: 6px;
}

.empty h3 {
  font-size: 14.5px;
  font-weight: 700;
}

.empty p {
  font-size: 12.5px;
  color: var(--muted);
  max-width: 340px;
}

.empty .btn {
  margin-top: 9px;
}

/* --------------------------------- banner --------------------------------- */

.banner {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 17px;
  border-radius: 13px;
  border: 1px solid #f5dfb7;
  background: linear-gradient(100deg, #fffaf0, #fff);
  flex-wrap: wrap;
}

.banner-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--warning-50);
  color: var(--warning);
  flex: 0 0 auto;
}

.banner > div {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.banner strong {
  font-size: 12.5px;
  font-weight: 700;
  color: #7c4a03;
}

.banner span:not(.banner-icon) {
  font-size: 11.5px;
  color: #9a6a1f;
}

.short {
  min-width: 0;
}

/* -------------------------------- callouts -------------------------------- */

.callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 11px;
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}

.callout > svg {
  margin-top: 1px;
  flex: 0 0 auto;
}

.callout strong {
  font-weight: 700;
}

.callout-blue {
  background: #f1f7ff;
  border-color: #d5e6fb;
  color: #26527b;
}

.callout-blue > svg { color: var(--blue-600); }

.callout-green {
  background: #effaf5;
  border-color: #c9eddd;
  color: #10634a;
}

.callout-green > svg { color: var(--success); }

.callout-orange {
  background: #fff8ef;
  border-color: #f8dfc2;
  color: #8a4c0c;
}

.callout-orange > svg { color: var(--orange-600); }

/* --------------------------------- table ---------------------------------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 700px;
}

.table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 13px 14px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
  color: var(--text-2);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: #fbfdff;
}

.table strong {
  color: var(--text);
  font-weight: 600;
}

.table-compact th,
.table-compact td {
  padding: 9px 12px;
}

.row-muted {
  opacity: 0.55;
}

.row-active {
  background: #fff8ef !important;
}

.table-user {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 190px;
}

.table-user > div {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
  min-width: 0;
}

.table-user strong {
  font-size: 12.5px;
  white-space: nowrap;
}

.table-user span {
  font-size: 10.5px;
  color: var(--muted);
  max-width: 290px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}

.search-empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------------------------------- tabs ---------------------------------- */

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px 12px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--navy);
}

.tab.active {
  color: var(--navy);
  border-bottom-color: var(--orange);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--orange-50);
  color: var(--orange-600);
  font-size: 9.5px;
  font-weight: 800;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.segmented button {
  border: none;
  background: none;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.segmented button:hover {
  color: var(--navy);
}

.segmented button.active {
  background: #fff;
  color: var(--navy);
  box-shadow: var(--shadow-xs);
}

.segmented.wrap {
  flex-wrap: wrap;
}

/* -------------------------------- progreso -------------------------------- */

.progress {
  height: 7px;
  border-radius: 10px;
  background: #eaf0f7;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--blue), var(--blue-600));
  transition: width 0.4s var(--ease);
}

.progress-orange > span { background: linear-gradient(90deg, var(--orange), #ff9a4d); }
.progress-green > span { background: linear-gradient(90deg, #0e9f6e, #34d399); }

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 6px;
}

/* ------------------------------- detail rows ------------------------------ */

.detail-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
  background: #fff;
}

.detail-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 13px;
  border-bottom: 1px solid #eef2f7;
  font-size: 12.5px;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: var(--muted);
  flex: 0 0 auto;
}

.detail-value {
  color: var(--text-2);
  font-weight: 600;
  text-align: right;
}

/* ---------------------------------- modales -------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(6, 20, 38, 0.55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.18s;
}

.modal-backdrop.in {
  opacity: 1;
}

.modal {
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 40px 90px -30px rgba(3, 12, 24, 0.55);
  transform: translateY(12px) scale(0.985);
  opacity: 0;
  transition: transform 0.22s var(--ease), opacity 0.22s;
  overflow: hidden;
}

.modal.in {
  transform: none;
  opacity: 1;
}

.modal-sm { max-width: 440px; }
.modal-md { max-width: 620px; }
.modal-lg { max-width: 820px; }
.modal-xl { max-width: 1060px; }

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 21px 24px 17px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.modal-head-text {
  flex: 1;
  min-width: 0;
}

.modal-eyebrow {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--orange-600);
  margin-bottom: 5px;
}

.modal-head h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-head p {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.modal-x {
  margin: -4px -6px 0 0;
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 15px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.modal-foot .btn-block {
  width: auto;
}

.confirm-text {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-2);
}

/* --------------------------------- toasts --------------------------------- */

.toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  background: #0d2747;
  color: #fff;
  border-radius: 11px;
  box-shadow: 0 20px 40px -18px rgba(5, 18, 34, 0.6);
  animation: toastIn 0.26s var(--ease);
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.toast.out {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.toast-icon {
  display: inline-flex;
  color: #7ee2b8;
  margin-top: 1px;
}

.toast-error .toast-icon { color: #ff9b9b; }
.toast-info .toast-icon { color: #9cc4ff; }

.toast-msg {
  flex: 1;
  font-size: 12.5px;
  line-height: 1.45;
  font-weight: 500;
}

.toast-close {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  padding: 1px;
  display: inline-flex;
}

.toast-close:hover {
  color: #fff;
}

/* --------------------------- utilidades varias ---------------------------- */

.no-print {}

.w-100 { width: 100%; }

@media (max-width: 1250px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .app-main {
    margin-left: 0;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
    box-shadow: 0 30px 80px rgba(4, 15, 28, 0.4);
  }

  body.sidebar-open .sidebar {
    transform: none;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(6, 20, 38, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .topbar-menu {
    display: inline-flex;
  }

  .page {
    padding: 24px 22px 44px;
  }

  .topbar {
    padding: 0 20px;
  }

  .app-footer {
    padding: 16px 22px 22px;
  }
}

@media (max-width: 760px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .stats-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
  }

  .kpi {
    padding: 15px;
  }

  .kpi-value {
    font-size: 20px;
  }

  .topbar {
    height: 62px;
    gap: 8px;
  }

  .topbar-title span {
    display: none;
  }

  .topbar-title strong {
    font-size: 12.5px;
  }

  .demo-chip {
    display: none;
  }

  .topbar-user > span {
    display: none;
  }

  .topbar-user {
    padding: 3px;
  }

  .topbar-help {
    display: none;
  }

  .page {
    padding: 18px 15px 38px;
  }

  .page-head {
    align-items: flex-start;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
  }

  .page-actions .select-inline {
    flex: 1;
  }

  .page-actions .select-inline .input {
    width: 100%;
  }

  .card-head,
  .card-body {
    padding: 16px;
  }

  .input-search {
    width: 100%;
  }

  .modal-backdrop {
    padding: 10px;
    align-items: flex-end;
  }

  .modal {
    max-height: 92vh;
    border-radius: 16px;
  }

  .modal-head {
    padding: 17px 17px 14px;
  }

  .modal-body {
    padding: 16px 17px;
  }

  .modal-foot {
    padding: 12px 17px;
  }

  .modal-foot .btn {
    flex: 1;
  }

  .toast-root {
    right: 12px;
    bottom: 12px;
    left: 12px;
    max-width: none;
  }

  .app-footer {
    padding: 14px 16px;
    font-size: 9.5px;
  }
}

@media (max-width: 460px) {
  .stats-grid,
  .stats-3 {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-label {
    font-size: 10.5px;
  }

  .topbar-logout {
    display: none;
  }
}
