/* ============================================================
   maintain-admin.css — Sistema de diseño completo
   Sin dependencias externas. Incluye Bootstrap 5 overrides.
   Fuentes: DM Sans + DM Mono (Google Fonts, autoincluidas
            en el layout PHP vía <link>)
   ============================================================ */

/* ── Variables globales ──────────────────────────────────── */
:root {
  /* Paleta verde Maintain */
  --m-900: #0d3d28;
  --m-800: #1a6b4a;
  --m-700: #1f7d56;
  --m-600: #2d9268;
  --m-500: #3aaa7d;
  --m-400: #5ec09a;
  --m-200: #9fe0c4;
  --m-100: #d0f0e3;
  --m-50:  #eaf9f3;

  /* Semánticos */
  --color-primary:   var(--m-800);
  --color-primary-hover: var(--m-600);
  --color-success:   #15803d;
  --color-warning:   #d97706;
  --color-danger:    #c0392b;
  --color-info:      #1a56a0;

  /* Superficies */
  --surface:   #f4f6f4;
  --card:      #ffffff;
  --border:    #e0e5e2;
  --border-lt: #edf0ec;

  /* Textos */
  --text-1: #1a1f1c;
  --text-2: #4a5a55;
  --text-3: #8fa49c;

  /* Layout */
  --sidebar-w:        240px;
  --sidebar-w-collapsed: 56px;
  --topbar-h:     56px;
  --content-pad:  24px;

  /* Tipografía */
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'DM Mono', 'Fira Code', 'Consolas', monospace;

  /* Espacios */
  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 14px;

  /* Sombras */
  --shadow:    0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.05);
}

/* ── Reset y base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-1);
  background: var(--surface);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--m-700); text-decoration: none; }
a:hover { color: var(--m-600); text-decoration: underline; }

/* ── LAYOUT ──────────────────────────────────────────────── */
.m-layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.m-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--m-900);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: transform .25s cubic-bezier(.4, 0, .2, 1), width .25s cubic-bezier(.4, 0, .2, 1);
  overflow: hidden;
}

/* App logo en el sidebar */
.m-app-logo {
  transition: opacity .2s, width .25s;
}
.m-sidebar.collapsed .m-app-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

/* Brand */
.m-sidebar-brand {
  padding: 18px 20px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  text-decoration: none;
}
.m-brand-logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--m-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.m-brand-name {
  font-size: 17px; font-weight: 600;
  color: #fff; letter-spacing: -.3px;
}
.m-brand-version {
  font-size: 10px; color: rgba(255,255,255,.35);
  font-family: var(--font-mono);
  margin-top: 1px; display: block;
}

/* Company pill */
.m-company-pill {
  margin: 12px 14px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 8px;
  padding: 9px 12px;
}
.m-company-pill-label {
  font-size: 10px; color: rgba(255,255,255,.45);
  text-transform: uppercase; letter-spacing: .8px;
  margin-bottom: 2px; font-weight: 600;
}
.m-company-pill-name {
  font-size: 12.5px; font-weight: 500;
  color: rgba(255,255,255,.9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Nav */
.m-nav { flex: 1; padding: 4px 0; overflow-y: auto; }
.m-nav::-webkit-scrollbar { width: 0; }
.m-nav-section {
  font-size: 9.5px; text-transform: uppercase;
  letter-spacing: 1.2px; font-weight: 600;
  color: rgba(255,255,255,.3);
  padding: 14px 18px 5px;
}
.m-nav-item { margin: 1px 8px; }
.m-nav-link {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px;
  color: rgba(255,255,255,.65);
  font-size: 13px; font-weight: 400;
  border-radius: 7px;
  transition: all .15s;
  cursor: pointer;
  overflow: hidden;    /* clip en expandido para que el ancho sea correcto */
}

/* Texto del nav — anima al colapsar */
.m-nav-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  transition: max-width .25s cubic-bezier(.4,0,.2,1),
              opacity    .2s;
  display: inline-block;
}
.m-nav-link:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.92);
  text-decoration: none;
}
.m-nav-link.active {
  background: var(--m-700);
  color: #fff;
  font-weight: 500;
}
.m-nav-icon {
  width: 18px; height: 18px; flex-shrink: 0; opacity: .75;
  fill: currentColor;
}
.m-nav-link.active .m-nav-icon { opacity: 1; }
.m-nav-badge {
  margin-left: auto;
  background: #e8a020; color: #fff;
  border-radius: 10px; padding: 1px 7px;
  font-size: 10px; font-weight: 700;
  font-family: var(--font-mono);
}

