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

:root {
  --font: 'Inter', -apple-system, sans-serif;
  /* PALETA TELECABLE (fiel al logo: azul + cian + verde) */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #60a5fa;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;

  --secondary: #0ea5e9;
  --success: #16a34a;
  --success-50: #f0fdf4;
  --success-100: #dcfce7;
  --danger: #ef4444;
  --danger-50: #fef2f2;
  --danger-100: #fee2e2;
  --warning: #f59e0b;
  --warning-50: #fffbeb;
  --warning-100: #fef3c7;
  --info: #06b6d4;
  --info-50: #ecfeff;
  --info-100: #cffafe;
  --purple: #8b5cf6;
  --purple-50: #f5f3ff;
  
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  
  --bg: #f1f5f9;
  --card-bg: #fff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  
  --sidebar-width: 260px;
  --header-height: 70px;
  
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 8px 20px -6px rgba(15, 23, 42, .10), 0 2px 6px -2px rgba(15, 23, 42, .05);
  --shadow-md: 0 16px 32px -10px rgba(15, 23, 42, .12), 0 4px 10px -3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 28px 50px -14px rgba(15, 23, 42, .18), 0 8px 16px -6px rgba(15, 23, 42, .08);
  --shadow-primary: 0 10px 28px -4px rgba(37, 99, 235, .38);
  
  --r-xs: 4px;
  --r-sm: 8px;
  --r: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-full: 9999px;
  --t: all .2s cubic-bezier(.4, 0, .2, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  font-family: var(--font);
  border: none;
}

input,
select,
textarea {
  font-family: var(--font);
  font-size: .875rem;
}

img {
  max-width: 100%;
}

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

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

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 99px;
}

