/* ── Variables ── */
:root {
  --navy:   #4a2a14;
  --blue:   #8a5a2c;
  --gold:   #c9a55c;
  --light:  #f7f1e6;
  --white:  #ffffff;
  --text:   #3a2a1a;
  --muted:  #8a7860;
  --border: #e3d5bd;
  --red:    #e74c3c;
  --green:  #27ae60;
  --yellow: #f39c12;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,.12);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--light); color: var(--text); font-size: 14px; }
a { text-decoration: none; color: inherit; cursor: pointer; }
button { cursor: pointer; font-family: inherit; font-size: 13px; }
input, select, textarea { font-family: inherit; font-size: 13px; }

/* ── Layout ── */
.layout { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 220px; min-width: 220px;
  background: var(--navy);
  color: var(--white);
  display: flex; flex-direction: column;
  box-shadow: 2px 0 8px rgba(0,0,0,.2);
}
.sidebar-brand {
  padding: 16px;
  background: var(--light);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.brand-logo { max-width: 100%; height: auto; display: block; }
.brand-name { font-size: 15px; font-weight: 600; line-height: 1.2; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px;
  color: rgba(255,255,255,.75);
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
  font-size: 13.5px;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: var(--white); }
.nav-item.active { background: rgba(255,255,255,.12); color: var(--white); border-left-color: var(--gold); font-weight: 600; }
.nav-icon { width: 18px; text-align: center; font-size: 15px; }

/* ── Main ── */
.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

/* ── Page header ── */
.page-header {
  background: var(--white);
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.page-title { font-size: 20px; font-weight: 700; color: var(--navy); }
.page-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Content ── */
.page-content { padding: 24px 28px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: #fafbfd;
}
.card-title { font-weight: 600; font-size: 14px; color: var(--navy); }
.card-body { padding: 18px; }

/* ── Dashboard grid ── */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-top: 4px solid var(--blue);
  text-align: center;
}
.stat-card.gold  { border-top-color: var(--gold); }
.stat-card.green { border-top-color: var(--green); }
.stat-card.red   { border-top-color: var(--red); }
.stat-value { font-size: 36px; font-weight: 700; color: var(--navy); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px;
  font-weight: 500; border: none; transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary   { background: var(--blue);  color: var(--white); }
.btn-navy      { background: var(--navy);  color: var(--white); }
.btn-gold      { background: var(--gold);  color: var(--white); }
.btn-danger    { background: var(--red);   color: var(--white); }
.btn-ghost     { background: transparent; color: var(--blue); border: 1px solid var(--blue); }
.btn-sm        { padding: 5px 10px; font-size: 12px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--navy); color: var(--white);
  padding: 10px 12px; text-align: left;
  font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; overflow-wrap: anywhere; word-break: break-word; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f7f9fc; }
tr.rev-warn td  { background-color: #fffbeb; }
tr.rev-warn:hover td  { background-color: #fff4c2; }
tr.rev-danger td { background-color: #fff1f1; }
tr.rev-danger:hover td { background-color: #ffe4e4; }
.monthly-table tr.rev-warn td  { background-color: #fffbeb; }
.monthly-table tr.rev-warn:hover td  { background-color: #fff4c2; }
.monthly-table tr.rev-danger td { background-color: #fff1f1; }
.monthly-table tr.rev-danger:hover td { background-color: #ffe4e4; }
.td-actions { display: flex; gap: 6px; white-space: nowrap; flex-wrap: nowrap; }

/* ── Estado badges ── */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px; white-space: nowrap;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
}
.badge-proceso    { background: #dbeafe; color: #1d4ed8; }
.badge-terminado  { background: #dcfce7; color: #15803d; }
.badge-suspendido { background: #fef9c3; color: #a16207; }

/* ── Filters bar ── */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  background: var(--white); padding: 16px 18px;
  border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); margin-bottom: 20px;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.filter-group select, .filter-group input {
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--white); color: var(--text);
  min-width: 150px;
}
.filter-group select:focus, .filter-group input:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(138,90,44,.15);
}

/* ── Monthly table ── */
.monthly-wrap { overflow-x: auto; }
.monthly-table { border-collapse: collapse; width: 100%; }
.monthly-table th {
  background: var(--navy); color: var(--white);
  padding: 9px 10px; font-size: 11px; text-transform: uppercase; white-space: nowrap;
}
.monthly-table th.day-col { min-width: 54px; text-align: center; }
.monthly-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13px; overflow-wrap: anywhere; word-break: break-word; }
.monthly-table tr:hover td { background: #f7f9fc; }
.day-cell { text-align: center; }
.day-btn {
  width: 44px; height: 32px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: #f8f9fc;
  cursor: pointer;
  font-size: 16px;
  color: transparent;
  transition: background .15s, border-color .15s, transform .1s;
  display: flex; align-items: center; justify-content: center;
}
.day-btn:hover { border-color: var(--blue); background: #f7f0e4; }
.day-btn:active { transform: scale(.92); }
.day-btn.day-checked {
  background: #dcfce7;
  border-color: #4ade80;
  color: #15803d;
  font-weight: 700;
}

.obs-input {
  width: 100%; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: 4px; font-size: 12px; resize: none;
}
.obs-input:focus { outline: none; border-color: var(--blue); }

.obs-btn {
  background: transparent; border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 10px; font-size: 12px;
  color: var(--text); cursor: pointer; text-align: left;
  width: 100%; min-width: 160px; max-width: 240px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color .15s, background .15s; display: block;
}
.obs-btn:hover { border-color: var(--blue); background: #f7f0e4; }
.obs-btn.sin-obs { color: var(--muted); font-style: italic; }

/* ── Semáforo de urgencia ── */
.urgencia-sel { display: flex; gap: 5px; align-items: center; justify-content: center; }
.urgencia-opt {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
  opacity: .28; transition: opacity .15s, transform .15s;
}
.urgencia-opt:hover  { opacity: .65; transform: scale(1.15); }
.urgencia-opt.active { opacity: 1; border-color: rgba(0,0,0,.25); transform: scale(1.2); box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.urgencia-opt.verde   { background: #22c55e; }
.urgencia-opt.naranja { background: #f97316; }
.urgencia-opt.rojo    { background: #ef4444; }

.urgencia-dot {
  width: 13px; height: 13px; border-radius: 50%; display: inline-block;
  border: 2px solid rgba(0,0,0,.15); flex-shrink: 0; cursor: default;
  vertical-align: middle;
}
button.urgencia-dot {
  padding: 0; background-color: transparent;
  cursor: pointer; appearance: none; -webkit-appearance: none;
}
button.urgencia-dot:focus { outline: none; }
.urgencia-dot.verde   { background: #22c55e; }
.urgencia-dot.naranja { background: #f97316; }
.urgencia-dot.rojo    { background: #ef4444; }
.urgencia-dot.has-comment {
  outline: 2.5px solid rgba(0,0,0,.35);
  outline-offset: 2px;
  transition: transform .15s, outline-offset .15s;
}
button.urgencia-dot.has-comment:hover {
  transform: scale(1.25);
  outline-offset: 3px;
}

/* ── Popover de urgencia ── */
#urgencia-popover {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  width: 260px;
  box-shadow: 0 8px 28px rgba(0,0,0,.16);
}
.urg-pop-header {
  display: flex; align-items: center; gap: 9px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.urg-pop-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 10px;
}

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: span 2; }
.form-group.span-3 { grid-column: span 3; }
.form-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.form-control {
  padding: 8px 11px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--white); color: var(--text); width: 100%;
}
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(138,90,44,.15); }
textarea.form-control { resize: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; }
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--white); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.25); z-index: 101;
  width: 540px; max-width: 95vw; max-height: 90vh;
  display: flex; flex-direction: column;
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: var(--white); border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--white); font-size: 18px; opacity: .7; }
.modal-close:hover { opacity: 1; }
.modal-body { padding: 22px 20px; overflow-y: auto; flex: 1; }
.modal.wide { width: 700px; }
.hidden { display: none !important; }

/* ── Config sections ── */
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.list-item:last-child { border-bottom: none; }
.list-item-name { font-weight: 500; }
.list-item-sub  { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Rotacion table ── */
.rot-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.rot-table th { background: #f0f4f8; color: var(--navy); padding: 8px 12px; font-size: 12px; text-align: left; }
.rot-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }

/* ── Leyenda ── */
.leyenda { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 12px; }
.leyenda-item { display: flex; align-items: center; gap: 5px; }
.leyenda-swatch { width: 24px; height: 16px; border-radius: 3px; border: 1px solid rgba(0,0,0,.1); font-size: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; }

/* ── Empty state ── */
.empty { text-align: center; padding: 40px; color: var(--muted); }
.empty-icon { font-size: 48px; opacity: .3; }
.empty-text { margin-top: 12px; font-size: 14px; }

/* ── Landing / Selección de usuario ── */
.landing-screen {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--gold) 100%);
}
.landing-box {
  background: var(--white); border-radius: 20px;
  padding: 44px 40px; max-width: 500px; width: 92%;
  box-shadow: 0 24px 64px rgba(0,0,0,.35); text-align: center;
}
.landing-logo-img { max-width: 260px; width: 80%; height: auto; margin-bottom: 16px; }
.landing-title { font-size: 24px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.landing-sub   { font-size: 13px; color: var(--muted); margin-bottom: 28px; }

.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.user-card {
  border: 2px solid var(--border); border-radius: 12px;
  padding: 18px 10px 14px; cursor: pointer; background: var(--white);
  transition: border-color .15s, box-shadow .15s, transform .12s;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.user-card:hover {
  border-color: var(--blue); box-shadow: 0 6px 20px rgba(138,90,44,.2);
  transform: translateY(-3px);
}
.user-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--navy); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; letter-spacing: -1px;
}
.user-card-name { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.3; }
.guest-row { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.guest-btn {
  width: 100%; padding: 11px 16px; cursor: pointer;
  border: 2px dashed var(--border); border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 13px;
  transition: border-color .15s, color .15s, background .15s;
}
.guest-btn:hover { border-color: var(--navy); color: var(--navy); background: var(--light); }

/* Indicador de estado de conexión / sincronización */
.sync-status { padding: 7px 14px; font-size: 11px; line-height: 1.4; border-top: 1px solid rgba(255,255,255,.08); }
.sync-status.offline { background: rgba(239,68,68,.18); color: #fca5a5; }
.sync-status.syncing { background: rgba(251,146,60,.18); color: #fdba74; }
.sync-status.online  { background: rgba(34,197,94,.15); color: #86efac; }

/* Usuario en sidebar */
.sidebar-user { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding: 12px 16px; }
.sidebar-user-name { color: var(--white); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,.45); margin-top: 2px; }
.sidebar-change-btn {
  font-size: 11px; color: rgba(255,255,255,.38); background: none;
  border: none; cursor: pointer; padding: 0; margin-top: 5px;
  width: 100%; text-align: left; transition: color .15s;
}
.sidebar-change-btn:hover { color: rgba(255,255,255,.75); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { width: 60px; min-width: 60px; }
  .brand-name, .nav-item span:not(.nav-icon) { display: none; }
  .config-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.span-2, .form-group.span-3 { grid-column: span 1; }
  .page-content { padding: 16px; }
}
