/* ==========================================================
   ESCALAS PRO — Design System
   ========================================================== */
:root {
  --brand: #4f46e5;
  --brand-600: #4338ca;
  --brand-700: #3730a3;
  --brand-soft: #eef2ff;
  --accent: #06b6d4;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-2: #eef2f6;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;

  --success: #16a34a;
  --success-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #2563eb;
  --info-soft: #dbeafe;

  --shift-m: #f59e0b;
  --shift-t: #2563eb;
  --shift-n: #7c3aed;
  --off: #94a3b8;
  --vacation: #0ea5e9;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.12);
  --sidebar-w: 264px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0 0 .4em; line-height: 1.25; color: var(--ink); font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
small { color: var(--muted); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
  color: #c7d2fe;
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform .25s ease;
}
.sidebar__brand {
  padding: 20px 22px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar__brand .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--brand));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 4px 12px rgba(6,182,212,.4);
}
.sidebar__brand b { color: #fff; font-size: 1.05rem; letter-spacing: .3px; }
.sidebar__brand span { display: block; font-size: 11px; color: #a5b4fc; font-weight: 500; }
.nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.nav__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #818cf8; margin: 16px 12px 6px; font-weight: 700; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9.5px 12px; margin: 2px 0; border-radius: 10px;
  color: #c7d2fe; font-weight: 500; font-size: 14px;
  transition: all .15s; text-decoration: none;
}
.nav a svg { width: 18px; height: 18px; opacity: .85; flex-shrink: 0; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav a .badge-count {
  margin-left: auto; background: var(--accent); color: #04283a;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
}

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 62px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; position: sticky; top: 0; z-index: 30;
}
.topbar__title { font-weight: 700; font-size: 1.05rem; }
.topbar__spacer { flex: 1; }
.topbar__user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-700);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.hamburger { display: none; background: none; border: 0; cursor: pointer; padding: 6px; }
.content { padding: 24px; max-width: 1400px; width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card__head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 12px; }
.card__head h3 { margin: 0; }
.card__head .spacer { flex: 1; }
.card__body { padding: 20px; }
.card__body.tight { padding: 0; }

