@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

/* ── DESIGN TOKENS ── */
:root {
  --primary:       #2563EB;
  --primary-dark:  #1D4ED8;
  --primary-light: #3B82F6;
  --accent:        #059669;
  --accent-light:  #10B981;
  --danger:        #DC2626;
  --danger-light:  #EF4444;
  --warning:       #D97706;
  --warning-light: #F59E0B;
  --purple:        #7C3AED;
  --purple-light:  #8B5CF6;

  --sidebar-bg:    #0F172A;
  --sidebar-hover: #1E293B;
  --sidebar-text:  #94A3B8;

  --bg:            #F1F5F9;
  --surface:       #FFFFFF;
  --surface-2:     #F8FAFC;
  --border:        #E2E8F0;
  --border-light:  #F1F5F9;

  --text-primary:  #0F172A;
  --text-secondary:#475569;
  --text-muted:    #94A3B8;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:  0 10px 40px rgba(0,0,0,.12);
  --shadow-blue:0 4px 20px rgba(37,99,235,.25);

  --transition: 150ms cubic-bezier(.4,0,.2,1);
  --sidebar-w:  240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
}

/* ══ SIDEBAR ══ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 50;
  border-right: 1px solid rgba(255,255,255,.05);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 10px; }

.sidebar-brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-decoration: none;
  display: block;
}
.brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; margin-bottom: .75rem;
  box-shadow: var(--shadow-blue);
}
.brand-name  { font-size: .95rem; font-weight: 700; color: #F8FAFC; letter-spacing: -.01em; }
.brand-sub   { font-size: .7rem; color: var(--sidebar-text); margin-top: 1px; }

.sidebar-nav { padding: 1rem 0; flex: 1; }
.nav-section {
  font-size: .65rem; font-weight: 700;
  color: var(--text-muted); letter-spacing: .08em;
  text-transform: uppercase;
  padding: .75rem 1.25rem .35rem;
}
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem; font-weight: 500;
  margin: 1px .5rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: #F1F5F9; }
.nav-item.active { background: rgba(37,99,235,.15); color: #60A5FA; }
.nav-item.active::before {
  content: '';
  position: absolute; left: -.5rem; top: 25%; bottom: 25%;
  width: 3px; background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff; font-size: .65rem; font-weight: 700;
  padding: 1px 6px; border-radius: 20px;
}

/* ══ MAIN ══ */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column; min-height: 100vh;
}
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .875rem 2rem;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 1rem; font-weight: 700; }
.topbar-sub   { font-size: .75rem; color: var(--text-muted); margin-top: 1px; }
.topbar-actions { display: flex; gap: .625rem; align-items: center; }
.main-content { padding: 1.75rem 2rem; flex: 1; }

