/* =============================================
   CSS VARIABLES
   ============================================= */
:root {
  --color-background-primary: #ffffff;
  --color-background-secondary: #f7f7f5;
  --color-background-tertiary: #efefed;
  --color-background-info: #eef4ff;
  --color-text-primary: #1c1c1a;
  --color-text-secondary: #6b6b67;
  --color-text-tertiary: #9b9b97;
  --color-text-danger: #a32d2d;
  --color-border-primary: #c8c8c4;
  --color-border-secondary: #ddddd9;
  --color-border-tertiary: #ebebea;
  --border-radius-sm: 4px;
  --border-radius-md: 6px;
  --border-radius-lg: 10px;
  --brand: #534AB7;
  --brand-dark: #3C3489;
  --brand-light: #EEEDFE;
}

/* =============================================
   RESET
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--color-background-secondary); color: var(--color-text-primary); font-size: 13px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* =============================================
   AUTH PAGES (login / register / suspended)
   ============================================= */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--color-background-secondary); padding: 16px; }
.auth-card { background: var(--color-background-primary); border: 0.5px solid var(--color-border-tertiary); border-radius: var(--border-radius-lg); padding: 32px; width: 100%; max-width: 400px; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.auth-logo-icon { width: 36px; height: 36px; background: var(--brand); border-radius: var(--border-radius-md); display: flex; align-items: center; justify-content: center; }
.auth-logo-icon svg { fill: #fff; width: 20px; height: 20px; }
.auth-logo-name { font-size: 15px; font-weight: 600; }
.auth-logo-sub { font-size: 11px; color: var(--color-text-tertiary); }
.auth-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.auth-sub { font-size: 12px; color: var(--color-text-secondary); margin-bottom: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field label { display: block; font-size: 11px; color: var(--color-text-secondary); margin-bottom: 4px; }
.auth-field input { width: 100%; padding: 8px 10px; font-size: 13px; border: 0.5px solid var(--color-border-secondary); border-radius: var(--border-radius-md); background: var(--color-background-primary); color: var(--color-text-primary); outline: none; }
.auth-field input:focus { border-color: var(--brand); }
.auth-btn { width: 100%; padding: 9px; background: var(--brand); color: #fff; border: none; border-radius: var(--border-radius-md); font-size: 13px; font-weight: 500; margin-top: 6px; }
.auth-btn:hover { background: var(--brand-dark); }
.auth-link { text-align: center; font-size: 12px; color: var(--color-text-secondary); margin-top: 16px; }
.auth-link a { color: var(--brand); font-weight: 500; }
.auth-error { background: #FCEBEB; color: #791F1F; border: 0.5px solid #F5C6C6; border-radius: var(--border-radius-md); padding: 8px 10px; font-size: 12px; display: none; }
.auth-error.show { display: block; }
.auth-trial-badge { background: var(--brand-light); color: var(--brand-dark); border-radius: var(--border-radius-md); padding: 8px 12px; font-size: 11px; margin-bottom: 18px; }

/* =============================================
   APP SHELL
   ============================================= */
#app-shell { display: none; }
.app { display: flex; min-height: 100vh; }
.sidebar { width: 190px; background: var(--color-background-primary); border-right: 0.5px solid var(--color-border-tertiary); display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0; overflow-y: auto; z-index: 10; }
.main { flex: 1; margin-left: 190px; overflow: auto; background: var(--color-background-primary); min-width: 0; }
.s-logo { padding: 14px 15px; border-bottom: 0.5px solid var(--color-border-tertiary); }
.s-logo-name { font-size: 13px; font-weight: 600; }
.s-logo-sub { font-size: 10px; color: var(--color-text-tertiary); margin-top: 1px; }
.s-sec { font-size: 10px; color: var(--color-text-tertiary); padding: 12px 15px 3px; text-transform: uppercase; letter-spacing: .06em; }
.nav-item { padding: 7px 15px; font-size: 12px; cursor: pointer; color: var(--color-text-secondary); border-left: 2px solid transparent; user-select: none; }
.nav-item:hover { background: var(--color-background-secondary); color: var(--color-text-primary); }
.nav-item.active { background: var(--color-background-secondary); color: var(--color-text-primary); border-left-color: var(--brand); }
.s-user { margin-top: auto; padding: 12px 15px; border-top: 0.5px solid var(--color-border-tertiary); display: flex; align-items: center; gap: 8px; }
.s-user-name { font-size: 11px; font-weight: 500; }
.s-user-role { font-size: 10px; color: var(--color-text-tertiary); }
.s-logout { font-size: 11px; color: var(--color-text-tertiary); cursor: pointer; margin-left: auto; }
.s-logout:hover { color: var(--color-text-danger); }

/* =============================================
   SECTIONS
   ============================================= */
.sec { display: none; }
.sec.active { display: block; }
.topbar { padding: 11px 18px; border-bottom: 0.5px solid var(--color-border-tertiary); display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; min-height: 50px; }
.tb-title { font-size: 14px; font-weight: 600; }
.tb-sub { font-size: 11px; color: var(--color-text-tertiary); }
.content { padding: 16px 18px; }

/* =============================================
   BUTTONS
   ============================================= */
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; font-size: 12px; border: 0.5px solid var(--color-border-secondary); border-radius: var(--border-radius-md); cursor: pointer; background: transparent; color: var(--color-text-primary); white-space: nowrap; }
.btn:hover { background: var(--color-background-secondary); }
.btn-p { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-p:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-s { padding: 4px 10px; font-size: 11px; }
.btn-ok { border-color: #0F6E56; color: #085041; }
.btn-ok:hover { background: #E1F5EE; }
.btn-no { border-color: #A32D2D; color: #791F1F; }
.btn-no:hover { background: #FCEBEB; }
.btn-danger { background: #FCEBEB; color: #791F1F; border-color: #F5C6C6; }
.btn-danger:hover { background: #F5C6C6; }

/* =============================================
   BADGES
   ============================================= */
.badge { display: inline-block; padding: 2px 7px; border-radius: 99px; font-size: 11px; font-weight: 500; }
.bp  { background: #EEEDFE; color: #3C3489; }
.bt  { background: #E1F5EE; color: #085041; }
.ba  { background: #FAEEDA; color: #633806; }
.bg  { background: #F1EFE8; color: #444441; }
.br  { background: #FCEBEB; color: #791F1F; }
.bbl { background: #E6F1FB; color: #0C447C; }

/* =============================================
   TABLE
   ============================================= */
.tbl { width: 100%; font-size: 12px; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 500; font-size: 11px; color: var(--color-text-secondary); padding: 6px 10px; border-bottom: 0.5px solid var(--color-border-tertiary); }
.tbl td { padding: 9px 10px; border-bottom: 0.5px solid var(--color-border-tertiary); color: var(--color-text-primary); font-size: 12px; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--color-background-secondary); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .total td { font-weight: 600; }

/* =============================================
   CARD
   ============================================= */
.card { background: var(--color-background-primary); border: 0.5px solid var(--color-border-tertiary); border-radius: var(--border-radius-lg); padding: 14px 16px; margin-bottom: 12px; }
.card-t { font-size: 13px; font-weight: 600; margin-bottom: 11px; }

/* =============================================
   AVATAR
   ============================================= */
.av { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; flex-shrink: 0; }
.av-lg { width: 36px; height: 36px; font-size: 12px; }
.avp { background: #EEEDFE; color: #3C3489; }
.avt { background: #E1F5EE; color: #085041; }
.ava { background: #FAEEDA; color: #633806; }
.avb { background: #E6F1FB; color: #0C447C; }
.avg { background: #F1EFE8; color: #444441; }

/* =============================================
   FORM
   ============================================= */
.fr { margin-bottom: 10px; }
.fl { display: block; font-size: 11px; color: var(--color-text-secondary); margin-bottom: 3px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=time], select, textarea {
  width: 100%; padding: 6px 9px; font-size: 12px; border: 0.5px solid var(--color-border-secondary);
  border-radius: var(--border-radius-md); background: var(--color-background-primary); color: var(--color-text-primary); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { resize: vertical; min-height: 54px; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.g4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }

/* =============================================
   TABS
   ============================================= */
.tabs { display: flex; border-bottom: 0.5px solid var(--color-border-tertiary); margin-bottom: 14px; }
.tab { padding: 7px 14px; font-size: 12px; cursor: pointer; color: var(--color-text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px; user-select: none; }
.tab:hover { color: var(--color-text-primary); }
.tab.active { color: var(--color-text-primary); border-bottom-color: var(--brand); font-weight: 500; }
.tab-c { display: none; }
.tab-c.active { display: block; }

/* =============================================
   METRICS
   ============================================= */
.metric { background: var(--color-background-secondary); border-radius: var(--border-radius-md); padding: 10px 12px; }
.metric-l { font-size: 10px; color: var(--color-text-secondary); margin-bottom: 3px; }
.metric-v { font-size: 20px; font-weight: 600; }

/* =============================================
   PROGRESS BAR
   ============================================= */
.prog-bar { height: 5px; background: var(--color-background-tertiary); border-radius: 3px; overflow: hidden; margin-top: 5px; }
.prog-fill { height: 100%; border-radius: 3px; background: var(--brand); }

/* =============================================
   TURNOS / CALENDAR
   ============================================= */
.view-btns { display: flex; border: 0.5px solid var(--color-border-secondary); border-radius: var(--border-radius-md); overflow: hidden; }
.vb { padding: 5px 13px; font-size: 11px; cursor: pointer; color: var(--color-text-secondary); background: transparent; border: none; user-select: none; }
.vb:hover { background: var(--color-background-secondary); }
.vb.active { background: var(--brand); color: #fff; }
.cal { width: 100%; border-collapse: collapse; font-size: 11px; }
.cal th { padding: 5px 3px; text-align: center; font-weight: 500; font-size: 10px; color: var(--color-text-secondary); border-bottom: 0.5px solid var(--color-border-tertiary); }
.cal td { padding: 3px; border: 0.5px solid var(--color-border-tertiary); vertical-align: top; min-width: 0; }
.cal td.today { background: var(--color-background-info); }
.cal td.weekend { background: var(--color-background-secondary); opacity: .75; }
.cal td.festivo { background: #FFF3CD; }
.shift { border-radius: 3px; padding: 2px 4px; font-size: 10px; margin-bottom: 2px; line-height: 1.3; cursor: pointer; }
.shift:hover { opacity: 0.8; }
.sh-p { background: #EEEDFE; color: #3C3489; }
.sh-t { background: #E1F5EE; color: #085041; }
.sh-a { background: #FAEEDA; color: #633806; }
.sh-v { background: #FCEBEB; color: #791F1F; }
.sh-f { background: #FFF3CD; color: #856404; }
.sh-n { background: #E6F1FB; color: #0C447C; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: 10px; align-items: center; }
.legend-dot { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }

/* =============================================
   VACACIONES BARS
   ============================================= */
.vac-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.vac-bar-wrap { flex: 1; background: var(--color-background-tertiary); border-radius: 3px; height: 16px; position: relative; overflow: hidden; }
.vac-seg { position: absolute; height: 100%; border-radius: 2px; display: flex; align-items: center; padding: 0 3px; font-size: 9px; }

/* =============================================
   NÓMINAS
   ============================================= */
.nom-row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 0.5px solid var(--color-border-tertiary); font-size: 12px; }
.nom-row.total { font-weight: 600; font-size: 13px; border-top: 1px solid var(--color-border-primary); border-bottom: none; padding-top: 8px; }
.nom-row.neg { color: var(--color-text-danger); }
.nom-row.result { font-size: 14px; font-weight: 600; color: var(--brand); padding-top: 6px; }
.nom-section { margin-bottom: 12px; }
.nom-section-t { font-size: 11px; font-weight: 600; color: var(--color-text-secondary); margin-bottom: 4px; }

/* =============================================
   PROYECTOS
   ============================================= */
.proj-item { border: 0.5px solid var(--color-border-tertiary); border-radius: var(--border-radius-md); padding: 10px 12px; margin-bottom: 9px; cursor: pointer; }
.proj-item:hover { background: var(--color-background-secondary); }

/* =============================================
   DOCUMENTOS
   ============================================= */
.emp-card { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 0.5px solid var(--color-border-tertiary); border-radius: var(--border-radius-md); cursor: pointer; margin-bottom: 6px; }
.emp-card:hover { background: var(--color-background-secondary); }
.emp-card.selected { border-color: var(--brand); background: var(--brand-light); }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 9px; margin-top: 10px; }
.folder-item { border: 0.5px solid var(--color-border-tertiary); border-radius: var(--border-radius-md); padding: 12px 10px; cursor: pointer; text-align: center; }
.folder-item:hover { background: var(--color-background-secondary); }
.folder-icon { width: 32px; height: 28px; margin: 0 auto 7px; position: relative; }
.folder-shape { width: 32px; height: 24px; background: #FAEEDA; border-radius: 3px; border: 0.5px solid #EF9F27; position: absolute; bottom: 0; }
.folder-tab { width: 14px; height: 7px; background: #FAEEDA; border: 0.5px solid #EF9F27; border-bottom: none; border-radius: 2px 2px 0 0; position: absolute; top: 0; left: 2px; }
.folder-name { font-size: 11px; }
.folder-count { font-size: 10px; color: var(--color-text-tertiary); margin-top: 2px; }

/* =============================================
   ROLES / PERMISSIONS
   ============================================= */
.perm-grid { display: grid; gap: 0; font-size: 12px; }
.perm-grid .ph { padding: 6px 0 4px; font-weight: 600; font-size: 11px; color: var(--color-text-secondary); text-align: center; }
.perm-grid .pl { padding: 7px 0; border-top: 0.5px solid var(--color-border-tertiary); }
.perm-grid .pc { padding: 7px 0; border-top: 0.5px solid var(--color-border-tertiary); text-align: center; }
.chk-box { width: 15px; height: 15px; border-radius: 3px; border: 0.5px solid var(--color-border-secondary); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 9px; user-select: none; }
.chk-box.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* =============================================
   TOGGLE
   ============================================= */
.toggle { width: 32px; height: 18px; border-radius: 99px; border: 0.5px solid var(--color-border-secondary); cursor: pointer; display: inline-flex; align-items: center; padding: 2px; background: var(--color-background-tertiary); }
.toggle.on { background: var(--brand); border-color: var(--brand); }
.toggle-dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle.on .toggle-dot { transform: translateX(14px); }

/* =============================================
   CHECK ROW (EPIs / Medical)
   ============================================= */
.check-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 0.5px solid var(--color-border-tertiary); font-size: 12px; }
.row { display: flex; gap: 7px; align-items: center; }

/* =============================================
   MODAL
   ============================================= */
#modal-root { display: none; position: fixed; inset: 0; z-index: 100; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--color-background-primary); border-radius: var(--border-radius-lg); border: 0.5px solid var(--color-border-tertiary); width: 100%; max-width: 460px; padding: 22px; max-height: 90vh; overflow-y: auto; }
.modal-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* =============================================
   TOAST
   ============================================= */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 14px; border-radius: var(--border-radius-md); font-size: 12px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,.12); animation: slideIn .2s ease; max-width: 320px; }
.toast-ok { background: #E1F5EE; color: #085041; border: 0.5px solid #0F6E56; }
.toast-err { background: #FCEBEB; color: #791F1F; border: 0.5px solid #A32D2D; }
.toast-info { background: var(--brand-light); color: var(--brand-dark); border: 0.5px solid var(--brand); }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* =============================================
   LOADING
   ============================================= */
#loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,.8); display: flex; align-items: center; justify-content: center; z-index: 300; }
.spinner { width: 28px; height: 28px; border: 2.5px solid var(--color-border-secondary); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================
   SUPERADMIN
   ============================================= */
.sa-page { min-height: 100vh; background: var(--color-background-secondary); }
.sa-header { background: var(--color-background-primary); border-bottom: 0.5px solid var(--color-border-tertiary); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; }
.sa-title { font-size: 14px; font-weight: 600; }
.sa-content { padding: 20px 24px; }
.sa-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-active { background: #1D9E75; }
.dot-trial { background: #EF9F27; }
.dot-suspended { background: #A32D2D; }

/* =============================================
   SUSPENDED PAGE
   ============================================= */
.suspended-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--color-background-secondary); padding: 16px; }
.suspended-card { background: var(--color-background-primary); border: 0.5px solid var(--color-border-tertiary); border-radius: var(--border-radius-lg); padding: 40px 32px; text-align: center; max-width: 420px; }
.suspended-icon { width: 48px; height: 48px; background: #FCEBEB; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; font-size: 22px; }

/* =============================================
   MISC UTILS
   ============================================= */
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary  { color: var(--color-text-tertiary); }
.text-danger    { color: var(--color-text-danger); }
.text-brand     { color: var(--brand); }
.fw500 { font-weight: 500; }
.fw600 { font-weight: 600; }
.fs10  { font-size: 10px; }
.fs11  { font-size: 11px; }
.fs12  { font-size: 12px; }
.fs13  { font-size: 13px; }
.mt4   { margin-top: 4px; }
.mt8   { margin-top: 8px; }
.mt12  { margin-top: 12px; }
.mb8   { margin-bottom: 8px; }
.mb12  { margin-bottom: 12px; }
.gap8  { gap: 8px; }