/* Sidebar footer */
.m-sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.m-user-row {
  display: flex; align-items: center; gap: 10px;
}
.m-user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--m-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.m-user-name {
  font-size: 12px; font-weight: 500;
  color: rgba(255,255,255,.9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-user-role {
  font-size: 10.5px; color: rgba(255,255,255,.4);
}
.m-logout-btn {
  width: 26px; height: 26px; border-radius: 6px;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.35);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; margin-left: auto; flex-shrink: 0;
}
.m-logout-btn:hover {
  background: rgba(255,255,255,.10);
  color: rgba(255,255,255,.7);
}
.m-logout-btn svg { width: 15px; height: 15px; }

/* ── MAIN WRAPPER ────────────────────────────────────────── */
.m-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .25s cubic-bezier(.4, 0, .2, 1);
}

/* ── SIDEBAR COLAPSADO ───────────────────────────────────── */
.m-sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
  overflow: visible;   /* permite que el tooltip salga del sidebar */
}

/* Ocultar textos cuando colapsado */
.m-sidebar.collapsed .m-brand-name,
.m-sidebar.collapsed .m-brand-version,
.m-sidebar.collapsed .m-company-pill,
.m-sidebar.collapsed .m-nav-section,
.m-sidebar.collapsed .m-nav-link .m-nav-text,
.m-sidebar.collapsed .m-nav-badge,
.m-sidebar.collapsed .m-user-name,
.m-sidebar.collapsed .m-user-role,
.m-sidebar.collapsed .m-logout-btn2 {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  pointer-events: none;
  transition: max-width .25s, opacity .2s;
  display: inline-block;
  vertical-align: middle;
}

/* Íconos: centrados y tamaño fijo, nunca recortados */
.m-sidebar.collapsed .m-nav-link {
  justify-content: center;
  padding: 9px 0;
  width: var(--sidebar-w-collapsed);
  position: relative;
  overflow: visible;
}

.m-sidebar.collapsed .m-nav-icon {
  width: 20px;
  height: 20px;
  font-size: 18px !important;
  opacity: 1;
  flex-shrink: 0;
}

/* Brand colapsada: solo mostrar el logo */
.m-sidebar.collapsed .m-sidebar-brand {
  justify-content: center;
  padding: 18px 0 14px;
  gap: 0;
  overflow: visible;
}

/* User row colapsada: solo mostrar avatar */
.m-sidebar.collapsed .m-user-row {
  justify-content: center;
  overflow: visible;
}
.m-sidebar.collapsed .m-user-avatar,
.m-sidebar.collapsed .m-user-avatar img {
  width: 32px;
  height: 32px;
}
.m-sidebar.collapsed .m-sidebar-footer {
  overflow: visible;
}

/* ── TOOLTIP del sidebar colapsado ──────────────────────── */
/* Implementado como div#m-sidebar-tooltip via JS,
   no como ::after (que queda bloqueado por overflow:hidden) */
