/* ------------------------------ Layout ------------------------------ */
.app { display: flex; min-height: 100vh; }
.side { width: 240px; flex: none; background: var(--navy); color: #c9d4ea; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; color: #fff; font-weight: 750; font-size: 16px; letter-spacing: -.01em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--primary); display: grid; place-items: center; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.nav a { display: flex; align-items: center; gap: 10px; color: #c9d4ea; padding: 9px 12px; border-radius: 9px; font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.nav .sub { display: none; margin: 2px 0 6px 27px; border-left: 1px solid #25386a; padding-left: 8px; }
.nav .group.open .sub { display: block; }
.nav .sub a { padding: 6px 10px; font-size: 13px; color: #9fb0d3; }
.nav .sub a.active { background: transparent; color: #fff; font-weight: 650; }
.side-foot { padding: 12px 16px 16px; border-top: 1px solid #1b2d57; font-size: 12px; color: #8ea0c6; }
.side-foot .dev { display: inline-flex; gap: 6px; align-items: center; background: #2a1f63; color: #cfc4ff; padding: 3px 8px; border-radius: 6px; font-weight: 600; }
.main { margin-left: 240px; flex: 1; min-width: 0; padding: 22px 30px 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.topbar .crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.topbar .crumbs a { color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn.hamburger { display: none; }

/* ------------------------------ Componentes ------------------------------ */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 15px; font-weight: 700; margin: 0; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.g-side { grid-template-columns: minmax(0, 1fr) 380px; }
.stack { display: grid; gap: 16px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 750; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; background: var(--primary); color: #fff; padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: 13.5px; white-space: nowrap; text-decoration: none !important; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { filter: brightness(.95); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.secondary { background: var(--primary-soft); color: var(--primary); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn.danger { background: var(--red); }
.btn.danger-ghost { background: #fff; border-color: #f5c2c4; color: var(--red); }
.btn.success { background: var(--green); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link-btn { background: none; border: 0; color: var(--primary); padding: 0; font-weight: 600; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.pill.active { background: var(--primary-soft); border-color: #c7d8ff; color: var(--primary); }

.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 11px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #f8faff; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--muted); }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.field input[type=text], .field input[type=number], .field input[type=password], .field input:not([type]), .field select, .field textarea, .input {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 9px 11px; outline: none;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: #9dbbff; box-shadow: 0 0 0 3px #e3ecff; }
.field .help { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #cfd6e4; border-radius: 99px; transition: .15s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px #0003; }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:disabled + i { opacity: .5; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type=color] { width: 42px; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; }

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 9px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 16px 26px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: -2px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 3px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); background: var(--primary); }
.timeline .dot.ok { background: var(--green); } .timeline .dot.warn { background: var(--amber); } .timeline .dot.bad { background: var(--red); } .timeline .dot.off { background: #a3adc2; }
.timeline .ev { font-weight: 650; font-size: 13px; }
.timeline .meta { font-size: 12px; color: var(--muted); }

.flow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.flow .step { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 10px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.flow .step.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.flow .arrow { color: #a3adc2; }

.menu { position: relative; display: inline-block; }
.menu-list { position: absolute; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px #0f1b3320; min-width: 150px; padding: 5px; z-index: 30; display: none; }
.menu.open .menu-list { display: block; }
.menu-list button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 7px; font-size: 13px; }
.menu-list button:hover:not(:disabled) { background: var(--bg); }
.menu-list button:disabled { color: #b6bfd0; cursor: not-allowed; }
.menu-list button.danger { color: var(--red); }

.modal-back { position: fixed; inset: 0; background: rgba(10, 26, 58, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; box-shadow: 0 20px 60px #0004; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.x { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); }

.toast-host { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 8px 24px #0003; font-weight: 500; max-width: 360px; }
.toast.err { background: #b4232a; }

.chart-legend { display: grid; gap: 8px; font-size: 13px; }
.chart-legend .row { display: flex; align-items: center; gap: 8px; }
.chart-legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.chart-legend .v { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; }
.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut-wrap svg { flex: none; }
.chart-tip { position: fixed; pointer-events: none; background: var(--navy); color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 7px; z-index: 70; display: none; }

.funnel-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 90px; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 13px; }
.funnel-bar { height: 26px; background: var(--line-2); border-radius: 7px; overflow: hidden; }
.funnel-bar i { display: block; height: 100%; background: var(--primary); border-radius: 7px; }

.gw-card { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; align-items: start; }
.gw-icon { width: 44px; height: 44px; border-radius: 11px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.stat-row .l { font-size: 11.5px; color: var(--muted); } .stat-row .v { font-weight: 700; font-size: 17px; }

.phone-frame { width: 300px; height: 610px; border: 10px solid #0d1526; border-radius: 40px; overflow: hidden; background: #fff; box-shadow: 0 16px 40px #0f1b3333; margin: 0 auto; position: relative; }
.phone-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.preview-bg { background: linear-gradient(180deg, #eef2f9, #e6ebf4); border-radius: 12px; padding: 22px 12px; }

.notice { border-radius: 10px; padding: 11px 14px; font-size: 13px; background: var(--primary-soft); color: #1f3f86; }
.notice.warn { background: var(--amber-soft); color: #7a4d00; }
.e2e-step { display: grid; grid-template-columns: 22px 170px minmax(0, 1fr) 60px; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; align-items: center; }
.e2e-step .ok { color: var(--green); font-weight: 800; } .e2e-step .bad { color: var(--red); font-weight: 800; }
.big-result { font-size: 18px; font-weight: 800; padding: 12px 14px; border-radius: 10px; margin-top: 12px; }
.big-result.pass { background: var(--green-soft); color: #0b7a3b; } .big-result.fail { background: var(--red-soft); color: #b4232a; }

/* ------------------------------ Login ------------------------------ */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 10%, #16306a, var(--navy) 60%); padding: 16px; }
.login .card { width: min(380px, 100%); padding: 28px; }
.login h2 { margin: 12px 0 4px; }

/* ------------------------------ Responsive ------------------------------ */
@media (max-width: 1180px) { .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g-side { grid-template-columns: 1fr; } }
@media (max-width: 1024px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .side { transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px #0006; }
  .main { margin-left: 0; padding: 16px; }
  .btn.hamburger { display: inline-flex; }
  .g2, .g5 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 120px minmax(0, 1fr); }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr; } .funnel-row { grid-template-columns: 90px minmax(0, 1fr) 70px; } }
