@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: #f8fafc;
    color: #0f172a;
    min-height: 100%;
    padding-bottom: 72px; /* clear bottom nav */
    -webkit-tap-highlight-color: transparent;
}

/* ── Bottom nav ───────────────────────────────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 64px;
    background: rgba(255,255,255,.96);
    border-top: 1px solid rgba(0,0,0,.08);
    display: flex;
    z-index: 1000;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}
.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    font-family: inherit;
    font-size: .6rem;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    padding: 8px 4px;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.nav-btn .nav-icon { font-size: 1.35rem; line-height: 1; }
.nav-btn.active { color: #2563eb; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tab { display: none; padding: 1rem .9rem; max-width: 640px; margin: 0 auto; }
.tab.active { display: block; }

/* ── Hero (home) ──────────────────────────────────────────────────────────── */
.hero {
    position: relative; overflow: hidden;
    padding: 2rem 1.4rem 2rem;
    margin-bottom: 1.25rem;
    border-radius: 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
}
.hero__orb {
    position: absolute; border-radius: 50%;
    pointer-events: none; filter: blur(64px); opacity: .5;
}
.hero__orb--1 { width:240px;height:240px;background:#2563eb;top:-80px;right:-40px; }
.hero__orb--2 { width:180px;height:180px;background:#7c3aed;bottom:-60px;left:25%; }
.hero__orb--3 { width:130px;height:130px;background:#059669;top:0;left:-30px; }
.hero__inner { position: relative; z-index: 1; }
.hero__badge {
    display: inline-flex; align-items: center; gap: .35rem;
    background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
    color: rgba(255,255,255,.82); font-size: .65rem; font-weight: 700;
    letter-spacing: .1em; text-transform: uppercase;
    padding: .25rem .75rem; border-radius: 100px; margin-bottom: .8rem;
}
.hero h1 {
    font-size: clamp(1.9rem,7vw,2.6rem);
    font-weight: 900; letter-spacing: -.04em;
    line-height: 1.05; margin-bottom: .5rem; color: #fff;
}
.hero p {
    font-size: clamp(.82rem,2.5vw,.95rem);
    opacity: .55; line-height: 1.65; color: #fff; max-width: 460px;
}

/* ── Module cards (home) ──────────────────────────────────────────────────── */
.module-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    background: #fff;
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,.07);
    margin-bottom: .75rem;
    cursor: pointer;
    transition: box-shadow .15s, transform .1s;
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
}
.module-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--accent);
    border-radius: 4px 0 0 4px;
}
.module-card:active { transform: scale(.985); }
.module-icon {
    width: 52px; height: 52px; flex-shrink: 0;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    background: var(--accent-bg);
}
.module-info { flex: 1; min-width: 0; }
.module-name { font-size: 1rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin-bottom: .2rem; }
.module-desc { font-size: .78rem; line-height: 1.55; color: #64748b; }
.module-arrow { font-size: 1.25rem; color: #cbd5e1; flex-shrink: 0; }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .85rem 0 .85rem;
    margin-bottom: 1.1rem;
    border-bottom: 2px solid var(--accent);
}
.page-header-icon {
    width: 44px; height: 44px; flex-shrink: 0;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    background: var(--accent-bg);
}
.page-header h2 {
    font-size: clamp(1.1rem,4.5vw,1.4rem);
    font-weight: 900; letter-spacing: -.03em; line-height: 1.1;
    margin-bottom: .15rem;
}
.page-header p {
    font-size: clamp(.65rem,2vw,.78rem);
    color: #64748b; line-height: 1.4;
}

/* ── Options panel ────────────────────────────────────────────────────────── */
.options-panel {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 14px;
    margin-bottom: 1rem;
    overflow: hidden;
}
.options-panel > summary {
    display: flex; align-items: center; gap: .5rem;
    padding: .9rem 1rem;
    font-size: .85rem; font-weight: 700;
    cursor: pointer;
    list-style: none;
    user-select: none;
    touch-action: manipulation;
}
.options-panel > summary::-webkit-details-marker { display: none; }
.options-panel > summary::after {
    content: '▸'; margin-left: auto; color: #94a3b8; font-size: .75rem;
    transition: transform .2s;
}
.options-panel[open] > summary::after { transform: rotate(90deg); }
.options-body { padding: .25rem 1rem 1rem; }
.opts-group { margin-bottom: .75rem; }
.opts-group-label {
    font-size: .68rem; font-weight: 700; letter-spacing: .07em;
    text-transform: uppercase; color: #94a3b8;
    margin-bottom: .4rem;
}
.opts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .1rem;
}
.opt-label {
    display: flex; align-items: center; gap: .5rem;
    font-size: .82rem; padding: .35rem .2rem;
    cursor: pointer; touch-action: manipulation;
    min-height: 36px;
}
.opt-label input[type=checkbox] {
    width: 18px; height: 18px; flex-shrink: 0;
    accent-color: var(--accent);
    cursor: pointer;
}
.lang-select {
    margin-top: .75rem;
    width: 100%; padding: .55rem .75rem;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 10px;
    font-family: inherit; font-size: .85rem; font-weight: 500;
    background: #f8fafc; cursor: pointer;
}

/* ── Upload zone ──────────────────────────────────────────────────────────── */
.upload-zone {
    border: 2px dashed rgba(0,0,0,.13);
    border-radius: 14px;
    background: #fff;
    margin-bottom: 1rem;
    overflow: hidden;
    min-height: 120px;
    display: flex; align-items: stretch; justify-content: center;
    flex-direction: column;
}
.upload-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem 1rem 1.5rem;
    width: 100%;
}
.upload-actions {
    display: flex;
    gap: .85rem;
    width: 100%;
    max-width: 480px;
}
.upload-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    padding: 1.1rem .75rem;
    border: 2px solid rgba(0,0,0,.1);
    border-radius: 14px;
    background: #f8fafc;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    transition: border-color .15s, background .15s, transform .1s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.upload-action-btn:hover  { border-color: rgba(0,0,0,.2); background: #f1f5f9; }
.upload-action-btn:active { transform: scale(.97); }
.upload-action-btn--primary {
    border-color: var(--accent);
    background: var(--accent-bg);
}
.upload-action-btn--primary:hover { filter: brightness(.97); }
.upload-action-icon { font-size: 1.75rem; line-height: 1; }
.upload-action-label {
    font-size: .88rem;
    font-weight: 700;
    letter-spacing: -.01em;
    color: #0f172a;
}
.upload-action-hint {
    font-size: .67rem;
    color: #94a3b8;
    line-height: 1.3;
}
.upload-action-btn--primary .upload-action-hint { color: var(--accent); opacity: .75; }
.video-preview {
    width: 100%; max-height: 260px;
    object-fit: cover;
    display: none;
}
.video-info {
    padding: .5rem 1rem;
    font-size: .75rem; color: #64748b;
    border-top: 1px solid rgba(0,0,0,.06);
    display: none;
}
.geo-status {
    padding: .3rem 1rem .5rem;
    font-size: .72rem;
    color: #059669;
    font-weight: 600;
}

