/* =============================================
   CERDOS CORRAL GRANDE — v1
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f5f6fa;
  --surface:   #ffffff;
  --border:    #e8ecf0;
  --border-lt: #f0f2f5;
  --accent:    #c24f7a;
  --accent-dk: #9e3460;
  --accent-lt: #fce8f0;
  --accent-xlt:#fef5f8;
  --text:      #1a1f36;
  --text-2:    #4a5568;
  --text-3:    #8a96a8;
  --green:     #0d9f6e;
  --green-lt:  #e6f9f3;
  --orange:    #e07b1f;
  --orange-lt: #fff4e6;
  --red:       #e03535;
  --red-lt:    #fef0f0;
  --blue:      #2563eb;
  --blue-lt:   #eff6ff;
  --purple:    #7c3aed;
  --purple-lt: #f5f3ff;
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow:    0 2px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --sidebar-w: 240px;
}

body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; font-size: 14px; line-height: 1.5; }

/* SIDEBAR */
#sidebar { width: var(--sidebar-w); background: #1a1f36; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; transition: transform .25s cubic-bezier(.4,0,.2,1); }
#sidebar-header { padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo { display: flex; align-items: center; gap: 12px; }
.sidebar-logo-img { width: 48px; height: 48px; border-radius: 50%; background: #f5f0e4; object-fit: contain; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.sidebar-logo h1 { font-size: .9rem; font-weight: 700; color: #fff; line-height: 1.2; }
.sidebar-logo p  { font-size: .66rem; color: rgba(255,255,255,.4); margin: 0; }
#sidebar nav { flex: 1; overflow-y: auto; padding: 12px 0; scrollbar-width: none; }
#sidebar nav::-webkit-scrollbar { display: none; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; cursor: pointer; font-size: .82rem; font-weight: 500; color: rgba(255,255,255,.55); transition: background .15s, color .15s; border: none; background: none; width: 100%; text-align: left; position: relative; }
.nav-item:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.9); }
.nav-item.active { background: rgba(194,79,122,.18); color: #f093b6; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; background: var(--accent); border-radius: 0 3px 3px 0; }
.nav-item .icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
#sidebar-footer { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: .7rem; color: rgba(255,255,255,.2); text-align: center; }

/* MAIN */
#main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
#top-bar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 28px; height: 60px; display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow-sm); }
#hamburger { display: none; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-2); padding: 4px; }
.top-bar-left { display: flex; align-items: center; gap: 10px; flex: 1; }
h2.page-title { font-size: 1rem; font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.top-bar-date { font-size: .75rem; color: var(--text-3); margin-left: auto; white-space: nowrap; }
#page-body { flex: 1; padding: 28px; max-width: 1100px; }
.section { display: none; }
.section.active { display: block; }

/* DASHBOARD BANNER */
.dash-banner { display: flex; align-items: center; gap: 18px; background: linear-gradient(135deg, #1a1f36 0%, #2d1a0e 100%); border-radius: var(--radius-lg); padding: 20px 24px; margin-bottom: 24px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.dash-banner::before { content: ''; position: absolute; top: -30px; right: -30px; width: 130px; height: 130px; background: rgba(194,79,122,.15); border-radius: 50%; }
.dash-banner-logo { width: 72px; height: 72px; border-radius: 50%; background: #f5f0e4; object-fit: contain; flex-shrink: 0; box-shadow: 0 4px 16px rgba(0,0,0,.3); position: relative; z-index: 1; }
.dash-banner-text { position: relative; z-index: 1; }
.dash-banner-text h2 { font-size: 1.25rem; font-weight: 800; color: #fff; margin-bottom: 4px; }
.dash-banner-text p  { font-size: .75rem; color: rgba(255,255,255,.5); text-transform: capitalize; }

/* STATS */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.stat-box::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--c, var(--accent)); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.stat-icon { font-size: 1.4rem; margin-bottom: 10px; display: block; }
.stat-val { font-size: 2rem; font-weight: 700; color: var(--c, var(--accent)); line-height: 1; letter-spacing: -.03em; }
.stat-lbl { font-size: .72rem; color: var(--text-3); margin-top: 5px; font-weight: 500; }

/* CARD */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 18px; overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border-lt); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title { font-size: .85rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.card-title .card-icon { width: 28px; height: 28px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: .9rem; flex-shrink: 0; }
.icon-bg-pink   { background: var(--accent-lt); }
.icon-bg-green  { background: var(--green-lt); }
.icon-bg-orange { background: var(--orange-lt); }
.icon-bg-blue   { background: var(--blue-lt); }
.card-body    { padding: 20px; }
.card-body-sm { padding: 16px 20px; }

/* PAGE ACTIONS */
.page-actions { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-actions-title { font-size: .85rem; font-weight: 600; color: var(--text-2); }

/* FORMS */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: .72rem; font-weight: 600; color: var(--text-2); }
input, select, textarea { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px; font-size: .83rem; font-family: inherit; color: var(--text); background: var(--surface); transition: border-color .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(194,79,122,.1); }
input::placeholder { color: var(--text-3); font-size: .8rem; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-size: .8rem; font-weight: 600; font-family: inherit; transition: all .15s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(194,79,122,.3); }
.btn-primary:hover { background: var(--accent-dk); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-2); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-2); padding: 6px 10px; }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 11px; font-size: .75rem; }
.btn-xs { padding: 3px 8px; font-size: .7rem; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: .9rem; padding: 5px 7px; border-radius: var(--radius-sm); color: var(--text-3); transition: all .15s; }
.btn-icon:hover { background: var(--bg); color: var(--red); }

/* TABLE */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .8rem; }
thead tr { background: var(--bg); border-bottom: 2px solid var(--border); }
thead th { padding: 10px 14px; font-size: .7rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; text-align: left; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border-lt); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--accent-xlt); }
tbody td { padding: 11px 14px; vertical-align: middle; color: var(--text-2); }
tbody td strong { color: var(--text); font-weight: 600; }

