:root {
    --bg: #070a10;
    --bg-2: #0b0f17;
    --card: rgba(18, 24, 36, 0.88);
    --card-solid: #121824;
    --card-border: rgba(148, 163, 184, 0.16);
    --card-border-strong: rgba(148, 163, 184, 0.24);
    --text: #f5f7fb;
    --muted: #9aa5b5;
    --muted-2: #707b8d;
    --accent: #8b7cff;
    --accent-2: #5ee7d0;
    --accent-soft: rgba(139, 124, 255, 0.12);
    --green: #39d98a;
    --green-bg: rgba(57, 217, 138, 0.11);
    --green-border: rgba(57, 217, 138, 0.30);
    --red: #ff7474;
    --red-bg: rgba(255, 116, 116, 0.11);
    --red-border: rgba(255, 116, 116, 0.30);
    --orange: #ffae66;
    --orange-bg: rgba(255, 174, 102, 0.11);
    --orange-border: rgba(255, 174, 102, 0.30);
    --gray-bg: rgba(156, 163, 175, 0.10);
    --gray-border: rgba(156, 163, 175, 0.22);
    --blue-bg: rgba(96, 165, 250, 0.10);
    --blue-border: rgba(96, 165, 250, 0.25);
    --blue-text: #9bc7ff;
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 5%, rgba(139, 124, 255, 0.10), transparent 28rem),
        radial-gradient(circle at 90% 12%, rgba(94, 231, 208, 0.07), transparent 26rem),
        linear-gradient(180deg, var(--bg) 0%, #080c13 45%, var(--bg-2) 100%);
    color: var(--text);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
}

button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.ambient {
    position: fixed;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    filter: blur(90px);
    pointer-events: none;
    opacity: .22;
    z-index: -1;
}
.ambient-one { background: #635bff; top: 5%; left: -220px; }
.ambient-two { background: #2dd4bf; top: 55%; right: -260px; }

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 30px 0 50px;
}

/* ---------- Hero ---------- */
.app-header {
    position: relative;
    overflow: hidden;
    padding: 28px 30px 32px;
    border: 1px solid var(--card-border);
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(18,24,36,.94), rgba(12,17,27,.82));
    box-shadow: var(--shadow);
}

.app-header::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, rgba(139,124,255,.08), transparent 45%, rgba(94,231,208,.05));
    pointer-events: none;
}

.top-brand-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--accent), #6157e8);
    box-shadow: 0 8px 28px rgba(99, 91, 255, .28);
    font-size: 20px;
}

.eyebrow {
    color: #a9b1c0;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.7px;
}

.brand-name { font-weight: 700; font-size: 14px; margin-top: 1px; }

.live-pill, .secure-chip, .data-source-chip {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 11px;
    border: 1px solid rgba(57,217,138,.22);
    border-radius: 999px;
    color: #9ee9bf;
    background: rgba(57,217,138,.07);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 4px rgba(57,217,138,.10);
}

.hero-grid {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
    align-items: center;
    gap: 35px;
}

.hero-copy { max-width: 680px; }
.hero-kicker {
    display: inline-flex;
    align-items: center;
    padding: 7px 11px;
    border-radius: 999px;
    border: 1px solid rgba(139,124,255,.22);
    background: rgba(139,124,255,.08);
    color: #bdb6ff;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 13px;
}

.main-title {
    margin: 0;
    font-size: clamp(34px, 4vw, 52px);
    line-height: 1.04;
    letter-spacing: -1.8px;
    font-weight: 850;
    background: linear-gradient(100deg, #fff, #cdd3ff 55%, #9ef0df);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    color: #9ea9ba;
    font-size: 16px;
    max-width: 650px;
    margin: 16px 0 18px;
    line-height: 1.65;
}

.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hero-chips span {
    padding: 7px 10px;
    border-radius: 8px;
    color: #b8c1d0;
    background: rgba(255,255,255,.035);
    border: 1px solid rgba(255,255,255,.07);
    font-size: 11px;
    font-weight: 650;
}

/* Built-in illustration */
.hero-art {
    position: relative;
    min-height: 250px;
    display: grid;
    place-items: center;
}
.art-glow {
    position: absolute;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139,124,255,.28), transparent 68%);
}
.art-ring { position: absolute; border: 1px solid rgba(139,124,255,.15); border-radius: 50%; }
.ring-one { width: 230px; height: 230px; }
.ring-two { width: 175px; height: 175px; border-color: rgba(94,231,208,.13); }