/* ===== LOGIN ===== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login-brand {
  background: linear-gradient(145deg, #0b1220 0%, #0f2043 55%, #123e8c 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  position: relative;
  overflow: hidden;
}

.login-brand::before {
  content: '';
  position: absolute;
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(6, 182, 212, .25) 0%, transparent 70%);
  top: -150px;
  left: -150px;
  pointer-events: none;
}

.login-brand::after {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(22, 163, 74, .2) 0%, transparent 70%);
  bottom: -100px;
  right: -100px;
  pointer-events: none;
}

.login-brand-content {
  position: relative;
  z-index: 1;
}

.brand-logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 56px;
}

.brand-logo-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: white;
  box-shadow: 0 8px 20px rgba(37, 99, 235, .4);
}

.brand-logo-name {
  font-size: 1.6rem;
  font-weight: 800;
  color: white;
  letter-spacing: -.5px;
}

.brand-logo-name small {
  display: block;
  font-size: .7rem;
  font-weight: 400;
  color: rgba(255, 255, 255, .4);
  margin-top: -2px;
}

.brand-headline {
  font-size: 2.4rem;
  font-weight: 800;
  color: white;
  line-height: 1.15;
  letter-spacing: -.8px;
  margin-bottom: 16px;
}

.brand-headline em {
  font-style: normal;
  background: linear-gradient(135deg, #67e8f9, #4ade80);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.brand-sub {
  color: rgba(255, 255, 255, .55);
  font-size: .95rem;
  line-height: 1.65;
  margin-bottom: 40px;
}

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

.brand-feat {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, .8);
  font-size: .875rem;
}

.brand-feat-icon {
  width: 32px;
  height: 32px;
  background: rgba(6, 182, 212, .18);
  border: 1px solid rgba(6, 182, 212, .3);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.login-brand-footer {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, .25);
  font-size: .78rem;
}

.login-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: white;
}

.login-form-wrap {
  width: 100%;
  max-width: 400px;
}

.login-welcome {
  margin-bottom: 32px;
}

.login-welcome h2 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.login-welcome p {
  color: var(--text-secondary);
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.input-wrap {
  position: relative;
}

.input-wrap input,
.input-wrap select {
  width: 100%;
  padding: 11px 40px 11px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: .9rem;
  color: var(--text-primary);
  background: var(--gray-50);
  transition: var(--t);
  outline: none;
}

.input-wrap input:focus,
.input-wrap select:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.input-icon-l {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.input-icon-r {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  background: none;
  padding: 0;
}

.input-icon-r:hover {
  color: var(--text-primary);
}

.form-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .83rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.link-sm {
  font-size: .83rem;
  color: var(--primary);
  font-weight: 500;
}

.link-sm:hover {
  color: var(--primary-dark);
}

.btn-login {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--primary), var(--info));
  color: white;
  border-radius: var(--r);
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .3px;
  transition: var(--t);
  box-shadow: var(--shadow-primary);
  position: relative;
  overflow: hidden;
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(37, 99, 235, .4);
}

.btn-login:active {
  transform: none;
}

.demo-creds {
  margin-top: 24px;
  padding: 14px 16px;
  background: var(--gray-50);
  border-radius: var(--r);
  border: 1px solid var(--border);
}

.demo-creds-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

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

.demo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: var(--t);
  border: 1px solid transparent;
}

.demo-item:hover {
  background: white;
  border-color: var(--primary-100);
}

.demo-info {
  font-size: .78rem;
  color: var(--text-secondary);
}

.login-error {
  background: var(--danger-50);
  border: 1px solid var(--danger-100);
  color: var(--danger);
  font-size: .85rem;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  margin-top: 12px;
  display: none;
}

/* ===== APP LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #0b1220 0%, #0f2043 55%, #14294f 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  transition: var(--t);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.s-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--primary), var(--info));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: white;
  box-shadow: 0 4px 15px rgba(37, 99, 235, .4);
  flex-shrink: 0;
}

.s-brand {
  font-size: 1rem;
  font-weight: 800;
  color: white;
}

.s-brand small {
  display: block;
  font-size: .65rem;
  font-weight: 400;
  color: rgba(255, 255, 255, .35);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
}

.nav-section-label {
  font-size: .63rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, .22);
  padding: 14px 8px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  color: rgba(255, 255, 255, .65);
  cursor: pointer;
  transition: var(--t);
  position: relative;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 1px;
  user-select: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, .06);
  color: white;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, .22), rgba(6, 182, 212, .1));
  color: white;
  border-right: 3px solid var(--primary-light);
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}

.nav-item.active::before {
  display: none;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: .7;
}

.nav-item.active svg,
.nav-item:hover svg {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: .62rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
}

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: var(--t);
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, .05);
}

.s-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.s-user-info {
  flex: 1;
  min-width: 0;
}

.s-username {
  font-size: .78rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.s-role {
  font-size: .63rem;
  color: rgba(255, 255, 255, .38);
}

.s-logout {
  color: rgba(255, 255, 255, .3);
  flex-shrink: 0;
  transition: var(--t);
}

.sidebar-user:hover .s-logout {
  color: var(--danger);
}

/* ===== HEADER ===== */
.main-wrap {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: var(--t);
}

.app-header {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-xs);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 5px;
}

.header-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-page-name {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-breadcrumb {
  font-size: .72rem;
  color: var(--text-muted);
}

.header-search {
  position: relative;
  width: 240px;
}

.header-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-full);
  font-size: .83rem;
  background: var(--gray-50);
  transition: var(--t);
  outline: none;
  color: var(--text-primary);
}

.header-search input:focus {
  border-color: var(--primary);
  background: white;
}

.header-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.company-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-50);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 4px 10px;
  margin-right: 8px;
  transition: var(--t);
}

.company-switcher:hover {
  background: white;
  border-color: var(--primary);
}

.company-switcher select {
  background: transparent;
  border: none;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  padding-right: 4px;
}

.hdr-btn {
  width: 36px;
  height: 36px;
  background: var(--gray-50);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--t);
  position: relative;
}

.hdr-btn:hover {
  background: var(--primary-50);
  color: var(--primary);
}

.notif-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 1.5px solid white;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px;
  border-radius: var(--r);
  cursor: pointer;
  transition: var(--t);
  border: 1.5px solid transparent;
}

.header-user:hover {
  background: var(--gray-50);
  border-color: var(--border);
}