#m-sidebar-tooltip {
  position: fixed;
  display: block;           /* siempre en DOM, controlado por opacity */
  background: #1a3a2a;
  color: #fff;
  font-size: 12.5px;
  font-family: var(--font-sans);
  font-weight: 500;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 7px;
  pointer-events: none;
  z-index: 99999;           /* encima de todo */
  opacity: 0;
  visibility: hidden;       /* hidden en lugar de display:none para que transition funcione */
  transition: opacity .18s ease, visibility .18s ease;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  line-height: 1.4;
}
#m-sidebar-tooltip.visible {
  opacity: 1;
  visibility: visible;
}
/* Flecha apuntando a la izquierda */
#m-sidebar-tooltip::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: #1a3a2a;
}

/* Ajustar main cuando sidebar colapsada */
.m-layout.sidebar-collapsed .m-main {
  margin-left: var(--sidebar-w-collapsed);
}

/* Botón de colapso */
.m-collapse-btn {
  position: absolute;
  right: 0px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px; height: 24px;
  background: var(--m-700);
  border: 2px solid var(--m-900);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  z-index: 1001;
  transition: background .15s, transform .25s;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.m-collapse-btn:hover {
  background: var(--m-600);
}
.m-layout.sidebar-collapsed .m-collapse-btn {
  transform: translateY(-50%) rotate(180deg);
}

/* ── TOPBAR ──────────────────────────────────────────────── */
.m-topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 500;
  flex-shrink: 0;
}

.m-hamburger {
  display: none;
  width: 34px; height: 34px; border-radius: 8px;
  border: none; background: none; cursor: pointer;
  color: var(--text-2); flex-shrink: 0;
  align-items: center; justify-content: center;
}
.m-hamburger svg { width: 18px; height: 18px; }
.m-hamburger:hover { background: var(--surface); }

.m-breadcrumb {
  flex: 1; display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-3);
  white-space: nowrap; overflow: hidden;
}
.m-breadcrumb-current {
  color: var(--text-1); font-weight: 500;
}
.m-breadcrumb-sep { color: var(--border); }

.m-topbar-actions {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}

.m-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px;
  transition: all .15s; cursor: text;
  color: var(--text-3); font-size: 12.5px;
}
.m-search svg { width: 14px; height: 14px; flex-shrink: 0; }
.m-search:focus-within {
  border-color: var(--m-500);
  box-shadow: 0 0 0 3px rgba(58,170,125,.12);
}
.m-search input {
  border: none; background: none; outline: none;
  font-size: 12.5px; color: var(--text-1);
  font-family: var(--font-sans); width: 160px;
}
.m-search input::placeholder { color: var(--text-3); }

.m-icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); position: relative;
  transition: all .15s;
}
.m-icon-btn:hover { background: var(--surface); color: var(--text-1); }
.m-icon-btn svg { width: 17px; height: 17px; }

.m-notif-dot {
  position: absolute; top: 5px; right: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-danger);
  border: 2px solid var(--card);
}

.m-locale-btn {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 8px;
  font-size: 11px; font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer; color: var(--text-2);
  transition: all .15s;
}
.m-locale-btn:hover { border-color: var(--m-500); color: var(--m-800); }

