:root {
    --ink: #eef6ff;
    --muted: #96a9bb;
    --line: rgba(151, 176, 199, .2);
    --soft: #121a24;
    --panel: rgba(16, 24, 35, .92);
    --blue: #4aa3ff;
    --teal: #22d3bd;
    --amber: #f1b94f;
    --red: #ff6975;
    --green: #51d88a;
    --shadow: 0 24px 70px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
    background:
        radial-gradient(circle at 15% 10%, rgba(34, 211, 189, .18), transparent 34%),
        radial-gradient(circle at 90% 0%, rgba(74, 163, 255, .16), transparent 34%),
        linear-gradient(180deg, #07101a 0, #0b121b 460px, #080d14 100%);
    color: var(--ink);
}

a { color: inherit; text-decoration: none; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px clamp(18px, 4vw, 52px);
    background: rgba(7, 16, 26, .82);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 280px; }
.brand-logo {
    display: grid;
    place-items: center;
    width: 92px;
    height: 44px;
}
.brand-logo img { max-width: 92px; max-height: 36px; object-fit: contain; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    color: #fff;
    font-weight: 800;
    background: linear-gradient(135deg, #0c73d8, #0c9a8a);
    box-shadow: 0 10px 28px rgba(12, 115, 216, .24);
}
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: 12px; margin-top: 2px; }

.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.nav a {
    padding: 10px 12px;
    color: #c7d6e6;
    font-size: 14px;
    font-weight: 700;
    border-radius: 8px;
}
.nav a:hover, .pill-link { background: rgba(74, 163, 255, .13); color: #dff0ff; }
.notif-badge {
    display: none;
    min-width: 20px;
    height: 20px;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
}
.notif-badge.active { display: inline-block; }
.nav-toggle { display: none; border: 0; background: rgba(74, 163, 255, .13); color: var(--ink); border-radius: 8px; padding: 10px 13px; font-size: 20px; }

.shell { width: min(1180px, calc(100% - 32px)); margin: 30px auto 56px; }
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
    gap: 28px;
    align-items: stretch;
    margin-bottom: 26px;
}
.hero-copy {
    padding: clamp(28px, 5vw, 56px);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(16, 24, 35, .98), rgba(7, 16, 26, .96));
    color: #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
}
.hero-copy:after {
    content: "";
    position: absolute;
    inset: auto -20% -50% 30%;
    height: 250px;
    background: radial-gradient(circle, rgba(12, 154, 138, .36), transparent 64%);
    pointer-events: none;
}
.eyebrow { color: #78d8ca; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
h1 { margin: 10px 0 12px; font-size: clamp(32px, 5vw, 58px); line-height: 1.02; letter-spacing: 0; }
h2 { margin: 0 0 18px; font-size: 24px; letter-spacing: 0; }
h3 { margin: 0 0 8px; font-size: 16px; }
p { color: var(--muted); line-height: 1.6; }
.hero-copy p { color: #c8d8e5; max-width: 760px; }

.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 28px; position: relative; z-index: 1; }
.metric, .panel, .flight-card, .form-panel, .login-box {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 12px 36px rgba(19, 32, 43, .07);
}
.metric { padding: 18px; background: rgba(255, 255, 255, .08); border-color: rgba(255,255,255,.14); color: #fff; }
.metric strong { display: block; font-size: 30px; }
.metric span { color: #c8d8e5; font-size: 13px; }

.panel, .form-panel, .login-box { padding: 22px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid.two { grid-template-columns: repeat(2, 1fr); }
.stack { display: grid; gap: 16px; }

.filters, .actions-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin: 0 0 18px; }
.filters .field { min-width: 170px; flex: 1; }
.table-actions { display: flex; gap: 10px; align-items: center; flex-wrap: nowrap; margin: 0; white-space: nowrap; }
.table-actions form { margin: 0; display: inline-flex; }

.field label { display: block; margin: 0 0 7px; color: #cfdeed; font-weight: 800; font-size: 13px; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 13px;
    font: inherit;
    color: var(--ink);
    background: rgba(6, 13, 22, .86);
    outline-color: #94c8f5;
}
textarea { min-height: 110px; resize: vertical; }
input[type="checkbox"] { width: auto; min-width: 22px; min-height: 22px; accent-color: var(--blue); }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    padding: 11px 16px;
    background: var(--blue);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}
.btn.secondary { background: rgba(74, 163, 255, .14); color: #cbe6ff; }
.btn.danger { background: var(--red); }
.btn.small { min-height: 34px; padding: 8px 11px; font-size: 13px; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: rgba(8, 14, 22, .7); }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: #b7cadc; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; background: rgba(255,255,255,.04); }
td { color: #e7f1fb; font-size: 14px; }
tr:last-child td { border-bottom: 0; }

.status, .phase {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.status.pending { background: #fff5dc; color: var(--amber); }
.status.confirmed { background: #e8f7ee; color: var(--green); }
.status.scheduled { background: #eaf3fc; color: var(--blue); }
.status.cancelled { background: #fdecee; color: var(--red); }
.phase { background: rgba(255,255,255,.08); color: #d8e8f7; }
.phase.andamento { background: #eaf3fc; color: var(--blue); }
.phase.retorno { background: #fff5dc; color: var(--amber); }
.phase.finalizado { background: #e8f7ee; color: var(--green); }

.flight-card { padding: 18px; display: grid; gap: 12px; }
.flight-card .route { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 900; font-size: 22px; }
.flight-card .meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px 14px; }
.flight-card .line { height: 4px; background: linear-gradient(90deg, var(--blue), var(--teal)); border-radius: 999px; }

#map, .map { height: 360px; border-radius: 8px; border: 1px solid var(--line); overflow: hidden; }
.leaflet-container { z-index: 1; }
.leaflet-top, .leaflet-bottom { z-index: 2; }
.login-page { min-height: calc(100vh - 76px); display: grid; place-items: center; padding: 24px; }
.login-box { width: min(430px, 100%); }
.flash { width: min(1180px, calc(100% - 32px)); margin: 18px auto 0; padding: 14px 16px; border-radius: 8px; font-weight: 700; }
.flash.success { background: #e8f7ee; color: var(--green); }
.flash.error { background: #fdecee; color: var(--red); }
.empty-state { text-align: center; padding: 42px 18px; border: 1px dashed var(--line); border-radius: 8px; background: rgba(255,255,255,.04); }
.pagination { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.pagination a { padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-weight: 800; }
.pagination a.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.chart-box { height: 310px; }
.metric-card strong { display: block; font-size: 42px; color: var(--blue); margin-top: 8px; }
.report-hero { background: linear-gradient(135deg, rgba(74,163,255,.18), rgba(34,211,189,.12)); }
.rab-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rab-item { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.04); }
.rab-item strong { display: block; color: #fff; margin-bottom: 4px; }
.attachment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.attachment-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.chat-box { display: grid; gap: 12px; max-height: 420px; overflow-y: auto; padding-right: 6px; }
.chat-message { width: min(720px, 92%); padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.04); }
.chat-message.mine { justify-self: end; background: rgba(74, 163, 255, .13); }
.chat-message strong { display: block; color: #fff; margin-bottom: 6px; }
.chat-message strong span { color: var(--muted); font-size: 12px; font-weight: 600; }
.chat-message p { margin: 0; color: #dbe9f6; }
.chat-image { display: block; margin-top: 10px; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.chat-image img { max-width: 180px; max-height: 140px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; }
.image-modal { position: fixed; inset: 0; z-index: 1300; display: none; place-items: center; padding: 24px; background: rgba(0,0,0,.82); }
.image-modal.open { display: grid; }
.image-modal img { max-width: min(100%, 980px); max-height: 82vh; border-radius: 8px; box-shadow: var(--shadow); }
.image-modal button { position: fixed; top: 18px; right: 18px; border: 0; border-radius: 8px; padding: 11px 14px; background: var(--blue); color: #fff; font-weight: 800; cursor: pointer; }
.chat-toggle {
    position: fixed;
    right: 18px;
    bottom: 22px;
    z-index: 1100;
    border: 0;
    border-radius: 999px;
    padding: 13px 18px;
    background: var(--blue);
    color: #fff;
    font-weight: 900;
    box-shadow: var(--shadow);
    cursor: pointer;
}
.active-flight-widget {
    position: fixed;
    right: 18px;
    bottom: 78px;
    z-index: 1100;
}
.active-flight-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    padding: 11px 15px;
    background: var(--teal);
    color: #06231f;
    font-weight: 900;
    box-shadow: var(--shadow);
    cursor: pointer;
}
.active-flight-list {
    position: absolute;
    right: 0;
    bottom: 52px;
    display: none;
    width: min(340px, calc(100vw - 28px));
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(8, 14, 22, .98);
    box-shadow: var(--shadow);
}
.active-flight-list.open { display: grid; gap: 8px; }
.active-flight-list a { display: grid; gap: 3px; padding: 10px; border-radius: 8px; background: rgba(255,255,255,.05); }
.active-flight-list strong { color: #fff; }
.active-flight-list span { color: var(--muted); font-size: 13px; }
.chat-drawer {
    position: fixed;
    top: 86px;
    right: 18px;
    bottom: 82px;
    z-index: 1099;
    width: min(420px, calc(100vw - 28px));
    display: none;
    grid-template-rows: auto 1fr auto;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(8, 14, 22, .98);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
.chat-drawer.open { display: grid; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.chat-header strong, .chat-header span { display: block; }
.chat-header span { color: var(--muted); font-size: 13px; margin-top: 2px; }
.chat-drawer .chat-box { max-height: none; }
.chat-drawer textarea { min-height: 82px; }
.muted { color: var(--muted); }

@media (max-width: 900px) {
    .hero, .grid, .grid.two { grid-template-columns: 1fr; }
    .nav-toggle { display: inline-flex; }
    .nav {
        display: none;
        position: absolute;
        left: 16px;
        right: 16px;
        top: 72px;
        z-index: 1001;
        padding: 12px;
        background: #101823;
        border: 1px solid var(--line);
        border-radius: 8px;
        box-shadow: var(--shadow);
        justify-content: stretch;
    }
    .nav.open { display: grid; }
    .nav a { width: 100%; }
    .metrics { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .topbar { padding: 12px 16px; }
    .brand small { display: none; }
    .hero-copy { padding: 26px; }
    h1 { font-size: 34px; }
    .filters .field { min-width: 100%; }
}

@media print {
    body { background: #fff; color: #111; }
    .topbar, .nav, .btn, .flash { display: none !important; }
    .shell { width: 100%; margin: 0; }
    .panel, .form-panel, .flight-card { box-shadow: none; background: #fff; color: #111; border-color: #ccc; }
    p, td, th, h1, h2, h3 { color: #111 !important; }
}
