/* ============================================================
   Agent Portal — design system
   Pure CSS. No framework. Inter + JetBrains Mono.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ---------- tokens ---------- */
:root {
    /* surface hierarchy (dark default) */
    --bg-base:       #0a0e17;
    --bg-surface:    #0d1117;
    --bg-elevated:   #161b27;
    --bg-muted:      #1c2333;

    --border:        #21262d;
    --border-strong: #30363d;

    --text-primary:  #e6edf3;
    --text-secondary:#7d8590;
    --text-muted:    #484f58;

    --accent:        #6366f1;
    --accent-hover:  #5254cc;
    --accent-soft:   rgba(99, 102, 241, 0.10);
    --accent-strong: rgba(99, 102, 241, 0.25);

    --success:       #3fb950;
    --warning:       #d29922;
    --error:         #f85149;
    --info:          #58a6ff;

    /* geometry */
    --radius-sm: 6px;
    --radius:    8px;
    --radius-lg: 12px;

    --sidebar-w: 240px;
    --topbar-h:  56px;

    /* motion */
    --ease: cubic-bezier(.2, .8, .2, 1);
    --dur:  150ms;

    /* shadows */
    --shadow-1: 0 1px 2px rgba(0,0,0,.35);
    --shadow-2: 0 8px 24px rgba(0,0,0,.45);
    --shadow-focus: 0 0 0 3px var(--accent-strong);

    /* typography */
    --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html[data-theme="light"] {
    --bg-base:       #ffffff;
    --bg-surface:    #f6f8fa;
    --bg-elevated:   #ffffff;
    --bg-muted:      #f6f8fa;

    --border:        #d0d7de;
    --border-strong: #afb8c1;

    --text-primary:  #1f2328;
    --text-secondary:#656d76;
    --text-muted:    #9198a1;

    --accent:        #6366f1;
    --accent-hover:  #4f46e5;
    --accent-soft:   rgba(99, 102, 241, 0.08);
    --accent-strong: rgba(99, 102, 241, 0.20);

    --shadow-1: 0 1px 2px rgba(15,23,42,.06);
    --shadow-2: 0 8px 24px rgba(15,23,42,.12);
}

/* ---------- reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
body { min-height: 100vh; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

p  { margin: 0; }

a  { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

code, pre, .mono { font-family: var(--font-mono); }

::selection { background: var(--accent-strong); color: var(--text-primary); }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar              { width: 10px; height: 10px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover  { background: var(--border-strong); }

/* ============================================================
   Shell
   ============================================================ */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ---------- sidebar ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar__brand-mark {
    width: 28px; height: 28px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
    display: grid; place-items: center;
    color: #fff;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.05) inset, 0 4px 12px rgba(99,102,241,0.35);
}
.sidebar__brand-mark svg { width: 16px; height: 16px; }
.sidebar__brand-name {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}
.sidebar__brand-sub {
    display: block;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 1px;
}

.sidebar__nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar__section-label {
    padding: 16px 12px 6px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 8px 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
    width: 100%;
    text-align: left;
}
.nav-item svg { width: 16px; height: 16px; flex: none; opacity: .8; }
.nav-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}
.nav-item:hover svg { opacity: 1; }
.nav-item.is-active {
    background: var(--accent-soft);
    color: var(--text-primary);
}
.nav-item.is-active svg { color: var(--accent); opacity: 1; }
.nav-item.is-active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}

.sidebar__foot {
    border-top: 1px solid var(--border);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* account switcher pill */
.acct-switcher {
    position: relative;
}
.acct-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.acct-btn:hover { border-color: var(--border-strong); background: var(--bg-muted); }
.acct-btn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: none; }
.acct-btn__dot.is-active  { background: var(--success); box-shadow: 0 0 0 3px rgba(63,185,80,0.15); }
.acct-btn__dot.is-limited { background: var(--warning); }
.acct-btn__dot.is-error   { background: var(--error); }
.acct-btn__label {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}
.acct-btn__caret { width: 12px; height: 12px; color: var(--text-secondary); flex: none; }

