:root {
  --bg: #f4f6fb; --card: #fff; --ink: #1c2434; --muted: #6b7690; --line: #e6e9f2;
  --brand: #4f46e5; --brand2: #7c3aed; --ok: #059669; --bad: #dc2626; --warn: #d97706; --side: #111827;
  --r: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
a { color: var(--brand); }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: #fff; }
.brand.big { color: var(--ink); font-size: 22px; justify-content: center; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand2)); font-weight: 800; }

.logo.has-img { width: auto; height: auto; background: none; border-radius: 0; }
.logo.has-img img { display: block; max-height: 40px; max-width: 150px; object-fit: contain; }
.login { background-size: cover; background-position: center; }
.preview { max-width: 100%; max-height: 120px; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 16px 16px; border-radius: 8px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-weight: 400; }
.checks label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.checks input { width: auto; }

.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #eef2ff, #f5f3ff); }
.login-card { width: 360px; background: var(--card); padding: 32px; border-radius: 20px; box-shadow: 0 20px 50px rgba(79, 70, 229, .15); display: grid; gap: 14px; }
.login-card p { text-align: center; margin: 0; }

label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus { outline: 2px solid rgba(79, 70, 229, .35); border-color: var(--brand); }
.error { color: var(--bad); min-height: 1em; font-size: 13px; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font: inherit; font-weight: 600; }
.btn:hover { background: #f3f4f8; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; border: 0; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.danger { color: var(--bad); }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }

.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: #cbd5e1; padding: 20px 14px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.empresa-sel { color: #94a3b8; }
.empresa-sel select { background: #1f2937; color: #fff; border-color: #374151; }
#nav { display: grid; gap: 2px; flex: 1; }
#nav .grp { margin: 14px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; }
#nav a { color: #cbd5e1; text-decoration: none; padding: 9px 12px; border-radius: 10px; display: block; }
#nav a:hover { background: #1f2937; }
#nav a.on { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; }
.sidebar-foot { font-size: 12px; display: grid; gap: 6px; }
.sidebar-foot a, .sidebar-foot .link { color: #a5b4fc; text-align: left; }

main { padding: 24px 32px 48px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.actions { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.actions label { font-size: 11px; }
.actions input, .actions select { width: auto; }

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.cols2 { grid-template-columns: 2fr 1fr; }
.cols3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .cols2, .cols3 { grid-template-columns: 1fr; } .app { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } }
.card { background: var(--card); border-radius: var(--r); padding: 18px; box-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .04); min-width: 0; }
.kpi .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 24px; font-weight: 700; margin: 4px 0; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.up { color: var(--ok); } .down { color: var(--bad); }
.chart { position: relative; height: 280px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f8f9fe; }
.tablewrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eef; color: var(--brand); }
.badge.ok { background: #d1fae5; color: #047857; } .badge.bad { background: #fee2e2; color: #b91c1c; }
.badge.warn { background: #fef3c7; color: #b45309; } .badge.gray { background: #e5e7eb; color: #4b5563; }

.crumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; align-items: center; }
.crumbs button { border: 0; background: #eef2ff; color: var(--brand); border-radius: 999px; padding: 3px 11px; cursor: pointer; font: inherit; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; cursor: pointer; font: inherit; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.bar { height: 6px; border-radius: 3px; background: #eef2ff; min-width: 70px; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--brand), var(--brand2)); }

.drop { border: 2px dashed #c7d2fe; border-radius: var(--r); padding: 22px; text-align: center; background: #fafaff; cursor: pointer; }
.drop.over { background: #eef2ff; border-color: var(--brand); }
.upload-progress { display: grid; gap: 6px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.upload-progress > div { display: flex; justify-content: space-between; gap: 8px; }
.upload-progress strong { color: var(--brand); font-variant-numeric: tabular-nums; }
.upload-progress progress { display: block; width: 100%; height: 8px; border: 0; border-radius: 8px; overflow: hidden; accent-color: var(--brand); }
.upload-progress progress::-webkit-progress-bar { background: #e6e9f2; border-radius: 8px; }
.upload-progress progress::-webkit-progress-value { background: var(--brand); border-radius: 8px; transition: width .12s ease; }
.upload-progress progress::-moz-progress-bar { background: var(--brand); border-radius: 8px; }
.imp-grid { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.form-row { display: grid; gap: 10px; margin: 12px 0; }
.empty { text-align: center; padding: 36px; color: var(--muted); }

dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, 94vw); box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(15, 23, 42, .5); }
#modalForm { padding: 24px; display: grid; gap: 12px; }
#modalForm h2 { font-size: 18px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fgrid .full { grid-column: 1 / -1; }
.mfoot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #111827; color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none; max-width: 420px; z-index: 99; }
.toast.show { opacity: 1; transform: none; } .toast.err { background: var(--bad); }
code.tok { display: block; word-break: break-all; background: #f3f4f8; padding: 10px; border-radius: 8px; user-select: all; }
.swal2-popup { border-radius: 14px !important; }
.swal2-title { color: var(--ink) !important; }
.swal2-styled.swal2-confirm { background: var(--brand) !important; }
.swal2-styled.swal2-cancel { background: #64748b !important; }
.import-context { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; align-items: end; gap: 16px; margin-bottom: 16px; }
.import-context span { padding-bottom: 10px; }
@media (max-width: 700px) { .import-context { grid-template-columns: 1fr; gap: 8px; } .import-context span { padding-bottom: 0; } }
