
:root {
    --bg: #f3f5f8;
    --bg-soft: #eef2f7;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef2f7;
    --text: #101828;
    --heading: #0b1220;
    --muted: #667085;
    --muted-2: #94a3b8;
    --border: #e4e7ec;
    --border-strong: #cbd5e1;
    --primary: #dc2626;
    --primary-dark: #991b1b;
    --primary-soft: #fff1f2;
    --accent: #16a34a;
    --warning: #d97706;
    --danger: #b91c1c;
    --info: #2563eb;
    --sidebar: #05070c;
    --sidebar-2: #0b1220;
    --sidebar-border: rgba(255,255,255,.08);
    --shadow: 0 22px 70px rgba(15, 23, 42, .12);
    --shadow-soft: 0 14px 42px rgba(15, 23, 42, .07);
    --radius: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
    --bg: #090c12;
    --bg-soft: #0f172a;
    --surface: #111827;
    --surface-2: #0b1220;
    --surface-3: #162033;
    --text: #e5e7eb;
    --heading: #f8fafc;
    --muted: #a3acba;
    --muted-2: #718096;
    --border: rgba(255,255,255,.09);
    --border-strong: rgba(255,255,255,.16);
    --primary-soft: rgba(220, 38, 38, .14);
    --sidebar: #030712;
    --sidebar-2: #0b1220;
    --shadow: 0 30px 90px rgba(0,0,0,.35);
    --shadow-soft: 0 18px 42px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(220, 38, 38, .10), transparent 30vw),
        radial-gradient(circle at bottom right, rgba(37, 99, 235, .08), transparent 34vw),
        var(--bg);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: var(--primary); text-decoration: none; font-weight: 700; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }

.app-shell { min-height: 100vh; }

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(360px, 540px) 1fr;
    background:
        radial-gradient(circle at 20% 20%, rgba(239, 68, 68, .26), transparent 32%),
        radial-gradient(circle at 80% 70%, rgba(37, 99, 235, .18), transparent 36%),
        linear-gradient(135deg, #020617 0%, #0f172a 46%, #111827 100%);
    color: white;
    overflow: hidden;
}
.login-card {
    margin: auto;
    width: min(456px, calc(100vw - 40px));
    background: rgba(255,255,255,.97);
    color: #101828;
    border: 1px solid rgba(255,255,255,.38);
    border-radius: 30px;
    padding: 30px;
    box-shadow: 0 30px 100px rgba(0,0,0,.28);
    backdrop-filter: blur(18px);
}
.login-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px;
    position: relative;
}
.login-hero:before {
    content: "";
    position: absolute;
    inset: 8% 10%;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 42px;
    background: linear-gradient(135deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
}
.hero-box { max-width: 690px; position: relative; }
.hero-box h1 {
    font-size: clamp(40px, 6vw, 82px);
    line-height: .92;
    margin: 0 0 22px;
    letter-spacing: -0.07em;
}
.hero-box p {
    max-width: 610px;
    color: #cbd5e1;
    font-size: 19px;
    line-height: 1.65;
}
.hero-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 34px;
}
.hero-metrics div {
    border: 1px solid rgba(255,255,255,.10);
    background: rgba(255,255,255,.06);
    border-radius: 18px;
    padding: 16px;
}
.hero-metrics strong { display: block; font-size: 22px; }
.hero-metrics span { display: block; color: #94a3b8; font-size: 12px; margin-top: 5px; }

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}
.logo-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, #ef4444, #7f1d1d);
    color: white;
    font-weight: 950;
    letter-spacing: -.04em;
    box-shadow: 0 12px 30px rgba(220, 38, 38, .28);
}
.brand-row strong { display: block; font-size: 20px; color: inherit; }
.brand-row span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.login-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: #f1f5f9;
    padding: 6px;
    border-radius: 18px;
    margin-bottom: 20px;
}
.login-tabs button {
    border: 0;
    background: transparent;
    border-radius: 13px;
    padding: 11px;
    color: #667085;
    font-weight: 800;
}
.login-tabs button.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 10px 22px rgba(15, 23, 42, .09);
}

