/* ============================================================
   Rastreio — prototipo. Design system.
   ============================================================ */
:root {
    --bg:        #0b1020;
    --bg-soft:   #11182e;
    --surface:   #ffffff;
    --ink:       #0f172a;
    --ink-soft:  #475569;
    --muted:     #94a3b8;
    --line:      #e2e8f0;
    --brand:     #6366f1;
    --brand-2:   #8b5cf6;
    --brand-3:   #0ea5e9;
    --ok:        #22c55e;
    --warn:      #f59e0b;
    --danger:    #ef4444;
    --radius:    16px;
    --radius-sm: 10px;
    --shadow:    0 20px 50px -20px rgba(15,23,42,.45);
    --shadow-sm: 0 6px 20px -8px rgba(15,23,42,.25);
    --font:      'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --mono:      'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* garante que .modal/.drawer/.sig-modal respeitem o atributo hidden */
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: #f1f5f9; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { justify-content: center; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.brand-mark { font-size: 1.3rem; filter: drop-shadow(0 2px 6px rgba(99,102,241,.5)); }
.brand-name { background: linear-gradient(90deg, #fff, #c7d2fe); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Buttons ---------- */
.btn-primary {
    border: 0; border-radius: 12px; padding: .8rem 1.4rem; font-weight: 600; font-size: .95rem; color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 10px 24px -10px var(--brand); transition: transform .12s ease, box-shadow .2s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 30px -10px var(--brand); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
    border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); color: #fff;
    border-radius: 12px; padding: .55rem 1.05rem; font-weight: 600; font-size: .9rem; backdrop-filter: blur(6px);
}
.btn-ghost:hover { background: rgba(255,255,255,.14); }
.btn-danger { border: 0; border-radius: 12px; padding: .7rem 1.2rem; font-weight: 600; color: #fff; background: var(--danger); }
.btn-danger:hover { filter: brightness(1.05); }

/* ============================================================
   SITE PUBLICO (rastreio) — visual de transportadora real
   ============================================================ */
.site { min-height: 100vh; display: flex; flex-direction: column; background: #eef2f7; color: var(--ink); }

/* Logo (emblema) */
.logo-mark { display: inline-grid; place-items: center; line-height: 0; }
.logo-mark svg { display: block; }

/* Cabecalho do site */
.site-head { display: flex; align-items: center; gap: .65rem; padding: .85rem clamp(1.1rem, 5vw, 3rem);
    background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 1px 2px rgba(15,23,42,.05); }
.brand-pub { font-size: 1.2rem; gap: .6rem; }
.brand-pub .brand-name { background: none; -webkit-background-clip: initial; color: #143a7b; font-weight: 800; letter-spacing: -.02em; }
.site-head-tag { margin-left: auto; font-size: .8rem; font-weight: 600; color: var(--muted); }

.site-main { flex: 1; display: flex; flex-direction: column; align-items: center;
    padding: clamp(1.6rem, 5vh, 3.2rem) 1.1rem 3rem; }

/* Estado vazio: emblema + titulo + campo */
.hero-empty { width: min(560px, 95vw); text-align: center; margin-top: clamp(.5rem, 5vh, 3rem); }
.hero-emblem { display: flex; justify-content: center; margin-bottom: 1.4rem; }
.hero-emblem .logo-mark svg { box-shadow: 0 14px 30px -12px rgba(20,58,123,.55); border-radius: 20px; }
.hero-title { font-size: clamp(1.6rem, 4.4vw, 2.25rem); font-weight: 800; letter-spacing: -.02em; color: #102a4c; }
.hero-sub { color: var(--ink-soft); font-size: 1rem; line-height: 1.55; margin: .8rem auto 1.7rem; max-width: 44ch; }

.track-box { display: flex; gap: .5rem; width: 100%; background: #fff; border: 1px solid var(--line);
    padding: .45rem; border-radius: 14px; box-shadow: 0 14px 34px -18px rgba(15,23,42,.45);
    transition: border-color .15s, box-shadow .15s; }
.track-box:focus-within { border-color: #2f5fb0; box-shadow: 0 14px 34px -16px rgba(20,58,123,.5); }
.track-box input { flex: 1; border: 0; background: transparent; color: var(--ink); font-size: 1.05rem;
    padding: .85rem 1rem; outline: none; letter-spacing: .02em; }
.track-box input::placeholder { color: #9aa7b8; }
.track-box button { border: 0; border-radius: 11px; padding: 0 1.7rem; font-weight: 700; color: #fff; font-size: 1rem;
    background: #143a7b; display: inline-flex; align-items: center; gap: .5rem; transition: background .15s; }
.track-box button:hover { background: #1c4a96; }
.btn-spin { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%;
    display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hero-note { margin-top: 1.3rem; color: var(--muted); font-size: .85rem; display: inline-flex; gap: .4rem;
    align-items: center; justify-content: center; }
.hero-note svg { width: 15px; height: 15px; color: #15914a; }

.site-foot { text-align: center; padding: 1.3rem; color: var(--muted); font-size: .8rem;
    border-top: 1px solid var(--line); background: #fff; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Resultado do rastreio ---------- */
.result { width: min(860px, 96vw); margin-top: 1.2rem; }

/* estados nao-encontrado / expirado */
.state-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 2.6rem 2rem;
    text-align: center; box-shadow: 0 18px 40px -24px rgba(15,23,42,.4); max-width: 480px; margin: 1.5rem auto 0;
    animation: rise .35s ease; }
.state-ic { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; margin-bottom: 1.1rem; }
.state-ic svg { width: 30px; height: 30px; }
.state-notfound .state-ic { background: #eff4ff; color: #2563eb; }
.state-expired .state-ic { background: #fff4e6; color: #d97706; }
.state-card h2 { font-size: 1.3rem; color: #102a4c; margin-bottom: .6rem; }
.state-card p { font-size: .95rem; line-height: 1.55; margin: 0 auto; max-width: 40ch; }
.state-code { display: inline-block; margin-top: 1.1rem; font-family: var(--mono); font-size: 1rem; font-weight: 600;
    color: #334155; background: #f1f5f9; border: 1px solid var(--line); border-radius: 9px; padding: .45rem .9rem; letter-spacing: .03em; }
.state-btn { display: inline-block; margin-top: 1.4rem; background: #143a7b; color: #fff; font-weight: 700;
    font-size: .92rem; padding: .8rem 1.6rem; border-radius: 11px; transition: background .15s; }
.state-btn:hover { background: #1c4a96; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: .4rem 0 0; }
.timeline li { position: relative; padding: 0 0 1.4rem 1.8rem; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 4px; bottom: -4px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.tl-dot { position: absolute; left: 0; top: 3px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff;
          box-shadow: 0 0 0 2px currentColor; }
.timeline li.is-first .tl-status { font-weight: 700; }
.tl-status { display: block; font-weight: 600; font-size: .95rem; }
.tl-desc { color: var(--ink-soft); font-size: .88rem; margin-top: .1rem; }
.tl-meta { color: var(--muted); font-size: .78rem; margin-top: .25rem; display: flex; gap: .6rem; flex-wrap: wrap; }

.result-error { background: var(--surface); color: var(--ink); border-radius: var(--radius); padding: 1.6rem; text-align: center;
                box-shadow: var(--shadow); border-left: 4px solid var(--danger); }
.result-error strong { color: var(--danger); }

/* ============================================================
   AUTH / Login
   ============================================================ */
.auth-wrap, .notfound { position: relative; min-height: 100vh; display: grid; place-items: center; overflow: hidden;
                        background: radial-gradient(900px 500px at 50% -10%, #1e293b, var(--bg)); padding: 1.5rem; }
.auth-card, .nf-card { position: relative; z-index: 2; width: min(420px, 94vw); background: var(--surface);
                       border-radius: 20px; padding: 2.2rem; box-shadow: var(--shadow); text-align: center; }
.auth-card .brand { margin-bottom: 1.4rem; }
.auth-card .brand-name { background: linear-gradient(90deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-card h1 { font-size: 1.35rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.6rem; text-align: left; }
.auth-form label, .grid-form label { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.auth-form input, .grid-form input, .grid-form select, .event-form input, .event-form select, .table-tools input {
    border: 1px solid var(--line); border-radius: 10px; padding: .7rem .85rem; font-size: .95rem; font-family: inherit; color: var(--ink); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.auth-form input:focus, .grid-form input:focus, .grid-form select:focus, .event-form input:focus, .event-form select:focus, .table-tools input:focus {
    border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.auth-form .btn-primary { margin-top: .4rem; }
.alert { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: 10px; padding: .7rem .9rem; font-size: .88rem; }
.auth-foot { margin-top: 1.4rem; font-size: .9rem; }
.auth-foot a { color: var(--brand); font-weight: 600; }
.auth-demo { margin-top: 1rem; font-size: .8rem; color: var(--muted); }
.auth-demo code { background: #f1f5f9; padding: .12rem .4rem; border-radius: 6px; font-family: var(--mono); }

.nf-code { font-size: 4rem; font-weight: 800; background: linear-gradient(135deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nf-card h1 { margin: .3rem 0 .6rem; }
.nf-card .btn-primary { margin-top: 1.4rem; display: inline-block; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dash { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.dash-side { background: linear-gradient(180deg, var(--bg), var(--bg-soft)); color: #fff; padding: 1.6rem 1.2rem; display: flex; flex-direction: column; }
.dash-side .brand { margin-bottom: 2rem; }
.dash-side .brand-name { background: linear-gradient(90deg, #fff, #c7d2fe); -webkit-background-clip: text; background-clip: text; color: transparent; }
.side-nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.side-nav a { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: 10px; color: #cbd5e1; font-weight: 500; font-size: .92rem; }
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.active { background: rgba(99,102,241,.18); color: #fff; }
.side-logout { color: #94a3b8; font-size: .9rem; padding: .6rem .8rem; border-radius: 10px; }
.side-logout:hover { background: rgba(239,68,68,.14); color: #fecaca; }

.dash-main { padding: 2rem clamp(1.2rem, 4vw, 2.6rem); background: #f1f5f9; }
.dash-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.6rem; }
.dash-top h1 { font-size: 1.6rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 1.2rem 1.3rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: .3rem; }
.stat .num { font-size: 1.8rem; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat.s-transit .num { color: var(--brand-3); }
.stat.s-route .num { color: var(--warn); }
.stat.s-deliver .num { color: var(--ok); }
.stat.s-pending .num { color: var(--warn); }

/* ---------- Previsao de e-mails (dinamica) ---------- */
.mail-pred-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.3rem 1.4rem; margin-bottom: 1.6rem; }
.mpc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.mpc-head h2 { font-size: 1.05rem; color: var(--ink); }
.mail-pred { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem; }
.mp-card { border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; display: flex; flex-direction: column; gap: .2rem; background: #fbfcfe; }
.mp-card .mp-num { font-size: 1.7rem; font-weight: 800; color: var(--ink); line-height: 1; font-variant-numeric: tabular-nums; }
.mp-card .mp-lbl { font-size: .78rem; font-weight: 600; color: var(--muted); }
.mp-card.mp-hi { background: #eef4ff; border-color: #cfe0ff; }
.mp-card.mp-hi .mp-num { color: #1d4ed8; }

/* ---------- Abas + e-mails + configuracoes ---------- */
.stats.stats-6 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat.s-fail .num { color: var(--danger); }
.btn-dark { border: 1px solid var(--line); background: #fff; color: var(--ink-soft); border-radius: 12px;
    padding: .6rem 1.1rem; font-weight: 600; font-size: .9rem; backdrop-filter: none; }
.btn-dark:hover { border-color: var(--brand); color: var(--brand); background: #fff; }

.worker-status { display: flex; align-items: center; gap: .7rem; padding: .85rem 1.1rem; border-radius: 12px;
    font-size: .9rem; font-weight: 500; margin-bottom: 1.4rem; }
.worker-status .ws-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.worker-status.ok { background: #e7f8ee; color: #15803d; } .worker-status.ok .ws-dot { background: #16a34a; }
.worker-status.warn { background: #fef3c7; color: #92560a; } .worker-status.warn .ws-dot { background: #f59e0b; }

.mail-st { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; }
.mail-st::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.mail-st.ok { background: #e7f8ee; color: #15803d; }
.mail-st.pend { background: #eef2ff; color: #4338ca; }
.mail-st.fail { background: #fef2f2; color: #b91c1c; }
.mail-report { max-width: 220px; font-size: .82rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cfg-card { padding: 1.4rem 1.5rem; margin-bottom: 1.4rem; }
.cfg-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.cfg-head h2 { font-size: 1.05rem; color: var(--ink); }
.cfg-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.cfg-form label { display: flex; flex-direction: column; gap: .35rem; font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.cfg-form .col-2 { grid-column: 1 / -1; }
.cfg-form input, .cfg-form select { border: 1px solid var(--line); border-radius: 10px; padding: .65rem .85rem; font: inherit; font-size: .92rem; color: var(--ink); background: #fff; }
.cfg-form input:focus, .cfg-form select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.cfg-actions { display: flex; justify-content: flex-end; }
.cfg-inline { display: flex; flex-direction: column; gap: .4rem; font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin: .4rem 0; }
.copy-field { display: flex; align-items: center; gap: .5rem; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; }
.copy-field code { flex: 1; font-family: var(--mono); font-size: .82rem; color: var(--ink); word-break: break-all; }
.cfg-worker-meta { margin-top: .8rem; font-size: .85rem; color: var(--ink-soft); }

/* ---------- SMTP ---------- */
.smtp-badge { font-size: .76rem; font-weight: 700; padding: .25rem .7rem; border-radius: 999px; }
.smtp-badge.on { background: #e7f8ee; color: #15803d; }
.smtp-badge.off { background: #fef3c7; color: #b45309; }
.smtp-cfg { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.smtp-cfg div { display: flex; flex-direction: column; gap: .15rem; }
.smtp-cfg span { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.smtp-cfg strong { font-size: .9rem; font-weight: 600; color: var(--ink); word-break: break-word; }
.smtp-test { display: flex; gap: .6rem; flex-wrap: wrap; }
.smtp-test input { flex: 1; min-width: 200px; border: 1px solid var(--line); border-radius: 10px; padding: .65rem .85rem; font: inherit; font-size: .92rem; }
.smtp-test input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.smtp-log { margin: 1rem 0 .6rem; padding: .9rem 1rem; border-radius: 10px; background: #0f172a; color: #cbd5e1;
    font-family: var(--mono); font-size: .78rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 280px; overflow: auto; }
.smtp-log.ok { box-shadow: inset 3px 0 0 #22c55e; }
.smtp-log.err { box-shadow: inset 3px 0 0 #ef4444; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.table-card { overflow: hidden; }
.table-tools { padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.table-tools input { width: min(340px, 100%); }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .9rem 1.2rem; border-bottom: 1px solid var(--line); }
.data-table td { padding: .9rem 1.2rem; border-bottom: 1px solid #f1f5f9; font-size: .92rem; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table .code-cell { font-family: var(--mono); font-weight: 500; }
.data-table .empty { text-align: center; color: var(--muted); padding: 2.5rem; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; }
.mini-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .35rem .7rem; font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.mini-btn:hover { border-color: var(--brand); color: var(--brand); }

.status-tag { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; font-weight: 600; }
.status-tag::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1.2rem;
         background: rgba(15,23,42,.55); backdrop-filter: blur(4px); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card { background: #fff; border-radius: 18px; width: min(560px, 96vw); box-shadow: var(--shadow); animation: rise .25s ease; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1.3rem 1.5rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.2rem; }
.modal-x { border: 0; background: transparent; font-size: 1.5rem; line-height: 1; color: var(--muted); }
.modal-x:hover { color: var(--ink); }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 1.5rem; }
.grid-form label small { font-weight: 400; color: var(--muted); }
.grid-form .col-2 { grid-column: 1 / -1; }
.modal-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: .7rem; margin-top: .4rem; }
.modal-actions .btn-ghost { border-color: var(--line); background: #fff; color: var(--ink-soft); }
.modal-actions .btn-ghost:hover { background: #f1f5f9; }

/* ---------- Drawer ---------- */
.drawer { position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.5); backdrop-filter: blur(3px); animation: fade .2s ease; }
.drawer-panel { position: absolute; right: 0; top: 0; height: 100%; width: min(480px, 96vw); background: #fff; box-shadow: -20px 0 60px -20px rgba(0,0,0,.4);
                padding: 1.6rem 1.6rem 2.4rem; overflow-y: auto; animation: slide .28s ease; }
@keyframes slide { from { transform: translateX(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-head h2 { font-family: var(--mono); font-size: 1.25rem; }
.drawer-meta { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin: 1.2rem 0 1.6rem; padding: 1.1rem; background: #f8fafc; border-radius: 12px; }
.drawer-meta div { display: flex; flex-direction: column; gap: .15rem; }
.drawer-meta span { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; }
.drawer-meta strong { font-size: .9rem; font-weight: 600; }
.drawer-tools { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.tool-btn { display: inline-flex; align-items: center; border: 1px solid var(--line); background: #fff;
    color: var(--ink-soft); border-radius: 10px; padding: .55rem .9rem; font-size: .86rem; font-weight: 600; }
.tool-btn:hover { border-color: var(--brand); color: var(--brand); }
.tool-btn.debug { border-style: dashed; border-color: #f59e0b; color: #b9700d; background: #fffbeb; }
.tool-btn.debug:hover { background: #fef3c7; }
.tool-btn:disabled { opacity: .55; cursor: default; }
.drawer-panel h3 { font-size: .95rem; margin: 1.4rem 0 .7rem; }
.event-form { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .5rem; }
.event-form select { grid-column: 1 / -1; }
.event-form .btn-primary { grid-column: 1 / -1; }
.drawer-danger { margin-top: 2rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }

/* ============================================================
   DOCS
   ============================================================ */
.docs { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.docs-side { position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
             background: linear-gradient(180deg, var(--bg), var(--bg-soft)); color: #fff; padding: 1.6rem 1.2rem; }
.docs-side .brand { margin-bottom: 1.6rem; }
.docs-side .brand-name { background: linear-gradient(90deg, #fff, #c7d2fe); -webkit-background-clip: text; background-clip: text; color: transparent; }
.docs-nav { display: flex; flex-direction: column; gap: .1rem; }
.docs-nav a { padding: .5rem .7rem; border-radius: 8px; color: #94a3b8; font-size: .88rem; }
.docs-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.docs-back { display: inline-block; margin-top: 1.6rem; color: #cbd5e1; font-size: .88rem; }

.docs-main { padding: 3rem clamp(1.4rem, 5vw, 4rem); max-width: 860px; }
.docs-main section { margin-bottom: 3rem; scroll-margin-top: 1.5rem; }
.kicker, .docs-main .kicker { color: var(--brand); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.docs-main h1 { font-size: 2.2rem; margin: .4rem 0 .8rem; letter-spacing: -.02em; }
.docs-main h2 { font-size: 1.4rem; margin-bottom: .8rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.docs-main h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1.2rem 0 .5rem; }
.docs-main p { color: var(--ink-soft); line-height: 1.6; }
.docs-main code { font-family: var(--mono); font-size: .88em; background: #eef2ff; color: #4338ca; padding: .12rem .4rem; border-radius: 6px; }
.base-url { display: flex; align-items: center; gap: .8rem; margin-top: 1.2rem; background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1.1rem; }
.base-url span { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.base-url code { background: transparent; color: var(--ink); padding: 0; font-size: .92rem; }
.copy { cursor: pointer; position: relative; }
.copy:hover { text-decoration: underline; }

pre.code { background: #0f172a; color: #e2e8f0; border-radius: 12px; padding: 1.1rem 1.2rem; overflow-x: auto; font-family: var(--mono); font-size: .85rem; line-height: 1.55; box-shadow: var(--shadow-sm); }
pre.code code { background: transparent; color: inherit; padding: 0; }

.ref-table, .ref-table th, .ref-table td { border-collapse: collapse; }
.ref-table { width: 100%; }
.ref-table th { text-align: left; font-size: .75rem; text-transform: uppercase; color: var(--muted); padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
.ref-table td { padding: .6rem .8rem; border-bottom: 1px solid #f1f5f9; font-size: .9rem; }

.endpoint .ep-line { display: flex; align-items: center; gap: .8rem; margin: .4rem 0 1rem; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; }
.endpoint .ep-line code { background: transparent; color: var(--ink); font-size: .95rem; }
.verb { font-family: var(--mono); font-size: .72rem; font-weight: 700; color: #fff; padding: .25rem .6rem; border-radius: 6px; letter-spacing: .03em; }
.m-get { background: #0ea5e9; } .m-post { background: #22c55e; } .m-patch { background: #f59e0b; } .m-del { background: #ef4444; }
.lock { font-size: .9rem; }
.docs-foot { color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); padding-top: 1.4rem; }

.toast { position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff;
         padding: .7rem 1.2rem; border-radius: 999px; font-size: .88rem; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .25s; z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 820px) {
    .dash, .docs { grid-template-columns: 1fr; }
    .dash-side { flex-direction: row; align-items: center; gap: 1rem; padding: 1rem 1.2rem; }
    .dash-side .brand { margin-bottom: 0; }
    .side-nav { flex-direction: row; overflow-x: auto; }
    .side-nav a span { display: none; }
    .docs-side { position: static; height: auto; }
    .docs-nav { flex-flow: row wrap; }
    .grid-form, .drawer-meta { grid-template-columns: 1fr; }
    .event-form { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
    .track-box { flex-direction: column; }
    .track-box button { padding: .85rem; }
    .dash-top { flex-direction: column; align-items: stretch; }
}

/* ============================================================
   RASTREIO PREMIUM (timeline profissional)
   ============================================================ */
.track {
    --line: #e8edf3;
    background: #fff; color: #0f1b2d; text-align: left;
    border-radius: 22px; overflow: hidden;
    box-shadow: 0 1px 0 rgba(15,23,42,.04), 0 30px 60px -28px rgba(8,20,40,.55);
    animation: trackIn .5s cubic-bezier(.16,.84,.44,1) both;
}
@keyframes trackIn { from { opacity: 0; transform: translateY(18px) scale(.99); } }

/* ---- Cabecalho ---- */
.track-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1.5rem 1.7rem; background: linear-gradient(180deg, #fbfdff, #f4f7fb);
    border-bottom: 1px solid var(--line);
}
.th-kicker { display: block; font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #8a98ab; }
.th-code { font-family: var(--mono); font-size: clamp(1.2rem, 3.6vw, 1.7rem); font-weight: 600; letter-spacing: .01em; margin-top: .25rem; color: #102a4c; }
.th-updated { display: inline-flex; align-items: center; gap: .4rem; margin-top: .55rem; font-size: .8rem; font-weight: 600; color: #6b7a8d; }
.th-updated svg { width: 14px; height: 14px; color: #15914a; }

/* Badge: cor derivada do estado via --bc (serve qualquer status, sem regra fixa) */
.badge {
    --bc: #64748b;
    display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap;
    padding: .5rem .9rem; border-radius: 999px; font-weight: 700; font-size: .82rem;
    background: color-mix(in srgb, var(--bc) 13%, #fff);
    color: color-mix(in srgb, var(--bc) 78%, #0b1220);
}
.badge-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bc);
    box-shadow: 0 0 0 0 var(--bc); animation: ping 2.4s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bc) 45%, transparent); }
    70%,100% { box-shadow: 0 0 0 7px transparent; } }

/* ---- Estado atual em destaque ---- */
.cur-status {
    display: flex; align-items: center; gap: 1rem; margin: 1.3rem 1.7rem 0;
    padding: 1rem 1.2rem; border-radius: 16px;
    background: color-mix(in srgb, var(--c) 9%, #fff);
    border: 1px solid color-mix(in srgb, var(--c) 22%, #fff);
    animation: curIn .5s cubic-bezier(.16,.84,.44,1) both .1s;
}
@keyframes curIn { from { opacity: 0; transform: translateY(10px); } }
.cur-ic { flex: none; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
    color: #fff; background: linear-gradient(135deg, color-mix(in srgb, var(--c) 80%, #fff), var(--c));
    box-shadow: 0 10px 22px -10px var(--c); animation: floaty 3.2s ease-in-out infinite; }
.cur-ic svg { width: 26px; height: 26px; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.cur-text strong { display: block; font-size: 1.05rem; color: #15243a; }
.cur-text p { margin: .2rem 0 0; font-size: .9rem; color: #5b6b80; line-height: 1.45; }

/* ---- Barra de progresso + stepper ---- */
.progress { padding: 1.6rem 1.7rem .4rem; }
.progress-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .6rem; }
.progress-top strong { font-size: 1rem; color: #0f1b2d; }
.progress-eta { font-size: .85rem; font-weight: 600; color: #5b6b80; }
.progress-track { height: 9px; border-radius: 999px; background: #eef2f7; overflow: hidden; }
.progress-fill {
    position: relative; display: block; height: 100%; width: var(--pct); border-radius: 999px; overflow: hidden;
    background: linear-gradient(90deg, color-mix(in srgb, var(--c) 70%, #2563eb), var(--c));
    box-shadow: 0 0 12px -2px var(--c);
    animation: fillBar 1.1s cubic-bezier(.4,0,.15,1) both .15s;
}
@keyframes fillBar { from { width: 0; } }

.stepper { list-style: none; display: flex; margin: 1.6rem 0 .4rem; padding: 0; }
.step { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.step::before { /* linha de ligacao com a etapa anterior */
    content: ''; position: absolute; top: 22px; right: 50%; width: 100%; height: 3px;
    background: var(--line); z-index: 0; border-radius: 2px;
}
.step:first-child::before { display: none; }
.step-ic { position: relative; z-index: 1; width: 46px; height: 46px; border-radius: 50%;
    display: grid; place-items: center; background: #eef2f7; color: #9aa7b8;
    border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); transition: .3s; }
.step-ic svg { width: 21px; height: 21px; }
.step-lbl { font-size: .76rem; font-weight: 600; color: #93a1b2; text-align: center; max-width: 9ch; line-height: 1.2; }

.step.is-done .step-ic   { background: #e7f8ee; color: #15914a; box-shadow: 0 0 0 1px #bdeccd; }
.step.is-done::before    { background: #2bbd6a; }
/* etapa atual: usa a cor do estado (--ac). 'alert' = tentativas/devolucao */
.step.is-active .step-ic, .step.is-alert .step-ic {
    background: linear-gradient(135deg, color-mix(in srgb, var(--ac) 78%, #fff), var(--ac)); color: #fff;
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--ac) 18%, transparent); animation: stepPulse 2.2s infinite; }
.step.is-active .step-lbl, .step.is-alert .step-lbl { color: var(--ac); }
.step.is-active::before, .step.is-alert::before { background: linear-gradient(90deg, #2bbd6a, var(--ac)); }
.step.is-alert .step-ic { animation: stepPulse 2.2s infinite, stepShake 4s ease-in-out infinite; }
@keyframes stepPulse { 0%,100% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--ac) 18%, transparent); }
    50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--ac) 5%, transparent); } }
@keyframes stepShake { 0%,92%,100% { transform: translateX(0); } 94% { transform: translateX(-2px); } 96% { transform: translateX(2px); } 98% { transform: translateX(-1px); } }

/* ---- Dados recebidos (topo) ---- */
.track-data {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
    background: var(--line); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: 1.2rem;
}
.track-data.cols-2 { grid-template-columns: repeat(2, 1fr); }
.data-col { background: #fff; padding: 1.3rem 1.5rem; }
.data-col h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: #2563eb; margin-bottom: .85rem; font-weight: 700; }
.data-col dl { margin: 0; display: grid; gap: .7rem; }
.data-col dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: #94a1b3; font-weight: 600; }
.data-col dd { margin: .1rem 0 0; font-size: .92rem; font-weight: 600; color: #1d2c42; word-break: break-word; }

/* ---- Historico (timeline) ---- */
.track-history { padding: 1.6rem 1.7rem 2rem; }
.track-history h3 { font-size: 1rem; margin-bottom: 1.3rem; color: #0f1b2d; }
.ptimeline { list-style: none; margin: 0; padding: 0; }
.pt-item { position: relative; padding: 0 0 1.7rem 3.1rem; animation: ptRise .5s ease both; animation-delay: calc(min(var(--i), 14) * .045s); }
@keyframes ptRise { from { opacity: 0; transform: translateY(10px); } }
.pt-item::before { content: ''; position: absolute; left: 17px; top: 42px; bottom: -.4rem; width: 2px; background: var(--line); }
.pt-item:last-child { padding-bottom: 0; }
.pt-item:last-child::before { display: none; }
.pt-node { position: absolute; left: 0; top: 0; width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center; background: #fff; color: var(--c);
    border: 2px solid color-mix(in srgb, var(--c) 38%, #fff);
    box-shadow: 0 5px 12px -5px color-mix(in srgb, var(--c) 55%, transparent); }
.pt-node svg { width: 18px; height: 18px; }
.pt-item.is-current .pt-node { border-color: var(--c);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 14%, transparent); animation: nodePulse 2s infinite; }
@keyframes nodePulse { 0%,100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 16%, transparent); }
    50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--c) 5%, transparent); } }
.pt-row { display: flex; justify-content: space-between; align-items: baseline; gap: .8rem; flex-wrap: wrap; padding-top: .35rem; }
.pt-status { font-weight: 700; font-size: .96rem; color: #16243a; }
.pt-item.is-current .pt-status { color: var(--c); }
.pt-time { font-size: .8rem; color: #97a4b6; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pt-desc { margin: .3rem 0 0; font-size: .89rem; color: #5a6b80; line-height: 1.45; }
.pt-loc { display: inline-flex; align-items: center; gap: .35rem; margin-top: .45rem; font-size: .82rem; font-weight: 600; color: #2563eb; }
.pt-loc svg { width: 14px; height: 14px; }

/* brilho sutil que percorre a barra de progresso */
.progress-fill::after { content: ''; position: absolute; inset: 0; border-radius: 999px;
    background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.45) 50%, transparent 80%);
    background-size: 200% 100%; animation: shimmer 2.6s linear infinite 1.2s; }
.progress-track { position: relative; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (max-width: 680px) {
    .track-data { grid-template-columns: 1fr; }
    .cur-status { margin-left: 1.1rem; margin-right: 1.1rem; gap: .8rem; padding: .9rem 1rem; }
    .cur-ic { width: 46px; height: 46px; }
    .step-lbl { font-size: .64rem; max-width: 7ch; }
    .step-ic { width: 38px; height: 38px; }
    .step-ic svg { width: 18px; height: 18px; }
    .step::before { top: 18px; }
    .track-head, .progress, .track-history { padding-left: 1.1rem; padding-right: 1.1rem; }
    .data-col { padding: 1.1rem 1.2rem; }
}
@media (max-width: 420px) {
    .stepper { overflow-x: auto; padding-bottom: .4rem; }
    .step { min-width: 64px; }
}

/* ===== Estados temporais dos eventos (verde/amarelo/cinza) ===== */
.pt-item.is-past .pt-node    { color: #16a34a; border-color: #16a34a; box-shadow: 0 4px 10px -5px rgba(22,163,74,.5); }
.pt-item.is-future           { opacity: .55; }
.pt-item.is-future .pt-node  { color: #cbd5e1; border-color: #cbd5e1; box-shadow: none; }
.pt-item.is-current .pt-node { color: #f59e0b; border-color: #f59e0b; animation: curPulse 1.6s infinite; }
@keyframes curPulse { 0%,100% { box-shadow: 0 0 0 4px rgba(245,158,11,.18); } 50% { box-shadow: 0 0 0 9px rgba(245,158,11,.04); } }
.pt-item.is-current .pt-body  { background: #fffaf0; border-radius: 10px; padding: .55rem .75rem; }
.pt-item.t-atraso .pt-body    { background: #fff5f5; border-radius: 10px; padding: .55rem .75rem; }
.pt-item.t-resolucao .pt-body { background: #f5fff5; border-radius: 10px; padding: .55rem .75rem; }

/* ===== Comprovante de entrega ===== */
.proof { padding: 1.6rem 1.7rem 2rem; border-top: 1px solid var(--line); }
/* comprovante em destaque no topo do cartao */
.proof-top { border-top: 0; margin: 1.2rem 1.7rem 0; padding: 1.1rem 1.3rem; border-radius: 14px;
    background: #f0fdf6; border: 1px solid #bbf2cf; }
.proof-top .proof-meta { margin: .2rem 0 1rem; }
.proof-title { font-size: 1.05rem; margin-bottom: 1.1rem; }
.proof-photo { margin: 0 0 1.1rem; }
.proof-photo img { width: 100%; max-width: 460px; display: block; margin: 0 auto; border-radius: 12px;
    box-shadow: 0 10px 24px -12px rgba(0,0,0,.45); }

/* Comprovante: imagem do formulario + campos preenchidos sobrepostos */
.rc { position: relative; width: 100%; max-width: 520px; margin: 0 auto; container-type: inline-size; }
.rc img { width: 100%; display: block; border-radius: 12px; box-shadow: 0 10px 24px -12px rgba(0,0,0,.45); }
.rc-f { position: absolute; transform: translateY(-50%); transform-origin: left center;
    font-family: 'Caveat', cursive; font-weight: 600; color: #15356b; white-space: nowrap;
    letter-spacing: .2px; line-height: 1; pointer-events: none; }

.proof-meta { display: flex; gap: 1.6rem; justify-content: center; flex-wrap: wrap; margin: 1.3rem 0; }
.proof-meta div { display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.proof-meta span { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.proof-meta strong { font-size: .92rem; font-family: var(--mono); color: var(--ink); }
.proof-ok { color: #16a34a !important; font-family: var(--font) !important; font-weight: 800; letter-spacing: .03em; }
.proof-btn { display: flex; align-items: center; gap: .5rem; margin: 0 auto; border: 1px solid var(--line);
    background: #fff; color: #1d4ed8; font-weight: 700; font-size: .9rem; padding: .8rem 1.4rem; border-radius: 12px; }
.proof-btn:hover { background: #f1f5f9; border-color: #c7d2fe; }
.proof-btn svg { width: 18px; height: 18px; }

/* ===== Modal: comprovante ampliado ===== */
.sig-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 1.2rem;
    background: rgba(15,23,42,.6); backdrop-filter: blur(4px); animation: fade .2s ease; }
.sig-card { position: relative; background: #fff; border-radius: 16px; width: min(680px, 96vw);
    padding: 1.6rem; box-shadow: var(--shadow); animation: rise .25s ease; }
.sig-card .modal-x { position: absolute; right: 1rem; top: .7rem; border: 0; background: transparent;
    font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; }
.sig-card .modal-x:hover { color: var(--ink); }
.rc-big { max-width: 100%; }
.pv-panel h3 { font-size: 1.05rem; text-align: center; margin: .3rem 0 1.2rem; }
.pv-opts { display: grid; gap: .8rem; }
.pv-opt { display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left;
    border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 1rem 1.1rem;
    font-size: .98rem; font-weight: 600; color: var(--ink); cursor: pointer; transition: .15s; }
.pv-opt:hover { border-color: var(--brand); color: var(--brand); background: #f7f8ff; }
.pv-opt svg { width: 24px; height: 24px; flex: none; }
.pv-back { border: 0; background: transparent; color: var(--brand); font-weight: 700; font-size: .9rem;
    cursor: pointer; padding: .2rem 0; margin-bottom: .8rem; }