/* ── Analyze button ───────────────────────────────────────────────────────── */
.analyze-btn {
    width: 100%;
    min-height: 54px;
    padding: .9rem 1.5rem;
    border: none;
    border-radius: 14px;
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 1rem; font-weight: 800;
    letter-spacing: -.01em;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
    touch-action: manipulation;
    margin-bottom: 1rem;
}
.analyze-btn:disabled { opacity: .45; cursor: not-allowed; }
.analyze-btn:not(:disabled):active { transform: scale(.98); }

/* ── Status / loading ─────────────────────────────────────────────────────── */
.status-box {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 14px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
    display: none;
}
.status-spinner {
    width: 36px; height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto .75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.status-msg { font-size: .88rem; font-weight: 600; color: #475569; }

/* ── Results ──────────────────────────────────────────────────────────────── */
.results-box { display: none; }

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .6rem;
    margin-bottom: 1rem;
}
.metric-card {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px;
    padding: .75rem .9rem;
}
.metric-label {
    font-size: .6rem; font-weight: 700;
    letter-spacing: .07em; text-transform: uppercase;
    color: #94a3b8; margin-bottom: .3rem;
}
.metric-value { font-size: 1rem; font-weight: 800; letter-spacing: -.02em; word-break: break-word; }

.info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: .85rem 1rem;
    font-size: .85rem; line-height: 1.65;
    color: #1e40af;
    margin-bottom: 1rem;
}
.info-box.warn  { background:#fffbeb; border-color:#fde68a; color:#92400e; }
.info-box.error { background:#fef2f2; border-color:#fecaca; color:#991b1b; }
.info-box.ok    { background:#f0fdf4; border-color:#bbf7d0; color:#166534; }

.criticas-box {
    background: #fff5f5;
    border: 1.5px solid #fca5a5;
    border-radius: 12px;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
}
.criticas-header {
    font-size: .82rem; font-weight: 700;
    color: #dc2626; display: flex; align-items: center;
    gap: .4rem; margin-bottom: .6rem;
}
.critica-item {
    font-size: .82rem; color: #7f1d1d;
    padding: .3rem .5rem;
    border-left: 3px solid #fca5a5;
    margin-bottom: .3rem;
    background: rgba(254,202,202,.25);
    border-radius: 0 6px 6px 0;
    display: flex; align-items: flex-start; gap: .4rem;
}
.critica-item i { flex-shrink: 0; margin-top: 1px; color: #dc2626; }

.section-title {
    font-size: .85rem; font-weight: 800;
    letter-spacing: -.01em; margin: 1.25rem 0 .65rem;
    display: flex; align-items: center; gap: .4rem;
    color: #1e293b;
}

.item-card {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px;
    margin-bottom: .5rem;
    overflow: hidden;
}
.item-card-header {
    display: flex; align-items: center; gap: .65rem;
    padding: .75rem 1rem;
    cursor: pointer;
    touch-action: manipulation;
    font-size: .88rem; font-weight: 600;
}
.item-card-body {
    padding: 0 1rem .75rem;
    font-size: .82rem; line-height: 1.65; color: #475569;
    border-top: 1px solid rgba(0,0,0,.06);
    display: none;
}
.item-card.open .item-card-body { display: block; }
.item-card.open .item-card-toggle { transform: rotate(90deg); }
.item-card-toggle { margin-left: auto; color: #cbd5e1; transition: transform .2s; }

.valor-total-card {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 2px solid #059669;
    border-radius: 14px;
    padding: 1.1rem 1.2rem;
    margin-top: .75rem;
    text-align: center;
}
.valor-total-label {
    font-size: .78rem;
    font-weight: 700;
    color: #065f46;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .35rem;
}
.valor-total-value {
    font-size: 1.7rem;
    font-weight: 900;
    color: #059669;
    letter-spacing: -.02em;
}
.valor-total-note {
    font-size: .68rem;
    color: #6ee7b7;
    margin-top: .3rem;
    color: #047857;
}

.badge {
    display: inline-block;
    padding: .18rem .6rem;
    border-radius: 100px;
    font-size: .7rem; font-weight: 700; letter-spacing: .02em;
    flex-shrink: 0;
}
.badge-green  { background:#dcfce7; color:#166534; }
.badge-yellow { background:#fef9c3; color:#854d0e; }
.badge-orange { background:#ffedd5; color:#9a3412; }
.badge-red    { background:#fee2e2; color:#991b1b; }
.badge-blue   { background:#dbeafe; color:#1e40af; }
.badge-gray   { background:#f1f5f9; color:#475569; }

/* ── Verdict banner ───────────────────────────────────────────────────────── */
.verdict {
    border-radius: 18px;
    padding: 1.5rem 1.5rem;
    margin-bottom: 1.1rem;
    display: flex; align-items: center; gap: 1.1rem;
    color: #fff; flex-wrap: wrap;
}
.verdict--apto         { background: linear-gradient(135deg,#059669 0%,#047857 100%); }
.verdict--ressalvas    { background: linear-gradient(135deg,#d97706 0%,#b45309 100%); }
.verdict--inapto       { background: linear-gradient(135deg,#dc2626 0%,#b91c1c 100%); }
.verdict__icon { font-size: 2.2rem; flex-shrink: 0; }
.verdict__label { font-size: clamp(.95rem,3.5vw,1.2rem); font-weight: 900; letter-spacing: -.025em; }
.verdict__reason { font-size: .85rem; opacity: .88; margin-top: .2rem; }
.verdict__conf {
    margin-left: auto; flex-shrink: 0;
    font-size: .7rem; font-weight: 700;
    background: rgba(255,255,255,.2);
    padding: .25rem .65rem; border-radius: 100px;
}

/* ── Download button ──────────────────────────────────────────────────────── */
.download-btn {
    display: flex; align-items: center; justify-content: center; gap: .5rem;
    width: 100%; min-height: 48px;
    padding: .8rem 1.5rem;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 12px;
    background: #fff;
    color: #1e293b;
    font-family: inherit; font-size: .9rem; font-weight: 700;
    cursor: pointer; text-decoration: none;
    margin-top: 1.25rem;
    touch-action: manipulation;
}

/* ── Checklist row ────────────────────────────────────────────────────────── */
.check-row {
    display: flex; align-items: center; gap: .65rem;
    padding: .55rem 0;
    font-size: .85rem; line-height: 1.4;
    border-bottom: 1px solid rgba(0,0,0,.05);
}
.check-row:last-child { border-bottom: none; }
.check-row .ci { font-size: 1rem; flex-shrink: 0; }

/* ── Reset / nova análise ─────────────────────────────────────────────────── */
.reset-btn {
    display: flex; align-items: center; gap: .45rem;
    margin-bottom: 1rem;
    padding: .55rem 1rem;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 100px;
    background: #fff;
    font-family: inherit;
    font-size: .8rem; font-weight: 700;
    color: #475569;
    cursor: pointer;
    touch-action: manipulation;
    transition: background .15s, color .15s;
}
.reset-btn:active { background: #f1f5f9; }

/* ── History sub-tabs ─────────────────────────────────────────────────────── */
.hist-subtabs {
    display: flex;
    gap: .3rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(0,0,0,.08);
    padding-bottom: .5rem;
}
.hist-subtab {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .42rem 1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    font-size: .82rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: background .14s, color .14s, border-color .14s;
}
.hist-subtab.active {
    background: rgba(100,116,139,.1);
    color: #334155;
    border-color: rgba(100,116,139,.2);
}

/* ── Case cards ───────────────────────────────────────────────────────────── */
.case-card {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 14px;
    padding: 1rem 1.1rem;
    margin-bottom: .75rem;
    position: relative;
    overflow: hidden;
}
.case-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: #64748b;
    border-radius: 4px 0 0 4px;
}
.case-card-header {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: .6rem;
}
.case-card-icon {
    width: 40px; height: 40px; flex-shrink: 0;
    border-radius: 11px;
    background: rgba(100,116,139,.1);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem; color: #64748b;
}
.case-card-info { flex: 1; min-width: 0; }
.case-card-name { font-weight: 700; font-size: .9rem; color: #1e293b; }
.case-card-meta { font-size: .76rem; color: #64748b; margin-top: .2rem; }
.case-card-badges { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0; }
.case-badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .22rem .6rem;
    border-radius: 100px;
    font-size: .72rem; font-weight: 700;
    letter-spacing: .01em;
}
.case-badge--ok    { background: #dcfce7; color: #15803d; }
.case-badge--warn  { background: #fef9c3; color: #854d0e; }
.case-badge--error { background: #fee2e2; color: #b91c1c; }
.case-badge--info  { background: #f1f5f9; color: #475569; }
.case-card-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: .6rem;
}
.case-btn {
    flex: 1;
    min-width: 120px;
    padding: .5rem .9rem;
    border-radius: 9px;
    border: 1px solid rgba(0,0,0,.1);
    font-size: .8rem; font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: .4rem;
    transition: background .12s, opacity .12s;
}
.case-btn--primary { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.case-btn--primary:active { opacity: .85; }
.case-btn--secondary { background: #f8fafc; color: #334155; }
.case-btn--secondary:active { background: #f1f5f9; }
.case-btn:disabled { opacity: .45; cursor: default; }

/* ── Case timeline ────────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
    content: '';
    position: absolute;
    left: .75rem; top: .5rem; bottom: .5rem;
    width: 2px;
    background: #e2e8f0;
}
.timeline-item { position: relative; margin-bottom: 1.25rem; }
.timeline-dot {
    position: absolute;
    left: -1.35rem; top: .35rem;
    width: 12px; height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #e2e8f0;
    background: #94a3b8;
}
.timeline-dot--ok   { background: #22c55e; box-shadow: 0 0 0 2px #dcfce7; }
.timeline-dot--warn { background: #f59e0b; box-shadow: 0 0 0 2px #fef9c3; }
.timeline-dot--wait { background: #94a3b8; box-shadow: 0 0 0 2px #f1f5f9; }
.timeline-dot--proc { background: #3b82f6; box-shadow: 0 0 0 2px #dbeafe; }
.timeline-box {
    background: #f8fafc;
    border: 1px solid rgba(0,0,0,.07);
    border-radius: 10px;
    padding: .75rem 1rem;
}
.timeline-label { font-weight: 700; font-size: .84rem; color: #1e293b; margin-bottom: .3rem; }
.timeline-date  { font-size: .75rem; color: #94a3b8; margin-bottom: .4rem; }
.timeline-criticas { margin-top: .4rem; }
.timeline-crit-title { font-size: .75rem; font-weight: 700; color: #b91c1c; margin-bottom: .25rem; }
.timeline-crit-item { font-size: .76rem; color: #dc2626; padding: .15rem 0; }

/* ── History tab ──────────────────────────────────────────────────────────── */
.hist-filter-bar {
    display: flex;
    gap: .4rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: .25rem;
    scrollbar-width: none;
}
.hist-filter-bar::-webkit-scrollbar { display: none; }
.hist-filter-btn {
    flex-shrink: 0;
    padding: .38rem .85rem;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 100px;
    background: #fff;
    font-family: inherit;
    font-size: .72rem; font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    color: #64748b;
    transition: background .15s, color .15s, border-color .15s;
}
.hist-filter-btn.active {
    background: #0f172a;
    color: #fff;
    border-color: #0f172a;
}
.hist-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
    font-size: .9rem; font-weight: 500;
}
.hist-card {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 14px;
    padding: .85rem 1rem;
    margin-bottom: .55rem;
    display: flex;
    align-items: center;
    gap: .85rem;
    cursor: pointer;
    touch-action: manipulation;
    position: relative;
    overflow: hidden;
    transition: opacity .12s;
}
.hist-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--hist-accent, #64748b);
    border-radius: 4px 0 0 4px;
}
.hist-card:active { opacity: .8; }
.hist-icon {
    width: 40px; height: 40px; flex-shrink: 0;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    background: var(--hist-accent-bg, #f1f5f9);
}
.hist-info { flex: 1; min-width: 0; }
.hist-title {
    font-size: .88rem; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: .18rem;
}
.hist-meta { font-size: .7rem; color: #94a3b8; font-weight: 500; }
.hist-user-badge {
    display: inline-block;
    background: rgba(37,99,235,.1);
    color: #2563eb;
    border-radius: 6px;
    padding: 1px 6px;
    font-size: .65rem;
    font-weight: 600;
    vertical-align: middle;
}
.hist-loc-line { margin-top: .2rem; }
.hist-loc-badge {
    display: inline-block;
    background: rgba(5,150,105,.08);
    color: #059669;
    border-radius: 6px;
    padding: 1px 7px;
    font-size: .65rem;
    font-weight: 600;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}
.hist-loc-search-wrap {
    padding: .5rem 0 .25rem;
}
.hist-loc-search {
    width: 100%;
    box-sizing: border-box;
    padding: .55rem .9rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: .85rem;
    background: #f8fafc;
    color: #1e293b;
    outline: none;
    transition: border-color .15s;
}
.hist-loc-search:focus { border-color: #059669; background: #fff; }
.hist-delete {
    background: none; border: none;
    cursor: pointer;
    font-size: 1.05rem;
    padding: .45rem;
    color: #cbd5e1; flex-shrink: 0;
    touch-action: manipulation;
    border-radius: 8px;
    min-width: 36px; min-height: 36px;
    display: flex; align-items: center; justify-content: center;
    transition: color .15s, background .15s;
}
.hist-delete:active { color: #ef4444; background: #fee2e2; }

/* ── History modal ────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 2000;
    display: none;
    align-items: flex-end;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal-sheet {
    width: 100%;
    max-height: 88vh;
    background: #f8fafc;
    border-radius: 24px 24px 0 0;
    display: flex;
    flex-direction: column;
    animation: slideUp .22s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
.modal-handle {
    width: 40px; height: 4px;
    background: #e2e8f0; border-radius: 100px;
    margin: .7rem auto .2rem; flex-shrink: 0;
}
.modal-header {
    display: flex; align-items: center; gap: .75rem;
    padding: .35rem 1.1rem .85rem;
    border-bottom: 1px solid rgba(0,0,0,.07);
    flex-shrink: 0;
}
.modal-header h3 {
    flex: 1; font-size: .95rem; font-weight: 800;
    letter-spacing: -.02em; line-height: 1.3;
}
.modal-close {
    width: 32px; height: 32px; flex-shrink: 0;
    border: none; border-radius: 50%;
    background: #e2e8f0; cursor: pointer;
    font-size: .9rem; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    touch-action: manipulation;
}
.modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: .85rem 1rem 2.5rem;
}
.modal-location {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    background: rgba(5,150,105,.07);
    border: 1px solid rgba(5,150,105,.18);
    border-radius: 10px;
    padding: .6rem .85rem;
    margin-bottom: .85rem;
    font-size: .78rem;
}
.modal-location-icon { font-size: 1rem; flex-shrink: 0; }
.modal-location-text { flex: 1; color: #334155; line-height: 1.4; }
.modal-location-link {
    flex-shrink: 0;
    color: #059669;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.modal-location-link:hover { text-decoration: underline; }

@media (max-width: 480px) {
    body { padding-bottom: 68px; }
    .tab { padding: .8rem .7rem; }
    .analyze-btn { min-height: 58px; font-size: 1.05rem; }
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    .nav-btn { font-size: .52rem; }
}

/* ── User bar ─────────────────────────────────────────────────────────────── */
.user-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 40px;
    background: rgba(15,23,42,.96);
    border-bottom: 1px solid rgba(255,255,255,.07);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 1100;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    gap: .75rem;
}
.user-bar-name {
    font-size: .72rem;
    font-weight: 700;
    color: rgba(255,255,255,.65);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.user-bar-actions {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
}
.user-bar-btn {
    display: inline-flex;
    align-items: center;
    padding: .22rem .65rem;
    border-radius: 100px;
    font-size: .68rem;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,.15);
    color: rgba(255,255,255,.65);
    background: rgba(255,255,255,.06);
    transition: background .15s, color .15s;
    white-space: nowrap;
    touch-action: manipulation;
}
.user-bar-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.user-bar-btn--logout { border-color: rgba(239,68,68,.35); color: rgba(239,68,68,.75); }
.user-bar-btn--logout:hover { background: rgba(239,68,68,.15); color: #f87171; }

body:not(.login-page):not(.admin-page) { padding-top: 40px; }

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-page {
    background: #0f172a;
    color: #f8fafc;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    padding-top: 0;
    padding-bottom: 0;
}
.login-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.login-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: .35;
}
.login-orb--1 { width:400px;height:400px;background:#2563eb;top:-100px;right:-80px; }
.login-orb--2 { width:300px;height:300px;background:#7c3aed;bottom:-80px;left:10%; }
.login-orb--3 { width:220px;height:220px;background:#059669;top:40%;left:-60px; }

.login-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}
.login-brand { text-align: center; }
.login-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    color: rgba(255,255,255,.75);
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: .25rem .75rem;
    border-radius: 100px;
    margin-bottom: .65rem;
}
.login-title {
    font-size: clamp(2rem,8vw,2.8rem);
    font-weight: 900;
    letter-spacing: -.04em;
    color: #fff;
    line-height: 1;
    margin-bottom: .35rem;
}
.login-sub {
    font-size: .82rem;
    color: rgba(255,255,255,.4);
    line-height: 1.5;
}
.login-card {
    width: 100%;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 20px;
    padding: 1.75rem 1.5rem;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}
.login-error {
    background: rgba(239,68,68,.15);
    border: 1px solid rgba(239,68,68,.3);
    color: #fca5a5;
    border-radius: 10px;
    padding: .65rem .9rem;
    font-size: .82rem;
    font-weight: 600;
    margin-bottom: 1rem;
}
.login-field { margin-bottom: 1rem; }
.login-label {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: rgba(255,255,255,.5);
    margin-bottom: .4rem;
}
.login-input {
    width: 100%;
    padding: .75rem 1rem;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 12px;
    color: #f8fafc;
    font-family: inherit;
    font-size: .95rem;
    outline: none;
    transition: border-color .15s, background .15s;
}
.login-input::placeholder { color: rgba(255,255,255,.25); }
.login-input:focus {
    border-color: rgba(37,99,235,.7);
    background: rgba(255,255,255,.1);
}
.login-btn {
    width: 100%;
    margin-top: .35rem;
    min-height: 50px;
    padding: .85rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg,#2563eb 0%,#1d4ed8 100%);
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -.01em;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
    touch-action: manipulation;
}
.login-btn:active { transform: scale(.98); opacity: .9; }
.login-footer {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: rgba(255,255,255,.2);
}

/* ── Admin page ───────────────────────────────────────────────────────────── */
.admin-wrap {
    max-width: 640px;
    margin: 0 auto;
    padding: 1rem .9rem 3rem;
    padding-top: calc(40px + 1rem);
}
.admin-section {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 16px;
    padding: 1.1rem 1.1rem;
    margin-bottom: 1rem;
}
.admin-section-title {
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: .85rem;
}
.admin-form-row {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: flex-end;
}
.admin-input {
    flex: 1;
    min-width: 120px;
    padding: .6rem .85rem;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 10px;
    font-family: inherit;
    font-size: .88rem;
    background: #f8fafc;
    outline: none;
    transition: border-color .15s;
}
.admin-input:focus { border-color: #2563eb; }
.admin-input--sm { flex: none; width: 160px; }
.admin-select {
    padding: .6rem .85rem;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 10px;
    font-family: inherit;
    font-size: .88rem;
    background: #f8fafc;
    cursor: pointer;
}
.admin-btn {
    padding: .6rem 1rem;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
    transition: opacity .15s;
}
.admin-btn:active { opacity: .8; }
.admin-btn--primary  { background: #2563eb; color: #fff; }
.admin-btn--secondary { background: #f1f5f9; color: #475569; border: 1px solid rgba(0,0,0,.1); }
.admin-btn--danger   { background: #fee2e2; color: #991b1b; }
.admin-msg {
    margin-top: .65rem;
    padding: .55rem .85rem;
    border-radius: 8px;
    font-size: .82rem;
    font-weight: 600;
}
.admin-msg--ok    { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.admin-msg--error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.admin-empty { text-align: center; padding: 1.5rem; color: #94a3b8; font-size: .88rem; }
.admin-user-card {
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: .6rem;
}
.admin-user-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem 1rem;
    background: #f8fafc;
}
.admin-user-icon { font-size: 1.15rem; flex-shrink: 0; }
.admin-user-info { flex: 1; min-width: 0; }
.admin-user-name {
    display: block;
    font-size: .9rem;
    font-weight: 800;
    letter-spacing: -.01em;
}
.admin-user-meta {
    display: block;
    font-size: .7rem;
    color: #94a3b8;
    margin-top: .1rem;
}
.admin-user-self {
    font-size: .7rem;
    font-weight: 700;
    color: #94a3b8;
    padding: .2rem .55rem;
    background: #e2e8f0;
    border-radius: 100px;
}
.admin-pw-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .65rem 1rem;
    border-top: 1px solid rgba(0,0,0,.06);
    background: #fff;
    flex-wrap: wrap;
}

/* ── Hero compacto (home) ─────────────────────────────────────────────────── */
.hero--compact {
    padding: 1.4rem 1.4rem 1.5rem;
    margin-bottom: 1rem;
}
.hero--compact h1 { font-size: clamp(1.6rem,6vw,2.1rem); }
.hero--compact p  { font-size: clamp(.78rem,2.2vw,.88rem); }

/* ── KPI grid ─────────────────────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .65rem;
    margin-bottom: 1rem;
}
@media (min-width: 520px) {
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}
.kpi-card {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 14px;
    padding: .85rem .9rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--kpi-accent, #2563eb);
    border-radius: 14px 14px 0 0;
}
.kpi-card--total { --kpi-accent: #0f172a; }
.kpi-icon { font-size: 1.5rem; flex-shrink: 0; }
.kpi-body { min-width: 0; }
.kpi-value {
    font-size: 1.45rem;
    font-weight: 900;
    letter-spacing: -.03em;
    line-height: 1;
    color: var(--kpi-accent, #0f172a);
}
.kpi-label {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-top: .2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Mapa ─────────────────────────────────────────────────────────────────── */
.map-section {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}
.map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem .6rem;
    border-bottom: 1px solid rgba(0,0,0,.06);
}
.map-title {
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: -.01em;
    color: #0f172a;
}
.map-badge {
    font-size: .68rem;
    font-weight: 700;
    color: #059669;
    background: rgba(5,150,105,.1);
    border-radius: 100px;
    padding: .18rem .65rem;
}
.map-container {
    height: 260px;
    width: 100%;
}
@media (min-width: 480px) {
    .map-container { height: 320px; }
}
@media (min-width: 640px) {
    .map-container { height: 380px; }
}
.map-legend {
    display: flex;
    gap: .85rem;
    padding: .55rem 1rem;
    border-top: 1px solid rgba(0,0,0,.05);
    flex-wrap: wrap;
}
.map-leg-item {
    font-size: .68rem;
    font-weight: 700;
    color: var(--leg, #64748b);
    letter-spacing: .02em;
}

/* ── Título de seção na Home ──────────────────────────────────────────────── */
.modules-title {
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: .65rem;
    padding-left: .1rem;
}

/* ── Image thumbnails ─────────────────────────────────────────────────────── */
.img-thumbs {
    display: none;
    flex-wrap: wrap;
    gap: .4rem;
    padding: .75rem 1rem;
    border-top: 1px solid rgba(0,0,0,.06);
}
.img-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 1.5px solid rgba(0,0,0,.1);
    background: #f1f5f9;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.img-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.img-thumb--more {
    font-size: .78rem;
    font-weight: 800;
    color: #475569;
    background: #f1f5f9;
}

/* ── PDF button no modal ──────────────────────────────────────────────────── */
.pdf-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    min-height: 46px;
    padding: .7rem 1.2rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    margin-bottom: .85rem;
    touch-action: manipulation;
    transition: opacity .15s;
    letter-spacing: -.01em;
}
.pdf-btn:active { opacity: .85; }

/* ── Link modal ───────────────────────────────────────────────────────────── */
#link-modal .modal-sheet { max-height: 90vh; }
.lnk-field { margin-bottom: 14px; }
.lnk-label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 5px;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.lnk-opts-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 6px;
}
.lnk-opts-toggle {
    font-size: .7rem; font-weight: 600; padding: 3px 10px;
    border-radius: 20px; border: 1.5px solid #cbd5e1;
    background: #fff; color: #475569; cursor: pointer;
    transition: all .15s;
}
.lnk-opts-toggle:hover { background: #e0f2fe; border-color: #7dd3fc; color: #0369a1; }
.lnk-opts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
    gap: 3px 4px;
    max-height: 210px;
    overflow-y: auto;
    background: #fff;
    border-radius: 10px;
    padding: 8px 10px;
    border: 1.5px solid #e2e8f0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,.04);
}
.lnk-opt-label {
    display: flex; align-items: center; gap: 7px;
    font-size: .8rem; font-weight: 500; color: #1e293b;
    cursor: pointer; padding: 5px 7px; border-radius: 7px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background .12s;
    -webkit-user-select: none; user-select: none;
}
.lnk-opt-label:hover { background: #f0f9ff; }
.lnk-opt-label:has(input:checked) { background: #eff6ff; color: #1d4ed8; font-weight: 600; }
.lnk-opt-label input[type=checkbox] {
    flex-shrink: 0; width: 15px; height: 15px;
    accent-color: #2563eb; cursor: pointer;
}
.lnk-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-family: inherit;
    font-size: .9rem;
    color: #0f172a;
    background: #fff;
    transition: border-color .15s;
    appearance: none;
}
.lnk-input:focus { outline: none; border-color: #0ea5e9; }
.lnk-textarea { resize: vertical; min-height: 72px; }
.lnk-submit-btn {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 6px;
    touch-action: manipulation;
    transition: opacity .15s;
}
.lnk-submit-btn:disabled { opacity: .5; cursor: not-allowed; }
.lnk-submit-btn:active:not(:disabled) { opacity: .85; }
.lnk-result {
    border-radius: 10px;
    padding: 14px 16px;
    font-size: .87rem;
    margin-bottom: 12px;
}
.lnk-result--ok    { background: #0ea5e9; color: #fff; }
.lnk-result--error { background: rgba(220,38,38,.08); border: 1px solid #fca5a5; color: #dc2626; }
.lnk-copy-btn {
    background: rgba(255,255,255,.25);
    border: 1px solid rgba(255,255,255,.4);
    color: #fff;
    padding: 5px 12px;
    border-radius: 7px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.lnk-copy-btn:active { opacity: .8; }
.lnk-input--error { border-color: #ef4444 !important; background: #fef2f2 !important; }
.lnk-field-error {
    font-size: .74rem;
    color: #dc2626;
    font-weight: 500;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 3px;
}

/* ── Link card on home ────────────────────────────────────────────────────── */
.link-card { border: 1.5px dashed rgba(14,165,233,.35); }
.link-card:hover, .link-card:active { border-style: solid; }

/* ── Geo status ───────────────────────────────────────────────────────────── */
.geo-status {
    font-size: .78rem;
    color: #059669;
    margin-top: 6px;
    text-align: center;
}

/* ── Phosphor Icons sizing ────────────────────────────────────────────────── */
.ph, .ph-bold, .ph-fill, .ph-light, .ph-thin, .ph-duotone {
    vertical-align: middle;
    line-height: 1;
}
.kpi-icon .ph, .kpi-icon .ph-bold   { font-size: 1.5rem; }
.module-icon .ph, .module-icon .ph-bold { font-size: 1.75rem; }
.page-header-icon .ph, .page-header-icon .ph-bold { font-size: 1.6rem; }
.nav-icon .ph, .nav-icon .ph-bold   { font-size: 1.35rem; display: block; }
.upload-icon .ph, .upload-icon .ph-bold { font-size: 2.4rem; }
.analyze-btn .ph                    { font-size: 1rem; margin-right: .1rem; }
.pdf-btn .ph                        { font-size: 1rem; }
.hist-delete .ph                    { font-size: 1rem; }
.user-bar-name .ph                  { font-size: 1rem; }
.user-bar-btn .ph                   { font-size: .9rem; }
.modal-close .ph                    { font-size: 1.1rem; }
.opts-group-label .ph               { font-size: .9rem; margin-right: 4px; }
.hist-filter-btn .ph                { font-size: .85rem; }
.map-title .ph                      { font-size: 1rem; }
.map-leg-item .ph                   { font-size: .8rem; }
.lnk-submit-btn .ph                 { font-size: 1rem; }
.lnk-copy-btn .ph                   { font-size: .85rem; }
.section-title .ph, .section-title .ph-bold { font-size: 1rem; }
.download-btn .ph                   { font-size: .9rem; }
.admin-user-icon .ph                { font-size: 1.2rem; }
.admin-btn .ph                      { font-size: .9rem; }
.ak-reveal-label .ph                { font-size: .9rem; }
.wh-card-meta .ph                   { font-size: .78rem; }
.admin-docs-link .ph                { font-size: 1rem; }
.hero__badge .ph                    { font-size: .85rem; }

/* ── Admin docs link card ─────────────────────────────────────────────────── */
.admin-docs-link {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(99,102,241,.08);
    border: 1px solid rgba(99,102,241,.22);
    border-radius: 10px;
    padding: 13px 16px;
    margin-bottom: 18px;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}
.admin-docs-link:hover { background: rgba(99,102,241,.15); border-color: rgba(99,102,241,.4); }
.admin-docs-link > .ph:first-child { font-size: 1.4rem; color: #818cf8; flex-shrink: 0; }
.admin-docs-link-title { font-size: .88rem; font-weight: 600; color: #1e293b; }
.admin-docs-link-sub   { font-size: .76rem; color: #64748b; margin-top: 1px; }

/* ── Admin section description ────────────────────────────────────────────── */
.admin-section-desc {
    font-size: .82rem;
    color: #94a3b8;
    margin: -4px 0 12px;
    line-height: 1.5;
}
.admin-section-desc code {
    background: #e0e7ff;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: .8rem;
    color: #3730a3;
}

/* ── API Keys ──────────────────────────────────────────────────────────────── */
.ak-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ak-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8fafc;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 10px;
    padding: 10px 14px;
}
.ak-card--revoked { opacity: .6; }
.ak-info { flex: 1; min-width: 0; }
.ak-name { display: block; font-size: .9rem; font-weight: 600; color: #0f172a; }
.ak-meta { display: block; font-size: .76rem; color: #64748b; margin-top: 2px; }
.ak-meta code { background: #e2e8f0; padding: 1px 5px; border-radius: 4px; color: #334155; }
.ak-badge {
    padding: 2px 9px;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}
.ak-badge--active  { background: rgba(5,150,105,.12); color: #065f46; }
.ak-badge--revoked { background: rgba(100,116,139,.12); color: #475569; }
.ak-reveal {
    margin: 10px 0;
    background: #fefce8;
    border: 1px solid #fde047;
    border-radius: 10px;
    padding: 12px 14px;
}
.ak-reveal-label { font-size: .78rem; color: #92400e; font-weight: 600; margin-bottom: 8px; }
.ak-reveal-key { display: flex; align-items: center; gap: 10px; }
.ak-reveal-key code {
    flex: 1;
    font-size: .78rem;
    word-break: break-all;
    background: #fff;
    border: 1px solid #fde047;
    padding: 6px 10px;
    border-radius: 6px;
    color: #1e293b;
}

/* ── Webhooks ──────────────────────────────────────────────────────────────── */
.wh-create-form {
    background: #f8fafc;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 14px;
}
.wh-events-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 10px 0 4px;
}
.wh-event-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .82rem;
    color: #475569;
    cursor: pointer;
    user-select: none;
}
.wh-event-label:hover { color: #0f172a; }
.wh-event-cb { width: 15px; height: 15px; accent-color: #6366f1; cursor: pointer; }
.wh-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.wh-card {
    background: #f8fafc;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 10px;
    overflow: hidden;
}
.wh-card--inactive { opacity: .6; }
.wh-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px 10px;
}
.wh-card-info { flex: 1; min-width: 0; }
.wh-card-name { display: block; font-size: .9rem; font-weight: 600; color: #0f172a; }
.wh-card-url  { display: block; font-size: .78rem; color: #4f46e5; word-break: break-all; margin-top: 2px; }
.wh-card-meta { display: block; font-size: .73rem; color: #64748b; margin-top: 3px; }
.wh-card-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.wh-toggle { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.wh-toggle input[type=checkbox] { width: 16px; height: 16px; accent-color: #6366f1; cursor: pointer; }
.wh-toggle-label { font-size: .75rem; color: #64748b; white-space: nowrap; }
.wh-events-row {
    padding: 8px 14px;
    background: rgba(99,102,241,.05);
    border-top: 1px solid rgba(99,102,241,.10);
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}
.wh-save-row {
    padding: 8px 14px 10px;
    display: flex;
    align-items: center;
}

/* ── Condition dot (replaces emoji circles) ───────────────────────────────── */
.cond-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ── Home grid / version ─────────────────────────────────────────────────── */
.home-grid { display: block; }
.home-version {
    text-align: center;
    margin-top: 1.5rem;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #cbd5e1;
}

/* Mobile: sidebar elements hidden */
.sidebar-brand,
.sidebar-footer { display: none; }
.nav-long { display: none; }
.nav-short { display: inline; }

/* ── Map center button ────────────────────────────────────────────────────── */
.map-center-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 7px;
    background: #fff;
    cursor: pointer;
    font-size: .95rem;
    color: #64748b;
    transition: color .15s, background .15s, border-color .15s;
    flex-shrink: 0;
    padding: 0;
}
.map-center-btn:hover { color: #0f172a; background: #f1f5f9; border-color: rgba(0,0,0,.2); }

/* ── Admin back link (hidden on mobile — user-bar already has one) ─────────── */
.admin-back-link { display: none; }

/* ════════════════════════════════════════════════════════════════
   DESKTOP LAYOUT  ≥ 960px  —  Left sidebar
   ════════════════════════════════════════════════════════════════ */
@media (min-width: 960px) {

    /* ── Body: remove mobile offsets, add left offset for sidebar ─── */
    body { padding-bottom: 0; }
    body:not(.login-page):not(.admin-page) {
        padding-left: 220px;
        padding-top: 0;
    }

    /* ── Hide mobile-only user-bar ───────────────────────────────── */
    .user-bar { display: none; }

    /* ── Bottom nav → left sidebar ───────────────────────────────── */
    .bottom-nav {
        position: fixed;
        left: 0; top: 0; bottom: 0; right: auto;
        width: 220px;
        height: 100vh;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        border-top: none;
        border-right: 1px solid rgba(0,0,0,.08);
        border-bottom: none;
        background: rgba(255,255,255,.98);
        padding: 0;
        gap: 0;
        -webkit-backdrop-filter: blur(14px);
        backdrop-filter: blur(14px);
        box-shadow: 1px 0 12px rgba(0,0,0,.05);
        z-index: 1100;
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* Brand */
    .sidebar-brand {
        display: flex;
        align-items: center;
        gap: .55rem;
        font-size: .95rem;
        font-weight: 800;
        letter-spacing: -.03em;
        color: #0f172a;
        text-decoration: none;
        flex-shrink: 0;
        padding: 1.1rem 1.1rem .9rem;
        white-space: nowrap;
        border-bottom: 1px solid rgba(0,0,0,.06);
        margin-bottom: .4rem;
    }
    .sidebar-brand .ph-bold { font-size: 1.2rem; color: #6366f1; }

    /* Nav items */
    .nav-short { display: none; }
    .nav-long  { display: inline; }

    .nav-btn {
        flex: none;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: .55rem;
        height: auto;
        padding: .6rem .9rem .6rem 1rem;
        margin: .06rem .6rem;
        width: calc(100% - 1.2rem);
        font-size: .83rem;
        font-weight: 600;
        text-transform: none;
        letter-spacing: 0;
        border-radius: 9px;
        min-height: unset;
        color: #64748b;
        border-bottom: none;
        border-left: 3px solid transparent;
        transition: color .15s, background .15s, border-left-color .15s;
        white-space: nowrap;
        text-align: left;
    }
    .nav-btn .nav-icon {
        font-size: 1rem;
        display: flex;
        align-items: center;
        flex-shrink: 0;
        width: 1rem;
    }
    .nav-btn.active {
        color: #2563eb;
        background: rgba(37,99,235,.08);
        border-left-color: #2563eb;
        font-weight: 700;
    }
    .nav-btn:hover:not(.active) {
        color: #334155;
        background: rgba(0,0,0,.04);
    }

    /* Sidebar footer */
    .sidebar-footer {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: .3rem;
        margin-top: auto;
        border-top: 1px solid rgba(0,0,0,.07);
        padding: .75rem .75rem .85rem;
        flex-shrink: 0;
    }
    .sidebar-user-info {
        display: flex;
        align-items: center;
        gap: .4rem;
        font-size: .76rem;
        font-weight: 600;
        color: #64748b;
        padding: .1rem .2rem .5rem;
        border-bottom: 1px solid rgba(0,0,0,.06);
        margin-bottom: .15rem;
        white-space: nowrap;
        overflow: hidden;
    }
    .sidebar-user-info .ph { font-size: .9rem; }
    .sidebar-action {
        display: flex;
        align-items: center;
        gap: .4rem;
        padding: .38rem .7rem;
        border: 1px solid rgba(0,0,0,.1);
        border-radius: 8px;
        font-size: .76rem;
        font-weight: 600;
        color: #475569;
        text-decoration: none;
        background: transparent;
        transition: background .12s, color .12s, border-color .12s;
        white-space: nowrap;
    }
    .sidebar-action .ph { font-size: .82rem; }
    .sidebar-action:hover { background: #f1f5f9; color: #0f172a; border-color: rgba(0,0,0,.18); }
    .sidebar-action--logout { color: #dc2626; border-color: rgba(220,38,38,.2); }
    .sidebar-action--logout:hover { background: #fef2f2; border-color: rgba(220,38,38,.35); }

    /* ── Content area ─────────────────────────────────────────────── */
    .tab {
        max-width: 1280px;
        margin: 0 auto;
        padding: 2rem 2.5rem;
    }

    /* ── HOME ─────────────────────────────────────────────────────── */
    .hero {
        padding: 2.5rem 2.5rem;
        margin-bottom: 1.5rem;
        border-radius: 22px;
    }
    .hero h1 { font-size: 2.6rem; }

    .kpi-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: .9rem;
        margin-bottom: 1.5rem;
    }
    .kpi-card { padding: 1rem 1.2rem; }

    /* Home 2-column: modules left, map right */
    .home-grid {
        display: grid;
        grid-template-columns: 1fr 540px;
        gap: 1.5rem;
        align-items: start;
    }
    .map-section { margin-bottom: 0; }
    .map-container { height: 520px; }

    /* Module cards 2×2 on desktop */
    .modules-cards {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: .65rem;
    }
    .modules-cards .module-card { margin-bottom: 0; }
    .module-card { border-radius: 16px; }

    /* ── ANALYSIS TABS: coluna única centralizada ────────────────── */
    #tab-ambientes,
    #tab-veiculos,
    #tab-areas,
    #tab-transporte {
        max-width: 860px;
    }

    /* opts-grid usa 3 colunas para aproveitar largura disponível */
    #tab-ambientes .opts-grid,
    #tab-veiculos .opts-grid,
    #tab-areas .opts-grid,
    #tab-transporte .opts-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .upload-zone { min-height: 160px; }
    .analyze-btn { min-height: 52px; font-size: 1rem; }
    .metrics-grid { grid-template-columns: repeat(3, 1fr); }

    /* ── HISTORY ──────────────────────────────────────────────────── */
    #tab-historico { max-width: 1100px; }

    #tab-historico .hist-filter-bar {
        flex-wrap: wrap;
        overflow-x: visible;
        gap: .6rem;
        margin-bottom: 1.25rem;
    }
    #tab-historico .hist-filter-btn {
        padding: .5rem 1.35rem;
        font-size: .8rem;
        border-radius: 10px;
    }
    .hist-loc-search { max-width: 480px; }
    #hist-list {
        display: flex;
        flex-direction: column;
        gap: .6rem;
    }
    #hist-list .hist-card { margin-bottom: 0; padding: 1rem 1.25rem; }
    #hist-list .hist-card .hist-icon { width: 46px; height: 46px; }
    #hist-list .hist-title { font-size: .95rem; }
    #hist-list .hist-meta  { font-size: .8rem; }

    /* ── MODAL: centered dialog ───────────────────────────────────── */
    .modal-overlay { align-items: center; justify-content: center; }
    .modal-sheet {
        width: 620px;
        max-width: 92vw;
        max-height: 85vh;
        border-radius: 22px;
        animation: dlgIn .2s ease;
    }
    @keyframes dlgIn {
        from { opacity: 0; transform: scale(.95) translateY(12px); }
        to   { opacity: 1; transform: scale(1)   translateY(0); }
    }
    .modal-handle { display: none; }
    .modal-header { padding: .9rem 1.5rem; }
    .modal-body   { padding: .85rem 1.5rem 2rem; }

    /* ── Misc refinements ─────────────────────────────────────────── */
    .page-header h2 { font-size: 1.4rem; }
    .item-card-header { font-size: .9rem; }

    /* ── Admin back link ──────────────────────────────────────────── */
    .admin-back-link {
        display: inline-flex;
        align-items: center;
        gap: .45rem;
        color: #64748b;
        text-decoration: none;
        font-size: .82rem;
        font-weight: 600;
        margin-bottom: 1rem;
        padding: .38rem .75rem .38rem .55rem;
        border: 1px solid rgba(0,0,0,.1);
        border-radius: 8px;
        background: #fff;
        transition: color .15s, background .15s;
    }
    .admin-back-link:hover { color: #0f172a; background: #f1f5f9; }
    .admin-back-link .ph { font-size: .85rem; }
    .admin-wrap { padding-top: 1.75rem; }

} /* end @media desktop */

/* ── Admin module permissions panel ──────────────────────────────────────── */
.admin-modules-row {
    padding: 10px 14px 12px;
    background: rgba(99,102,241,.05);
    border-top: 1px solid rgba(99,102,241,.12);
    border-bottom: 1px solid rgba(99,102,241,.12);
}
.admin-modules-label {
    font-size: .75rem;
    font-weight: 600;
    color: #6366f1;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.admin-modules-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 10px;
}
.admin-mod-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .82rem;
    color: #475569;
    cursor: pointer;
    user-select: none;
}
.admin-mod-label:hover { color: #0f172a; }
.admin-mod-cb {
    width: 15px;
    height: 15px;
    accent-color: #6366f1;
    cursor: pointer;
}
.admin-mod-cb:disabled { opacity: .45; cursor: not-allowed; }
.admin-btn--sm {
    padding: 4px 10px;
    font-size: .78rem;
}
.admin-mod-saved {
    font-size: .78rem;
    color: #059669;
    margin-left: 8px;
}

/* ── Processing card in history ──────────────────────────────────────────── */
.hist-card--processing {
    opacity: .85;
    cursor: default;
    pointer-events: none;
}

/* ── Failed job card in history ──────────────────────────────────────────── */
.hist-card--failed {
    cursor: default;
    pointer-events: all;
}
.hist-card--failed:active { opacity: 1; }
.hist-err-msg {
    font-size: .7rem;
    color: #f87171;
    margin-top: .25rem;
    line-height: 1.4;
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.hist-proc-spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid rgba(0,0,0,.1);
    border-top-color: var(--spin-color, #2563eb);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

/* ── Upload progress bar ──────────────────────────────────────────────────── */
.upload-progress-track {
    width: 100%;
    height: 4px;
    background: rgba(37,99,235,.12);
    border-radius: 99px;
    overflow: hidden;
    margin-top: .65rem;
}
.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent,#2563eb), #7c3aed);
    border-radius: 99px;
    transition: width .2s ease;
}

/* ── Job cards ────────────────────────────────────────────────────────────── */
.job-card {
    border-radius: 14px;
    margin-bottom: 1rem;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,.07);
    background: #fff;
}
.job-card--processing {
    border-color: #bfdbfe;
    background: #eff6ff;
}
.job-card--done {
    padding: 1rem;
    border-color: rgba(0,0,0,.07);
}
.job-card--error {
    border-color: #fecaca;
    background: #fef2f2;
}
.job-card-header {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .875rem 1rem;
}
.job-spinner {
    width: 20px !important;
    height: 20px !important;
    border-width: 2.5px !important;
    margin: 0 !important;
    flex-shrink: 0;
    border-top-color: #2563eb !important;
}
.job-card-title {
    flex: 1;
    font-size: .875rem;
    font-weight: 600;
    color: #1e40af;
}
.job-card-time {
    font-size: .72rem;
    color: #94a3b8;
    font-weight: 500;
}
.job-card-done-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .875rem;
    padding-bottom: .875rem;
    border-bottom: 1px solid rgba(0,0,0,.06);
}
.job-card-done-badge {
    font-size: .72rem;
    font-weight: 700;
    color: #059669;
    background: #dcfce7;
    padding: .22rem .7rem;
    border-radius: 100px;
    letter-spacing: .01em;
}
.job-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: .95rem;
    padding: .2rem .35rem;
    line-height: 1;
    border-radius: 6px;
    transition: background .12s, color .12s;
    font-family: inherit;
}
.job-close-btn:hover {
    background: #f1f5f9;
    color: #475569;
}