.acct-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0; right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 4px;
    box-shadow: var(--shadow-2);
    display: none;
}
.acct-menu.is-open { display: block; }
.acct-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    width: 100%;
    color: var(--text-primary);
    transition: background var(--dur) var(--ease);
}
.acct-menu__item:hover { background: var(--bg-muted); }
.acct-menu__item .acct-btn__dot { margin: 0; }
.acct-menu__meta {
    flex: 1;
    min-width: 0;
}
.acct-menu__meta b {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acct-menu__meta span {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acct-menu__check { color: var(--accent); width: 14px; height: 14px; }

/* user card */
.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
}
.user-card__avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    display: grid; place-items: center;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    flex: none;
}
.user-card__meta { flex: 1; min-width: 0; }
.user-card__name {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-card__role {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: capitalize;
}
.user-card__logout {
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.user-card__logout:hover { background: var(--bg-muted); color: var(--error); }
.user-card__logout svg { width: 14px; height: 14px; }

/* ---------- content area ---------- */
.content {
    grid-column: 2;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-base) 85%, transparent);
    backdrop-filter: blur(8px);
}
.topbar__crumb {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 13px;
}
.topbar__crumb svg { width: 14px; height: 14px; }
.topbar__crumb .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.topbar__crumb strong { color: var(--text-primary); font-weight: 600; }

.topbar__actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: var(--radius);
    color: var(--text-secondary);
    border: 1px solid transparent;
    transition: all var(--dur) var(--ease);
}
.icon-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--text-primary);
}
.icon-btn svg { width: 16px; height: 16px; }
html[data-theme="dark"]  .icon-btn .icn-sun  { display: none; }
html[data-theme="dark"]  .icon-btn .icn-moon { display: block; }
html[data-theme="light"] .icon-btn .icn-sun  { display: block; }
html[data-theme="light"] .icon-btn .icn-moon { display: none; }

.main-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px 48px;
}

.panel { display: none; animation: panelIn 180ms var(--ease); }
.panel.is-active { display: block; }
@keyframes panelIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.panel__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.panel__title { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
.panel__subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.panel__actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   Controls
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-primary);
    transition: all var(--dur) var(--ease);
    white-space: nowrap;
}
.btn:hover      { border-color: var(--border-strong); background: var(--bg-muted); }
.btn:focus-visible { outline: 0; box-shadow: var(--shadow-focus); }
.btn[disabled]  { opacity: 0.5; cursor: not-allowed; }
.btn svg        { width: 14px; height: 14px; }
.btn--sm        { height: 28px; padding: 0 10px; font-size: 12px; }
.btn--lg        { height: 40px; padding: 0 18px; font-size: 14px; }

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(99,102,241,.25), 0 0 0 1px rgba(255,255,255,.06) inset;
}
.btn--primary:hover  { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:focus-visible { box-shadow: var(--shadow-focus); }

.btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}
.btn--ghost:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border); }

.btn--danger {
    color: var(--error);
    border-color: rgba(248,81,73,0.25);
    background: rgba(248,81,73,0.08);
}
.btn--danger:hover {
    background: rgba(248,81,73,0.16);
    border-color: rgba(248,81,73,0.4);
}

