* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: #eef1f5; color: #1e293b; }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #f8fafc, #e2e8f0); }
.login-card { background: #fff; padding: 34px; border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.1); width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 4px 0 8px; font-size: 20px; text-align: center; }
.login-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; margin: 0 auto; color: #fff; }
.login-card label { display: flex; flex-direction: column; font-size: 13px; color: #64748b; gap: 4px; }
.login-card input { padding: 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; }
.login-card button { margin-top: 8px; border: none; color: #fff; padding: 11px; border-radius: 8px; font-weight: 600; font-size: 15px; cursor: pointer; }
.login-error { background: #fee2e2; color: #b91c1c; padding: 9px; border-radius: 8px; font-size: 13px; text-align: center; }

/* Top bar */
.panel-top { display: flex; align-items: center; gap: 20px; color: #fff; padding: 0 20px; height: 56px; }
.pt-brand strong { font-size: 17px; }
.pt-sub { opacity: .8; font-size: 12px; margin-left: 8px; }
.pt-nav { display: flex; gap: 4px; flex: 1; }
.pt-nav a { color: #fff; text-decoration: none; padding: 8px 14px; border-radius: 8px; font-size: 14px; opacity: .85; }
.pt-nav a:hover { background: rgba(255,255,255,.12); opacity: 1; }
.pt-nav a.active { background: rgba(255,255,255,.2); opacity: 1; font-weight: 600; }
.pt-user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.pt-logout { color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.4); padding: 5px 12px; border-radius: 8px; }
.pt-logout:hover { background: rgba(255,255,255,.15); }

/* Impersonation banner */
.imp-banner { background: #fef9c3; color: #854d0e; padding: 10px 20px; display: flex; align-items: center; gap: 14px; font-size: 14px; border-bottom: 1px solid #fde68a; }
.imp-banner a { color: #92400e; font-weight: 600; }

/* Main */
.panel-main { max-width: 1100px; margin: 24px auto; padding: 0 20px; }
.panel-title { font-size: 22px; margin: 0 0 18px; }

/* Cards & grid */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 18px; }
.card h3 { margin: 0 0 6px; font-size: 14px; color: #64748b; font-weight: 600; }
.card .big { font-size: 28px; font-weight: 700; }

.section { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 20px; margin-bottom: 20px; }
.section h2 { font-size: 16px; margin: 0 0 14px; }

/* Tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #e2e8f0; }
.tbl th { color: #64748b; font-size: 12px; text-transform: uppercase; }

/* Buttons */
.btn { display: inline-block; border: none; cursor: pointer; border-radius: 8px; padding: 9px 15px; font-size: 14px; font-weight: 600; text-decoration: none; color: #fff; background: var(--area, #7C3AED); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-ghost { background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; }
.btn-danger { background: #ef4444; }
.btn-ok { background: #16a34a; }

/* Forms */
.form-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13px; color: #64748b; }
.form-row input, .form-row select { padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; color: #1e293b; }
.form-inline { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }

.pill { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #e2e8f0; color: #334155; }
.pill-ok { background: #dcfce7; color: #16a34a; }
.pill-off { background: #fee2e2; color: #dc2626; }
.muted { color: #64748b; font-size: 13px; }
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert-ok { background: #dcfce7; color: #166534; }
.alert-err { background: #fee2e2; color: #b91c1c; }
code { font-family: ui-monospace, monospace; background: #f1f5f9; padding: 2px 6px; border-radius: 5px; }
a.link { color: var(--area, #7C3AED); }

/* ===== Mejoras UI/UX ===== */
.panel-top { flex-wrap: wrap; height: auto; min-height: 56px; padding-top: 8px; padding-bottom: 8px; gap: 8px 20px; }
.pt-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.pt-nav a { white-space: nowrap; }
.pt-rol { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; background: rgba(255,255,255,.18); padding: 3px 8px; border-radius: 20px; font-weight: 600; }
.pt-name { font-weight: 600; }
.tbl td { vertical-align: top; }
.tbl tbody tr:hover { background: #f8fafc; }
details > summary { cursor: pointer; font-weight: 600; }
details > summary:hover { color: var(--area, #7C3AED); }
.form-row textarea { padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; color: #1e293b; font-family: inherit; }
.btn-ghost:hover { background: #e2e8f0; }
.card { transition: border-color .15s, box-shadow .15s; }
.card:hover { border-color: #cbd5e1; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--area, #7C3AED); outline-offset: 0; }
.btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid #0ea5e9; outline-offset: 2px; }
.section > h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== Modales ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-overlay[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 14px; width: min(720px, 100%); max-height: 88vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid #e2e8f0; font-size: 15px; position: sticky; top: 0; background: #fff; }
.modal-close { border: none; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; color: #64748b; }
.modal-close:hover { color: #1e293b; }
.modal-body { padding: 18px; }