/* ---------- KPI grid ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi__icon {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 12px;
}
.kpi__icon svg { width: 21px; height: 21px; }
.kpi__value { font-size: 1.85rem; font-weight: 800; color: var(--ink); line-height: 1; }
.kpi__label { color: var(--muted); font-size: 13px; margin-top: 5px; font-weight: 500; }
.kpi--indigo .kpi__icon { background: var(--brand-soft); color: var(--brand); }
.kpi--cyan .kpi__icon { background: #cffafe; color: #0891b2; }
.kpi--green .kpi__icon { background: var(--success-soft); color: var(--success); }
.kpi--amber .kpi__icon { background: var(--warn-soft); color: var(--warn); }
.kpi--red .kpi__icon { background: var(--danger-soft); color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; transition: all .15s;
  background: var(--surface); color: var(--ink-2); border-color: var(--line);
  text-decoration: none; line-height: 1.2; white-space: nowrap;
}
.btn:hover { text-decoration: none; box-shadow: var(--shadow); transform: translateY(-1px); }
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn--primary:hover { background: var(--brand-600); }
.btn--accent { background: var(--accent); color: #04283a; border-color: var(--accent); }
.btn--success { background: var(--success); color: #fff; border-color: var(--success); }
.btn--danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--sm { padding: 6px 11px; font-size: 13px; }
.btn--icon { padding: 7px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input, .select, textarea, input[type=text], input[type=email], input[type=password],
input[type=date], input[type=time], input[type=number], input[type=color], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  background: var(--surface); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
input[type=color] { padding: 4px; height: 42px; }
textarea { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line-2); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; padding: 11px 16px; background: var(--surface-2);
  color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge--green { background: var(--success-soft); color: #15803d; }
.badge--amber { background: var(--warn-soft); color: #b45309; }
.badge--red { background: var(--danger-soft); color: #b91c1c; }
.badge--blue { background: var(--info-soft); color: #1d4ed8; }
.badge--gray { background: #f1f5f9; color: var(--muted); }
.badge--indigo { background: var(--brand-soft); color: var(--brand-700); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ---------- Alerts / flash ---------- */
.flash-stack { position: fixed; top: 74px; right: 24px; z-index: 60; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.flash {
  padding: 13px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  display: flex; align-items: flex-start; gap: 10px; font-size: 14px; font-weight: 500;
  animation: slideIn .3s ease; background: #fff; border-left: 4px solid;
}
.flash--success { border-color: var(--success); color: #14532d; }
.flash--error { border-color: var(--danger); color: #7f1d1d; }
.flash svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.flash button { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; padding: 0; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

.notice { padding: 14px 16px; border-radius: var(--radius-sm); font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.notice svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.notice--info { background: var(--info-soft); color: #1e40af; }
.notice--warn { background: var(--warn-soft); color: #92400e; }
.notice--danger { background: var(--danger-soft); color: #991b1b; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head__text h1 { margin: 0; }
.page-head__text p { margin: 3px 0 0; color: var(--muted); }
.page-head__actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Filters bar ---------- */
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filters .field { margin: 0; min-width: 150px; }

/* ---------- Schedule grid ---------- */
.schedule-scroll { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
table.schedule { border-collapse: collapse; font-size: 12.5px; width: 100%; }
table.schedule th, table.schedule td { border: 1px solid var(--line-2); text-align: center; }
table.schedule thead th { background: var(--surface-2); padding: 5px 4px; font-weight: 600; position: sticky; top: 0; z-index: 5; }
table.schedule th.emp-col, table.schedule td.emp-col {
  text-align: left; padding: 7px 12px; position: sticky; left: 0; background: #fff; z-index: 4;
  min-width: 190px; max-width: 190px; box-shadow: 2px 0 4px rgba(0,0,0,.03);
}
table.schedule thead th.emp-col { z-index: 6; background: var(--surface-2); }
table.schedule td.day-cell { width: 34px; min-width: 34px; height: 34px; padding: 0; cursor: pointer; font-weight: 700; user-select: none; position: relative; }
table.schedule td.day-cell:hover { outline: 2px solid var(--brand); outline-offset: -2px; z-index: 3; }
table.schedule th.weekend, table.schedule td.weekend { background: #f1f5f9; }
table.schedule th.sunday { color: var(--danger); }
.cell-M { background: #fef3c7; color: #92400e; }
.cell-T { background: #dbeafe; color: #1e40af; }
.cell-N { background: #ede9fe; color: #5b21b6; }
.cell-FOLGA { background: #f1f5f9; color: #94a3b8; }
.cell-FERIAS { background: #cffafe; color: #0e7490; }
.cell-ATESTADO { background: #fce7f3; color: #9d174d; }
.cell-FALTA { background: #fee2e2; color: #b91c1c; }
.cell-FERIADO { background: #dcfce7; color: #166534; }
.emp-sector { font-size: 11px; color: var(--muted); font-weight: 500; }
.emp-name { font-weight: 600; color: var(--ink); font-size: 13px; }
tr.coverage-row td { background: #0f172a; color: #cbd5e1; font-weight: 700; font-size: 11px; }
tr.coverage-row td.emp-col { background: #0f172a; color: #fff; }
tr.coverage-row td.over-limit { background: #7f1d1d; color: #fecaca; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); align-items: center; }
.legend .chip { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 15px; height: 15px; border-radius: 4px; border: 1px solid rgba(0,0,0,.08); }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-brand {
  background: linear-gradient(140deg, #312e81 0%, #4f46e5 60%, #06b6d4 130%);
  color: #fff; padding: 60px; display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}
.auth-brand::after {
  content: ""; position: absolute; width: 480px; height: 480px; border-radius: 50%;
  background: rgba(255,255,255,.06); right: -160px; bottom: -160px;
}
.auth-brand .logo-lg {
  width: 60px; height: 60px; border-radius: 16px; background: rgba(255,255,255,.15);
  display: grid; place-items: center; font-weight: 800; font-size: 28px; margin-bottom: 26px;
  backdrop-filter: blur(8px);
}
.auth-brand h1 { color: #fff; font-size: 2.1rem; max-width: 420px; }
.auth-brand p { color: #c7d2fe; font-size: 1.05rem; max-width: 420px; }
.auth-brand ul { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-direction: column; gap: 12px; }
.auth-brand li { display: flex; align-items: center; gap: 11px; color: #e0e7ff; font-weight: 500; }
.auth-brand li svg { width: 20px; height: 20px; color: #67e8f9; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 1.5rem; }
.auth-card > p { color: var(--muted); margin-bottom: 26px; }

/* ---------- Misc ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 240px; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.chart-box { position: relative; height: 300px; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state svg { width: 54px; height: 54px; color: var(--muted-2); margin-bottom: 14px; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
.pagination a, .pagination span {
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--ink-2); background: #fff;
}
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.avatar-lg { width: 64px; height: 64px; border-radius: 16px; background: var(--brand-soft); color: var(--brand-700); display: grid; place-items: center; font-weight: 800; font-size: 24px; }
dl.detail { display: grid; grid-template-columns: 160px 1fr; gap: 0; }
dl.detail dt { padding: 10px 0; color: var(--muted); font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--line-2); }
dl.detail dd { padding: 10px 0; margin: 0; border-bottom: 1px solid var(--line-2); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal__head { padding: 18px 22px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; }
.modal__head h3 { margin: 0; }
.modal__head button { margin-left: auto; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal__body { padding: 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .form-grid { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}
@media (max-width: 640px) {
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .page-head__actions { margin-left: 0; width: 100%; }
  .kpi__value { font-size: 1.5rem; }
  dl.detail { grid-template-columns: 1fr; }
  dl.detail dt { border-bottom: 0; padding-bottom: 0; }
}
.sidebar-backdrop { display: none; }
@media (max-width: 980px) {
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; }
}
