:root {
  --naranja: #FF9900;
  --gris: #A6A6A6;
  --gris-claro: #F5F5F5;
  --blanco: #FFFFFF;
  --negro: #000000;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Calibri, "Calibri Light", Segoe UI, Arial, sans-serif;
  background: var(--gris-claro);
  color: #222;
}

.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--naranja) 0%, #ffb84d 100%);
}
.login-card {
  background: var(--blanco);
  border-radius: 12px;
  padding: 40px 36px;
  width: 380px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.login-logo {
  font-size: 28px; font-weight: bold; color: var(--naranja); margin-bottom: 8px;
}
.login-logo span { color: var(--gris); font-weight: normal; font-size: 16px; margin-left: 4px; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-sub { color: var(--gris); margin-bottom: 24px; font-size: 14px; }
#loginForm label { display: block; font-size: 13px; margin: 12px 0 4px; color: #555; }
#loginForm input {
  width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px;
}
.error-msg { color: #c0392b; font-size: 13px; margin-top: 10px; min-height: 16px; }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary, .btn-danger {
  border: none; border-radius: 8px; padding: 10px 18px; font-size: 14px;
  cursor: pointer; font-weight: bold; transition: opacity .15s;
}
.btn-primary { background: var(--naranja); color: var(--blanco); }
.btn-secondary { background: var(--gris); color: var(--blanco); }
.btn-danger { background: #c0392b; color: var(--blanco); }
.btn-primary:hover, .btn-secondary:hover, .btn-danger:hover { opacity: .88; }
.btn-block { width: 100%; margin-top: 20px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- App shell ---------- */
.topbar {
  background: var(--naranja); color: var(--blanco);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; box-shadow: 0 2px 6px rgba(0,0,0,.1);
}
.topbar-logo { font-size: 18px; font-weight: bold; display: flex; align-items: center; gap: 8px; }
.topbar-logo span { font-weight: normal; opacity: .85; font-size: 14px; }
.topbar-logo small { font-weight: normal; opacity: .9; margin-left: 10px; font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-badge { background: rgba(255,255,255,.2); padding: 6px 12px; border-radius: 20px; font-size: 13px; }
.icon-btn {
  background: none; border: none; color: var(--blanco); font-size: 18px; cursor: pointer; position: relative;
}
.badge {
  position: absolute; top: -6px; right: -8px; background: #c0392b; color: white;
  border-radius: 10px; font-size: 10px; padding: 1px 5px;
}

.app-body { display: flex; min-height: calc(100vh - 56px); }

.sidebar {
  width: 230px; background: var(--blanco); border-right: 1px solid #e5e5e5; padding: 16px 0;
}
.sidebar button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 12px 22px; font-size: 14px; cursor: pointer; color: #444; border-left: 3px solid transparent;
}
.sidebar button:hover { background: var(--gris-claro); }
.sidebar button.active { border-left-color: var(--naranja); background: var(--gris-claro); font-weight: bold; color: var(--naranja); }
.sidebar-group {
  padding: 16px 22px 6px; font-size: 11px; font-weight: bold; letter-spacing: .05em;
  text-transform: uppercase; color: var(--gris);
}
.sidebar-group:first-child { padding-top: 4px; }

.content { flex: 1; padding: 24px; }

h2 { color: #333; margin-bottom: 16px; font-size: 20px; }

.card {
  background: var(--blanco); border-radius: 10px; padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06); margin-bottom: 18px;
}

/* ---------- KPI dashboard cards ---------- */
.kpi-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.kpi-card {
  background: var(--blanco); border-radius: 10px; padding: 16px 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06); border-left: 4px solid var(--naranja);
}
.kpi-card .kpi-valor { font-size: 26px; font-weight: bold; color: #222; }
.kpi-card .kpi-label { font-size: 12px; color: var(--gris); margin-top: 4px; }
.kpi-card.kpi-alerta { border-left-color: #c0392b; }
.kpi-card.kpi-ok { border-left-color: #2e7d32; }
.kpi-card.kpi-bypass { border-left-color: #6a1b9a; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 13px; color: #555; margin-bottom: 4px; }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%; padding: 9px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px;
}
.form-msg { margin-left: 12px; font-size: 13px; }

.filtros-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filtros-bar input, .filtros-bar select { padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eee; }
th { background: var(--gris); color: var(--blanco); font-weight: bold; }
tr:hover { background: #fafafa; }

.tag {
  display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: bold; color: white;
}
.tag-pendiente { background: #f0ad4e; }
.tag-rechazada { background: #c0392b; }
.tag-causada { background: #2e7d32; }
.tag-bypass { background: #6a1b9a; margin-left: 6px; }

.row-actions { display: flex; gap: 8px; }
.row-actions button { padding: 5px 10px; font-size: 12px; }

/* ---------- Notif panel ---------- */
.notif-panel {
  position: absolute; right: 24px; top: 60px; width: 320px; max-height: 400px; overflow-y: auto;
  background: var(--blanco); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.15); z-index: 50;
}
.notif-item { padding: 12px 16px; border-bottom: 1px solid #eee; font-size: 13px; }
.notif-item.unread { background: #fff7ec; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  background: var(--blanco); border-radius: 10px; padding: 24px; width: 420px; max-width: 90vw;
}
.modal-box h3 { margin-bottom: 14px; color: #333; }
.modal-box label { display: block; font-size: 13px; color: #555; margin: 10px 0 4px; }
.modal-box input, .modal-box textarea, .modal-box select {
  width: 100%; padding: 9px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-box.modal-wide { width: 560px; }

/* ---------- Timeline (detalle de factura) ---------- */
.timeline-item { padding: 10px 0; border-bottom: 1px solid #eee; font-size: 13px; }
.timeline-item:last-child { border-bottom: none; }
.timeline-item .t-title { font-weight: bold; color: #333; }
.timeline-item .t-meta { color: var(--gris); font-size: 12px; margin-top: 2px; }
.timeline-item .t-comentario { font-style: italic; color: #555; margin-top: 4px; }
