/* ═══ RESET & VARIABLES ═══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

:root {
  --bg: #f6f8fb;
  --panel: #fff;
  --panel-subtle: #fbfcfe;
  --ink: #111827;
  --muted: #667085;
  --line: #d8e0ec;
  --line-soft: #ebf0f7;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eaf2ff;
  --green: #159447;
  --green-soft: #e9f8ef;
  --red: #dc2626;
  --red-soft: #fff0f0;
  --orange: #d97706;
  --orange-soft: #fff6e5;
  --gray-soft: #f1f4f8;
  --shadow: 0 18px 44px rgba(17,24,39,.08);
  --shadow-sm: 0 6px 18px rgba(17,24,39,.06);
  --focus-ring: 0 0 0 3px rgba(37,99,235,.16);
  --radius: 8px;
  --header-h: 56px;
  --font: 'Inter', system-ui, sans-serif;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef4fb 0, var(--bg) 190px);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

/* ═══ LAYOUT ═══ */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

.nav-btn {
  height: 44px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s, transform .15s;
  padding: 0 10px;
}
.nav-btn:hover { background: var(--gray-soft); color: var(--ink); border-color: var(--line-soft); }
.nav-btn.active {
  background: #fff;
  color: var(--blue-dark);
  border-color: #c7d8fb;
  box-shadow: var(--shadow-sm);
}
.nav-label { font-size: 10px; font-weight: 500; line-height: 1; }