.layout {
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    min-height: 100vh;
}
.sidebar {
    background:
        linear-gradient(180deg, rgba(220,38,38,.12), transparent 24%),
        linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
    color: white;
    padding: 22px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
    border-right: 1px solid var(--sidebar-border);
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 99px; }
.sidebar .brand-row { margin-bottom: 22px; padding: 0 5px; }
.sidebar .brand-row span { color: #94a3b8; }
.context-pill {
    border: 1px solid rgba(148, 163, 184, .22);
    background: rgba(15, 23, 42, .72);
    padding: 14px;
    border-radius: 18px;
    margin: 0 4px 18px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.context-pill small { display: block; color: #94a3b8; margin-bottom: 4px; }
.context-pill strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.context-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.context-dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 5px rgba(34,197,94,.12); }
.nav-title {
    color: #64748b;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .16em;
    margin: 22px 8px 8px;
    font-weight: 900;
}
.nav-button {
    width: 100%;
    border: 0;
    color: #cbd5e1;
    background: transparent;
    padding: 11px 12px;
    border-radius: 14px;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 4px 0;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}
.nav-button:hover { background: rgba(248, 250, 252, .09); color: white; transform: translateX(2px); }
.nav-button.active {
    background: linear-gradient(90deg, rgba(220,38,38,.24), rgba(255,255,255,.06));
    color: white;
    box-shadow: inset 3px 0 0 var(--primary);
}

.main {
    min-width: 0;
    padding: 30px;
}
.main-inner { max-width: 1580px; margin: 0 auto; }
.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 22px;
}
.topbar h1 {
    margin: 0;
    font-size: clamp(27px, 3vw, 38px);
    color: var(--heading);
    letter-spacing: -0.055em;
}
.topbar p { margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
.breadcrumb { color: var(--muted-2); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .10em; margin-bottom: 8px; }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.command-hint {
    display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px;
    border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 8px 11px;
}
.command-hint kbd { background: var(--surface-3); border: 1px solid var(--border); border-radius: 7px; padding: 2px 5px; color: var(--text); }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 19px;
    min-width: 0;
}
.card h2, .card h3 { margin: 0 0 13px; color: var(--heading); letter-spacing: -0.03em; }
.card > p:first-child { margin-top: 0; }
.kpi { display: flex; flex-direction: column; gap: 7px; position: relative; overflow: hidden; }
.kpi:after { content: ""; position: absolute; right: -18px; top: -28px; width: 92px; height: 92px; border-radius: 50%; background: var(--primary-soft); }
.kpi .value { font-size: clamp(30px, 3vw, 42px); font-weight: 950; letter-spacing: -0.06em; color: var(--heading); z-index: 1; }
.kpi .label { color: var(--muted); font-weight: 850; z-index: 1; }
.kpi small { z-index: 1; color: var(--muted); }

.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-row.one { grid-template-columns: 1fr; }
.field { margin-bottom: 13px; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 900;
    color: var(--muted);
    margin: 0 0 7px;
    text-transform: uppercase;
    letter-spacing: .065em;
}
.input, .textarea, .select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 11px 13px;
    outline: none;
    background: var(--surface);
    color: var(--text);
    transition: border .15s ease, box-shadow .15s ease, background .15s ease;
}
.textarea { min-height: 90px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus {
    border-color: #f87171;
    box-shadow: 0 0 0 4px rgba(248, 113, 113, .16);
}
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 700; margin: 7px 0 12px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn {
    border: 0;
    border-radius: 14px;
    padding: 10px 14px;
    font-weight: 900;
    background: var(--surface-3);
    color: var(--text);
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(15,23,42,.08); }
.btn.primary { background: linear-gradient(135deg, #ef4444, #b91c1c); color: white; }
.btn.primary:hover { background: linear-gradient(135deg, #dc2626, #991b1b); }
.btn.ghost { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: #fee2e2; color: #991b1b; }
.btn.small { padding: 7px 10px; font-size: 12px; border-radius: 11px; }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .075em; font-weight: 950; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(220, 38, 38, .025); }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 900; background: var(--surface-3); color: var(--text); white-space: nowrap; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.yellow { background: #fef3c7; color: #92400e; }
.badge.blue { background: #dbeafe; color: #1e40af; }
:root[data-theme="dark"] .badge.green { background: rgba(22,101,52,.25); color: #86efac; }
:root[data-theme="dark"] .badge.red { background: rgba(153,27,27,.25); color: #fecaca; }
:root[data-theme="dark"] .badge.yellow { background: rgba(146,64,14,.25); color: #fde68a; }
:root[data-theme="dark"] .badge.blue { background: rgba(30,64,175,.28); color: #bfdbfe; }
.notice { border-radius: 16px; padding: 13px 15px; margin-bottom: 15px; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-soft); }
.notice.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.notice.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
:root[data-theme="dark"] .notice.error { background: rgba(153,27,27,.18); border-color: rgba(248,113,113,.25); color: #fecaca; }
:root[data-theme="dark"] .notice.success { background: rgba(22,101,52,.18); border-color: rgba(74,222,128,.20); color: #bbf7d0; }

.split-view { display: grid; grid-template-columns: 390px minmax(0, 1fr); gap: 16px; }
.list-panel { display: flex; flex-direction: column; gap: 9px; }
.list-item { border: 1px solid var(--border); border-radius: 16px; padding: 13px; background: var(--surface); color: var(--text); text-align: left; }
.list-item.active, .list-item:hover { border-color: #f87171; box-shadow: 0 12px 26px rgba(15, 23, 42, .08); }
.list-item strong { display: block; margin-bottom: 5px; color: var(--heading); }
.list-item span { color: var(--muted); font-size: 12px; }
.message-thread { background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--border); border-radius: 18px; padding: 16px; min-height: 390px; display: flex; flex-direction: column; gap: 11px; max-height: 590px; overflow: auto; }
.bubble { max-width: 76%; padding: 11px 13px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); box-shadow: 0 8px 20px rgba(15,23,42,.04); }
.bubble.outbound { align-self: flex-end; background: var(--primary-soft); border-color: rgba(248,113,113,.35); }
.bubble.inbound { align-self: flex-start; }
.bubble small { display: block; margin-top: 7px; color: var(--muted); }

.empty-state { border: 1px dashed var(--border-strong); background: var(--surface-2); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--heading); font-size: 17px; margin-bottom: 5px; }
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 14px; min-height: 18px; }
.skeleton:after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); animation: shimmer 1.5s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }

.command-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, .58); backdrop-filter: blur(6px); z-index: 1000; display: grid; place-items: start center; padding-top: 8vh; }
.command-box { width: min(680px, calc(100vw - 28px)); background: var(--surface); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow); overflow: hidden; }
.command-box input { width: 100%; border: 0; outline: none; padding: 18px 20px; background: var(--surface); color: var(--text); font-size: 17px; border-bottom: 1px solid var(--border); }
.command-results { max-height: 420px; overflow: auto; padding: 8px; }
.command-item { width: 100%; border: 0; background: transparent; color: var(--text); text-align: left; border-radius: 15px; padding: 12px 14px; display: flex; justify-content: space-between; gap: 14px; }
.command-item:hover, .command-item.active { background: var(--primary-soft); }
.command-item small { color: var(--muted); }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.hidden { display: none !important; }

@media (max-width: 1180px) {
    .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split-view { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
    .login-page, .layout { grid-template-columns: 1fr; }
    .login-hero { display: none; }
    .sidebar { position: relative; height: auto; }
    .main { padding: 18px; }
    .grid.cols-2, .grid.cols-3, .grid.cols-4, .form-row { grid-template-columns: 1fr; }
    .topbar { flex-direction: column; }
    .top-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
    .login-card { padding: 22px; border-radius: 24px; }
    .main { padding: 14px; }
    th, td { padding: 10px; }
    .bubble { max-width: 92%; }
}
