/* === PANEL ADMINISTRATIVO — CAFETERIA ===
   Dashboard de cobros, consumos y control de alumnos.
   ============================================================ */
.sgad {
  --sgad-primary:   #0057b8;
  --sgad-primary-dark: #004a9e;
  --sgad-bg:        #f8fafc;
  --sgad-card:      #ffffff;
  --sgad-soft:      #f1f5f9;
  --sgad-border:    #e2e8f0;
  --sgad-text:      #0f172a;
  --sgad-muted:     #64748b;
  --sgad-success:   #0f8f91;
  --sgad-danger:    #d62828;
  --sgad-warn:      #d97706;
  --sgad-shadow:    0 1px 3px rgba(0,0,0,.08);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--sgad-text);
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.sgad h2, .sgad h3, .sgad h4 { margin: 0; }

.sgad-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px solid var(--sgad-border);
  border-radius: 16px;
  background: var(--sgad-card);
  box-shadow: var(--sgad-shadow);
}
.sgad-tab {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--sgad-border);
  border-radius: 12px;
  background: var(--sgad-soft);
  color: var(--sgad-text);
  font-weight: 700;
  cursor: pointer;
}
.sgad-tab.is-active {
  background: var(--sgad-primary);
  border-color: var(--sgad-primary);
  color: #fff;
}
.sgad-tab-panel[hidden] { display: none !important; }
.sgad-tab-panel { display: grid; gap: 18px; }

/* === HEADER === */
.sgad-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(135deg,#2f63e7 0%,#1f56dc 100%);
  border-radius: 18px;
  color: #fff;
}
.sgad-header h2 { font-size: 20px; font-weight: 700; color: #fff; }
.sgad-header p { margin: 4px 0 0; color: rgba(255,255,255,.85); font-size: 14px; }

.sgad-date {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.15);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

/* === FILTERS === */
.sgad-filters {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}
.sgad-filter {
  display: grid;
  gap: 4px;
}
.sgad-filter__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--sgad-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.sgad-filters select {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--sgad-border);
  border-radius: 10px;
  background: var(--sgad-card);
  color: var(--sgad-text);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}

/* === SEARCH === */
.sgad-search { position: relative; }
.sgad-search input { width: 100%; min-height: 44px; padding-left: 16px; }
.sgad-search__results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 6px;
  background: var(--sgad-card);
  border: 1px solid var(--sgad-border);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,63,138,.12);
  z-index: 30;
  max-height: 380px;
  overflow: auto;
}
.sgad-search__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--sgad-border);
  cursor: pointer;
  transition: background .12s;
}
.sgad-search__item:last-child { border-bottom: 0; }
.sgad-search__item:hover { background: var(--sgad-soft); }
.sgad-search__item strong { font-weight: 600; }
.sgad-search__item span { color: var(--sgad-muted); font-size: 12px; }

/* === BUTTONS === */
.sgad-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.sgad-btn--primary {
  background: var(--sgad-primary);
  border-color: var(--sgad-primary);
  color: #fff;
}
.sgad-btn--primary:hover { background: var(--sgad-primary-dark); border-color: var(--sgad-primary-dark); }
.sgad-btn--light {
  background: var(--sgad-card);
  border-color: var(--sgad-border);
  color: var(--sgad-text);
}
.sgad-btn--light:hover { border-color: var(--sgad-primary); color: var(--sgad-primary); }

/* === WIDGET GRID === */
.sgad-grid {
  display: grid;
  gap: 16px;
}
.sgad-grid--3 { grid-template-columns: repeat(3, 1fr); }

.sgad-widget {
  background: var(--sgad-card);
  border: 1px solid var(--sgad-border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--sgad-shadow);
}
.sgad-widget h3 { font-size: 15px; font-weight: 700; color: var(--sgad-text); margin-bottom: 14px; }
.sgad-widget__body--loading { color: var(--sgad-muted); font-size: 14px; padding: 20px 0; }
.sgad-widget__empty { color: var(--sgad-muted); font-size: 13px; padding: 16px 0; text-align: center; }

/* widget kpi */
.sgad-kpi {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}
.sgad-kpi strong { font-size: 32px; font-weight: 800; color: var(--sgad-primary); line-height: 1; }
.sgad-kpi span { color: var(--sgad-muted); font-size: 13px; }