/* ══ BUTTONS ══ */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: .875rem; font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary  { background: var(--primary); color: #fff; box-shadow: var(--shadow-blue); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text-secondary); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #B91C1C; }
.btn-success  { background: var(--accent); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-ghost    { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-icon {
  width: 30px; height: 30px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: .85rem;
}

/* ══ STAT CARDS ══ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem; margin-bottom: 1.75rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative; overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; margin-bottom: .875rem;
}
.ci-blue   { background: #EFF6FF; color: var(--primary); }
.ci-red    { background: #FEF2F2; color: var(--danger); }
.ci-green  { background: #ECFDF5; color: var(--accent); }
.ci-amber  { background: #FFFBEB; color: var(--warning); }
.ci-purple { background: #F5F3FF; color: var(--purple); }
.card-value { font-size: 1.75rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.card-label { font-size: .72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-top: .35rem; }

/* ══ SECTION HEADER ══ */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.section-title { font-size: .95rem; font-weight: 700; }
.section-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ══ FILTER TABS ══ */
.filter-tabs {
  display: flex; gap: .25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  width: fit-content;
}
.filter-tab {
  padding: .4rem .9rem;
  border-radius: var(--radius-sm);
  font-size: .8rem; font-weight: 600;
  border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.filter-tab:hover { color: var(--text-primary); }
.filter-tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ══ TABLE ══ */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--surface-2); border-bottom: 1px solid var(--border); }
th {
  padding: .7rem 1rem;
  text-align: left;
  font-size: .7rem; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .07em;
  white-space: nowrap;
}
td {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border-light);
  font-size: .875rem;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover td { background: #F8FAFC; }
.td-main { font-weight: 600; }
.td-sub  { font-size: .73rem; color: var(--text-muted); margin-top: 2px; }
.empty-row { text-align: center; color: var(--text-muted); padding: 3rem 1rem !important; }

/* ══ BADGES ══ */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .22rem .6rem;
  border-radius: 20px;
  font-size: .7rem; font-weight: 700;
  white-space: nowrap;
}
/* Status */
.badge-pendiente   { background: #F1F5F9; color: #475569; }
.badge-en_progreso { background: #EFF6FF; color: #1E40AF; }
.badge-completado  { background: #ECFDF5; color: #065F46; }
.badge-vencido     { background: #FEF2F2; color: #991B1B; }
.badge-cancelado   { background: #F5F3FF; color: #5B21B6; }
/* Priority */
.badge-alta  { background: #FEF2F2; color: #991B1B; }
.badge-media { background: #FFFBEB; color: #92400E; }
.badge-baja  { background: #ECFDF5; color: #065F46; }
/* Type */
.badge-type { background: #F1F5F9; color: #334155; font-weight: 600; }

/* ══ MODAL ══ */
.modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  animation: fadeIn .15s ease;
}
.modal.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%; max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 99px; border: none;
  background: var(--surface-2); color: var(--text-muted);
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); font-family: inherit;
}
.modal-close:hover { background: var(--border); color: var(--text-primary); }

/* ══ FORMS ══ */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .8rem; font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: .4rem;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .6rem .875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: .875rem;
  color: var(--text-primary);
  background: var(--surface);
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-group textarea { min-height: 72px; resize: vertical; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
.form-actions {
  display: flex; gap: .75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  margin-top: 1.25rem;
}

/* ══ PAGE HEADER ══ */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem; gap: 1rem;
}
.page-title    { font-size: 1.4rem; font-weight: 800; letter-spacing: -.03em; }
.page-subtitle { font-size: .85rem; color: var(--text-muted); margin-top: .2rem; }

/* ══ ALERT ══ */
.alert {
  display: flex; align-items: center; gap: .625rem;
  padding: .75rem 1rem;
  border-radius: var(--radius-md);
  font-size: .875rem; font-weight: 500;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-success { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
.alert-danger  { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }

/* ══ ROW HIGHLIGHTS ══ */
tr.row-vencido td { background: #FFF5F5 !important; }
tr.row-alta td    { border-left: 3px solid var(--danger); }

/* ══ SEARCH INPUT ══ */
.search-wrap { position: relative; }
.search-wrap input {
  padding-left: 2.2rem;
  width: 220px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: .85rem;
  padding-top: .45rem; padding-bottom: .45rem;
  background: var(--surface);
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-wrap input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.search-wrap .search-icon {
  position: absolute; left: .7rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .9rem; pointer-events: none;
}

/* ══ TOAST NOTIFICATION ══ */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--text-primary);
  color: #fff;
  padding: .75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: .875rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  animation: toastIn .25s ease;
  max-width: 320px;
}
.toast.toast-success { background: var(--accent); }
.toast.toast-danger  { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ══ EMBED MODE ══ */
body[data-embed="1"] .sidebar {
  display: flex !important;
  transform: none !important;
  position: fixed !important;
}
body[data-embed="1"] .topbar,
body[data-embed="1"] .sidebar-overlay,
body[data-embed="1"] .hamburger {
  display: none !important;
  height: 0 !important;
}
body[data-embed="1"] .main-wrap { margin-left: var(--sidebar-w) !important; }
body[data-embed="1"] .main-content { padding: 1rem !important; }
body[data-embed="1"] .card { box-shadow: 0 1px 3px rgba(0,0,0,.08) !important; border-radius: 8px !important; }
body[data-embed="1"] {
  background: #F1F5F9;
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 transparent;
}

/* ══ MOBILE ══ */
.hamburger {
  display: none; flex-direction: column; justify-content: center;
  align-items: center; gap: 5px;
  width: 36px; height: 36px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); cursor: pointer; padding: 0; flex-shrink: 0;
}
.hamburger span { display: block; width: 18px; height: 2px; background: var(--text-secondary); border-radius: 2px; transition: all var(--transition); }
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 49; }
.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .28s cubic-bezier(.4,0,.2,1); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .main-content { padding: 1rem; }
  .topbar { padding: .75rem 1rem; gap: .75rem; }
  .hamburger { display: flex; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: .625rem; }
  .card { padding: 1rem; }
  .card-value { font-size: 1.35rem; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 640px; }
  .filter-tabs { overflow-x: auto; flex-wrap: nowrap; width: 100%; scrollbar-width: none; }
  .filter-tabs::-webkit-scrollbar { display: none; }
  .filter-tab { white-space: nowrap; }
  .section-header { flex-wrap: wrap; gap: .5rem; }
  .modal { align-items: flex-end; padding: 0; }
  .modal-box { max-width: 100%; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .page-header { flex-direction: column; }
  .page-title { font-size: 1.15rem; }
  .search-wrap input { width: 100%; }
}