/* ── NOTIFICATION PANEL ──────────────────────────────────── */
.m-notif-panel {
  position: fixed; top: calc(var(--topbar-h) + 8px); right: 16px;
  width: 320px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 600;
  overflow: hidden;
  display: none;
}
.m-notif-panel.open {
  display: block;
  animation: m-slide-down .18s cubic-bezier(.4,0,.2,1);
}
@keyframes m-slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.m-notif-header {
  padding: 13px 15px;
  border-bottom: 1px solid var(--border-lt);
  display: flex; justify-content: space-between; align-items: center;
}
.m-notif-header-title { font-size: 13px; font-weight: 600; }
.m-notif-mark-all {
  font-size: 11px; color: var(--m-600);
  cursor: pointer; background: none; border: none; padding: 0;
}
.m-notif-mark-all:hover { color: var(--m-800); text-decoration: underline; }
.m-notif-list { max-height: 340px; overflow-y: auto; }
.m-notif-item {
  padding: 11px 15px;
  border-bottom: 1px solid var(--border-lt);
  cursor: pointer; transition: background .12s;
}
.m-notif-item:hover { background: var(--m-50); }
.m-notif-item.unread { background: #f0faf5; }
.m-notif-item:last-child { border-bottom: none; }
.m-notif-title {
  font-size: 12.5px; font-weight: 600; color: var(--text-1);
  display: flex; align-items: center; gap: 5px;
}
.m-notif-dot-inline {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--m-600); flex-shrink: 0;
}
.m-notif-msg { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.m-notif-time {
  font-size: 10.5px; color: var(--text-3); margin-top: 4px;
  font-family: var(--font-mono);
}
.m-notif-empty {
  padding: 28px; text-align: center;
  font-size: 13px; color: var(--text-3);
}

/* ── CONTENT AREA ────────────────────────────────────────── */
.m-content {
  flex: 1;
  padding: var(--content-pad);
}

/* ── PAGE HEADER ─────────────────────────────────────────── */
.m-page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 20px; gap: 12px;
}
.m-page-title {
  font-size: 19px; font-weight: 600;
  color: var(--text-1); letter-spacing: -.3px;
  margin-bottom: 2px;
}
.m-page-subtitle { font-size: 12.5px; color: var(--text-3); }

/* ── FLASH ALERTS ────────────────────────────────────────── */
.m-alerts { margin-bottom: 16px; }
.m-alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 8px; border: 1px solid;
  animation: m-fade-in .2s ease;
}
@keyframes m-fade-in { from { opacity:0; transform: translateY(-4px); } to { opacity:1; transform: translateY(0); } }
.m-alert-success { background: #edf7f2; border-color: #a3d9bc; color: #0f5132; }
.m-alert-danger   { background: var(--color-danger)/10; background: #fdecea; border-color: #f5b7b1; color: #7b241c; }
.m-alert-warning  { background: #fffbeb; border-color: #f9e4b7; color: #78520a; }
.m-alert-info     { background: #eff6ff; border-color: #bfdbfe; color: #1e3a5f; }
.m-alert-icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.m-alert-close {
  margin-left: auto; background: none; border: none;
  cursor: pointer; opacity: .5; font-size: 16px; line-height: 1;
  padding: 0 2px; color: inherit;
}
.m-alert-close:hover { opacity: 1; }

/* ── CARDS ───────────────────────────────────────────────── */
.m-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.m-card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-lt);
  font-size: 13px; font-weight: 600; color: var(--text-1);
}
.m-card-body { padding: 16px; }
.m-card-footer {
  padding: 11px 16px;
  border-top: 1px solid var(--border-lt);
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── KPI CARDS ───────────────────────────────────────────── */
.m-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.m-kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .2s;
}
.m-kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.m-kpi-label {
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-3); margin-bottom: 7px;
}
.m-kpi-value {
  font-size: 24px; font-weight: 600;
  color: var(--text-1); line-height: 1;
  margin-bottom: 5px; font-family: var(--font-sans);
}
.m-kpi-trend { font-size: 11.5px; color: var(--text-3); }
.m-kpi-trend.up   { color: var(--m-600); }
.m-kpi-trend.down { color: var(--color-danger); }
.m-kpi-card.m-kpi-alert .m-kpi-value  { color: var(--color-danger); }
.m-kpi-card.m-kpi-success .m-kpi-value { color: var(--m-700); }

/* ── TABLES ──────────────────────────────────────────────── */
.m-table-wrap { overflow-x: auto; }
.m-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.m-table thead th {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-3);
  background: #fafbfa;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}
.m-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-lt);
  vertical-align: middle;
  color: var(--text-2);
}
.m-table tbody tr:last-child td { border-bottom: none; }
.m-table tbody tr:hover td { background: var(--m-50); }
.m-table-link {
  color: var(--m-700); font-weight: 500;
  text-decoration: none;
}
.m-table-link:hover { color: var(--m-600); text-decoration: underline; }