.h-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 700;
  color: white;
}

.h-user-name {
  font-size: .83rem;
  font-weight: 600;
}

.h-user-role {
  font-size: .7rem;
  color: var(--text-muted);
}

/* ===== VIEW ===== */
.view-content {
  flex: 1;
  padding: 24px;
  animation: fadeIn .25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.view-header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.view-header p {
  font-size: .83rem;
  color: var(--text-secondary);
}

.view-header-actions {
  display: flex;
  gap: 8px;
}

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: white;
  border-radius: var(--r-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  transition: var(--t);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .04);
}

.stat-icon.indigo {
  background: var(--primary-50);
  color: var(--primary);
}

.stat-icon.green {
  background: var(--success-50);
  color: var(--success);
}

.stat-icon.amber {
  background: var(--warning-50);
  color: var(--warning);
}

.stat-icon.blue {
  background: var(--info-50);
  color: var(--info);
}

.stat-icon.red {
  background: var(--danger-50);
  color: var(--danger);
}

.stat-icon.purple {
  background: var(--purple-50);
  color: var(--purple);
}

.stat-number {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 3px;
}

.stat-label {
  font-size: .78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-change {
  font-size: .73rem;
  font-weight: 500;
  margin-top: 3px;
}

.stat-change.pos {
  color: var(--success);
}

.stat-change.neg {
  color: var(--danger);
}

/* ===== CARDS ===== */
.card {
  background: white;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: .9rem;
  font-weight: 700;
}

.card-subtitle {
  font-size: .74rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.card-body {
  padding: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.col-span-2 {
  grid-column: span 2;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--r);
  font-size: .85rem;
  font-weight: 600;
  transition: var(--t);
  cursor: pointer;
  border: 1.5px solid transparent;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .32);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-dark));
  box-shadow: var(--shadow-primary);
  transform: translateY(-1px);
}

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

.btn-ghost:hover {
  background: var(--gray-50);
  color: var(--text-primary);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #0ed104;
}

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 12px;
  font-size: .78rem;
}

.btn-icon {
  padding: 8px;
  width: 34px;
  height: 34px;
}

/* ===== TABLES ===== */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
}

thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-muted);
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

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

tbody tr:hover {
  background: var(--gray-50);
}

.td-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.td-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.td-name {
  font-weight: 600;
  font-size: .85rem;
}