.header-nav { display: flex; align-items: center; gap: 2px; margin-left: 8px; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

/* ═══ HEADER ═══ */
.app-header {
  height: var(--header-h);
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(255,255,255,.7), 0 10px 30px rgba(17,24,39,.04);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.app-name { font-size: 16px; color: var(--muted); white-space: nowrap; font-weight: 600; letter-spacing: 0; }
.app-name strong { color: var(--ink); }
.header-center { flex: 1; }
.header-right { display: flex; align-items: center; gap: 8px; }

.month-year-picker { display: flex; gap: 6px; align-items: center; }
.month-year-picker select,
.month-year-picker input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 9px;
  font-size: 13px;
  font-family: var(--font);
  background: var(--panel-subtle);
  color: var(--ink);
  outline: none;
}
.month-year-picker input { width: 72px; }
.month-year-picker select:focus,
.month-year-picker input:focus { border-color: var(--blue); box-shadow: var(--focus-ring); }

/* ═══ PAGE AREA ═══ */
.page-area { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 22px; min-height: 0; }

/* visibilidade controlada por inline style via JS */
.schedule-daily-page { margin-top: 18px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.page-header h2 { font-size: 21px; font-weight: 750; letter-spacing: 0; }
.page-header h3 { font-size: 16px; font-weight: 600; }

/* ═══ CARDS ═══ */
.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  border: 1px solid var(--line-soft);
}
.card h3 { font-size: 13px; font-weight: 700; margin-bottom: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mt-16 { margin-top: 16px; }
.mt-8 { margin-top: 8px; }

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #f8fafc);
  color: var(--ink);
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s, transform .12s;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(255,255,255,.9), 0 1px 2px rgba(17,24,39,.04);
}
.btn:hover { background: var(--gray-soft); border-color: #c6d1df; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; border-color: var(--blue); box-shadow: var(--focus-ring); }
.btn.primary { background: linear-gradient(180deg, #3478f6, var(--blue)); color: #fff; border-color: var(--blue); box-shadow: 0 8px 18px rgba(37,99,235,.18); }
.btn.primary:hover { background: linear-gradient(180deg, #2563eb, var(--blue-dark)); }
.btn.success { background: var(--green); color: #fff; border-color: var(--green); }
.btn.success:hover { background: #15803d; }
.danger-btn { border-color: #f3b7b7; color: var(--red); background: #fffafa; }
.danger-btn:hover { background: var(--red-soft); }
.mode-toggle-btn { border-color: var(--orange); color: #92400e; }
.mode-toggle-btn.fixed-mode { background: var(--orange); color: #fff; border-color: var(--orange); }
.toggle-totals-btn.pinned { background: #1e3a8a; color: #fff; border-color: #1e3a8a; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.schedule-daily-page .btn-group {
  align-items: center;
  gap: 8px;
}
.btn-icon,
.title-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.title-icon {
  width: 18px;
  height: 18px;
  margin-right: 6px;
  vertical-align: -3px;
}
.inline-icon {
  width: 12px;
  height: 12px;
  display: inline-block;
  vertical-align: -2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.status-icon {
  width: 15px;
  height: 15px;
  display: inline-block;
  vertical-align: -3px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn {
  width: 32px;
  padding: 0;
  justify-content: center;
}

/* ═══ SETTINGS GRID ═══ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.settings-day-col { display: flex; flex-direction: column; gap: 6px; }
.settings-day-col .day-header {
  text-align: center;
  font-weight: 600;
  font-size: 12px;
  padding: 6px 4px;
  background: var(--blue-soft);
  border-radius: 6px;
  color: var(--blue-dark);
  border: 1px solid #cfe0ff;
}
.settings-day-col.weekend .day-header { background: var(--orange-soft); color: #92400e; border-color: #fed7aa; }
.settings-day-header-wrap { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.settings-day-header-wrap span { flex: 1; text-align: center; }
.copy-day-btn { font-size: 10px; padding: 1px 5px; height: auto; flex-shrink: 0; opacity: 0.75; }
.copy-day-btn:hover { opacity: 1; }
.copy-day-popover {
  position: fixed;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.14);
  z-index: 9999;
  min-width: 160px;
}
.copy-day-popover-title { font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em; }
.copy-day-popover-days { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.copy-day-check-lbl { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); cursor: pointer; }
.copy-day-check-lbl input { cursor: pointer; }
.copy-day-popover-actions { display: flex; gap: 6px; justify-content: flex-end; }
.settings-field { display: flex; flex-direction: column; gap: 2px; }
.settings-field label { font-size: 11px; color: var(--muted); }
.settings-field input[data-time-mask],
.settings-field input[type="number"] {
  width: 100%;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--font);
  background: var(--panel-subtle);
  color: var(--ink);
  outline: none;
}
.settings-field input:focus { border-color: var(--blue); box-shadow: var(--focus-ring); background: #fff; }
.settings-field.checkbox-field { flex-direction: row; align-items: center; gap: 6px; }
.settings-field.checkbox-field label { font-size: 12px; color: var(--ink); }
.settings-day-ranges {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line-soft);
}
.settings-day-ranges-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.settings-day-ranges-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.settings-day-ranges .weekly-range-row {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 0;
  border-bottom: 1px solid var(--line-soft);
}
.settings-day-ranges .weekly-range-row input[data-time-mask] {
  width: 52px;
  min-height: 26px;
  padding: 4px 5px;
  font-size: 12px;
}
.settings-day-ranges .icon-btn { padding: 2px 4px; height: 26px; }
.settings-movement-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.settings-movement-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.settings-movement-header h4 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}
.settings-movement-header .muted { margin-bottom: 0; }
.settings-movement-ranges {
  max-width: 520px;
}
.settings-empty-note {
  padding: 9px 10px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--panel-subtle);
  font-size: 12px;
}

.global-params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.param-field { display: flex; flex-direction: column; gap: 4px; }
.param-field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.param-field input, .param-field select {
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
  background: var(--panel-subtle);
  color: var(--ink);
  outline: none;
}
.param-field input:focus, .param-field select:focus { border-color: var(--blue); box-shadow: var(--focus-ring); background: #fff; }

/* ═══ TABLES ═══ */
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: #f8fafc;
  padding: 10px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:nth-child(even) td { background: #fafcff; }
.data-table tr:hover td { background: var(--blue-soft); }
.data-table input, .data-table select {
  width: 100%;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--font);
  background: transparent;
  color: var(--ink);
  outline: none;
  min-width: 60px;
}
.data-table input:focus, .data-table select:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: var(--focus-ring);
}
.data-table input[type="color"] { width: 36px; height: 28px; padding: 1px; cursor: pointer; border-radius: 4px; border: 1px solid var(--line); }
input[type="checkbox"] {
  accent-color: var(--blue);
}
.availability-cell {
  min-width: 238px;
  background: #f3f7ff !important;
}
.avail-checks {
  display: grid;
  grid-template-columns: repeat(7, minmax(26px, 1fr));
  gap: 6px;
  align-items: stretch;
  width: 100%;
}
.avail-day {
  min-height: 42px;
  display: grid;
  grid-template-rows: 18px 1fr;
  place-items: center;
  gap: 3px;
  padding: 4px 3px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #0f172a;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.avail-day:hover {
  background: #fff;
  border-color: #c7d8fb;
}
.avail-day input {
  width: 14px;
  height: 14px;
  min-width: 14px;
  padding: 0;
  margin: 0;
}
.avail-day span {
  display: block;
  white-space: nowrap;
}

/* ═══ IMPORT AREA ═══ */
.import-area {
  background: linear-gradient(180deg, #f2f7ff, var(--blue-soft));
  border: 1px dashed #94b8f8;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.import-area textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
  resize: vertical;
  background: #fff;
}
.real-import-period {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  margin: 8px 0 10px;
}
.real-import-period label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.real-import-period select,
.real-import-period input {
  height: 34px;
  min-width: 150px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: 500 13px/1 var(--font);
}
.real-import-period input {
  min-width: 90px;
  width: 96px;
}
.muted { color: var(--muted); font-size: 12px; margin-bottom: 8px; }

/* ═══ SCHEDULE TABLE ═══ */
.schedule-container { position: relative; }
.schedule-table-wrap {
  overflow: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  isolation: isolate;
}
.schedule-table { border-collapse: separate; border-spacing: 0; font-size: 12px; width: max-content; background: var(--panel); }
.schedule-table th, .schedule-table td {
  border: 1px solid var(--line);
  padding: 0;
  white-space: nowrap;
}
.sch-name-cell {
  position: sticky;
  left: 0;
  z-index: 18;
  background: var(--panel);
  padding: 5px 10px;
  font-weight: 500;
  min-width: 120px;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 2px solid #cbd5e1;
  box-shadow: 3px 0 10px rgba(17,24,39,.04);
  background-clip: padding-box;
}
.sch-day-header {
  text-align: center;
  padding: 3px 5px;
  font-size: 11px;
  min-width: 44px;
  background: var(--gray-soft);
  -webkit-user-select: none;
  user-select: none;
}
.sch-day-header.weekend { background: var(--orange-soft); border-left: 2px solid var(--orange); border-right: 2px solid var(--orange); }
.sch-day-header.extended-day-header.prev {
  background: #eef2f7;
  color: #64748b;
  box-shadow: inset 0 3px 0 #94a3b8;
}
.sch-day-header.extended-day-header.next {
  background: #ecfdf5;
  color: #047857;
  box-shadow: inset 0 3px 0 #10b981;
}
.sch-day-header .day-num { font-weight: 700; display: block; }
.sch-day-header .day-name { font-size: 10px; color: var(--muted); }
.sch-total-header {
  text-align: center;
  padding: 4px 5px;
  font-size: 10px;
  font-weight: 600;
  background: var(--gray-soft);
  min-width: 42px;
  width: 42px;
  max-width: 42px;
  z-index: 4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Group header row 1 */
.grp-hdr-trabalho {
  background: #f97316;
  color: #1a1a1a;
  font-size: 9px;
  letter-spacing: .06em;
  border-left: 3px solid #ea580c;
  border-bottom: 1px solid #c2410c;
}
.grp-hdr-folga {
  background: #dbeafe;
  color: #1e3a8a;
  font-size: 9px;
  letter-spacing: .06em;
  border-left: 3px solid #2563eb;
  border-bottom: 1px solid #93c5fd;
}
.grp-hdr-outros {
  background: #e5e7eb;
  color: #111827;
  font-size: 9px;
  letter-spacing: .06em;
  border-left: 3px solid #374151;
  border-bottom: 1px solid #9ca3af;
}
.grp-hdr-ferias {
  background: #fef3c7;
  color: #7c2d12;
  font-size: 9px;
  letter-spacing: .06em;
  border-left: 2px solid #374151;
  border-bottom: 1px solid #f59e0b;
}
/* Sub-header row 2 */
.sch-sub-hdr { font-size: 9px; font-weight: 700; }
.grp-col-trabalho.sch-sub-hdr { background: #fff3e0; border-left: 1px solid #fed7aa; }
.grp-col-folga.sch-sub-hdr    { background: #eff6ff; border-left: 1px solid #bfdbfe; }
.grp-col-outros.sch-sub-hdr   { background: #f3f4f6; border-left: 3px solid #9ca3af; }
.grp-col-ferias.sch-sub-hdr   { background: #fefce8; border-left: 3px solid #fde68a; }
/* ── Sticky header rows (always, vertical scroll) ── */
.sch-header-row th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #f8fafc;
  background-clip: padding-box;
}
.sch-subheader-row th {
  position: sticky;
  top: 22px;
  z-index: 19;
  background-clip: padding-box;
}
/* Split day header cells */
.sch-day-num-cell {
  font-weight: 700;
  font-size: 12px;
  height: 22px;
  line-height: 22px;
  padding: 0 3px;
}
.sch-day-name-cell {
  font-size: 10px;
  color: var(--muted);
  height: 20px;
  line-height: 20px;
  padding: 0 3px;
  font-weight: 400;
}
.sch-cell {
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  height: 30px;
  text-align: center;
  cursor: pointer;
  position: relative;
  font-size: 11px;
  font-weight: 600;
  transition: filter .1s, box-shadow .1s, transform .1s;
  -webkit-user-select: none;
  user-select: none;
}
.sch-cell:hover { filter: brightness(0.94); box-shadow: inset 0 0 0 2px rgba(17,24,39,.16); }
.sch-cell.weekend-cell { border-left: 2px solid var(--orange) !important; border-right: 2px solid var(--orange) !important; }
.sch-cell.extended-day-cell.prev {
  color: #475569 !important;
  border-left-color: #cbd5e1 !important;
  border-right-color: #cbd5e1 !important;
}
.sch-cell.extended-day-cell.next {
  border-left-color: #bbf7d0 !important;
  border-right-color: #bbf7d0 !important;
}
.sch-cell.extended-day-cell.readonly {
  cursor: default;
  opacity: .86;
}
.sch-cell.extended-day-cell.readonly:hover {
  filter: none;
  box-shadow: none;
}
.sch-cell.cell-selected { outline: 2px solid var(--blue) !important; outline-offset: -2px; filter: brightness(0.88); }
.sch-cell.drag-src  { opacity: .45; }
.sch-cell.drag-over-cell { outline: 2px dashed var(--blue); outline-offset: -2px; filter: brightness(0.88); }

/* Multi-select action bar */
.sel-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 12px; margin-bottom: 10px;
  background: #172554; border-radius: 8px; color: #fff;
  box-shadow: 0 10px 24px rgba(23,37,84,.18);
}
.sel-count { font-size: 13px; font-weight: 700; flex-shrink: 0; }
.sel-apply-btn { background: #fff; color: #1e3a8a; font-weight: 700; }
.sel-apply-btn:hover { background: #e0e7ff; }
.sel-del-btn { background: var(--red); color: #fff; border-color: transparent; }
.sel-del-btn:hover { background: #b91c1c; }
.sel-clear-btn { background: transparent; color: #93c5fd; border-color: #93c5fd; }
.sel-clear-btn:hover { color: #fff; border-color: #fff; }
.sch-cell.locked { box-shadow: inset 0 0 0 2px var(--blue); }
.sch-cell .lock-icon {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  opacity: .72;
}
.sch-cell .lock-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sch-cell .consec-warn-flag {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 8px 0 0;
  border-color: #ef4444 transparent transparent transparent;
  pointer-events: none;
}
.sch-cell .consec-warn-flag[title] { pointer-events: auto; cursor: help; }
.sch-total-cell {
  text-align: center;
  padding: 2px 3px;
  font-size: 11px;
  font-weight: 600;
  z-index: 8;
  min-width: 42px;
  width: 42px;
  max-width: 42px;
  overflow: hidden;
  background-clip: padding-box;
}
/* ── Sticky totals (right axis) — only when .totals-fixed ── */
/* right value is delivered via --tot-right CSS custom property set in JS */
.totals-fixed .sch-total-header  {
  position: sticky;
  right: var(--tot-right, auto);
  z-index: 24;
  background-clip: padding-box;
}
.totals-fixed .sch-sub-hdr {
  position: sticky;
  right: var(--tot-right, auto);
  z-index: 23;
  background-clip: padding-box;
}
.totals-fixed .sch-total-cell {
  position: sticky;
  right: var(--tot-right, auto);
  z-index: 12;
  background-clip: padding-box;
}
/* Visual hint when pinned */
.totals-fixed .grp-col-first.grp-col-trabalho { box-shadow: -6px 0 10px rgba(17,24,39,.12); }
.totals-fixed .sch-total-header,
.totals-fixed .sch-sub-hdr,
.totals-fixed .sch-total-cell {
  border-left-color: rgba(100,116,139,.32);
}
.totals-fixed .grp-col-first {
  box-shadow: -5px 0 0 #fff, -7px 0 12px rgba(17,24,39,.12);
}
/* Cell group tints */
.grp-col-trabalho { background-color: #fff7ed; }
.grp-col-folga    { background-color: #eff6ff; }
.grp-col-outros   { background-color: #f3f4f6; }
.grp-col-ferias   { background-color: #fefce8; }
.sch-total-header.grp-col-trabalho,
.sch-total-cell.grp-col-trabalho { color: #7c2d12; }
.sch-total-header.grp-col-folga,
.sch-total-cell.grp-col-folga { color: #1e3a8a; }
.sch-total-header.grp-col-outros,
.sch-total-cell.grp-col-outros { color: #111827; }
.sch-total-header.grp-col-ferias,
.sch-total-cell.grp-col-ferias { color: #7c2d12; }
/* First column of each group gets a strong left separator */
.grp-col-first.grp-col-trabalho { border-left: 3px solid #f97316 !important; }
.grp-col-first.grp-col-folga    { border-left: 3px solid #3b82f6 !important; }
.grp-col-first.grp-col-outros   { border-left: 3px solid #6b7280 !important; }
.grp-col-first.grp-col-ferias   { border-left: 3px solid #ca8a04 !important; }

.total-ok   { color: var(--green)  !important; font-weight: 700; }
.total-warn { color: #fff          !important; font-weight: 700; background: #ef4444 !important; border-radius: 3px; }
.total-over { color: #fff          !important; font-weight: 700; background: #ef4444 !important; border-radius: 3px; }
.total-ferias { color: #b45309; font-weight: 700; }

.sch-header-row th:first-child {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 40;
  background: #f8fafc;
  background-clip: padding-box;
}
.sch-name-header {
  position: sticky !important;
  left: 0 !important;
  top: 0 !important;
  z-index: 40 !important;
  min-width: 130px;
  max-width: 160px;
  padding: 4px 10px;
  font-size: 12px;
  background: #f8fafc !important;
  border-right: 2px solid #cbd5e1 !important;
  box-shadow: 5px 0 12px rgba(17,24,39,.08);
  background-clip: padding-box;
}
.sch-subheader-row th:first-child {
  position: sticky;
  left: 0;
  z-index: 39;
  background: #f8fafc;
  background-clip: padding-box;
}
.schedule-table tbody .sch-name-cell {
  left: 0;
  z-index: 16;
}
.coverage-row td { background: var(--panel); font-size: 10px; text-align: center; padding: 2px; }
.coverage-ok { background: var(--green-soft) !important; color: var(--green); font-weight: 600; }
.coverage-bad { background: var(--red-soft) !important; color: var(--red); font-weight: 600; }

/* ═══ TOOLBAR ═══ */
.toolbar { background: rgba(255,255,255,.92); border-radius: var(--radius); border: 1px solid var(--line-soft); padding: 8px 12px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm); }
.toolbar-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar-row .btn {
  flex: 0 1 150px;
  min-width: 0;
  justify-content: center;
  padding-left: 10px;
  padding-right: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
}
.toolbar-row .btn .btn-icon { flex-shrink: 0; }
.toolbar-row .mode-toggle-btn,
.toolbar-row .danger-btn {
  min-width: 0;
}
.toolbar-row #fillPreferredBtn { flex: 0 1 260px; }
.toolbar-row #validateBtn { flex-basis: 142px; }
.toolbar-row #toggleTotalsBtn,
.toolbar-row #toggleExtendedBtn { flex-basis: 132px; }
.toolbar-row #saveBtn { flex-basis: 104px; }
.toolbar-row #clearAllBtn,
.toolbar-row #undoBtn { flex-basis: 116px; }
.toolbar-row #fdsBtn { flex-basis: 150px; }
.toolbar-icon-only {
  width: 40px;
  flex: 0 0 40px !important;
  padding: 0;
}
.toolbar-icon-only .btn-icon {
  width: 17px;
  height: 17px;
}
.toolbar-row #toggleExtendedBtn.active {
  background: #065f46;
  border-color: #065f46;
  color: #fff;
}
.toolbar-sep { display: none; }

@media (min-width: 1500px) {
  .toolbar {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    overflow: hidden;
  }
  .toolbar-row {
    display: contents;
  }
  .toolbar-row .btn {
    width: auto;
    flex: 0 0 auto;
    min-width: 0;
  }
  .toolbar-row .btn.toolbar-icon-only {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
  }
  .toolbar-row #modeToggleBtn { width: 150px; }
  .toolbar-row #fillPreferredBtn { width: 256px; }
  .toolbar-row #clearEmptyBtn { width: 150px; }
  .toolbar-row #fdsBtn { width: 150px; }
  .toolbar-row #undoBtn { width: 118px; }
  .toolbar-row #validateBtn { width: 152px; }
  .toolbar-row #copyScheduleBtn { width: 132px; }
  .toolbar-row #openDailyBtn { width: 142px; }
  .toolbar-row #toggleTotalsBtn { width: 138px; }
  .toolbar-row #toggleExtendedBtn { width: 124px; }
}

/* ═══ FILTERS ═══ */
.filters-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.schedule-header-filters {
  flex: 1;
  justify-content: flex-end;
  margin-bottom: 0;
  min-width: 520px;
}
.schedule-header-filters .filter-input {
  min-width: 220px;
}
.schedule-header-filters .filter-select {
  min-width: 190px;
}
.filter-input, .filter-select {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font);
  background: var(--panel);
  color: var(--ink);
  outline: none;
}
.filter-input { min-width: 180px; }
.filter-input:focus, .filter-select:focus { border-color: var(--blue); box-shadow: var(--focus-ring); }

/* ═══ ISSUES PANEL ═══ */
.issues-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 340px;
  max-height: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 200;
}
.issues-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--orange-soft); }
.issues-title-wrap { display: flex; align-items: center; gap: 8px; }
.issues-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.issues-badge.hidden { display: none; }
.issues-panel ul { overflow-y: auto; padding: 10px 14px; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.issues-panel ul li { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--ink); padding: 6px 8px; background: var(--red-soft); border-radius: 4px; border-left: 3px solid var(--red); }
.issues-panel ul li .issue-num { min-width: 18px; font-weight: 700; color: #b91c1c; font-size: 11px; flex-shrink: 0; }

/* ═══ POPUP ═══ */
.popup-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.42);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.popup {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 30px 70px rgba(15,23,42,.24);
  width: 440px;
  max-width: 96vw;
  overflow: visible;
  border: 1px solid rgba(255,255,255,.72);
}
#shiftPopup {
  width: min(920px, 96vw);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}
.popup-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
  border-radius: 12px 12px 0 0;
  background: var(--panel);
  overflow: hidden;
}
.popup-header span { font-weight: 700; font-size: 15px; line-height: 1.3; flex: 1; padding-right: 10px; }
.popup-close {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  border-radius: 6px;
}
.popup-close:hover { color: var(--ink); }
.popup-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; overflow-y: auto; }
.popup-footer { display: flex; gap: 8px; padding: 13px 18px; border-top: 1px solid var(--line-soft); background: #f8fafc; flex-wrap: wrap; border-radius: 0 0 12px 12px; overflow: hidden; }

.popup-info-message {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(207,47,47,.28);
  background: rgba(255,246,246,.94);
  color: #641616;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.popup-info-info {
  border-color: rgba(10,109,240,.24);
  background: rgba(246,250,255,.94);
  color: #17375f;
}

/* Current code card */
.popup-current-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  background: var(--panel-subtle);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pcc-top { font-size: 13px; font-weight: 600; color: var(--ink); }
.pcc-detail { font-size: 12px; color: var(--muted); }
.pcc-note { font-size: 12px; color: var(--muted); font-style: italic; }

/* Chooser label */
.popup-chooser-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* Custom code select */
.popup-cselect-wrap { position: relative; }
.pcs-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-subtle);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  outline: none;
  gap: 8px;
}
.pcs-trigger:hover { border-color: var(--blue); }
.pcs-trigger:focus { border-color: var(--blue); box-shadow: var(--focus-ring); background: #fff; }
.pcs-trigger-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcs-chevron { color: var(--muted); flex-shrink: 0; transition: transform .15s; display: inline-flex; }
.pcs-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15,23,42,.14);
  max-height: 260px;
  overflow-y: auto;
  z-index: 600;
}
.pcs-dropdown.pcs-open { display: block; }
.pcs-dropdown.pcs-drop-up { top: auto; bottom: calc(100% + 4px); }
.pcs-option {
  padding: 7px 12px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid rgba(0,0,0,.04);
}
.pcs-option:hover { filter: brightness(0.92); }
.pcs-option.pcs-selected { font-weight: 700; box-shadow: inset 3px 0 0 var(--blue); }

/* Quick buttons */
#popupQuickBtns { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 2px solid transparent;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: filter .15s, border-color .15s;
  background: var(--gray-soft);
  color: var(--ink);
}
.quick-btn:hover { filter: brightness(0.9); }
.quick-btn.quick-btn-active { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.2); }

.popup-compatible-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 0 8px;
  flex-wrap: wrap;
}
.popup-compatible-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.compatible-search {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}
.compatible-search label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.compatible-search input {
  width: 72px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: 600 12px/1 var(--font);
}
.compatible-search input::placeholder { color: var(--muted); font-weight: 400; }
.compatible-search-clear {
  height: 30px;
  min-height: 30px;
  padding: 0 9px;
}
.compatible-code-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding: 2px 2px 4px;
}
.compatible-code-btn {
  min-height: 62px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  gap: 2px 8px;
  align-items: center;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--code-bg, var(--blue));
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(17,24,39,.04);
}
.compatible-code-btn:hover {
  border-color: #b8c8dd;
  background: var(--blue-soft);
}
.compatible-code-btn.compatible-code-active {
  box-shadow: 0 0 0 3px rgba(37,99,235,.16);
  border-color: var(--blue);
}
.compatible-code-btn.compatible-code-nearest {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22,163,74,.16);
}
.compatible-code-main {
  grid-row: 1 / 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 34px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--code-bg, var(--blue));
  color: var(--code-fg, #fff);
  font-size: 12px;
  font-weight: 800;
}
.compatible-code-time {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compatible-code-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compatible-code-badge {
  grid-column: 2;
  justify-self: start;
  margin-top: 2px;
  padding: 2px 5px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
}

@media (max-width: 560px) {
  #shiftPopup {
    width: 96vw;
  }
  .compatible-code-grid {
    grid-template-columns: 1fr;
  }
}

/* Help button & popup */
.help-btn {
  width: 32px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}
.help-btn .btn-icon {
  width: 17px;
  height: 17px;
}
.help-popup { width: 460px; max-width: 96vw; overflow: visible; }
.help-popup-body { gap: 18px; }
.help-section { display: flex; flex-direction: column; gap: 6px; }
.help-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.help-table { width: 100%; border-collapse: collapse; }
.help-table tr + tr td { border-top: 1px solid var(--line); }
.help-table td { padding: 6px 4px; font-size: 13px; vertical-align: middle; }
.help-key { white-space: nowrap; width: 1%; padding-right: 14px; }
kbd {
  display: inline-block;
  padding: 2px 7px;
  font-size: 11px;
  font-family: var(--font);
  font-weight: 600;
  background: var(--gray-soft);
  border: 1px solid #cbd5e1;
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--ink);
  white-space: nowrap;
}

/* ═══ TOAST ═══ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: #0f172a;
  color: #fff;
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
  box-shadow: 0 16px 36px rgba(15,23,42,.24);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ═══ DAILY MAP ═══ */
.daily-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; align-items: center; }
.daily-subtitle { margin: -8px 0 12px; font-size: 13px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 4px 7px; border: 1px solid var(--line-soft); border-radius: 999px; background: var(--panel); }
.legend-swatch { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(17,24,39,.12); }
.legend-line-swatch {
  width: 5px;
  min-width: 5px;
  height: 18px;
  border-radius: 999px;
}
.legend-mismatch-swatch {
  width: 22px;
  border: 2px dashed var(--red);
  box-shadow: none;
}
.legend-off-swatch {
  background:
    linear-gradient(135deg, rgba(37,99,235,.09), rgba(22,163,74,.08)),
    repeating-linear-gradient(135deg, rgba(37,99,235,.18) 0 6px, transparent 6px 12px) !important;
  border: 1px solid rgba(37,99,235,.24);
}

.daily-map-wrap { overflow: auto; background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.daily-map { min-width: 900px; padding: 0; }

.segmented-control {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--gray-soft);
}
.segment-btn {
  height: 28px;
  min-height: 28px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: 600 12px/1 var(--font);
  cursor: pointer;
}
.segment-btn.active {
  background: var(--panel);
  color: var(--blue);
  box-shadow: 0 1px 4px rgba(22,32,51,.12);
}

.daily-time-header { display: flex; border-bottom: 2px solid var(--line); background: var(--gray-soft); }
.daily-time-header .dh-name { width: 130px; min-width: 130px; padding: 6px 10px; font-size: 11px; color: var(--muted); font-weight: 600; border-right: 1px solid var(--line); flex-shrink: 0; }
.daily-time-header .dh-slots { display: flex; flex: 1; }
.time-slot-label { flex: 1; text-align: center; font-size: 10px; color: var(--muted); padding: 4px 0; border-right: 1px solid var(--line); }
.time-slot-label.hour-mark { font-weight: 700; color: var(--ink); border-right: 1px solid var(--muted); }

.daily-row { display: flex; border-bottom: 1px solid var(--line); min-height: 38px; position: relative; align-items: center; }
.daily-row:hover { background: #fafcff; }
.daily-row .dr-name { width: 130px; min-width: 130px; padding: 4px 10px; font-size: 12px; font-weight: 500; border-right: 1px solid var(--line); flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.daily-row .dr-slots { flex: 1; position: relative; height: 38px; }
.daily-row.daily-off-row .dr-name {
  color: #475569;
  background: rgba(37,99,235,.045);
}
.daily-off-indicator {
  position: absolute;
  inset: 5px 8px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 12px;
  border: 1px solid rgba(37,99,235,.18);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(37,99,235,.055), rgba(22,163,74,.045)),
    repeating-linear-gradient(135deg, rgba(37,99,235,.09) 0 8px, transparent 8px 16px);
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  pointer-events: none;
  z-index: 1;
}

.movement-range-band {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(251, 191, 36, 0.18);
  border-left: 2px solid rgba(245, 158, 11, 0.5);
  border-right: 2px solid rgba(245, 158, 11, 0.5);
  pointer-events: none;
  z-index: 0;
}
.dh-hour-group.movement-range-hour {
  background: rgba(251, 191, 36, 0.22) !important;
  color: #92400e;
  font-weight: 700;
}
.shift-bar {
  position: absolute;
  top: 5px;
  height: 28px;
  z-index: 1;
  border-radius: 6px;
  cursor: grab;
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
  transition: box-shadow .15s;
  -webkit-user-select: none;
  user-select: none;
}
.shift-bar:hover { box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.reduction-marker {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  background: repeating-linear-gradient(-45deg, rgba(0,0,0,0.22) 0, rgba(0,0,0,0.22) 3px, transparent 3px, transparent 7px);
  border-left: 2px dashed rgba(0,0,0,0.4);
  pointer-events: none;
  border-radius: 0 4px 4px 0;
}
.shift-bar:active { cursor: grabbing; }
.shift-bar.group-mismatch {
  outline: 2px dashed var(--red);
  outline-offset: 2px;
}
.allowed-start-guide {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 4px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22,163,74,.16);
  pointer-events: none;
  z-index: 4;
}
.allowed-start-guide.active {
  width: 5px;
  box-shadow: 0 0 0 4px rgba(37,99,235,.18);
}
.allowed-start-guide.warning {
  opacity: .45;
}
.allowed-start-guide.warning.active {
  opacity: 1;
}
.allowed-start-guide.multi-code {
  width: 4px;
  background: linear-gradient(to bottom, var(--blue), var(--green));
}
.allowed-start-guide.multi-code.active {
  width: 6px;
  box-shadow: 0 0 0 5px rgba(37,99,235,.22);
}
.guide-alt-badge {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--blue);
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  padding: 1px 3px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1.4;
}
.drag-time-tooltip {
  position: absolute;
  top: -31px;
  transform: translateX(-50%);
  z-index: 8;
  padding: 5px 8px;
  border-radius: 6px;
  background: #0f172a;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 8px 18px rgba(15,23,42,.22);
}
.drag-time-tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #0f172a;
}

.contract-window {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(37,99,235,.06);
  border-left: 1px dashed rgba(37,99,235,.3);
  border-right: 1px dashed rgba(37,99,235,.3);
  pointer-events: none;
}
.anchor-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  transform: translateX(-1px);
  border-radius: 999px;
  background: var(--green);
  opacity: .95;
  box-shadow: 0 0 0 2px rgba(22,163,74,.14);
  pointer-events: none;
  z-index: 3;
}
.min-start-line,
.max-end-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  transform: translateX(-1px);
  border-radius: 999px;
  pointer-events: none;
  z-index: 3;
}
.min-start-line {
  background: var(--blue);
  opacity: .95;
  box-shadow: 0 0 0 2px rgba(37,99,235,.16);
}
.max-end-line {
  background: var(--red);
  opacity: .95;
  box-shadow: 0 0 0 2px rgba(220,38,38,.14);
}
.rest-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(220,38,38,.07);
  pointer-events: none;
}

.coverage-map-row { display: flex; border-bottom: 1px solid var(--line); background: #f8fafc; }
.coverage-map-row .dr-name { width: 130px; min-width: 130px; padding: 4px 10px; font-size: 10px; font-weight: 600; color: var(--muted); border-right: 1px solid var(--line); flex-shrink: 0; display: flex; align-items: center; }
.coverage-map-row .dr-slots { flex: 1; display: flex; height: 22px; }
.cov-slot {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  border-right: 1px solid var(--line);
}
.cov-slot.cov-ok { background: rgba(22,163,74,.12); color: var(--green); }
.cov-slot.cov-bad { background: rgba(220,38,38,.12); color: var(--red); }

/* ── Horizontal header: 2-row (hour groups + minutes) ── */
.daily-time-header.dh-two-row { align-items: stretch; }
.daily-time-header.dh-two-row .dh-name {
  display: flex; align-items: center; justify-content: center;
  text-align: center; line-height: 1.3;
}
.dh-slots-col { display: flex; flex-direction: column; }
.dh-hours-row { display: flex; border-bottom: 1px solid var(--line); }
.dh-hour-group {
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: var(--ink);
  border-right: 1px solid var(--muted); flex-shrink: 0; padding: 5px 0;
}
.dh-hour-group.dh-hour-even { background: #eef2ff; }
.dh-hour-group.dh-hour-odd  { background: var(--gray-soft); }
.dh-mins-row { display: flex; }
.dh-min-slot {
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 500; color: var(--muted);
  border-right: 1px solid var(--line); flex-shrink: 0; padding: 3px 0;
}
.dh-min-slot.dh-min-zero { font-weight: 700; color: var(--ink); border-right: 1px solid var(--muted); }

/* ── Vertical mode: column-per-person layout ── */
.daily-vertical-wrap { background: #fffaf0; }
.daily-map-vertical  { width: 100%; background: var(--panel); }

.dv-container { display: flex; flex-direction: row; min-width: max-content; }

.dv-time-col {
  position: sticky; left: 0; z-index: 3; flex-shrink: 0;
  background: var(--gray-soft); border-right: 2px solid var(--line);
}
.dv-date-cell {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid var(--line); padding: 4px; text-align: center;
}
.dv-time-lbl {
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 6px; font-size: 9px; color: var(--muted);
  border-bottom: 1px solid var(--line); box-sizing: border-box;
}
.dv-time-lbl.dv-hour {
  font-size: 10px; font-weight: 700; color: var(--ink);
  border-bottom: 1px solid var(--muted);
}
.dv-time-lbl.movement-range-lbl {
  background: rgba(251, 191, 36, 0.2);
  color: #92400e !important;
  font-weight: 700 !important;
}
.movement-range-band-v {
  position: absolute;
  left: 0;
  width: 100%;
  background: rgba(251, 191, 36, 0.18);
  border-top: 2px solid rgba(245, 158, 11, 0.5);
  border-bottom: 2px solid rgba(245, 158, 11, 0.5);
  pointer-events: none;
  z-index: 0;
}

.dv-person-col { flex-shrink: 0; border-right: 1px solid var(--line); }
.dv-person-col.dv-off-col .dv-person-hdr {
  color: #475569;
  background: rgba(37,99,235,.06);
}
.dv-person-hdr {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500; padding: 4px; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-bottom: 2px solid var(--line); background: var(--gray-soft);
  position: sticky; top: 0; z-index: 1;
}

.dv-slot-area { position: relative; }
.dv-off-indicator {
  position: absolute;
  inset: 6px 5px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8px;
  border: 1px solid rgba(37,99,235,.18);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(37,99,235,.055), rgba(22,163,74,.045)),
    repeating-linear-gradient(135deg, rgba(37,99,235,.09) 0 8px, transparent 8px 16px);
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  pointer-events: none;
  z-index: 1;
}
.dv-grid-line {
  position: absolute; left: 0; right: 0;
  border-bottom: 1px solid var(--line); box-sizing: border-box;
}
.dv-grid-hour { border-bottom: 1px solid var(--muted); }

.dv-rest-band {
  position: absolute; top: 0; left: 0; right: 0; pointer-events: none;
  background-image: repeating-linear-gradient(135deg, rgba(220,38,38,.08), rgba(220,38,38,.08) 4px, transparent 4px, transparent 8px);
}
.dv-contract-window {
  position: absolute; left: 0; right: 0; pointer-events: none;
  background: rgba(96,165,250,.1);
}
.dv-anchor-line {
  position: absolute; left: 0; right: 0; height: 3px; pointer-events: none;
  transform: translateY(-1px);
  border-radius: 999px;
  background: var(--green); opacity: .95;
  box-shadow: 0 0 0 2px rgba(22,163,74,.14);
  z-index: 3;
}
.dv-limit-line {
  position: absolute; left: 0; right: 0; height: 3px; pointer-events: none;
  transform: translateY(-1px);
  border-radius: 999px;
  opacity: .95;
  z-index: 3;
}
.dv-min-start-line {
  background: var(--blue);
  box-shadow: 0 0 0 2px rgba(37,99,235,.16);
}
.dv-max-end-line {
  background: var(--red);
  box-shadow: 0 0 0 2px rgba(220,38,38,.14);
}
.dv-shift-bar {
  position: absolute; left: 4px; right: 4px;
  border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 4px; overflow: hidden; cursor: grab;
  box-shadow: 0 1px 4px rgba(0,0,0,.15); -webkit-user-select: none; user-select: none;
}
.dv-bar-name { font-size: 9px; font-weight: 500; opacity: .8; line-height: 1.2; text-align: center; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 3px; }
.dv-bar-code { font-size: 11px; font-weight: 700; line-height: 1.2; text-align: center; }
.dv-shift-bar:hover { box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.dv-reduction-marker {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: repeating-linear-gradient(-45deg, rgba(0,0,0,0.22) 0, rgba(0,0,0,0.22) 3px, transparent 3px, transparent 7px);
  border-top: 2px dashed rgba(0,0,0,0.4);
  pointer-events: none;
  border-radius: 0 0 4px 4px;
}
.dv-shift-bar:active { cursor: grabbing; }
.dv-shift-bar.dv-group-mismatch { outline: 2px dashed var(--red); outline-offset: 2px; }

.dv-count-col {
  position: sticky; right: 0; z-index: 3; flex-shrink: 0;
  border-left: 2px solid var(--line); background: #f8fafc;
}
.dv-count-cell {
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700;
  border-bottom: 1px solid var(--line); box-sizing: border-box;
}
.dv-count-cell.cov-ok  { background: rgba(22,163,74,.12); color: var(--green); }
.dv-count-cell.cov-bad { background: rgba(220,38,38,.12); color: var(--red); }

/* ── Folga Dupla FDS modal ── */
.fds-popup {
  max-width: 1120px;
  width: 96vw;
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
}
.fds-popup-body {
  display: grid;
  grid-template-columns: minmax(300px, .9fr) minmax(520px, 1.35fr);
  gap: 14px;
  overflow: auto;
}
.fds-popup-body .popup-info {
  grid-column: 1 / -1;
}
.fds-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-subtle);
  min-width: 0;
}
.fds-section-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 10px;
}
.fds-count-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fds-count-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.fds-count-input {
  width: 64px; padding: 4px 8px; text-align: center;
  border: 1px solid var(--line); border-radius: 6px;
  font-size: 14px; font-weight: 700; font-family: var(--font);
}
.fds-suggestion-note { font-size: 11px; color: var(--muted); }
.fds-preview {
  max-height: 420px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; background: var(--gray-soft);
  font-size: 12px; line-height: 1.7;
}
.fds-week { display: flex; gap: 6px; align-items: baseline; padding: 3px 0; border-bottom: 1px solid var(--line); }
.fds-week:last-child { border-bottom: none; }
.fds-week-label { font-weight: 700; color: var(--ink); min-width: 90px; flex-shrink: 0; }
.fds-week-people { color: var(--muted); flex: 1; }
.fds-week-locked { font-size: 10px; color: var(--red); margin-left: 4px; }
.fds-section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.weekend-worker-fill {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(31,42,55,.14);
}

.weekend-worker-fields {
  display: grid;
  grid-template-columns: minmax(180px, 1fr);
  gap: 10px;
}

.weekend-worker-summary {
  min-height: 32px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(31,42,55,.14);
  background: linear-gradient(180deg, rgba(255,255,255,.68), rgba(255,255,255,.38));
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.weekly-config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 10px;
}
.weekly-config-grid--mt { margin-top: 8px; }
.weekly-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.weekly-field input,
.weekly-field select,
.weekly-peak-day input[type="number"],
.weekly-range-row input {
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: 500 13px/1 var(--font);
}
.weekly-overwrite {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.weekly-subtitle {
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.weekly-peak-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(72px, 1fr));
  gap: 6px;
}
.weekly-peak-day {
  display: grid;
  grid-template-columns: 16px 1fr;
  grid-template-rows: auto auto;
  gap: 4px 5px;
  align-items: center;
  padding: 7px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}
.weekly-peak-day input[type="number"] {
  grid-column: 1 / -1;
  width: 100%;
}
.weekly-peak-day input[type="number"]:disabled {
  opacity: .55;
  background: var(--gray-soft);
}
.weekly-ranges {
  display: grid;
  gap: 6px;
}
.weekly-range-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}
.weekly-range-row input { width: 72px; flex-shrink: 0; }
.mov-range-sep { color: var(--muted); font-size: 13px; }
.mov-range-day-section {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.mov-range-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: var(--gray-soft);
  border-bottom: 1px solid var(--line);
}
.mov-range-day-name { font-size: 12px; font-weight: 700; color: var(--text); }
.mov-range-day-section .weekly-range-row {
  padding: 4px 10px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line);
}
.mov-range-day-section .weekly-range-row:last-child { border-bottom: none; }
.btn-xs { font-size: 11px; padding: 2px 7px; height: auto; }
.weekly-add-range-btn { margin-top: 8px; }
.weekly-model-block {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  margin-bottom: 4px;
}
.closed-model-block {
  background: #fef9ec;
  border-color: #f0c040;
}
.weekly-model-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.closed-model-block .weekly-model-title { color: #a0760a; border-bottom-color: #f0c040; }
.weekly-model-sep {
  margin: 10px 0;
  border: none;
  border-top: 1px solid var(--line);
}
.weekly-model-note {
  font-size: 11px;
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.45;
}
.weekly-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.weekly-summary {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  max-height: 220px;
  overflow: auto;
}
.weekly-summary-result,
.weekly-summary-error {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 800;
}
.weekly-summary-result { color: var(--green); }
.weekly-summary-error { color: var(--red); }
.weekly-summary-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(54px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.weekly-summary-days div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--gray-soft);
  font-size: 11px;
}
.weekly-summary-days strong { color: var(--blue-dark); }
.weekly-summary-meta {
  columns: 2 260px;
  column-gap: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.weekly-summary-meta div {
  break-inside: avoid;
  margin-bottom: 5px;
}
.weekly-summary-warnings {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.weekly-summary-warnings-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.weekly-warnings-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.weekly-warnings-badge.ok { background: var(--green); }
.weekly-warnings-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.weekly-warnings-list li {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text);
  line-height: 1.3;
}
.weekly-warnings-list li .warn-num {
  min-width: 18px;
  font-weight: 700;
  color: #ef4444;
  font-size: 11px;
}
.weekly-warnings-list li .warn-tag {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  background: #fee2e2;
  color: #b91c1c;
  white-space: nowrap;
}
.weekly-warnings-list li .warn-tag.warn-tag-excess { background: #fef3c7; color: #92400e; }
.weekly-warnings-list li .warn-tag.warn-tag-consec { background: #ede9fe; color: #5b21b6; }
.weekly-warnings-list li .warn-tag.warn-tag-ok { background: #dcfce7; color: #166534; }

@media (max-width: 980px) {
  .fds-popup {
    width: 94vw;
  }
  .fds-popup-body {
    grid-template-columns: 1fr;
  }
  .fds-popup-body .popup-info {
    grid-column: auto;
  }
  .fds-preview {
    max-height: 260px;
  }
  .weekly-peak-days,
  .weekly-summary-days {
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  }
}

/* drag guides – vertical mode */
.allowed-start-guide-v {
  position: absolute; left: 0; right: 0; height: 2px;
  background: var(--green); opacity: .6; z-index: 10; pointer-events: none;
}
.allowed-start-guide-v.active { height: 3px; opacity: 1; background: var(--blue); }
.allowed-start-guide-v.warning { background: #f59e0b; }
.allowed-start-guide-v.multi-code { background: linear-gradient(to right, var(--blue), var(--green)); height: 3px; }
.allowed-start-guide-v .guide-alt-badge { top: auto; bottom: 3px; left: 4px; transform: none; }
.drag-time-tooltip-v {
  position: absolute; left: 2px; right: 2px; z-index: 20; pointer-events: none;
  background: var(--ink); color: #fff; font-size: 9px; font-weight: 600;
  border-radius: 3px; padding: 2px 4px; white-space: nowrap; overflow: hidden;
}
.daily-grid-table {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
  font-size: 12px;
}
.daily-grid-table th,
.daily-grid-table td {
  border-right: 1px solid #d9e2f0;
  border-bottom: 1px solid #d9e2f0;
}
.daily-grid-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 36px;
  padding: 6px 8px;
  background: #f8fafc;
  color: #001b42;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.daily-grid-table td {
  height: 28px;
  min-width: 116px;
  padding: 0 6px;
  background: #fffaf0;
  text-align: center;
  vertical-align: middle;
}
.daily-grid-table .daily-hour-col {
  position: sticky;
  left: 0;
  z-index: 4;
  width: 80px;
  min-width: 80px;
  background: #f8fafc;
  color: #60708a;
  font-weight: 700;
  text-align: left;
}
.daily-grid-table .daily-hour-col.valid-time-label {
  color: #fff;
  background: var(--valid-time-color, var(--blue));
  box-shadow: inset 4px 0 0 #0f172a;
}
.daily-grid-table th.daily-hour-col { z-index: 5; }
.daily-grid-table .daily-person-col {
  width: 116px;
  min-width: 116px;
  max-width: 116px;
}
.daily-grid-table .daily-count-col {
  position: sticky;
  right: 0;
  z-index: 4;
  width: 52px;
  min-width: 52px;
  font-weight: 800;
  color: #002451;
  background: #f8fafc;
}
.daily-grid-table th.daily-count-col { z-index: 5; }
.daily-grid-table tr.daily-hour-row td {
  border-top: 1px solid #cbd5e1;
}
.daily-v-cell {
  position: relative;
  overflow: hidden;
}
.daily-v-cell.contract-cell { background: #f3f8df; }
.daily-v-cell.rest-cell {
  background-image: repeating-linear-gradient(135deg, rgba(248,113,113,.22) 0 8px, transparent 8px 16px);
}
.daily-v-cell.preferred-marker::before,
.daily-v-cell.max-start-marker::before,
.daily-v-cell.max-end-marker::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  pointer-events: none;
}
.daily-v-cell.preferred-marker::before {
  top: 0;
  background: #7c3aed;
}
.daily-v-cell.max-start-marker::before {
  bottom: 0;
  background: #2563eb;
}
.daily-v-cell.max-end-marker::after {
  bottom: 0;
  background: #dc2626;
}
.daily-v-cell.shift-cell {
  font-weight: 800;
  box-shadow: inset 0 0 0 999px rgba(255,255,255,.08);
}
.daily-v-cell.group-mismatch-cell {
  outline: 2px dashed var(--red);
  outline-offset: -3px;
}
.daily-v-cell.shift-start-cell {
  cursor: grab;
}
.daily-v-cell.shift-start-cell:active {
  cursor: grabbing;
}
.daily-v-cell.valid-code-slot {
  box-shadow: inset 0 0 0 3px #2563eb;
  background-color: #dbeafe !important;
  background-image: none !important;
}
.daily-v-cell.valid-code-slot::before {
  content: '';
  position: absolute;
  inset: 2px;
  border: 2px solid #2563eb;
  border-radius: 4px;
  pointer-events: none;
  z-index: 5;
}
.daily-v-cell.valid-code-slot::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 3px;
  bottom: 3px;
  width: 10px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--valid-slot-color, var(--green));
  box-shadow: 0 0 0 3px rgba(15,23,42,.14);
  pointer-events: none;
  z-index: 6;
}
.daily-v-cell.valid-code-slot.warning-slot::after {
  opacity: .45;
}
.daily-v-cell.drag-over {
  box-shadow: inset 0 0 0 3px rgba(37,99,235,.55);
}
.daily-v-cell.shift-start-cell {
  border-top: 3px solid #2563eb;
}
.daily-v-cell.shift-end-cell {
  border-bottom: 3px solid #dc2626;
}
.daily-grid-table .daily-count-ok { color: var(--green); background: #f0fdf4; }
.daily-grid-table .daily-count-bad { color: var(--red); background: #fff1f2; }

.zoom-label { font-size: 12px; font-weight: 600; color: var(--muted); min-width: 38px; text-align: right; }
.day-input { width: 58px; height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; font-family: var(--font); text-align: center; outline: none; background: var(--panel); }
.day-input:focus { border-color: var(--blue); }
.day-label { height: 36px; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.daily-nav-btn { width: 44px; height: 36px; min-height: 36px; padding: 0; justify-content: center; }
.daily-nav-btn .btn-icon { width: 18px; height: 18px; }
.zoom-control { height: 36px; display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 10px; }
.fit-width-btn {
  height: 36px;
  min-height: 36px;
  padding: 0 12px;
}
.fit-width-btn[disabled] {
  opacity: .48;
  cursor: not-allowed;
}
.zoom-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--muted);
}
.zoom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  outline: none;
  cursor: pointer;
}
.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.zoom-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

/* ═══ REAL SCHEDULES ═══ */
.real-schedules-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.real-schedule-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.real-schedule-item strong { font-size: 14px; }
.real-schedule-item .item-btns { display: flex; gap: 6px; }

/* ═══ VISUAL REFRESH - inspirado no layout base ═══ */
:root {
  --bg: #eef3f8;
  --panel: rgba(255,255,255,.76);
  --panel-subtle: rgba(255,255,255,.54);
  --ink: #17202a;
  --muted: #536071;
  --line: rgba(31,42,55,.16);
  --line-soft: rgba(255,255,255,.34);
  --blue: #0a6df0;
  --blue-dark: #084fbe;
  --blue-soft: rgba(10,109,240,.11);
  --green: #238458;
  --green-soft: rgba(75,189,140,.15);
  --red: #cf2f2f;
  --red-soft: rgba(255,82,82,.11);
  --orange: #b96f18;
  --orange-soft: rgba(245,169,79,.18);
  --gray-soft: rgba(255,255,255,.46);
  --glass: linear-gradient(180deg, rgba(255,255,255,.78), rgba(255,255,255,.52));
  --glass-strong: linear-gradient(180deg, rgba(255,255,255,.9), rgba(255,255,255,.66));
  --shadow: 0 18px 44px rgba(15,23,42,.14);
  --shadow-sm: 0 8px 22px rgba(15,23,42,.10);
  --focus-ring: 0 0 0 3px rgba(10,109,240,.18);
  --radius: 12px;
}

body {
  position: relative;
  isolation: isolate;
  background: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255,255,255,.46), rgba(242,246,250,.76)),
    url("https://cdn-assets-eu.frontify.com/s3/frontify-enterprise-files-eu/eyJwYXRoIjoibmVzdGxlXC9maWxlXC85WHplbjR4UVh4Z1hoMlV0UW5QZC5qcGcifQ:nestle:OO6m2qZgXRffvTAsIZU1XXkm05CsFPzkEh3QQDCmDI8") center/cover no-repeat,
    linear-gradient(135deg, #e8eff8, #f9f6ef 48%, #ebf4f1);
  filter: saturate(1.02) brightness(1.03);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 16% 12%, rgba(10,109,240,.13), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(75,189,140,.12), transparent 24%),
    linear-gradient(180deg, rgba(255,255,255,.36), rgba(238,243,248,.82));
}

.app-shell {
  position: relative;
  z-index: 1;
  padding: 10px;
  gap: 10px;
}

.main-area {
  border: 1px solid rgba(255,255,255,.36);
  border-radius: 16px;
  background: rgba(255,255,255,.18);
  box-shadow: 0 24px 70px rgba(15,23,42,.18);
  -webkit-backdrop-filter: blur(10px) saturate(128%);
  backdrop-filter: blur(10px) saturate(128%);
}

.app-header,
.card,
.toolbar,
.table-wrap,
.schedule-table-wrap,
.daily-map-wrap,
.issues-panel,
.real-schedule-item,
.popup,
.copy-day-popover {
  background: var(--glass);
  border-color: rgba(255,255,255,.38);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(12px) saturate(135%);
  backdrop-filter: blur(12px) saturate(135%);
}

.app-header {
  height: 62px;
  margin: 0;
  border-radius: 16px 16px 0 0;
  border-bottom-color: rgba(31,42,55,.12);
  background: linear-gradient(180deg, rgba(255,255,255,.86), rgba(255,255,255,.64));
  box-shadow: 0 1px 0 rgba(255,255,255,.76), 0 14px 34px rgba(15,23,42,.10);
}

.app-name {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.48);
  border: 1px solid rgba(255,255,255,.38);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.46);
  color: #465263;
}

.app-name strong {
  color: #17202a;
}

.page-area {
  padding: 18px;
}

.page-header {
  padding: 0 2px;
}

.page-header h2 {
  color: #17202a;
  text-shadow: 0 1px 0 rgba(255,255,255,.42);
}

.card {
  padding: 18px 20px;
  border-radius: 14px;
}

.card h3 {
  color: #445166;
}

.nav-btn {
  min-width: 56px;
  border-radius: 11px;
  color: #526074;
}

.nav-btn:hover {
  background: rgba(255,255,255,.5);
  color: #17202a;
  border-color: rgba(255,255,255,.4);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5);
}

.nav-btn.active {
  background: linear-gradient(180deg, rgba(10,109,240,.95), rgba(8,79,190,.95));
  color: #fff;
  border-color: rgba(10,109,240,.46);
  box-shadow: 0 12px 24px rgba(10,109,240,.22);
}

.btn,
.month-year-picker select,
.month-year-picker input,
.filter-input,
.filter-select,
.param-field input,
.param-field select,
.settings-field input[data-time-mask],
.settings-field input[type="number"],
.day-input,
.zoom-control,
.segmented-control,
.real-import-period select,
.real-import-period input {
  background: linear-gradient(180deg, rgba(255,255,255,.74), rgba(255,255,255,.42));
  border-color: rgba(31,42,55,.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 4px 12px rgba(15,23,42,.05);
}

.btn {
  min-height: 34px;
  border-radius: 10px;
  font-weight: 650;
  color: #263241;
}

.btn:hover {
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(255,255,255,.58));
  border-color: rgba(10,109,240,.24);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.64), 0 8px 18px rgba(15,23,42,.08);
}

.btn.primary {
  background: linear-gradient(180deg, #2f8cff, var(--blue));
  border-color: rgba(10,109,240,.72);
  box-shadow: 0 12px 24px rgba(10,109,240,.24);
}

.btn.primary:hover {
  background: linear-gradient(180deg, #1f7df8, var(--blue-dark));
}

.btn.success {
  background: linear-gradient(180deg, #44b87d, var(--green));
  border-color: rgba(35,132,88,.72);
  box-shadow: 0 10px 20px rgba(35,132,88,.2);
}

.danger-btn {
  background: linear-gradient(180deg, rgba(255,255,255,.8), rgba(255,240,240,.6));
  border-color: rgba(207,47,47,.28);
}

.mode-toggle-btn {
  background: linear-gradient(180deg, rgba(255,255,255,.76), rgba(255,246,229,.58));
  border-color: rgba(185,111,24,.35);
}

.month-year-picker select:focus,
.month-year-picker input:focus,
.param-field input:focus,
.param-field select:focus,
.settings-field input:focus,
.data-table input:focus,
.data-table select:focus,
.filter-input:focus,
.filter-select:focus,
.day-input:focus {
  background: rgba(255,255,255,.9);
}

.settings-day-col .day-header {
  border-color: rgba(10,109,240,.18);
  background: linear-gradient(180deg, rgba(10,109,240,.15), rgba(10,109,240,.07));
}

.settings-day-col.weekend .day-header {
  border-color: rgba(185,111,24,.24);
  background: linear-gradient(180deg, rgba(245,169,79,.22), rgba(245,169,79,.09));
}

.table-wrap,
.schedule-table-wrap,
.daily-map-wrap {
  border-radius: 14px;
  overflow: auto;
}

.data-table,
.schedule-table {
  background: rgba(255,255,255,.68);
}

.data-table th,
.sch-name-header,
.sch-subheader-row th:first-child,
.schedule-table thead th,
.daily-time-header {
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(246,249,253,.78)) !important;
  color: #475468;
}

.data-table td,
.schedule-table th,
.schedule-table td,
.daily-row {
  border-color: rgba(31,42,55,.13);
}

.data-table tr:nth-child(even) td {
  background: rgba(255,255,255,.36);
}

.data-table tr:hover td {
  background: rgba(10,109,240,.09);
}

.sch-name-cell {
  background: rgba(255,255,255,.86);
  border-right-color: rgba(31,42,55,.18);
}

.sch-day-header {
  background: rgba(255,255,255,.58);
}

.sch-day-header.weekend {
  background: rgba(245,169,79,.18);
}

.coverage-row td {
  background: rgba(255,255,255,.58);
}

.toolbar {
  border-radius: 14px;
  padding: 10px 12px;
}

.filters-bar {
  padding: 0;
}

.sel-bar {
  background: linear-gradient(180deg, rgba(10,109,240,.9), rgba(8,79,190,.9));
  border-color: rgba(255,255,255,.28);
  box-shadow: var(--shadow-sm);
}

.issues-panel {
  border-radius: 14px;
}

.issues-header {
  background: linear-gradient(180deg, rgba(255,246,229,.9), rgba(255,246,229,.6));
}

.issues-panel ul li {
  border-radius: 8px;
}

.popup-overlay {
  background: rgba(15,23,42,.34);
  -webkit-backdrop-filter: blur(7px) saturate(120%);
  backdrop-filter: blur(7px) saturate(120%);
}

.popup {
  border-radius: 16px;
  border-color: rgba(255,255,255,.44);
  box-shadow: 0 34px 76px rgba(15,23,42,.28);
}

.popup-header {
  background: linear-gradient(180deg, rgba(255,255,255,.86), rgba(255,255,255,.58));
  border-bottom-color: rgba(31,42,55,.12);
  border-radius: 16px 16px 0 0;
}

.popup-footer {
  background: rgba(255,255,255,.46);
  border-top-color: rgba(31,42,55,.12);
  border-radius: 0 0 16px 16px;
}

.popup-current-card,
.pcs-trigger,
.compatible-card,
.legend-item,
.weekly-model-block,
.fds-section,
kbd {
  background: linear-gradient(180deg, rgba(255,255,255,.68), rgba(255,255,255,.38));
  border-color: rgba(31,42,55,.14);
}

.pcs-dropdown {
  background: rgba(255,255,255,.94);
  border-color: rgba(31,42,55,.16);
  box-shadow: 0 22px 44px rgba(15,23,42,.18);
  -webkit-backdrop-filter: blur(10px) saturate(125%);
  backdrop-filter: blur(10px) saturate(125%);
}

.toast {
  top: 18px;
  bottom: auto;
  width: min(92vw, 380px);
  max-width: calc(100vw - 28px);
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255,255,255,.84);
  color: #17202a;
  border: 1px solid rgba(255,255,255,.5);
  border-left: 4px solid var(--blue);
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 14px 34px rgba(15,23,42,.18);
  -webkit-backdrop-filter: blur(10px) saturate(135%);
  backdrop-filter: blur(10px) saturate(135%);
  transform: translateX(-50%) translateY(-32px);
  white-space: normal;
  overflow-wrap: anywhere;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast-info {
  background: rgba(255,255,255,.9);
  color: #17202a;
  border-left-color: var(--blue);
}

.toast-success {
  background: rgba(246,255,250,.92);
  color: #123c28;
  border-left-color: var(--green);
}

.toast-error {
  background: rgba(255,246,246,.94);
  color: #641616;
  border-left-color: var(--red);
}

.import-area {
  background: linear-gradient(180deg, rgba(246,250,255,.74), rgba(10,109,240,.09));
  border-color: rgba(10,109,240,.28);
  box-shadow: var(--shadow-sm);
  -webkit-backdrop-filter: blur(10px) saturate(125%);
  backdrop-filter: blur(10px) saturate(125%);
}

.import-area textarea,
.compatible-search input,
.weekly-field input,
.weekly-field select,
.weekly-peak-day input[type="number"],
.weekly-range-row input,
.fds-count-input {
  background: linear-gradient(180deg, rgba(255,255,255,.82), rgba(255,255,255,.54));
  border-color: rgba(31,42,55,.15);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55);
}

.quick-btn {
  background: linear-gradient(180deg, rgba(255,255,255,.76), rgba(255,255,255,.45));
  border: 1px solid rgba(31,42,55,.13);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55);
}

.quick-btn.quick-btn-active {
  border-color: rgba(10,109,240,.62);
  box-shadow: 0 0 0 3px rgba(10,109,240,.14), inset 0 1px 0 rgba(255,255,255,.55);
}

.availability-cell {
  background: rgba(10,109,240,.06) !important;
}

.avail-day:hover {
  background: rgba(255,255,255,.78);
}

.danger-btn:hover {
  background: linear-gradient(180deg, rgba(255,255,255,.86), rgba(255,232,232,.68));
  border-color: rgba(207,47,47,.38);
}

.mode-toggle-btn:hover {
  background: linear-gradient(180deg, rgba(255,255,255,.86), rgba(255,246,229,.7));
  border-color: rgba(185,111,24,.44);
}

.page-area,
.table-wrap,
.schedule-table-wrap,
.daily-map-wrap,
.popup-body,
.fds-preview {
  scrollbar-color: rgba(71,84,104,.42) transparent;
  scrollbar-width: thin;
}

.page-area::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
.schedule-table-wrap::-webkit-scrollbar,
.daily-map-wrap::-webkit-scrollbar,
.popup-body::-webkit-scrollbar,
.fds-preview::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.page-area::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
.schedule-table-wrap::-webkit-scrollbar-thumb,
.daily-map-wrap::-webkit-scrollbar-thumb,
.popup-body::-webkit-scrollbar-thumb,
.fds-preview::-webkit-scrollbar-thumb {
  background: rgba(71,84,104,.34);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

.page-area::-webkit-scrollbar-thumb:hover,
.table-wrap::-webkit-scrollbar-thumb:hover,
.schedule-table-wrap::-webkit-scrollbar-thumb:hover,
.daily-map-wrap::-webkit-scrollbar-thumb:hover,
.popup-body::-webkit-scrollbar-thumb:hover,
.fds-preview::-webkit-scrollbar-thumb:hover {
  background-color: rgba(71,84,104,.5);
}

/* Tabela da escala: totais fixos precisam de fundo e linhas 100% opacos. */
.schedule-table th,
.schedule-table td {
  border-color: #fff !important;
}

.schedule-table-wrap.totals-fixed .sch-total-header,
.schedule-table-wrap.totals-fixed .sch-sub-hdr,
.schedule-table-wrap.totals-fixed .sch-total-cell {
  background-clip: border-box !important;
  border-color: #fff !important;
  box-shadow: none !important;
}

.schedule-table-wrap.totals-fixed .grp-hdr-trabalho {
  background: #f97316 !important;
  color: #1a1a1a;
}

.schedule-table-wrap.totals-fixed .grp-hdr-folga {
  background: #dbeafe !important;
  color: #1e3a8a;
}

.schedule-table-wrap.totals-fixed .grp-hdr-outros {
  background: #e5e7eb !important;
  color: #111827;
}

.schedule-table-wrap.totals-fixed .grp-hdr-ferias {
  background: #fef3c7 !important;
  color: #7c2d12;
}

.schedule-table-wrap.totals-fixed .grp-col-trabalho:not(.total-warn):not(.total-over) {
  background: #fff7ed !important;
}

.schedule-table-wrap.totals-fixed .grp-col-folga:not(.total-warn):not(.total-over) {
  background: #eff6ff !important;
}

.schedule-table-wrap.totals-fixed .grp-col-outros:not(.total-warn):not(.total-over) {
  background: #f3f4f6 !important;
}

.schedule-table-wrap.totals-fixed .grp-col-ferias:not(.total-warn):not(.total-over) {
  background: #fefce8 !important;
}

.schedule-table-wrap.totals-fixed .total-ok {
  background: #f0fdf4 !important;
}

.schedule-table-wrap.totals-fixed .total-warn,
.schedule-table-wrap.totals-fixed .total-over {
  background: #ef4444 !important;
  color: #fff !important;
}

.schedule-table-wrap.totals-fixed .grp-col-first {
  border-left: 1px solid #fff !important;
  box-shadow: none !important;
}

.schedule-table-wrap.totals-fixed .grp-col-first.grp-col-trabalho,
.schedule-table-wrap.totals-fixed .grp-col-first.grp-col-folga,
.schedule-table-wrap.totals-fixed .grp-col-first.grp-col-outros,
.schedule-table-wrap.totals-fixed .grp-col-first.grp-col-ferias {
  border-left: 1px solid #fff !important;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .app-header,
  .card,
  .toolbar,
  .table-wrap,
  .schedule-table-wrap,
  .daily-map-wrap,
  .issues-panel,
  .real-schedule-item,
  .popup {
    background: rgba(255,255,255,.94);
  }
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 768px) {
  html, body { overflow: auto; }
  .app-shell { min-height: 100vh; height: auto; }
  .main-area { min-height: 100vh; }
  .page-area { padding: 14px; overflow-y: visible; }
  .page-header { align-items: flex-start; }
  .page-header h2 { font-size: 18px; }
  .header-left { min-width: 0; }
  .app-name { font-size: 14px; }
  .header-nav { overflow-x: auto; padding-bottom: 2px; }
  .header-right { gap: 6px; }
  .month-year-picker select { max-width: 108px; }
  .month-year-picker input { width: 62px; }
  .nav-label { display: none; }
  .nav-btn { padding: 0 8px; height: 40px; }
  .settings-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar-row { flex-direction: column; align-items: flex-start; }
  .toolbar-row .btn,
  .btn-group .btn { width: 100%; justify-content: center; }
  .btn-group { width: 100%; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .schedule-header-filters {
    min-width: 100%;
    width: 100%;
    justify-content: stretch;
  }
  .filter-input, .filter-select { width: 100%; }
  .schedule-table-wrap { max-height: 62vh; }
  .app-header { padding: 0 10px; gap: 8px; }
  .header-right .btn span { display: none; }
  .popup { width: calc(100vw - 22px); }
  .issues-panel { left: 12px; right: 12px; bottom: 12px; width: auto; }
}
