/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-light: #eff6ff;
  --green: #16a34a;
  --green-light: #dcfce7;
  --green-border: #86efac;
  --blue: #1d4ed8;
  --blue-light: #dbeafe;
  --blue-border: #93c5fd;
  --red: #dc2626;
  --red-light: #fee2e2;
  --red-border: #fca5a5;
  --sunday-bg: #fffbeb;
  --hour-h: 60px;
  --header-h: 56px;
  --metrics-h: 60px;
}
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; overflow-x: hidden; }
.hidden { display: none !important; }
button { cursor: pointer; border: none; border-radius: 6px; font-size: 13px; font-family: inherit; transition: all .15s; }

/* ===== LOGIN ===== */
.login-screen {
  position: fixed; inset: 0; background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.login-box {
  background: white; border-radius: 16px; padding: 48px 40px; width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); text-align: center;
}
.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-box h1 { font-size: 22px; color: #1e3a5f; margin-bottom: 4px; }
.login-box p { color: var(--text-muted); margin-bottom: 28px; }
.login-box input[type=password] {
  width: 100%; padding: 12px 16px; border: 2px solid var(--border); border-radius: 8px;
  font-size: 16px; outline: none; transition: border-color .2s; margin-bottom: 12px;
}
.login-box input[type=password]:focus { border-color: var(--primary); }
.login-box button { width: 100%; padding: 12px; background: var(--primary); color: white; font-size: 15px; border-radius: 8px; }
.login-box button:hover { background: #1d4ed8; }
.login-error { color: var(--red); font-size: 13px; margin-top: 8px; }

/* ===== HEADER ===== */
.app-header {
  position: sticky; top: 0; z-index: 100; height: var(--header-h);
  background: linear-gradient(135deg, #1e1b4b 0%, #3730a3 100%);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px; gap: 8px;
  box-shadow: 0 2px 12px rgba(30,27,75,.35);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.logo-text { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: -.2px; }
.role-tag { font-size: 11px; background: rgba(255,255,255,.18); color: #e0e7ff; padding: 2px 10px; border-radius: 20px; font-weight: 600; text-transform: uppercase; border: 1px solid rgba(255,255,255,.2); }
.header-center { display: flex; align-items: center; gap: 6px; }
.btn-nav { width: 32px; height: 32px; background: rgba(255,255,255,.15); color: #fff; border-radius: 50%; font-size: 16px; }
.btn-nav:hover { background: rgba(255,255,255,.28); }
.btn-today { padding: 6px 18px; background: rgba(255,255,255,.18); color: #fff; font-weight: 600; border-radius: 20px; border: 1px solid rgba(255,255,255,.25); }
.btn-today:hover { background: rgba(255,255,255,.3); }
.period-label { font-size: 15px; font-weight: 600; color: #fff; min-width: 200px; text-align: center; }
.header-right { display: flex; align-items: center; gap: 6px; }
.btn-view { padding: 6px 16px; background: rgba(255,255,255,.12); color: rgba(255,255,255,.75); border-radius: 20px; border: 1px solid rgba(255,255,255,.15); }
.btn-view.active { background: #fff; color: #3730a3; font-weight: 700; border-color: transparent; }
.btn-view:hover:not(.active) { background: rgba(255,255,255,.22); color: #fff; }
.btn-logout { padding: 6px 14px; background: transparent; color: rgba(255,255,255,.65); border-radius: 20px; }
.btn-logout:hover { background: rgba(220,38,38,.35); color: #fca5a5; }
.btn-refresh { width: 32px; height: 32px; background: transparent; color: rgba(255,255,255,.65); font-size: 18px; line-height: 1; border-radius: 50%; }
.btn-refresh:hover { background: rgba(255,255,255,.15); color: #fff; }
.btn-refresh.spinning { animation: spin .6s linear; }
@keyframes spin { to { transform: rotate(360deg); } }
.refresh-status { font-size: 12px; color: #6ee7b7; font-weight: 600; white-space: nowrap; }

/* ===== METRICS ===== */
.metrics-bar {
  display: flex; gap: 10px; padding: 8px 16px; background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0; height: var(--metrics-h); align-items: center;
}
.metric-card {
  display: flex; flex: 1; align-items: center; gap: 10px; background: #2563eb;
  border-radius: 12px; padding: 8px 16px; min-width: 0;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.metric-card.metric-done    { background: #16a34a; box-shadow: 0 2px 8px rgba(22,163,74,.3); }
.metric-card.metric-pending { background: #dc2626; box-shadow: 0 2px 8px rgba(220,38,38,.3); }
.metric-card.metric-ventas  { background: #7c3aed; box-shadow: 0 2px 8px rgba(124,58,237,.3); }
.metric-label { font-size: 11px; color: rgba(255,255,255,.8); white-space: nowrap; }
.metric-value { font-size: 17px; font-weight: 700; color: #fff; white-space: nowrap; }
.metric-done    .metric-value { color: #fff; }
.metric-pending .metric-value { color: #fff; }
.metric-ventas  .metric-value { color: #fff; }

/* ===== CALENDAR CONTAINER ===== */
#calendarContainer {
  height: calc(100vh - var(--header-h) - var(--metrics-h));
  overflow-y: auto; overflow-x: auto;
}

/* ===== WEEK VIEW ===== */
.week-view { display: flex; flex-direction: column; min-width: 900px; }
.week-header { display: grid; position: sticky; top: 0; z-index: 50; background: #f1f5f9; border-bottom: 2px solid #cbd5e1; }
.week-header-inner { display: grid; }
.time-gutter { width: 60px; flex-shrink: 0; }
.day-col-header {
  text-align: center; padding: 10px 4px; border-left: 1px solid #e2e8f0;
  font-weight: 600; font-size: 13px; cursor: default; background: #f1f5f9;
}
.day-col-header .day-name { color: #2563eb; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; font-weight: 700; }
.day-col-header .day-num { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1; }
.day-col-header.today .day-num { background: #2563eb; color: white; border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; margin: 0 auto; box-shadow: 0 2px 8px rgba(37,99,235,.4); }
.day-col-header.sunday-header { background: #fef3c7; }

.week-body { display: flex; flex: 1; }
.time-col { width: 60px; flex-shrink: 0; }
.time-slot-label {
  height: var(--hour-h); display: flex; align-items: flex-start; justify-content: flex-end;
  padding-right: 8px; padding-top: 2px; font-size: 11px; color: #94a3b8; font-variant-numeric: tabular-nums;
}
.days-grid { flex: 1; display: grid; }
.day-col { border-left: 1px solid #e2e8f0; position: relative; }
.day-col.sunday-col { background: #fffbeb; }

.hour-row {
  height: var(--hour-h); border-top: 1px solid #cbd5e1; position: relative; background: #ffffff;
}
.hour-row.half::after {
  content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed #e2e8f0;
}

.events-layer { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.hour-row { cursor: default; }

/* ===== EVENTS ===== */
.cal-event {
  position: absolute; border-radius: 5px; padding: 3px 6px 10px; font-size: 11px;
  cursor: grab; pointer-events: all; overflow: hidden; border-left: 3px solid transparent;
  user-select: none; transition: box-shadow .15s;
  line-height: 1.35;
}
.cal-event:hover { box-shadow: 0 2px 8px rgba(0,0,0,.2); z-index: 10; }
.cal-event.dragging { opacity: .35; cursor: grabbing; z-index: 999; }
.cal-event.realizado { opacity: .7; }
.cal-event.realizado::after { content: ' ✓'; font-weight: bold; }

.cal-event.tipo-medidas { background: #bbf7d0; border-left: 4px solid #16a34a; color: #14532d; }
.cal-event.tipo-instalacion { background: #bfdbfe; border-left: 4px solid #2563eb; color: #1e3a8a; }
.cal-event.tipo-reparacion { background: #fecaca; border-left: 4px solid #dc2626; color: #7f1d1d; }

.event-time-label { font-size: 10px; opacity: .8; }
.event-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-tipo { font-size: 10px; opacity: .75; }
.event-registrado {
  position: absolute; top: 2px; right: 5px;
  font-size: 9px; opacity: 0.65; font-style: italic;
  max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  pointer-events: none;
}

/* Drop target highlight */
.day-col.drag-over .hour-row { background: rgba(37,99,235,.04); }
.drag-placeholder {
  position: absolute; border-radius: 5px; background: rgba(37,99,235,.15);
  border: 2px dashed var(--primary); pointer-events: none; z-index: 5;
}

/* ===== NOTES STRIP (before 8am) ===== */
.notes-gutter-spacer {
  height: 64px; background: #f1f3f5; border-bottom: 2px solid var(--border);
}
.notes-strip {
  min-height: 64px; background: #f1f3f5; border-bottom: 2px solid var(--border);
  position: relative;
}
.notes-strip-placeholder {
  display: flex; align-items: center; gap: 6px; padding: 10px 8px;
  min-height: 64px; cursor: text; color: #9ca3af; font-size: 12px;
}
.notes-strip-placeholder:hover { background: #e8eaed; }
.notes-pencil { font-size: 13px; flex-shrink: 0; }
.notes-hint { font-style: italic; }
.notes-strip-ta {
  width: 100%; min-height: 64px; padding: 8px 10px; border: none;
  background: #eef0f3; resize: none; font-size: 12px; color: var(--text);
  line-height: 1.5; outline: none; font-family: inherit; display: block;
}
.notes-strip-ta:focus { background: #e6eaf0; }

/* ===== SUNDAY NOTES ===== */
.sunday-notes-zone {
  height: 100%; padding: 12px; background: #fdf6e3;
  border-left: 2px solid #e9d8a6; display: flex; flex-direction: column; gap: 8px;
}
.sunday-notes-label {
  font-size: 12px; font-weight: 700; color: #92400e;
  text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; gap: 5px;
}
.sunday-notes-textarea {
  flex: 1; width: 100%; border: none; background: transparent; resize: none;
  font-size: 13px; color: #44403c; line-height: 1.6; outline: none; font-family: inherit; min-height: 200px;
}

/* ===== MONTH VIEW ===== */
.month-view { display: flex; flex-direction: column; height: 100%; min-width: 700px; }
.month-header-row {
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: #f1f5f9; border-bottom: 2px solid #cbd5e1; position: sticky; top: 0; z-index: 50;
}
.month-day-name {
  text-align: center; padding: 10px 4px; font-weight: 700; font-size: 12px;
  color: #2563eb; text-transform: uppercase; letter-spacing: .8px;
}
.month-day-name:last-child { background: #fef3c7; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); flex: 1; }
.month-cell {
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  min-height: 120px; padding: 4px; cursor: pointer; background: white; transition: background .1s;
}
.month-cell:nth-child(7n) { background: var(--sunday-bg); }
.month-cell:hover { background: var(--primary-light); }
.month-cell.other-month { background: #f7f8fa; }
.month-cell.other-month .month-day-num { color: #c9cdd4; }
.month-day-num { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.month-cell.today-cell .month-day-num {
  background: var(--primary); color: white; border-radius: 50%;
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.month-event {
  border-radius: 3px; padding: 1px 5px; font-size: 11px; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.month-event.tipo-medidas { background: #bbf7d0; color: #14532d; border-left: 4px solid #16a34a; }
.month-event.tipo-instalacion { background: #bfdbfe; color: #1e3a8a; border-left: 4px solid #2563eb; }
.month-event.tipo-reparacion { background: #fecaca; color: #7f1d1d; border-left: 4px solid #dc2626; }
.month-event.realizado { opacity: .65; }
.month-more { font-size: 11px; color: var(--primary); font-weight: 600; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 4000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  background: white; border-radius: 12px; width: 100%; max-width: 680px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  border-top: 4px solid #e5e7eb; transition: border-color .2s;
}
.modal-box.modal-medidas    { border-top-color: #16a34a; }
.modal-box.modal-instalacion { border-top-color: #2563eb; }
.modal-box.modal-reparacion  { border-top-color: #dc2626; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 2; background: white; transition: background .2s;
}
.modal-box.modal-medidas .modal-header    { background: linear-gradient(135deg,#f0fdf4 0%,#fff 55%); }
.modal-box.modal-instalacion .modal-header { background: linear-gradient(135deg,#eff6ff 0%,#fff 55%); }
.modal-box.modal-reparacion .modal-header  { background: linear-gradient(135deg,#fff5f5 0%,#fff 55%); }

.modal-header h2 { font-size: 17px; font-weight: 700; color: #111827; }
.modal-close { width: 32px; height: 32px; background: var(--bg); font-size: 20px; line-height: 1; border-radius: 6px; }
.modal-close:hover { background: var(--red-light); color: var(--red); }

.event-form { padding: 20px 24px; }
.form-row { display: flex; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; margin-bottom: 14px; }
.form-group.flex2 { flex: 2; }
.form-group label { font-size: 11px; font-weight: 700; color: #374151; text-transform: uppercase; letter-spacing: .5px; }
.form-group input, .form-group select, .form-group textarea {
  padding: 9px 12px; border: 1.5px solid #d1d5db; border-radius: 8px;
  font-size: 14px; font-family: inherit; outline: none; transition: border-color .2s, box-shadow .2s;
  background: #fafafa; color: #111827;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary); background: white; box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-group input[type=file] { padding: 6px; background: white; }
.check-group { justify-content: flex-end; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--green); }
.checkbox-label input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--green); }

/* ===== FIELD WITH ACTION BUTTON ===== */
.field-with-action { display: flex; align-items: stretch; }
.field-with-action > input {
  flex: 1; border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: none;
}
.field-with-action > input:focus { position: relative; z-index: 1; }
.field-action-btn {
  border: 1.5px solid #d1d5db; border-top-right-radius: 8px; border-bottom-right-radius: 8px;
  padding: 0 13px; cursor: pointer; transition: background .15s, color .15s;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.maps-btn { background: #eff6ff; color: #2563eb; }
.maps-btn:hover { background: #dbeafe; }
.wa-btn { background: #f0fdf4; color: #16a34a; }
.wa-btn:hover { background: #dcfce7; }

/* ===== FORM SECTION DIVIDER ===== */
.form-divider { height: 1px; background: #e5e7eb; margin: 2px 0 16px; }

/* ===== FORMA DE PAGO TOGGLES ===== */
.pago-toggles { display: flex; gap: 6px; }
.pago-btn {
  flex: 1; padding: 9px 12px; border: 1.5px solid #d1d5db; border-radius: 8px;
  background: #fafafa; color: var(--text-muted); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.pago-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.pago-btn[data-value="contado"].active { background: #16a34a; border-color: #16a34a; color: white; font-weight: 700; }
.pago-btn[data-value="6meses"].active  { background: #7c3aed; border-color: #7c3aed; color: white; font-weight: 700; }
.pago-btn[data-value="otro"].active    { background: #d97706; border-color: #d97706; color: white; font-weight: 700; }
.pago-nota {
  margin-top: 8px; width: 100%; padding: 9px 12px; border: 1.5px solid #d1d5db;
  border-radius: 8px; font-size: 13px; font-family: inherit; outline: none; transition: border-color .2s;
  background: #fafafa;
}
.pago-nota:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* ===== INGRESADO POR TOGGLES ===== */
.ingresado-toggles { display: flex; gap: 6px; }
.ingresado-btn {
  flex: 1; padding: 9px 12px; border: 1.5px solid #d1d5db; border-radius: 8px;
  background: #fafafa; color: var(--text-muted); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.ingresado-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.ingresado-btn[data-value="ventas"].active    { background: #0ea5e9; border-color: #0ea5e9; color: white; font-weight: 700; }
.ingresado-btn[data-value="direccion"].active { background: #8b5cf6; border-color: #8b5cf6; color: white; font-weight: 700; }

/* ===== PROGRAMAR INSTALACIÓN ===== */
.prog-inst {
  background: #eff6ff; border: 1.5px solid #bfdbfe; border-radius: 10px;
  padding: 16px 18px; margin-bottom: 16px;
}
.prog-inst-header {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; color: #1e3a8a;
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px;
}
.prog-inst-icon { font-size: 15px; }
.prog-inst-check-row {
  display: flex; align-items: center; gap: 9px;
  font-size: 14px; font-weight: 500; color: #1e40af; cursor: pointer; user-select: none;
}
.prog-inst-check-row input[type=checkbox] {
  width: 17px; height: 17px; cursor: pointer; accent-color: var(--primary); flex-shrink: 0;
}
.prog-inst-form { margin-top: 14px; }
.prog-inst-actions { display: flex; align-items: center; gap: 14px; margin-top: 6px; flex-wrap: wrap; }
.btn-crear-inst {
  padding: 10px 22px; background: var(--primary); color: white;
  font-weight: 700; font-size: 13px; border-radius: 8px;
}
.btn-crear-inst:hover:not(:disabled) { background: #1d4ed8; }
.btn-crear-inst:disabled { background: #93c5fd; cursor: not-allowed; opacity: .7; }
.inst-confirmacion {
  font-size: 13px; font-weight: 600; color: var(--green);
  display: flex; align-items: center; gap: 4px;
}

.modal-actions { display: flex; gap: 10px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.autosave-hint { flex: 1; font-size: 11px; color: var(--text-muted); font-style: italic; min-width: 80px; }
.btn-primary { padding: 10px 24px; background: var(--primary); color: white; font-weight: 600; flex: 1; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { padding: 10px 24px; background: var(--bg); color: var(--text); border-radius: 7px; }
.btn-secondary:hover { background: var(--border); }
.btn-danger { padding: 10px 24px; background: var(--red-light); color: var(--red); font-weight: 600; border-radius: 7px; }
.btn-danger:hover { background: var(--red); color: white; }

/* ===== COPY SUMMARY BUTTON ===== */
.btn-copy-resumen {
  padding: 7px 13px; background: transparent; color: var(--text-muted);
  border: 1.5px solid #d1d5db; border-radius: 7px; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-copy-resumen:hover { background: var(--bg); color: var(--text); border-color: #9ca3af; }
.btn-copy-resumen.copied { background: #f0fdf4; color: #16a34a; border-color: #86efac; font-weight: 600; }

/* ===== TYPE PICKER ===== */
.type-picker {
  position: fixed; z-index: 3500;
  background: white; border-radius: 10px; padding: 5px;
  box-shadow: 0 6px 28px rgba(0,0,0,.16), 0 0 0 1px rgba(0,0,0,.07);
  display: flex; flex-direction: column; gap: 2px; min-width: 185px;
}
.type-picker-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 12px; border-radius: 7px; text-align: left;
  font-size: 13px; font-weight: 500; background: transparent; color: var(--text);
}
.type-picker-btn:hover { background: var(--bg); }
.tp-medidas:hover  { background: #dcfce7; color: #14532d; }
.tp-instalacion:hover { background: #dbeafe; color: #1e3a8a; }
.tp-reparacion:hover { background: #fee2e2; color: #7f1d1d; }
.tp-nota:hover { background: #fef9c3; color: #78350f; }

/* ===== QUICK NOTE POPUP ===== */
.quick-note-popup {
  position: fixed; z-index: 3500; background: white; border-radius: 10px; padding: 14px;
  box-shadow: 0 6px 28px rgba(0,0,0,.16), 0 0 0 1px rgba(0,0,0,.07);
  width: 230px; display: flex; flex-direction: column; gap: 8px;
}
.quick-note-label { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.quick-note-popup textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: 7px;
  padding: 8px 10px; font-size: 13px; font-family: inherit; resize: none; outline: none;
}
.quick-note-popup textarea:focus { border-color: var(--primary); }
.quick-note-popup input[type=text] {
  width: 100%; border: 1.5px solid var(--border); border-radius: 7px;
  padding: 8px 10px; font-size: 13px; font-family: inherit; outline: none;
  background: #fafafa; color: var(--text);
}
.quick-note-popup input[type=text]:focus { border-color: var(--primary); background: white; }
.quick-note-actions { display: flex; gap: 6px; }
.quick-note-actions .btn-primary { flex: 1; padding: 8px; font-size: 12px; font-weight: 600; }
.quick-note-actions .btn-secondary { padding: 8px 12px; font-size: 12px; }

/* ===== EVENT PREVIEW (while modal is open) ===== */
.event-preview { opacity: 0.5; pointer-events: none; }

/* ===== RESIZE HANDLE ===== */
.resize-handle {
  position: absolute; bottom: 0; left: 0; right: 0; height: 10px;
  cursor: ns-resize; z-index: 2;
}
.resize-handle::after {
  content: ''; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; border-radius: 2px; background: currentColor; opacity: 0;
  transition: opacity .15s;
}
.cal-event:hover .resize-handle::after { opacity: 0.45; }

/* ===== DRAG GHOST ===== */
.drag-ghost {
  position: fixed; pointer-events: none; z-index: 9000;
  box-shadow: 0 8px 24px rgba(0,0,0,.3); transform: rotate(1.5deg) scale(1.02);
  transition: none !important;
}

/* ===== FOTOS DROP ZONE ===== */
.fotos-drop-zone {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  border: 2px dashed var(--border); border-radius: 8px; padding: 12px 16px;
  background: var(--bg); cursor: default; transition: border-color .15s, background .15s;
}
.fotos-drop-zone.drag-over {
  border-color: var(--primary); background: var(--primary-light);
}
.fotos-drop-hint { font-size: 13px; color: var(--text-muted); }
.fotos-file-label {
  display: inline-block; padding: 5px 12px; background: white; border: 1px solid var(--border);
  border-radius: 6px; font-size: 12px; color: var(--text); cursor: pointer; white-space: nowrap;
  transition: background .15s;
}
.fotos-file-label:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.fotos-file-label input[type=file] { display: none; }

/* ===== FOTOS PREVIEW ===== */
.fotos-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.foto-thumb { position: relative; }
.foto-thumb img {
  width: 80px; height: 80px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--border); cursor: zoom-in; transition: transform .15s;
}
.foto-thumb img:hover { transform: scale(1.05); }
.foto-remove {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
  background: var(--red); color: white; border-radius: 50%; font-size: 12px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  line-height: 1;
}

/* ===== LIGHTBOX ===== */
.lightbox-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.93); z-index: 5000;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-overlay img {
  max-width: 90vw; max-height: 85vh; object-fit: contain; border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6); user-select: none;
}
.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,.15); color: white; width: 44px; height: 44px;
  font-size: 26px; border-radius: 50%; line-height: 1;
}
.lightbox-close:hover { background: rgba(255,255,255,.3); }
.lightbox-prev, .lightbox-next {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.15); color: white; width: 52px; height: 52px;
  font-size: 36px; border-radius: 50%; line-height: 1;
}
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-prev:hover, .lightbox-next:hover { background: rgba(255,255,255,.3); }
.lightbox-counter {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.65); font-size: 13px; pointer-events: none;
}

/* ===== CURRENT TIME LINE ===== */
.current-time-line {
  position: absolute; left: 0; right: 0; height: 2px; background: #ef4444; z-index: 20; pointer-events: none;
}
.current-time-line::before {
  content: ''; position: absolute; left: -4px; top: -4px;
  width: 10px; height: 10px; border-radius: 50%; background: #ef4444;
}

/* ===== SCROLLBAR ===== */
#calendarContainer::-webkit-scrollbar { width: 6px; }
#calendarContainer::-webkit-scrollbar-track { background: transparent; }
#calendarContainer::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== AGENTS BUTTON ===== */
.btn-agents {
  padding: 6px 16px; background: rgba(255,255,255,.15); color: #fff;
  font-weight: 600; border-radius: 20px; font-size: 13px;
  border: 1px solid rgba(255,255,255,.25);
}
.btn-agents:hover { background: rgba(255,255,255,.28); }

/* ===== AGENTS MODAL ===== */
.agents-modal-box { max-width: 560px; }
.agents-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; }

.agents-list { display: flex; flex-direction: column; gap: 6px; min-height: 40px; }
.agent-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--bg); border-radius: 8px;
  border: 1px solid var(--border);
}
.agent-info { display: flex; flex-direction: column; gap: 2px; }
.agent-name { font-weight: 600; font-size: 14px; color: var(--text); }
.agent-username { font-size: 12px; color: var(--text-muted); }
.btn-agent-delete {
  padding: 5px 12px; background: var(--red-light); color: var(--red);
  border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.btn-agent-delete:hover { background: var(--red); color: white; }
.btn-agent-delete.confirming { background: var(--red); color: white; }
.agents-empty { font-size: 13px; color: var(--text-muted); padding: 10px 0; font-style: italic; }
.agents-loading { font-size: 13px; color: var(--text-muted); padding: 10px 0; }

.agents-add-section {
  border-top: 1px solid var(--border); padding-top: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.agents-add-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.agent-form .form-row { gap: 10px; }
.agent-form .form-group { margin-bottom: 0; }
.agents-form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }
.agents-add-btn { flex: none; padding: 9px 20px; }
.agent-form-error { font-size: 12px; color: var(--red); flex: 1; }

/* ===== LOGIN USERNAME ===== */
.login-box input[type=text] {
  width: 100%; padding: 12px 16px; border: 2px solid var(--border); border-radius: 8px;
  font-size: 16px; outline: none; transition: border-color .2s; margin-bottom: 12px;
}
.login-box input[type=text]:focus { border-color: var(--primary); }

/* ===== MOBILE ===== */
@media (max-width: 767px) {
  .app-header {
    height: auto; flex-wrap: wrap; padding: 8px 10px; gap: 6px;
  }
  .header-left { flex: 1; min-width: 0; }
  .logo-text { font-size: 15px; }
  .role-tag { font-size: 10px; }
  .header-center { order: 3; width: 100%; justify-content: center; }
  .header-right { gap: 4px; }
  .period-label { font-size: 13px; min-width: 120px; }
  .btn-today { padding: 6px 10px; font-size: 12px; }
  .btn-view { padding: 6px 10px; font-size: 12px; }
  .btn-logout { padding: 6px 10px; font-size: 12px; }

  .metrics-bar { height: auto; flex-wrap: wrap; padding: 6px 10px; gap: 6px; background: #f1f5f9; }
  .metric-card { flex: 1; min-width: 140px; padding: 6px 10px; border-radius: 10px; }
  .metric-label { font-size: 10px; }
  .metric-value { font-size: 14px; }

  #calendarContainer { height: calc(100vh - 112px - 52px); }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-box {
    max-width: 100%; width: 100%; max-height: 92vh;
    border-radius: 14px 14px 0 0;
  }

  .form-row { flex-direction: column; gap: 0; }
  .form-group.flex2 { flex: 1; }
}

@media (max-width: 768px) {
  .period-label { display: none; }
  .header-right .btn-logout { display: none; }
}
