:root {
    --bg: #07101f;
    --panel: #101827;
    --line: #26354f;
    --text: #f8fafc;
    --muted: #bdd0ee;
    --soft: #93a4bc;
    --accent: #38bdf8;
    --ok: #86efac;
    --err: #fecaca;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at top right, rgba(56,189,248,.10), transparent 35%), var(--bg);
    color: var(--text);
    font-family: Aptos, Segoe UI, Arial, sans-serif;
}

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

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
}

.login-card {
    width: 100%;
    max-width: 470px;
    background: rgba(16,24,39,.96);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 34px;
}

.brand-mark, .brand-icon {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: rgba(56,189,248,.14);
    border: 1px solid rgba(56,189,248,.45);
    font-weight: 800;
}

.brand-icon { width: 46px; height: 46px; border-radius: 15px; }

.login-title, .page-title {
    margin: 0;
    font-size: 34px;
    letter-spacing: -0.03em;
}

.login-subtitle, .page-kicker {
    color: var(--muted);
    line-height: 1.55;
    margin-top: 8px;
    font-size: 16px;
}

.form-group { margin-top: 18px; }

label {
    display: block;
    margin-bottom: 8px;
    color: #dbeafe;
    font-weight: 650;
}

input, textarea, select {
    width: 100%;
    background: #081120;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 13px 14px;
    font-size: 15px;
    outline: none;
}

textarea { min-height: 130px; }

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(56,189,248,.12);
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    padding: 11px 16px;
    border-radius: 14px;
    border: 0;
    background: linear-gradient(135deg, #38bdf8, #60a5fa);
    color: #03111f;
    font-weight: 900;
    cursor: pointer;
}

.btn.ghost {
    background: #111d32;
    color: var(--text);
    border: 1px solid var(--line);
}

.btn.full { width: 100%; }

.alert {
    margin: 16px 0;
    padding: 13px 15px;
    border-radius: 14px;
    line-height: 1.5;
}

.alert.ok {
    color: var(--ok);
    background: rgba(20,83,45,.22);
    border: 1px solid rgba(74,222,128,.25);
}

.alert.error {
    color: var(--err);
    background: rgba(127,29,29,.22);
    border: 1px solid rgba(248,113,113,.28);
}

.app-shell {
    display: grid;
    grid-template-columns: 285px 1fr;
    min-height: 100vh;
}

.sidebar {
    border-right: 1px solid var(--line);
    padding: 22px;
    background: rgba(5,12,24,.82);
}

.brand-row {
    display: flex;
    gap: 13px;
    align-items: center;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line);
}

.brand-name { font-size: 20px; font-weight: 900; }
.brand-mini { color: var(--muted); margin-top: 4px; font-size: 13px; }

.nav {
    margin-top: 24px;
    display: grid;
    gap: 10px;
}

.nav a {
    padding: 13px 14px;
    border-radius: 14px;
    color: var(--muted);
    border: 1px solid transparent;
}

.nav a.active, .nav a:hover {
    color: var(--text);
    background: #101827;
    border-color: var(--line);
}

.main { padding: 30px; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.admin-pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 14px;
    color: var(--muted);
    background: #0c1526;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 16px;
}

.card {
    background: rgba(16,24,39,.94);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 20px;
    margin-bottom: 18px;
}

.metric-label { color: var(--muted); }
.metric-value { margin-top: 10px; font-size: 32px; font-weight: 900; }

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    text-align: left;
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    vertical-align: top;
}

.table th { color: #dbeafe; }
.table td { color: var(--muted); }

.chat-text {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.72;
    color: #f8fafc;
    font-size: 16px;
    background: #081120;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
}

.status {
    display: inline-flex;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 800;
    background: #17233a;
    color: #bfdbfe;
}

.status.imported, .status.ready { color: #bbf7d0; background: rgba(20,83,45,.28); }
.status.failed { color: #fecaca; background: rgba(127,29,29,.28); }
.status.processing, .status.queued { color: #fde68a; background: rgba(113,63,18,.28); }

.search-hit {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 14px;
    background: #0b1527;
}

.search-hit-title { font-weight: 900; color: #7dd3fc; }
.search-hit-meta { margin-top: 6px; color: var(--soft); font-size: 13px; }
.search-hit-excerpt { margin-top: 10px; line-height: 1.65; color: #f8fafc; }

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 14px 0;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

.app-shell,
.main,
.card {
    min-width: 0;
}

.audit-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.audit-head h2 {
    margin: 0 0 8px 0;
}

.audit-head p {
    margin: 0;
    color: #bdd0ee;
    line-height: 1.6;
}

.audit-list {
    display: grid;
    gap: 14px;
}

.audit-item {
    border: 1px solid #26354f;
    border-radius: 18px;
    background: #0b1527;
    padding: 16px;
    overflow: hidden;
}

.audit-meta-row {
    display: grid;
    grid-template-columns: 180px 220px minmax(120px, 1fr);
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.audit-time,
.audit-ip {
    color: #bdd0ee;
    overflow-wrap: anywhere;
}

.audit-event {
    display: inline-flex;
    width: fit-content;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 900;
    color: #bfdbfe;
    background: #17233a;
    overflow-wrap: anywhere;
}

.audit-ready .audit-event {
    color: #bbf7d0;
    background: rgba(20,83,45,.28);
}

.audit-failed .audit-event {
    color: #fecaca;
    background: rgba(127,29,29,.28);
}

.audit-queued .audit-event {
    color: #fde68a;
    background: rgba(113,63,18,.28);
}

.audit-summary {
    color: #f8fafc;
    line-height: 1.65;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.audit-details {
    margin-top: 12px;
}

.audit-details summary {
    cursor: pointer;
    color: #7dd3fc;
    font-weight: 900;
}

.audit-details pre {
    margin: 12px 0 0 0;
    max-height: 360px;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    background: #07101f;
    border: 1px solid #26354f;
    border-radius: 14px;
    padding: 14px;
    color: #e5efff;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.55;
}

@media (max-width: 900px) {
    .audit-head {
        flex-direction: column;
    }

    .audit-meta-row {
        grid-template-columns: 1fr;
    }
}