.btn__spin {
    width: 12px; height: 12px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* form fields */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.input, .select, .textarea {
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
    outline: 0;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus  { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.textarea { resize: vertical; min-height: 140px; }
.textarea.mono { font-family: var(--font-mono); font-size: 13px; line-height: 1.55; }

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d8590' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* search input */
.search {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 320px;
}
.search svg {
    position: absolute;
    left: 11px;
    width: 14px; height: 14px;
    color: var(--text-muted);
    pointer-events: none;
}
.search .input { padding-left: 34px; }

/* toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    flex: none;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider {
    position: absolute; inset: 0;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.switch__slider::before {
    content: '';
    position: absolute;
    left: 2px; top: 1px;
    width: 12px; height: 12px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}
.switch input:checked + .switch__slider {
    background: var(--accent);
    border-color: var(--accent);
}
.switch input:checked + .switch__slider::before {
    transform: translateX(14px);
    background: #fff;
}
.switch input:focus-visible + .switch__slider { box-shadow: var(--shadow-focus); }

/* ============================================================
   Data tables
   ============================================================ */
.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
    text-align: left;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table th {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg-surface);
    position: sticky; top: 0;
    cursor: pointer;
    user-select: none;
}
.table th:hover { color: var(--text-primary); }
.table th .sort-ind {
    display: inline-block;
    margin-left: 4px;
    color: var(--accent);
    font-size: 10px;
}
.table tbody tr {
    transition: background var(--dur) var(--ease);
}
.table tbody tr:hover { background: var(--bg-elevated); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); }
.table td.num  { font-variant-numeric: tabular-nums; text-align: right; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions .btn { margin-left: 6px; }

/* badges + dots */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    text-transform: capitalize;
}
.badge.is-success { color: var(--success); border-color: rgba(63,185,80,.3);  background: rgba(63,185,80,.08); }
.badge.is-warning { color: var(--warning); border-color: rgba(210,153,34,.3); background: rgba(210,153,34,.08); }
.badge.is-error   { color: var(--error);   border-color: rgba(248,81,73,.3);  background: rgba(248,81,73,.08); }
.badge.is-info    { color: var(--info);    border-color: rgba(88,166,255,.3); background: rgba(88,166,255,.08); }
.badge.is-accent  { color: var(--accent);  border-color: var(--accent-strong); background: var(--accent-soft); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.dot.is-active   { background: var(--success); box-shadow: 0 0 0 3px rgba(63,185,80,0.15); }
.dot.is-limited  { background: var(--warning); }
.dot.is-error    { background: var(--error); }
.dot.is-inactive { background: var(--text-muted); }

.proj-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text-primary);
}
.proj-chip__swatch {
    width: 8px; height: 8px; border-radius: 2px;
    display: inline-block;
}

/* ============================================================
   Prompt tab
   ============================================================ */
.prompt-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    align-items: start;
}
@media (max-width: 960px) {
    .prompt-grid { grid-template-columns: 1fr; }
}
.sidepane {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: calc(var(--topbar-h) + 28px);
}
.sidepane__group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 4px 8px;
}

.pick-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
}
.pick-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.pick-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}
.pick-item.is-active {
    background: var(--accent-soft);
    border-color: var(--accent-strong);
    color: var(--text-primary);
}
.pick-item__swatch {
    width: 8px; height: 8px; border-radius: 2px;
    flex: none;
    background: var(--text-muted);
}
.pick-item__body { min-width: 0; flex: 1; }
.pick-item__title {
    display: block;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pick-item__meta {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.prompt-main { display: flex; flex-direction: column; gap: 20px; }

.prompt-shell {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    overflow: hidden;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.prompt-shell:focus-within {
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
}
.prompt-shell textarea {
    width: 100%;
    min-height: 160px;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    padding: 16px 18px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    outline: 0;
}
.prompt-shell__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 10px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
}
.prompt-shell__hint {
    font-size: 11px;
    color: var(--text-muted);
}
.prompt-shell__hint kbd {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

/* output terminal */
.terminal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.terminal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}
.terminal__dots { display: flex; gap: 6px; }
.terminal__dots span {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--bg-muted);
    border: 1px solid var(--border);
}
.terminal__title {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}
.terminal__status {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}
.terminal__body {
    padding: 14px 16px;
    min-height: 240px;
    max-height: 480px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.65;
    background: var(--bg-base);
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
}
.terminal__body .line { padding: 1px 0; }
.terminal__body .line-sys { color: var(--text-muted); font-style: italic; }
.terminal__body .line-ok  { color: var(--success); }
.terminal__body .line-err { color: var(--error); }
.terminal__body .line-info{ color: var(--info); }
.terminal__body .line-prefix {
    color: var(--accent);
    margin-right: 6px;
}
.terminal__foot {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}
.terminal__foot .kv strong { color: var(--text-primary); font-weight: 500; }

.status-dot--idle    { color: var(--text-muted); }
.status-dot--running { color: var(--warning); }
.status-dot--done    { color: var(--success); }
.status-dot--error   { color: var(--error); }

@keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50%      { opacity: .45; }
}
.is-running { animation: pulse-soft 1.2s ease-in-out infinite; }