.robot-card {
    position: relative;
    width: 205px;
    min-height: 215px;
    padding: 12px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 20px;
    background: linear-gradient(160deg, rgba(28,35,52,.96), rgba(12,17,27,.94));
    box-shadow: 0 22px 50px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.06);
    transform: rotate(2deg);
}
.robot-topbar { display: flex; gap: 5px; }
.robot-topbar span { width: 6px; height: 6px; border-radius: 50%; background: #4b5563; }
.robot-face { display: grid; place-items: center; padding: 15px 0 10px; }
.robot-antenna { width: 2px; height: 15px; background: #8b7cff; margin-bottom: -1px; }
.robot-head {
    width: 86px; height: 70px; border-radius: 24px;
    background: linear-gradient(145deg, #9a8fff, #5f56e8);
    display: flex; align-items: center; justify-content: center; gap: 18px;
    position: relative;
    box-shadow: 0 12px 28px rgba(99,91,255,.25);
}
.robot-eye { width: 9px; height: 13px; border-radius: 6px; background: #0b1020; }
.robot-mouth { position: absolute; bottom: 13px; width: 22px; height: 7px; border-bottom: 2px solid #0b1020; border-radius: 0 0 20px 20px; }
.signal-card {
    padding: 7px 9px; margin-top: 6px; border-radius: 8px;
    background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.07);
    font-size: 9px; color: #cbd5e1;
}
.signal-one { transform: translateX(-22px); }
.signal-two { transform: translateX(18px); }
.signal-three { transform: translateX(-6px); }

/* ---------- Navigation ---------- */
.tabs {
    display: flex;
    gap: 6px;
    margin: 20px 0 25px;
    padding: 6px;
    border: 1px solid var(--card-border);
    border-radius: 14px;
    background: rgba(12,17,27,.75);
    width: fit-content;
}
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: transparent;
    border: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    padding: 10px 16px;
    border-radius: 9px;
    cursor: pointer;
    transition: .2s ease;
}
.tab-btn:hover { color: var(--text); background: rgba(255,255,255,.04); }
.tab-btn.active { color: #fff; background: linear-gradient(135deg, rgba(139,124,255,.24), rgba(99,91,255,.13)); box-shadow: inset 0 0 0 1px rgba(139,124,255,.18); }
.tab-panel { display: none; animation: panelIn .28s ease both; }
.tab-panel.active { display: block; }
@keyframes panelIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Section headers ---------- */
.section-heading-row, .page-section-header {
    display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 13px;
}
.section-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px;
    color: #aeb8c8; margin: 25px 0 10px;
}
.section-title-large { font-size: 17px; color: #e5e9f0; margin: 0; letter-spacing: .3px; }
.section-subtitle { color: var(--muted-2); font-size: 12px; margin: 5px 0 0; }
.meta-caption { color: var(--muted-2); font-size: 12px; margin: -3px 0 14px; }

/* ---------- Cards / form ---------- */
.card {
    position: relative;
    padding: 24px;
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(19,25,38,.94), rgba(14,19,29,.90));
    border: 1px solid var(--card-border);
    box-shadow: 0 14px 40px rgba(0,0,0,.16);
    margin-bottom: 9px;
    overflow: hidden;
}
.input-card { max-width: 900px; margin-left: auto; margin-right: auto; }
.card-accent { position: absolute; top: 0; left: 24px; right: 24px; height: 1px; background: linear-gradient(90deg, transparent, rgba(139,124,255,.7), transparent); }
.input-card-intro { display: flex; gap: 12px; align-items: center; margin-bottom: 21px; }
.input-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--accent-soft); border: 1px solid rgba(139,124,255,.22); color: #bdb6ff; }
.input-card-intro strong { display: block; font-size: 14px; }
.input-card-intro span { display: block; color: var(--muted-2); font-size: 11px; margin-top: 2px; }

.result-box {
    padding: 20px 22px;
    border-radius: 15px;
    background: rgba(17,23,34,.88);
    border: 1px solid var(--card-border);
    line-height: 1.7;
    margin-bottom: 9px;
    white-space: pre-wrap;
    box-shadow: 0 10px 30px rgba(0,0,0,.10);
}

.example-expander {
    border: 1px solid var(--card-border); border-radius: 14px; background: rgba(17,23,34,.62);
    margin-bottom: 15px; padding: 0 14px;
}
.example-expander summary { cursor: pointer; padding: 12px 0; font-size: 12px; color: #c7cfdb; font-weight: 650; list-style: none; }
.example-expander summary::-webkit-details-marker { display: none; }
.example-expander summary::before { content: "›"; display: inline-block; margin-right: 8px; transition: transform .15s ease; color: var(--accent); }
.example-expander[open] summary::before { transform: rotate(90deg); }
.example-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 0 13px; }

.field-label { display: block; font-size: 12px; font-weight: 700; color: #cbd5e1; margin: 17px 0 7px; }
.card > .field-label:first-of-type { margin-top: 0; }
input[type="text"], input[type="email"], textarea, .history-filters select {
    width: 100%; background: rgba(6,10,17,.72); border: 1px solid rgba(148,163,184,.17); border-radius: 10px;
    color: var(--text); padding: 12px 13px; font-size: 13px; font-family: inherit; resize: vertical; transition: .18s ease;
}
input:focus, textarea:focus, .history-filters select:focus { outline: none; border-color: rgba(139,124,255,.65); box-shadow: 0 0 0 3px rgba(139,124,255,.09); }
input::placeholder, textarea::placeholder { color: #596579; }
input:disabled, textarea:disabled { opacity: .72; cursor: not-allowed; }
.field-helper { display: flex; align-items: center; gap: 5px; color: #6f7b8c; font-size: 10px; margin-top: 7px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border-radius: 10px; padding: 11px 17px; font-size: 12.5px; font-weight: 750; cursor: pointer;
    border: 1px solid var(--card-border); transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #8175ff, #6157e8); border-color: rgba(139,124,255,.7); color: #fff; box-shadow: 0 9px 24px rgba(99,91,255,.20); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 12px 28px rgba(99,91,255,.30); }
.btn-secondary { background: rgba(255,255,255,.035); color: #d9dee7; }
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,.07); border-color: var(--card-border-strong); }
.btn-row { display: flex; gap: 9px; margin: 13px 0 7px; }
.btn-row .btn { flex: 1; }
.main-actions { max-width: 900px; margin-left: auto; margin-right: auto; }
.btn-icon { font-size: 14px; }
.copy-btn-row { display: flex; justify-content: flex-end; margin: -2px 0 20px; }
.copy-btn { background: rgba(255,255,255,.025); color: #aab4c3; border: 1px solid rgba(148,163,184,.18); border-radius: 8px; padding: 6px 11px; font-size: 11px; font-weight: 650; cursor: pointer; transition: .15s ease; }
.copy-btn:hover { background: rgba(255,255,255,.06); color: #e5e7eb; border-color: rgba(148,163,184,.32); }

/* ---------- Analysis badges become dashboard cards ---------- */
.badge-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 19px; }
.badge {
    min-height: 70px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px;
    padding: 12px 14px; border-radius: 14px; font-size: 14px; font-weight: 750; border: 1px solid transparent;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}
.badge-label { opacity: .62; font-size: 10px; text-transform: uppercase; letter-spacing: .8px; font-weight: 700; margin: 0; }
.badge-green { background: linear-gradient(145deg, rgba(57,217,138,.10), rgba(57,217,138,.035)); color: #65e6a1; border-color: var(--green-border); }
.badge-red { background: linear-gradient(145deg, rgba(255,116,116,.11), rgba(255,116,116,.035)); color: #ff8989; border-color: var(--red-border); }
.badge-orange { background: linear-gradient(145deg, rgba(255,174,102,.11), rgba(255,174,102,.035)); color: #ffbd80; border-color: var(--orange-border); }
.badge-gray { background: linear-gradient(145deg, rgba(156,163,175,.10), rgba(156,163,175,.035)); color: #d8dee8; border-color: var(--gray-border); }

/* ---------- Alerts ---------- */
.alert { padding: 13px 15px; border-radius: 11px; font-size: 12px; margin-bottom: 12px; border: 1px solid; }
.alert-warning { background: var(--orange-bg); border-color: var(--orange-border); color: #ffd0a3; }
.alert-success { background: var(--green-bg); border-color: var(--green-border); color: #9bf0bd; }
.alert-error { background: var(--red-bg); border-color: var(--red-border); color: #ffb0b0; }
.alert-info { background: var(--blue-bg); border-color: var(--blue-border); color: var(--blue-text); }
.alert code { display: block; margin-top: 8px; background: #080c13; padding: 8px 10px; border-radius: 7px; font-size: 10px; white-space: pre-wrap; word-break: break-word; }

/* ---------- Human review / status ---------- */
#result-container .section-title { margin-top: 27px; }
#result-container textarea { background: rgba(7,11,18,.78); }
.reviewer-caption { color: var(--muted); font-size: 11px; margin: 6px 0 0; }
#send-email-btn { min-height: 44px; }

/* ---------- History ---------- */
.history-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 12px; }
.history-filters select { padding: 10px 11px; color: #cbd5e1; }
.table-wrap { overflow: auto; border: 1px solid var(--card-border); border-radius: 15px; background: rgba(12,17,27,.65); box-shadow: 0 15px 40px rgba(0,0,0,.12); }
table { width: 100%; border-collapse: collapse; font-size: 11px; min-width: 900px; }
th, td { text-align: left; padding: 11px 13px; border-bottom: 1px solid rgba(148,163,184,.09); white-space: nowrap; }
th { background: #121824; color: #98a3b4; font-weight: 750; position: sticky; top: 0; z-index: 1; }
td { color: #cbd5e1; }
td.wrap-cell { white-space: normal; max-width: 300px; line-height: 1.45; }
tbody tr:hover { background: rgba(139,124,255,.035); }
.table-caption { color: var(--muted-2); font-size: 10.5px; margin: 8px 2px; }
.empty-state { color: var(--muted); font-size: 13px; padding: 34px 20px; text-align: center; border: 1px dashed rgba(148,163,184,.16); border-radius: 15px; background: rgba(17,23,34,.45); }

/* ---------- Distribution / Analytics Dashboard ---------- */
.analytics-header-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 22px 24px;
    margin-bottom: 14px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(99,102,241,.15), rgba(17,24,39,.88));
    border: 1px solid rgba(139,124,255,.22);
    box-shadow: 0 14px 38px rgba(0,0,0,.14);
}
.analytics-eyebrow { color: #9d94ff; font-size: 10px; font-weight: 800; letter-spacing: 1.5px; margin-bottom: 4px; }
.analytics-header-card h2 { margin: 0; color: #f3f4f6; font-size: 21px; letter-spacing: -.3px; }
.analytics-header-card p { margin: 5px 0 0; color: var(--muted); font-size: 12px; max-width: 650px; }
.analytics-header-icon { width: 52px; height: 52px; flex: 0 0 52px; display: grid; place-items: center; border-radius: 15px; background: rgba(139,124,255,.13); border: 1px solid rgba(139,124,255,.22); font-size: 25px; }

.metric-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; margin-bottom: 16px; }
.metric-card { position: relative; overflow: hidden; display: flex; align-items: center; gap: 11px; background: linear-gradient(145deg, rgba(18,24,36,.96), rgba(14,19,29,.90)); border: 1px solid var(--card-border); border-radius: 15px; padding: 15px; text-align: left; box-shadow: 0 12px 35px rgba(0,0,0,.13); }
.metric-card::after { content: ""; position: absolute; width: 70px; height: 70px; border-radius: 50%; background: rgba(139,124,255,.07); right: -28px; top: -30px; }
.metric-icon { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.06); font-size: 17px; }
.metric-value { font-size: 24px; line-height: 1; font-weight: 800; }
.metric-label { font-size: 10px; color: var(--muted); margin-top: 4px; }
.metric-positive .metric-value { color: #4ade80; }
.metric-negative .metric-value { color: #f87171; }
.metric-high .metric-value { color: #fb923c; }

.analytics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.analytics-panel { min-width: 0; padding: 16px; border-radius: 17px; background: linear-gradient(145deg, rgba(18,24,36,.82), rgba(14,19,29,.74)); border: 1px solid var(--card-border); box-shadow: 0 12px 34px rgba(0,0,0,.10); }
.analytics-panel-wide { grid-column: 1 / -1; }
.analytics-panel-title { color: #e5e7eb; font-size: 13px; font-weight: 800; letter-spacing: .2px; }
.analytics-panel-subtitle { color: var(--muted-2); font-size: 10.5px; margin-top: 3px; }

.chart-wrap { position: relative; background: rgba(10,15,24,.62); border: 1px solid rgba(148,163,184,.10); border-radius: 13px; padding: 10px; margin-top: 12px; margin-bottom: 0; height: 245px; }
.chart-wrap.chart-doughnut { height: 255px; }
.chart-wrap.chart-category { height: 310px; }

.analytics-note { display: flex; align-items: flex-start; gap: 9px; margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: rgba(99,102,241,.07); border: 1px solid rgba(99,102,241,.14); color: var(--muted); font-size: 10.5px; line-height: 1.55; }
.analytics-note strong { color: #cbd5e1; }

@media (max-width: 760px) {
    .analytics-grid { grid-template-columns: 1fr; }
    .analytics-panel-wide { grid-column: auto; }
}

@media (max-width: 520px) {
    .analytics-header-card { align-items: flex-start; }
    .analytics-header-icon { display: none; }
    .metric-row { grid-template-columns: 1fr 1fr; }
    .metric-card { padding: 12px; }
    .metric-icon { width: 31px; height: 31px; flex-basis: 31px; font-size: 14px; }
    .metric-value { font-size: 20px; }
}

/* ---------- Footer ---------- */
.app-footer { display: flex; justify-content: center; gap: 8px; color: #5e697a; font-size: 10px; margin-top: 34px; }

@media (max-width: 900px) {
    .hero-grid { grid-template-columns: 1fr; }
    .hero-art { min-height: 210px; margin-top: -8px; }
    .example-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
    .page { width: min(100% - 18px, 1180px); padding-top: 9px; }
    .app-header { padding: 20px 18px 24px; border-radius: 20px; }
    .top-brand-row { align-items: flex-start; }
    .live-pill { display: none; }
    .main-title { font-size: 34px; }
    .hero-art { transform: scale(.88); margin: -12px 0 -20px; }
    .tabs { width: 100%; justify-content: space-between; }
    .tab-btn { flex: 1; justify-content: center; padding: 9px 8px; }
    .section-heading-row, .page-section-header { align-items: flex-start; flex-direction: column; }
    .secure-chip, .data-source-chip { margin-left: 0; }
    .card { padding: 18px; }
    .badge-row { grid-template-columns: 1fr; }
    .metric-row { grid-template-columns: repeat(2, 1fr); }
    .example-grid { grid-template-columns: 1fr 1fr; }
    .btn-row { flex-direction: column; }
    .btn-row .btn { width: 100%; }
}

@media (max-width: 460px) {
    .example-grid { grid-template-columns: 1fr; }
    .metric-row { grid-template-columns: 1fr 1fr; }
    .hero-chips span { font-size: 10px; }
    .app-footer { flex-wrap: wrap; }
}