/* ── FORMS ───────────────────────────────────────────────── */
.m-form-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.m-form-section-title {
  font-size: 12.5px; font-weight: 600;
  color: var(--m-800);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--m-100);
  display: flex; align-items: center; gap: 7px;
}

.m-label {
  display: block;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-2); margin-bottom: 5px;
}
.m-label-required::after {
  content: ' *'; color: var(--color-danger);
}

.m-input, .m-select, .m-textarea {
  display: block; width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-size: 13.5px; font-family: var(--font-sans);
  color: var(--text-1);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  -webkit-appearance: none;
}
.m-input:hover, .m-select:hover, .m-textarea:hover {
  border-color: #b8c5be;
}
.m-input:focus, .m-select:focus, .m-textarea:focus {
  border-color: var(--m-500);
  box-shadow: 0 0 0 3px rgba(58,170,125,.15);
}
.m-input.is-invalid, .m-select.is-invalid, .m-textarea.is-invalid {
  border-color: var(--color-danger);
}
.m-input.is-invalid:focus, .m-select.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(192,57,43,.12);
}
.m-invalid-feedback {
  font-size: 11.5px; color: var(--color-danger); margin-top: 4px;
}
.m-form-text {
  font-size: 11.5px; color: var(--text-3); margin-top: 4px;
}
.m-textarea { resize: vertical; min-height: 80px; line-height: 1.55; }

/* Input group */
.m-input-group { position: relative; }
.m-input-group .m-input { padding-left: 36px; }
.m-input-group-icon {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
  width: 16px; height: 16px;
}
.m-input-group-append .m-input { padding-right: 36px; }
.m-input-group-icon-right {
  position: absolute; right: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3); cursor: pointer;
  width: 16px; height: 16px;
  background: none; border: none; padding: 0;
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.m-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer; border: 1px solid transparent;
  transition: all .15s; text-decoration: none;
  white-space: nowrap; line-height: 1;
}
.m-btn:active { transform: scale(.98); }
.m-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.m-btn-sm { padding: 6px 11px; font-size: 12px; }
.m-btn-sm svg { width: 13px; height: 13px; }
.m-btn-lg { padding: 11px 20px; font-size: 14px; }

.m-btn-primary {
  background: var(--m-800); border-color: var(--m-800); color: #fff;
}
.m-btn-primary:hover {
  background: var(--m-600); border-color: var(--m-600); color: #fff;
  text-decoration: none;
}

.m-btn-secondary {
  background: var(--card); border-color: var(--border); color: var(--text-2);
}
.m-btn-secondary:hover {
  background: var(--surface); border-color: var(--m-400); color: var(--text-1);
  text-decoration: none;
}

.m-btn-danger {
  background: var(--card); border-color: #f5b7b1; color: var(--color-danger);
}
.m-btn-danger:hover {
  background: #fdecea; border-color: var(--color-danger); color: var(--color-danger);
  text-decoration: none;
}

.m-btn-ghost {
  background: none; border-color: transparent; color: var(--m-700);
}
.m-btn-ghost:hover {
  background: var(--m-50); color: var(--m-800); text-decoration: none;
}