/* ============================================================
   Filter bar
   ============================================================ */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.filter-bar__right { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   Accounts — clean list
   ============================================================ */
.acct-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.acct-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 16px;
    align-items: center;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    transition: border-color var(--dur) var(--ease);
}
.acct-row:hover { border-color: var(--border-strong); }
.acct-row.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent) inset, 0 0 0 4px var(--accent-soft);
}
.acct-row__icon {
    width: 36px; height: 36px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    display: grid; place-items: center;
    color: var(--text-secondary);
}
.acct-row__icon svg { width: 18px; height: 18px; }
.acct-row__body { min-width: 0; }
.acct-row__label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.acct-row__meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    font-family: var(--font-mono);
}

/* ============================================================
   Teammates — list left, matrix right
   ============================================================ */
.teammates {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 24px;
    align-items: start;
}
@media (max-width: 960px) { .teammates { grid-template-columns: 1fr; } }

.user-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    padding: 8px;
    position: sticky;
    top: calc(var(--topbar-h) + 28px);
}
.user-pick {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: background var(--dur) var(--ease);
    cursor: pointer;
    width: 100%;
    text-align: left;
}
.user-pick:hover { background: var(--bg-elevated); color: var(--text-primary); }
.user-pick.is-active { background: var(--accent-soft); color: var(--text-primary); }
.user-pick__del {
    width: 26px; height: 26px;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    border: 1px solid transparent;
    transition: color var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
    flex: none;
    opacity: 0;
}
.user-pick:hover .user-pick__del { opacity: 1; }
.user-pick__del svg { width: 13px; height: 13px; }
.user-pick__del:hover {
    color: var(--error);
    background: rgba(248,81,73,0.08);
    border-color: rgba(248,81,73,0.25);
}
.user-pick__del[disabled] {
    cursor: not-allowed;
    opacity: 0.35 !important;
    color: var(--text-muted);
    background: transparent;
    border-color: transparent;
}
.user-pick__avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: grid; place-items: center;
    flex: none;
}
.user-pick__body { min-width: 0; flex: 1; }
.user-pick__name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-pick__email {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============================================================
   Plugins — genuine card grid (each card is a toggle)
   ============================================================ */
.plugin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.plugin-card {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.plugin-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.plugin-card.is-enabled {
    border-color: var(--accent-strong);
    background: linear-gradient(180deg, var(--accent-soft) 0%, var(--bg-surface) 60%);
}
.plugin-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.plugin-card__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.plugin-card__version {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.plugin-card__desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.55;
    flex: 1;
    min-height: 34px;
}
.plugin-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* ============================================================
   Backup
   ============================================================ */
.backup-create {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: end;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    margin-bottom: 20px;
}
.backup-create__status {
    grid-column: 1 / -1;
    font-size: 12px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* ============================================================
   History
   ============================================================ */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.history-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 14px;
    align-items: center;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.history-row:hover {
    border-color: var(--border-strong);
    background: var(--bg-elevated);
}
.history-row__icon {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--bg-muted);
    color: var(--text-secondary);
    flex: none;
}
.history-row__icon svg { width: 14px; height: 14px; }
.history-row.is-success  .history-row__icon { color: var(--success); background: rgba(63,185,80,.12); }
.history-row.is-error    .history-row__icon { color: var(--error);   background: rgba(248,81,73,.12); }
.history-row.is-running  .history-row__icon { color: var(--warning); background: rgba(210,153,34,.12); }
.history-row__body { min-width: 0; }
.history-row__prompt {
    display: block;
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-row__meta {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 2px;
}
.history-row__time {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
}

/* ============================================================
   Empty states
   ============================================================ */
.empty {
    padding: 48px 20px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    color: var(--text-secondary);
}
.empty__icon {
    width: 40px; height: 40px;
    margin: 0 auto 12px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--bg-muted);
    color: var(--text-muted);
}
.empty__icon svg { width: 18px; height: 18px; }
.empty__title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.empty__body  { font-size: 12px; color: var(--text-secondary); max-width: 360px; margin: 0 auto; }

/* ============================================================
   Skeleton loading
   ============================================================ */
.skeleton {
    background: linear-gradient(90deg, var(--bg-surface) 0%, var(--bg-elevated) 50%, var(--bg-surface) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.3s infinite linear;
    border-radius: var(--radius);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel-row { height: 44px; margin-bottom: 6px; }
.skel-card { height: 140px; margin-bottom: 12px; }

/* ============================================================
   Toast
   ============================================================ */
#toast-root {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 80;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    min-width: 260px;
    max-width: 380px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    animation: toastIn 220ms var(--ease);
    font-size: 13px;
    color: var(--text-primary);
}
.toast.is-leaving { animation: toastOut 180ms var(--ease) forwards; }
.toast__icon { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast__body { flex: 1; min-width: 0; }
.toast__title { font-weight: 600; }
.toast__msg   { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.toast.is-success { border-left: 3px solid var(--success); }
.toast.is-success .toast__icon { color: var(--success); }
.toast.is-error   { border-left: 3px solid var(--error); }
.toast.is-error   .toast__icon { color: var(--error); }
.toast.is-info    { border-left: 3px solid var(--info); }
.toast.is-info    .toast__icon { color: var(--info); }

@keyframes toastIn  { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(16px); } }

/* ============================================================
   Modal (confirm)
   ============================================================ */
#modal-root {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    background: rgba(5,8,15,.65);
    backdrop-filter: blur(4px);
    z-index: 90;
    animation: fadeIn 160ms var(--ease);
}
#modal-root.is-open { display: grid; }
.modal {
    width: min(420px, 92vw);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px 20px;
    box-shadow: var(--shadow-2);
    animation: modalIn 180ms var(--ease);
}
.modal__title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.modal__body  { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Inline form inside a modal (e.g. new user) */
.new-user-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

@keyframes fadeIn  { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ============================================================
   Suggestion bar (Feature 3)
   ============================================================ */
.suggest-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    animation: panelIn 160ms var(--ease);
}
.suggest-bar.hidden { display: none; }
.suggest-bar__label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}
.suggest-bar__chips {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.suggest-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    background: var(--accent-soft);
    border: 1px solid var(--accent-strong);
    color: var(--accent);
    font-family: var(--font-mono);
    transition: all var(--dur) var(--ease);
}
.suggest-chip:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.suggest-bar__dismiss {
    width: 22px; height: 22px;
    display: grid; place-items: center;
    color: var(--text-muted);
    border-radius: 4px;
    transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.suggest-bar__dismiss svg { width: 12px; height: 12px; }
.suggest-bar__dismiss:hover { background: var(--bg-muted); color: var(--text-primary); }

/* ============================================================
   Injected-skills ribbon (Feature 2)
   ============================================================ */
.inject-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--accent-soft) 0%, transparent 100%);
    border: 1px solid var(--accent-strong);
    color: var(--text-primary);
    font-size: 12px;
    animation: panelIn 160ms var(--ease);
}
.inject-bar.hidden { display: none; }
.inject-bar__icon {
    width: 22px; height: 22px;
    display: grid; place-items: center;
    color: var(--accent);
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--accent-strong);
    flex: none;
}
.inject-bar__icon svg { width: 12px; height: 12px; }
.inject-bar__label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
}
.inject-bar__list { display: flex; gap: 6px; flex-wrap: wrap; }
.inject-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 11px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
}
.inject-pill__kw {
    font-size: 10px;
    color: var(--text-muted);
}