/* bar chart */
.sgad-bars { display: grid; gap: 8px; }
.sgad-bar {
  display: grid;
  grid-template-columns: 110px 1fr 44px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.sgad-bar__label { color: var(--sgad-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sgad-bar__track { height: 14px; background: var(--sgad-soft); border-radius: 999px; overflow: hidden; }
.sgad-bar__fill { height: 100%; background: var(--sgad-primary); border-radius: 999px; min-width: 2px; transition: width .3s; }
.sgad-bar__value { text-align: right; font-weight: 700; color: var(--sgad-text); }

/* --- Barra clickable (nivel) --- */
.sgad-bar--clickable { cursor: pointer; padding: 6px 8px; border-radius: 10px; transition: background .15s, transform .1s; }
.sgad-bar--clickable:hover { background: #eef4ff; transform: translateX(2px); }
.sgad-bar--clickable:hover .sgad-bar__fill { background: var(--sgad-primary-dark); }
.sgad-bar--clickable:hover .sgad-bar__label { color: var(--sgad-primary); }

/* --- Vista de lista de alumnos --- */
.sgad-listview__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

/* === TABLES === */
.sgad-table-wrap { overflow: auto; border: 1px solid var(--sgad-border); border-radius: 14px; max-height: 320px; }
.sgad-table-wrap--wide { max-height: 620px; }
.sgad-table { width: 100%; min-width: 480px; border-collapse: collapse; background: var(--sgad-card); }
.sgad-table--material { min-width: 820px; }
.sgad-table th, .sgad-table td { padding: 9px 12px; border-bottom: 1px solid var(--sgad-border); font-size: 13px; vertical-align: middle; }
.sgad-table th { background: var(--sgad-soft); text-align: left; color: var(--sgad-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; }
.sgad-table tr:last-child td { border-bottom: 0; }
.sgad-table tr.debt-red td { background: #fef2f2; }
.sgad-table tr.debt-yellow td { background: #fffbeb; }
.sgad-status-select { min-width: 124px; padding: 7px 10px; border: 1px solid var(--sgad-border); border-radius: 10px; background: #fff; font-weight: 700; color: var(--sgad-text); }
.sgad-status-select.is-saved { border-color: var(--sgad-success); box-shadow: 0 0 0 3px rgba(15, 143, 145, .14); }
.sgad-status-select.is-error { border-color: var(--sgad-danger); }

/* badges */
.sgad-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.sgad-badge--payment { background: #ecfdf5; color: var(--sgad-success); }
.sgad-badge--consumption { background: #fef2f2; color: var(--sgad-danger); }
.sgad-amount--payment { color: var(--sgad-success); font-weight: 700; }
.sgad-amount--consumption { color: var(--sgad-danger); font-weight: 700; }

.sgad-student { font-weight: 600; line-height: 1.25; }
.sgad-student small { display: block; color: var(--sgad-muted); font-weight: 400; font-size: 11px; }

/* === ACTION CARDS === */
.sgad-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sgad-action-card {
  background: var(--sgad-card);
  border: 1px solid var(--sgad-border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--sgad-shadow);
}
.sgad-action-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.sgad-action-card form { display: grid; gap: 10px; }
.sgad-action-card input[type="date"] {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--sgad-border);
  border-radius: 10px;
  background: var(--sgad-card);
  color: var(--sgad-text);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}
.sgad-action-card input:focus,
.sgad-action-card select:focus,
.sgad-filters select:focus,
.sgad-search input:focus {
  outline: none;
  border-color: var(--sgad-primary);
  box-shadow: 0 0 0 2px rgba(0, 87, 184, .15);
}

/* === CORTE DE CAJA === */
.sgad-cuts {
  background: var(--sgad-card);
  border: 1px solid var(--sgad-border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--sgad-shadow);
  margin-top: 18px;
}
.sgad-cuts__form form {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 10px;
  align-items: end;
}
.sgad-cuts__form input[type="date"] {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--sgad-border);
  border-radius: 10px;
  background: var(--sgad-card);
  color: var(--sgad-text);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}

/* --- Student combo (input + datalist) --- */
.sgad-student-combo {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--sgad-border);
  border-radius: 10px;
  background: var(--sgad-card);
  color: var(--sgad-text);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .15s;
}
.sgad-student-combo:focus {
  outline: none;
  border-color: var(--sgad-primary);
  box-shadow: 0 0 0 2px rgba(0, 87, 184, .15);
}
.sgad-student-combo::placeholder {
  color: var(--sgad-muted);
  opacity: .7;
}
.sgad-student-combo[hidden] { display: none; }

.sgad-note { display: block; min-height: 16px; }

.sgad-form-msg { font-size: 13px; padding: 8px 12px; border-radius: 10px; display: none; }
.sgad-form-msg.is-ok { display: block; background: #ecfdf5; color: var(--sgad-success); }
.sgad-form-msg.is-err { display: block; background: #fef2f2; color: var(--sgad-danger); }

/* === MODAL === */
.sgad-modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 9999; }
.sgad-modal[hidden] { display: none !important; }
.sgad-modal__box { background: var(--sgad-card); border-radius: 18px; padding: 24px; max-width: 640px; width: 92%; max-height: 86vh; overflow: auto; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.sgad-modal__close { position: absolute; top: 12px; right: 16px; background: none; border: none; font-size: 26px; cursor: pointer; color: var(--sgad-muted); line-height: 1; }
.sgad-modal__box h3 { margin-bottom: 14px; }

/* === PANEL STATES === */
.sgad-panel { padding: 14px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; }
.sgad-panel--warn { background: #fff1f1; border: 1px solid #f3c3be; color: var(--sgad-danger); }

/* === RESPONSIVE === */
@media (max-width: 920px) {
  .sgad-grid--3 { grid-template-columns: 1fr; }
  .sgad-actions { grid-template-columns: 1fr; }
  .sgad-header { flex-direction: column; }
}
@media (max-width: 760px) {
  .sgad-filters { grid-template-columns: 1fr; }
  .sgad-cuts__form form { grid-template-columns: 1fr; }
}