.m-btn-success {
  background: #166534; border-color: #166534; color: #fff;
}
.m-btn-success:hover { background: #15803d; border-color: #15803d; }

/* ── BADGES ──────────────────────────────────────────────── */
.m-badge {
  display: inline-block; border-radius: 20px;
  padding: 2px 9px; font-size: 11px; font-weight: 600;
  letter-spacing: .1px;
}
.m-badge-pending  { background: #fff8e6; color: #92620a; }
.m-badge-authorized { background: #eff6ff; color: #1d4ed8; }
.m-badge-scheduled  { background: #f0fdf4; color: #15803d; }
.m-badge-completed  { background: var(--m-50); color: var(--m-800); }
.m-badge-invoiced   { background: #f8f9fa; color: #6c757d; }
.m-badge-rejected   { background: #fdecea; color: var(--color-danger); }
.m-badge-draft      { background: #f8f9fa; color: #6c757d; }
.m-badge-sent       { background: #eff6ff; color: var(--color-info); }
.m-badge-partial    { background: #fff8e6; color: #92620a; }
.m-badge-paid       { background: var(--m-50); color: var(--m-800); }
.m-badge-overdue    { background: #fdecea; color: var(--color-danger); }
.m-badge-cancelled  { background: #f8f9fa; color: #6c757d; }
.m-badge-active     { background: var(--m-50); color: var(--m-800); }
.m-badge-inactive   { background: #f8f9fa; color: #6c757d; }

/* ── PAGINATION ──────────────────────────────────────────── */
.m-pagination {
  display: flex; align-items: center; gap: 4px;
  list-style: none; padding: 0; margin: 0;
}
.m-page-item {}
.m-page-link {
  display: flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 12.5px; color: var(--text-2);
  background: var(--card); cursor: pointer;
  transition: all .15s; text-decoration: none;
}
.m-page-link:hover { border-color: var(--m-500); color: var(--m-800); background: var(--m-50); }
.m-page-item.active .m-page-link {
  background: var(--m-800); border-color: var(--m-800); color: #fff;
}
.m-page-item.disabled .m-page-link {
  opacity: .4; cursor: not-allowed; pointer-events: none;
}

/* ── TIMELINE (auditoría) ────────────────────────────────── */
.m-timeline { position: relative; padding-left: 28px; }
.m-timeline::before {
  content: '';
  position: absolute; left: 10px; top: 0; bottom: 0;
  width: 1px; background: var(--border);
}
.m-timeline-item { position: relative; margin-bottom: 18px; }
.m-timeline-dot {
  position: absolute; left: -23px; top: 3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--m-700);
  border: 2px solid var(--card);
  box-shadow: 0 0 0 2px var(--m-100);
}
.m-timeline-date { font-size: 11px; color: var(--text-3); margin-bottom: 3px; font-family: var(--font-mono); }
.m-timeline-text { font-size: 13px; color: var(--text-1); }
.m-timeline-sub  { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .m-sidebar {
    transform: translateX(-100%);
  }
  .m-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.25);
  }
  .m-main {
    margin-left: 0;
  }
  .m-hamburger {
    display: flex;
  }
  .m-content {
    padding: 14px;
  }
  .m-kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
  .m-search { display: none; }
  .m-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
    display: none;
  }
  .m-overlay.open { display: block; }
}
@media (max-width: 480px) {
  .m-kpi-grid { grid-template-columns: 1fr; }
}

/* ── MISC UTILITIES ──────────────────────────────────────── */
.m-mono { font-family: var(--font-mono); }
.m-text-muted { color: var(--text-3); }
.m-text-primary { color: var(--m-800); }
.m-fw-500 { font-weight: 500; }
.m-fw-600 { font-weight: 600; }
.m-gap-actions { display: flex; gap: 6px; align-items: center; }
.m-divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* Loading skeleton */
@keyframes m-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.m-skeleton {
  background: linear-gradient(90deg, #f0f2f0 25%, #e4e8e4 50%, #f0f2f0 75%);
  background-size: 800px 100%;
  animation: m-shimmer 1.4s infinite;
  border-radius: 4px;
}
.m-skeleton-text  { height: 14px; margin-bottom: 8px; }
.m-skeleton-title { height: 20px; margin-bottom: 12px; width: 40%; }

/* ── Date input localizado ────────────────────────────────── */
/* El input nativo queda oculto (opacidad 0) sobre el display */
/* El display muestra la fecha en el locale correcto          */
input[type="date"][data-localized-init] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  cursor: pointer;
  z-index: 2;
  margin: 0;
}

/* Wrapper que contiene el input nativo + display + icono */
input[type="date"][data-localized-init] + input[type="text"] {
  position: relative;
  padding-right: 34px;  /* espacio para el ícono */
}