/* ============================================================
   Skills tab
   ============================================================ */
.skills-layout { display: flex; flex-direction: column; gap: 16px; }

.skill-scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    font-family: var(--font-mono);
}
.skill-scope-badge.is-global {
    background: rgba(88,166,255,.08);
    border: 1px solid rgba(88,166,255,.25);
    color: var(--info);
}
.skill-scope-badge.is-project {
    background: var(--accent-soft);
    border: 1px solid var(--accent-strong);
    color: var(--accent);
}

.kw-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.kw-tag {
    padding: 1px 7px;
    border-radius: 4px;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
}

/* ============================================================
   Skill editor (slide-over)
   ============================================================ */
.skill-editor {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 85;
    background: rgba(5,8,15,.6);
    backdrop-filter: blur(4px);
}
.skill-editor.is-open { display: block; animation: fadeIn 160ms var(--ease); }

.skill-editor__panel {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: min(640px, 92vw);
    background: var(--bg-elevated);
    border-left: 1px solid var(--border);
    box-shadow: -20px 0 60px rgba(0,0,0,.45);
    display: flex;
    flex-direction: column;
    animation: slideInRight 220ms var(--ease);
}
@keyframes slideInRight {
    from { transform: translateX(24px); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

.skill-editor__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 22px 24px 18px;
    border-bottom: 1px solid var(--border);
}
.skill-editor__title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.skill-editor__sub   { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.skill-editor__body {
    flex: 1;
    overflow-y: auto;
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.skill-editor__grid {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 14px;
}
@media (max-width: 640px) {
    .skill-editor__grid { grid-template-columns: 1fr; }
}
.field__help {
    font-size: 11px;
    color: var(--text-muted);
}
.skill-editor__body .textarea { min-height: 280px; }

.skill-editor__foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
}

/* ============================================================
   Login
   ============================================================ */
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1000px 600px at 80% -20%, rgba(99,102,241,0.10), transparent 50%),
        radial-gradient(900px 500px at 0% 100%, rgba(168,85,247,0.08), transparent 55%),
        var(--bg-base);
}
.login-card {
    width: min(420px, 100%);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 32px 32px 28px;
    box-shadow: var(--shadow-2);
}
.login-card__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.login-card__mark {
    width: 38px; height: 38px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
    display: grid; place-items: center;
    color: #fff;
    box-shadow: 0 10px 30px -10px rgba(99,102,241,.6);
}
.login-card__mark svg { width: 20px; height: 20px; }
.login-card__title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.login-card__sub   { font-size: 12px; color: var(--text-secondary); }
.login-card__head-theme {
    margin-left: auto;
}
.login-card__error {
    margin-bottom: 16px;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid rgba(248,81,73,.3);
    background: rgba(248,81,73,.08);
    color: var(--error);
    font-size: 12px;
}
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card__foot {
    margin-top: 20px;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ============================================================
   Mobile
   ============================================================ */
.sidebar__toggle {
    display: none;
    position: fixed;
    top: 12px; left: 12px;
    z-index: 40;
    width: 36px; height: 36px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    place-items: center;
}
.sidebar__toggle svg { width: 16px; height: 16px; }

@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 220ms var(--ease);
        box-shadow: var(--shadow-2);
    }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar__toggle { display: grid; }
    .main-scroll { padding: 18px 18px 36px; }
    .topbar { padding: 0 14px 0 60px; }
}

/* utility */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.hidden { display: none !important; }
