/* ============================================================
   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; }
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); }

/* ============================================================
   HERO / Landing
   ============================================================ */
.hero { position: relative; min-height: 100vh; display: flex; flex-direction: column; overflow: hidden;
        background: radial-gradient(1200px 600px at 70% -10%, #1e293b, var(--bg)); color: #fff; }
.hero-bg, .auth-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; }
.orb-1 { width: 520px; height: 520px; background: var(--brand); top: -160px; left: -120px; }
.orb-2 { width: 460px; height: 460px; background: var(--brand-3); bottom: -180px; right: -120px; opacity: .45; }
.orb-3 { width: 360px; height: 360px; background: var(--brand-2); top: 30%; right: 20%; opacity: .35; }

.topbar { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between;
          padding: 1.4rem clamp(1.2rem, 5vw, 4rem); }
.topnav { display: flex; align-items: center; gap: 1.4rem; }
.topnav > a:first-child { font-weight: 600; opacity: .85; }
.topnav > a:first-child:hover { opacity: 1; }

.hero-center { position: relative; z-index: 2; flex: 1; display: flex; flex-direction: column; align-items: center;
               justify-content: center; text-align: center; padding: 2rem 1.2rem 4rem; }
.hero-title { font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 800; letter-spacing: -.03em; max-width: 16ch;
              background: linear-gradient(180deg, #fff, #cbd5e1); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: #cbd5e1; font-size: 1.05rem; margin: 1rem 0 2.2rem; }

.track-box { display: flex; gap: .5rem; width: min(620px, 92vw); background: rgba(255,255,255,.08);
             border: 1px solid rgba(255,255,255,.16); padding: .5rem; border-radius: 18px; backdrop-filter: blur(14px);
             box-shadow: 0 30px 70px -30px rgba(0,0,0,.7); }
.track-box input { flex: 1; border: 0; background: transparent; color: #fff; font-size: 1.05rem; padding: .85rem 1rem;
                   outline: none; letter-spacing: .02em; }
.track-box input::placeholder { color: #8ea0bd; }
.track-box button { border: 0; border-radius: 13px; padding: 0 1.6rem; font-weight: 700; color: #fff; font-size: 1rem;
                    background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: inline-flex; align-items: center; gap: .5rem; }
.track-box button:hover { filter: brightness(1.07); }
.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-hint { margin-top: 1.2rem; color: #94a3b8; font-size: .9rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; justify-content: center; }
.chip { border: 1px dashed rgba(255,255,255,.25); background: transparent; color: #cbd5e1; border-radius: 999px;
        padding: .25rem .7rem; font-family: var(--mono); font-size: .82rem; }
.chip:hover { background: rgba(255,255,255,.08); color: #fff; }

.hero-foot { position: relative; z-index: 2; text-align: center; padding: 1.4rem; color: #64748b; font-size: .85rem; }

/* ---------- Resultado do rastreio ---------- */
.result { width: min(680px, 94vw); margin-top: 2.4rem; }
.result-card { background: var(--surface); color: var(--ink); border-radius: var(--radius); padding: 1.6rem;
               box-shadow: var(--shadow); text-align: left; animation: rise .35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.result-label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.result-code { font-family: var(--mono); font-size: 1.3rem; margin-top: .15rem; }
.status-pill { display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .8rem; border-radius: 999px;
               font-weight: 600; font-size: .82rem; color: #fff; white-space: nowrap; }
.status-pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .9; }
.result-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .9rem 1.2rem;
               margin: 1.4rem 0; padding: 1.2rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.result-meta > div { display: flex; flex-direction: column; gap: .15rem; }
.result-meta span { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.result-meta strong { font-weight: 600; font-size: .95rem; }

/* ---------- 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-deliver .num { color: var(--ok); }
.stat.s-pending .num { color: var(--warn); }

.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); }
.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-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; }
}