.td-sub {
  font-size: .75rem;
  color: var(--text-muted);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green {
  background: var(--success-100);
  color: #166534;
  border: 1px solid rgba(22, 163, 74, .22);
}

.badge-red {
  background: var(--danger-100);
  color: #991b1b;
  border: 1px solid rgba(239, 68, 68, .2);
}

.badge-amber {
  background: var(--warning-100);
  color: #92400e;
  border: 1px solid rgba(245, 158, 11, .22);
}

.badge-blue {
  background: var(--info-100);
  color: #155e75;
  border: 1px solid rgba(6, 182, 212, .22);
}

.badge-gray {
  background: var(--gray-100);
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}

.badge-purple {
  background: #ede9fe;
  color: #5b21b6;
  border: 1px solid rgba(139, 92, 246, .22);
}

.badge-indigo {
  background: var(--primary-100);
  color: #1e40af;
  border: 1px solid rgba(37, 99, 235, .22);
}

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ===== FORMS ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-full {
  grid-column: 1 / -1;
}

.mb-4 {
  margin-bottom: 4px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.form-full {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: .83rem;
  font-weight: 500;
  color: var(--text-primary);
}

.field input,
.field select,
.field textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: .875rem;
  color: var(--text-primary);
  background: var(--gray-50);
  transition: var(--t);
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.field textarea {
  resize: vertical;
  min-height: 80px;
}

.field input[readonly] {
  background: var(--gray-100);
  color: var(--text-muted);
}

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  position: relative;
  min-width: 220px;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: .83rem;
  background: white;
  outline: none;
  transition: var(--t);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.search-box-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.filter-select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: .83rem;
  color: var(--text-primary);
  background: white;
  outline: none;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}

.modal {
  background: white;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalIn .25s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes modalIn {
  from {
    transform: scale(.92);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-lg {
  max-width: 840px;
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--gray-100);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--t);
}

.modal-close:hover {
  background: var(--danger-100);
  color: var(--danger);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab {
  padding: 9px 16px;
  font-size: .83rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--t);
  white-space: nowrap;
}

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

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ===== EMPLOYEE CARDS ===== */
.emp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.emp-card {
  background: white;
  border-radius: var(--r-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: var(--t);
  cursor: pointer;
  text-align: center;
}

.emp-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: var(--primary-100);
}

.emp-card-avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
}

.emp-card-name {
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.emp-card-pos {
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.emp-card-dept {
  font-size: .75rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

/* ===== DEPT CARDS ===== */
.dept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.dept-card {
  background: white;
  border-radius: var(--r-md);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: var(--t);
  cursor: pointer;
}

.dept-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.dept-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.dept-name {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.dept-desc {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.5;
}

.dept-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dept-count {
  font-size: .78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.dept-jefe {
  font-size: .78rem;
  font-weight: 500;
}

/* ===== TIMELINE / ATTENDANCE ===== */
.att-today-bar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: var(--r-md);
  padding: 20px 24px;
  margin-bottom: 20px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.att-today-info h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.att-today-info p {
  font-size: .85rem;
  opacity: .8;
  margin-top: 3px;
}

.att-clock-btn {
  background: white;
  color: var(--primary);
  padding: 10px 20px;
  border-radius: var(--r);
  font-size: .85rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: var(--t);
}

.att-clock-btn:hover {
  background: var(--primary-50);
}

/* ===== PAYROLL TABLE ===== */
.payroll-header {
  background: linear-gradient(135deg, #0b1220, #0f2a66);
  color: white;
  border-radius: var(--r-md);
  padding: 20px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.payroll-period {
  font-size: 1.1rem;
  font-weight: 700;
}

.payroll-period small {
  display: block;
  font-size: .78rem;
  opacity: .6;
  font-weight: 400;
  margin-bottom: 2px;
}

.payroll-totals {
  display: flex;
  gap: 28px;
}

.pay-total-item {
  text-align: right;
}

.pay-total-label {
  font-size: .72rem;
  opacity: .6;
}

.pay-total-num {
  font-size: 1.1rem;
  font-weight: 800;
}

.pay-total-num.success {
  color: #13f766;
}

/* ===== VACATIONS ===== */
.vac-saldo {
  background: linear-gradient(135deg, var(--success), #15803d);
  color: white;
  border-radius: var(--r-md);
  padding: 18px 22px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.vac-saldo-num {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
}

.vac-saldo-label {
  font-size: .85rem;
  opacity: .85;
}

.vac-saldo-used {
  font-size: .78rem;
  opacity: .7;
  margin-top: 3px;
}

/* ===== REPORTS ===== */
.reports-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

/* ===== CHART CONTAINER ===== */
.chart-wrap {
  position: relative;
}

.chart-wrap canvas {
  max-width: 100%;
}

/* ===== VISOR DE DOCUMENTOS (boletas y expedientes) ===== */
.modal.doc-viewer-modal {
  max-width: 950px;
  width: 95%;
}

.doc-viewer {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.doc-viewer-preview {
  background: #525659;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.doc-viewer-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* La columna con la nota, la firma y las acciones: siempre desplazable */
.doc-viewer-side {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  justify-content: space-between;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Tarjeta que reemplaza al visor cuando el navegador no puede mostrar el archivo */
.doc-viewer-fallback {
  width: 100%;
  min-height: 100%;
  padding: 32px 20px;
  background: #475569;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  color: var(--gray-100);
}

.doc-viewer-fallback-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-viewer-fallback-nombre {
  font-weight: 800;
  font-size: .95rem;
  color: white;
  word-break: break-word;
  max-width: 340px;
}

.doc-viewer-fallback-nota {
  font-size: .82rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, .7);
  max-width: 340px;
}

.doc-viewer-fallback-btn {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary);
  color: white;
  text-decoration: none;
  font-weight: 800;
  font-size: .9rem;
  padding: 12px 20px;
  border-radius: 10px;
  min-height: 46px;
}

.doc-viewer-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.doc-viewer-actions .btn,
.doc-viewer-actions a.btn {
  width: 100%;
  justify-content: center;
  min-height: 46px;
}

/* --- En celular: hoja a pantalla completa y firma siempre a la vista --- */
@media (max-width: 768px) {
  .doc-viewer-overlay {
    padding: 0;
  }

  .modal.doc-viewer-modal {
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  .doc-viewer {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .doc-viewer-preview {
    flex: none;
  }

  .doc-viewer-side {
    padding: 16px;
    overflow: visible;
    gap: 14px;
  }

  /* El bloque de firma queda pegado abajo: no hay que buscarlo desplazando */
  .doc-viewer-actions {
    position: sticky;
    bottom: 0;
    background: white;
    margin: 0 -16px -16px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -8px 20px rgba(15, 23, 42, .07);
  }

  /* Objetivos tactiles comodos */
  .doc-viewer-side input[type="checkbox"] {
    width: 22px;
    height: 22px;
  }

  /* Detalle de la boleta: la tabla de conceptos no cabe a 360px y obligaba
     a desplazarse en horizontal. Solo afecta a la pantalla; la impresion
     y el PDF conservan su diseño porque usan su propia media query. */
  #boletaPrintArea {
    padding: 20px 16px 12px !important;
  }

  #boletaPrintArea table {
    width: 100%;
    table-layout: fixed;
  }

  #boletaPrintArea table th,
  #boletaPrintArea table td {
    padding: 7px 4px !important;
    font-size: .74rem !important;
    overflow-wrap: anywhere;
  }

  /* Los titulos en mayusculas no caben en tres columnas iguales y se
     montaban unos sobre otros: se les da mas aire al concepto y menos cuerpo */
  #boletaPrintArea table th {
    font-size: .6rem !important;
    letter-spacing: 0 !important;
  }

  #boletaPrintArea table th:nth-child(1),
  #boletaPrintArea table td:nth-child(1) {
    width: 40%;
  }

  #boletaPrintArea table th:nth-child(2),
  #boletaPrintArea table td:nth-child(2) {
    width: 27%;
  }

  /* "DESCUENTOS" es la palabra mas larga de la cabecera: necesita mas sitio */
  #boletaPrintArea table th:nth-child(3),
  #boletaPrintArea table td:nth-child(3) {
    width: 33%;
  }

  /* Cabecera del comprobante: empresa arriba, periodo debajo */
  #boletaPrintArea > div:first-child {
    flex-direction: column;
    gap: 10px;
  }

  #boletaPrintArea > div:first-child > div:last-child {
    text-align: left !important;
  }

  #boletaPrintArea h2 {
    font-size: 1.05rem !important;
  }

  .modal .no-print-btn {
    padding: 14px 16px !important;
  }
}

/* ===== AVATAR COLORS ===== */
.av-indigo { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.av-purple { background: linear-gradient(135deg, #a78bfa, #8b5cf6); }
.av-blue { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.av-green { background: linear-gradient(135deg, #22c55e, #15803d); }
.av-amber { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.av-red { background: linear-gradient(135deg, #f87171, #ef4444); }
.av-pink { background: linear-gradient(135deg, #f472b6, #ec4899); }
.av-teal { background: linear-gradient(135deg, #2dd4bf, #14b8a6); }

/* ===== MISC ===== */
.section-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-muted { color: var(--text-muted); font-size: .82rem; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-700 { font-weight: 700; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state svg {
  width: 26px;
  height: 26px;
  margin: 0 auto 16px;
  display: block;
  color: var(--gray-400);
  padding: 15px;
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: 50%;
  box-sizing: content-box;
}
.empty-state p { font-size: .88rem; font-weight: 500; }

.progress-bar { height: 6px; background: var(--gray-100); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: var(--t); }

.tag { display: inline-flex; padding: 2px 8px; border-radius: var(--r-xs); font-size: .72rem; font-weight: 600; background: var(--gray-100); color: var(--gray-600); }

.info-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--gray-100); font-size: .85rem; }
.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--text-muted); width: 130px; flex-shrink: 0; font-size: .78rem; }
.info-row-value { font-weight: 500; }

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

/* ===== DROPDOWNS (NOTIFICACIONES Y AYUDA) ===== */
.dropdown-menu {
  position: absolute;
  top: 50px;
  right: 0;
  width: 320px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
  animation: slideDown 0.2s ease forwards;
}

.s-logo.s-logo-tc {
    background: #ffffff;
    overflow: hidden;
    padding: 4px;
}

.s-logo.s-logo-tc img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.dropdown-menu.show { display: flex; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-header { padding: 14px 16px; font-weight: 700; border-bottom: 1px solid var(--border); background: var(--gray-50); font-size: 0.85rem; color: var(--text-primary); }
.dropdown-body { max-height: 320px; overflow-y: auto; }
.notif-item { padding: 14px 16px; border-bottom: 1px solid var(--gray-100); display: flex; gap: 12px; align-items: flex-start; transition: var(--t); cursor: pointer; }
.notif-item:hover { background: var(--gray-50); }
.notif-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--warning-50); color: var(--warning); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-text { font-size: 0.82rem; color: var(--text-primary); line-height: 1.4; }
.notif-time { font-size: 0.72rem; color: var(--text-muted); margin-top: 5px; display: block; font-weight: 500; }

/* =========================================
   MODO IMPRESIÓN (PDF Y PAPEL) 🖨️
   ========================================= */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .sidebar, .app-header, .view-header-actions, button, .modal-overlay { display: none !important; }
  body, .app-layout { background: white !important; }
  .main-wrap { margin-left: 0 !important; width: 100% !important; min-height: auto !important; }
  .view-content { padding: 0 !important; }
  .card, .stat-card { box-shadow: none !important; border: 1px solid #cbd5e1 !important; break-inside: avoid; }
  .stats-grid { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; gap: 10px !important; }
  .grid-2 { display: grid !important; grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
}


/* =========================================
   🔥 RESPONSIVE DESIGN (MODO CELULAR) 📱 🔥
   ========================================= */

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}

@media (max-width: 768px) {
  /* 1. Mostrar el botón SOLO en celular */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    background: transparent;
  }

  /* 2. Ocultar sidebar por defecto (Empuja fuera de la pantalla) */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  
  /* Clase para abrir sidebar */
  .sidebar.open {
    transform: translateX(0);
  }

  /* 3. Quitar el margen en el contenido principal */
  .main-wrap {
    margin-left: 0 !important;
    width: 100% !important;
  }

  /* 4. Ajustes de la cabecera */
  .app-header {
    padding: 0 15px;
    justify-content: space-between;
  }
  
  .header-breadcrumb, .header-search, .h-user-name, .h-user-role {
    display: none; /* Esconde textos en la barra de arriba */
  }

  .company-switcher select {
    max-width: 90px;
  }

  /* 5. Ajustes de contenido general */
  .view-content {
    padding: 15px;
  }
  .view-header {
    flex-direction: column;
    gap: 15px;
  }
  .view-header-actions {
    width: 100%;
    justify-content: space-between;
  }

  /* 6. Apilar todo en 1 sola columna */
  .stats-grid,
  .grid-2, 
  .form-grid, 
  .form-grid-3,
  .reports-grid {
    grid-template-columns: 1fr !important;
  }

  /* 7. Barra de herramientas */
  .toolbar, .toolbar-left {
    flex-direction: column;
    align-items: stretch;
  }

  /* 8. Modales responsive */
  .modal {
    max-height: 95vh;
    border-radius: var(--r);
  }
  .modal-body {
    padding: 15px;
  }
  .modal-footer {
    flex-direction: column-reverse;
    gap: 10px;
  }
  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }

  /* 9. Menús Desplegables de Notificaciones */
  .dropdown-menu {
    position: fixed;
    top: 70px;
    right: 15px;
    left: 15px;
    width: auto;
  }
}