/* BADGES */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: .68rem; font-weight: 700; }
.badge-green  { background: var(--green-lt);  color: var(--green); }
.badge-orange { background: var(--orange-lt); color: var(--orange); }
.badge-red    { background: var(--red-lt);    color: var(--red); }
.badge-blue   { background: var(--blue-lt);   color: var(--blue); }
.badge-pink   { background: var(--accent-lt); color: var(--accent-dk); }
.badge-purple { background: var(--purple-lt); color: var(--purple); }

/* ALERTS */
.alerts-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: var(--radius); font-size: .81rem; border: 1px solid transparent; }
.alert-item.danger  { background: var(--red-lt);    border-color: rgba(224,53,53,.2); }
.alert-item.warning { background: var(--orange-lt); border-color: rgba(224,123,31,.2); }
.alert-item.info    { background: var(--blue-lt);   border-color: rgba(37,99,235,.15); }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.danger  .alert-dot { background: var(--red); }
.warning .alert-dot { background: var(--orange); }
.info    .alert-dot { background: var(--blue); }
.alert-body strong { display: block; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.alert-body span   { color: var(--text-2); font-size: .76rem; }

/* CALENDAR */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell { min-height: 80px; border-radius: 8px; padding: 6px; background: var(--bg); border: 1.5px solid var(--border-lt); position: relative; }
.cal-cell.cal-hdr { min-height: auto; background: transparent; border: none; text-align: center; font-size: .68rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; padding: 4px 2px 6px; }
.cal-cell.cal-empty { background: transparent; border-color: transparent; }
.cal-cell.cal-today { border-color: var(--accent); background: var(--accent-xlt); }
.cal-cell.cal-has-events { border-color: var(--orange); }
.cal-day-num { font-size: .75rem; font-weight: 600; color: var(--text-3); margin-bottom: 4px; }
.cal-cell.cal-today .cal-day-num { background: var(--accent); color: #fff; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .68rem; }
.cal-event { border-radius: 4px; padding: 2px 5px; font-size: .62rem; font-weight: 600; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event.parto  { background: var(--red-lt);    color: var(--red);    border-left: 2px solid var(--red); }
.cal-event.subida { background: var(--orange-lt); color: var(--orange); border-left: 2px solid var(--orange); }
.cal-resumen { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-lt); font-size: .75rem; color: var(--text-3); font-weight: 500; }
.cal-resumen span { display: flex; align-items: center; gap: 6px; }
.cal-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cal-dot.parto  { background: var(--red); }
.cal-dot.subida { background: var(--orange); }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,12,30,.5); backdrop-filter: blur(2px); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn .15s ease; }
.modal-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 500px; box-shadow: var(--shadow-lg); animation: slideUp .2s cubic-bezier(.4,0,.2,1); overflow: hidden; }
@keyframes slideUp { from { transform:translateY(16px);opacity:0 } to { transform:translateY(0);opacity:1 } }
.modal-header { padding: 18px 20px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: .95rem; font-weight: 700; color: var(--text); }
.modal-close { background: var(--bg); border: none; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: .9rem; color: var(--text-3); display: flex; align-items: center; justify-content: center; transition: all .15s; }
.modal-close:hover { background: var(--red-lt); color: var(--red); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--bg); }

/* HISTORIAL MODAL */
.hist-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.hist-stat-box { flex: 1; min-width: 90px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; text-align: center; }
.hst-lbl { font-size: .65rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.hst-val { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.hist-info-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.hist-info-item { flex: 1; min-width: 200px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hi-lbl { font-size: .72rem; color: var(--text-3); font-weight: 600; }
.hi-val { font-size: .82rem; font-weight: 700; color: var(--text); }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* FILTER BAR */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-bar label { font-size: .75rem; color: var(--text-3); white-space: nowrap; }
.filter-bar select, .filter-bar input { min-width: 140px; max-width: 200px; padding: 6px 10px; font-size: .78rem; }

/* EMPTY */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .6; }
.empty-state p { font-size: .82rem; }

/* TOAST */
#toast { position: fixed; bottom: 28px; right: 28px; background: var(--text); color: #fff; padding: 11px 18px; border-radius: var(--radius); font-size: .8rem; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; transform: translateY(8px); z-index: 1000; box-shadow: var(--shadow-lg); }
#toast.show { opacity: 1; transform: translateY(0); }

/* SIDEBAR OVERLAY */
#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 99; }
#sidebar-overlay.show { display: block; }

/* RESPONSIVE */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  #main { margin-left: 0; }
  #hamburger { display: flex; }
  #page-body { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .cal-cell { min-height: 58px; padding: 4px; }
  .cal-event { font-size: .55rem; }
}
