/* ============================================
   OSX Agent — MANUS AI Theme
   Black & White Minimalist Design
   ============================================ */

/* ── Tokens ── */
:root {
    --bg:        #050505;
    --bg-elev:   #0a0a0a;
    --bg-card:   #0f0f0f;
    --bg-hover:  #141414;
    --bg-input:  #111111;

    --border:    #1e1e1e;
    --border-hi: #2a2a2a;
    --border-mid:#222222;

    --white:     #ffffff;
    --gray-100:  #f5f5f5;
    --gray-200:  #e5e5e5;
    --gray-300:  #cccccc;
    --gray-400:  #aaaaaa;
    --gray-500:  #888888;
    --gray-600:  #666666;
    --gray-700:  #444444;
    --gray-800:  #2a2a2a;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;

    --sidebar-w:  240px;
    --panel-w:    300px;
    --topbar-h:   52px;

    --transition: 0.15s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--gray-200);
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
}

input, textarea, select {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--gray-200);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    outline: none;
    transition: border-color var(--transition);
    width: 100%;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--gray-500);
}

textarea { resize: none; overflow: hidden; }

::selection { background: var(--gray-700); color: var(--white); }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-800); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-700); }

/* ── App Layout ── */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ══════════════════════════════════════════
   LEFT SIDEBAR
   ══════════════════════════════════════════ */
.sidebar-left {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 600;
    font-size: 14px;
    color: var(--white);
    letter-spacing: -0.01em;
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: var(--white);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--bg);
    font-weight: 700;
}

.btn-new-project {
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid var(--border-hi);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: 12px;
    transition: all var(--transition);
}

.btn-new-project:hover {
    border-color: var(--gray-500);
    color: var(--white);
    background: var(--bg-hover);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 10px;
}

.nav-section { margin-bottom: 16px; }

.nav-section-title {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-600);
    padding: 6px 8px 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.project-count {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    padding: 0 6px;
    border-radius: 20px;
    font-size: 9px;
    color: var(--gray-500);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    color: var(--gray-500);
    text-decoration: none;
    transition: all var(--transition);
    margin-bottom: 1px;
    cursor: pointer;
    font-size: 13px;
}

.nav-item i { width: 16px; text-align: center; font-size: 13px; }

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--gray-300);
}

.nav-item.active {
    background: var(--white);
    color: var(--bg);
    font-weight: 500;
}

.project-list { margin-top: 2px; }

.project-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    color: var(--gray-500);
    position: relative;
}

.project-item:hover {
    background: var(--bg-hover);
    color: var(--gray-300);
}

.project-item.active {
    background: var(--bg-hover);
    color: var(--white);
}

.project-item i { font-size: 12px; width: 15px; text-align: center; }

.project-item-name {
    flex: 1;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-item-delete {
    opacity: 0;
    color: var(--gray-600);
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all var(--transition);
}

.project-item:hover .project-item-delete { opacity: 1; }
.project-item-delete:hover { color: var(--white); background: var(--gray-700); }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.provider-status {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: var(--gray-600);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--white);
    animation: pulse-dot 2s infinite;
}

.status-dot.disconnected {
    background: var(--gray-600);
    animation: none;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ══════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
    min-width: 0;
}

.topbar {
    height: var(--topbar-h);
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
    flex-shrink: 0;
}

.topbar-left h1 {
    font-size: 14px;
    font-weight: 500;
    color: var(--white);
    letter-spacing: -0.01em;
}

.current-project {
    font-size: 11px;
    color: var(--gray-600);
    margin-top: 1px;
}

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

.provider-select, .model-select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--gray-300);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    min-width: 150px;
}

.provider-select option, .model-select option {
    background: var(--bg-card);
    color: var(--gray-300);
}

.topbar-btn {
    width: 30px;
    height: 30px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    font-size: 12px;
    transition: all var(--transition);
}

.topbar-btn:hover {
    border-color: var(--gray-600);
    color: var(--white);
}

.view-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.view-container.hidden { display: none; }

/* ══════════════════════════════════════════
   CHAT
   ══════════════════════════════════════════ */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.welcome-message {
    text-align: center;
    padding: 80px 20px;
    max-width: 560px;
    margin: auto;
}

.welcome-icon {
    width: 48px;
    height: 48px;
    background: var(--white);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin: 0 auto 24px;
    color: var(--bg);
}

.welcome-message h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--white);
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}

.welcome-message p {
    color: var(--gray-500);
    margin-bottom: 36px;
    font-size: 14px;
    line-height: 1.6;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.quick-actions button {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    color: var(--gray-400);
    font-size: 12px;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 7px;
}

.quick-actions button:hover {
    border-color: var(--gray-600);
    color: var(--white);
    background: var(--bg-hover);
}

/* ── Messages ── */
.message {
    display: flex;
    gap: 12px;
    max-width: 82%;
    animation: msg-in 0.2s ease;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.message.user  { align-self: flex-end; flex-direction: row-reverse; }
.message.assistant { align-self: flex-start; }
.message.tool  { align-self: center; max-width: 95%; }

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

.message.user .message-avatar {
    background: var(--white);
    color: var(--bg);
}

.message.assistant .message-avatar {
    background: var(--bg-hover);
    border: 1px solid var(--border-hi);
    color: var(--gray-300);
}

.message.tool .message-avatar {
    background: transparent;
    border: 1px solid var(--border);
    font-size: 11px;
    color: var(--gray-500);
}

.message-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    line-height: 1.65;
    font-size: 13px;
    color: var(--gray-200);
}

.message.user .message-content {
    background: var(--white);
    border-color: var(--white);
    color: var(--bg);
}

.message.tool .message-content {
    background: var(--bg);
    border-color: var(--border);
    font-family: var(--font-mono);
    font-size: 12px;
    max-width: 100%;
}

.message-content pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--gray-300);
}

.message-content code {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--gray-300);
}

.message-content p  { margin-bottom: 8px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul,
.message-content ol { padding-left: 18px; margin: 6px 0; }
.message-content li { margin-bottom: 3px; color: var(--gray-300); }

.message-time {
    font-size: 10px;
    color: var(--gray-700);
    margin-top: 4px;
    padding: 0 4px;
}
.message.user .message-time { text-align: right; }

/* Tool call block */
.tool-call-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: 6px 0;
    overflow: hidden;
}

.tool-call-header {
    padding: 5px 10px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tool-call-body {
    padding: 8px 10px;
    font-size: 11px;
    color: var(--gray-500);
    white-space: pre-wrap;
    word-break: break-all;
    font-family: var(--font-mono);
}

/* Typing indicator */
.typing-indicator { display: flex; gap: 4px; padding: 10px 14px; }
.typing-indicator span {
    width: 5px; height: 5px;
    background: var(--gray-600);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Chat input */
.chat-input-area {
    padding: 14px 28px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px 6px 6px 14px;
    transition: border-color var(--transition);
}

.input-wrapper:focus-within { border-color: var(--gray-500); }

#chatInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--gray-200);
    font-size: 13px;
    padding: 5px 0;
    min-height: 22px;
    max-height: 140px;
}
#chatInput:focus { box-shadow: none; }
#chatInput::placeholder { color: var(--gray-700); }

.attach-btn, .send-btn {
    width: 30px; height: 30px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.attach-btn {
    background: transparent;
    color: var(--gray-600);
    font-size: 14px;
}
.attach-btn:hover { color: var(--gray-300); }

.send-btn {
    background: var(--white);
    color: var(--bg);
    font-size: 12px;
}
.send-btn:hover { opacity: 0.85; transform: scale(1.04); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

.input-hints {
    display: flex; align-items: center; gap: 8px;
    margin-top: 7px; font-size: 10px; color: var(--gray-700);
}
.hint-separator { color: var(--border-hi); }

/* ══════════════════════════════════════════
   SEARCH VIEWS
   ══════════════════════════════════════════ */
.search-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.search-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.search-box {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 9px 14px;
    transition: border-color var(--transition);
}
.search-box:focus-within { border-color: var(--gray-500); }

.search-box i { color: var(--gray-600); font-size: 14px; }
.search-box input {
    background: transparent; border: none;
    color: var(--gray-200); font-size: 14px;
    padding: 2px 0;
}
.search-box input:focus { box-shadow: none; }
.search-box input::placeholder { color: var(--gray-700); }

.search-box button {
    background: var(--white);
    color: var(--bg);
    padding: 7px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: opacity var(--transition);
}
.search-box button:hover { opacity: 0.85; }

.search-results { flex: 1; overflow-y: auto; padding: 20px 24px; }

.search-placeholder {
    text-align: center; padding: 80px 20px; color: var(--gray-700);
}
.search-placeholder i { font-size: 32px; margin-bottom: 14px; opacity: 0.4; }
.search-placeholder p { font-size: 13px; }

.search-result-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 10px;
    transition: all var(--transition);
}
.search-result-item:hover {
    border-color: var(--border-hi);
    background: var(--bg-hover);
}

.search-result-title {
    font-size: 14px; font-weight: 500;
    color: var(--white); margin-bottom: 4px;
    text-decoration: none; display: block;
}
.search-result-title:hover { text-decoration: underline; }

.search-result-url {
    font-size: 11px; color: var(--gray-600);
    margin-bottom: 6px; font-family: var(--font-mono);
}

.search-result-snippet {
    font-size: 12px; color: var(--gray-400); line-height: 1.55;
}

/* Image results */
.image-results { flex: 1; overflow-y: auto; padding: 20px 24px; }

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.image-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition);
    cursor: pointer;
}
.image-card:hover {
    border-color: var(--gray-600);
    transform: translateY(-2px);
}

.image-card img {
    width: 100%; height: 140px;
    object-fit: cover;
    display: block;
}

.image-card-info {
    padding: 8px 10px;
    font-size: 11px; color: var(--gray-600);
    font-family: var(--font-mono);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ══════════════════════════════════════════
   RIGHT PANEL
   ══════════════════════════════════════════ */
.sidebar-right {
    width: var(--panel-w);
    min-width: var(--panel-w);
    background: var(--bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.right-panel-header {
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.right-panel-header h3 {
    font-size: 12px; font-weight: 500;
    color: var(--gray-400);
    margin-bottom: 10px;
    display: flex; align-items: center; gap: 7px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.right-panel-tabs { display: flex; gap: 2px; }

.tab-btn {
    flex: 1; padding: 5px 6px;
    font-size: 11px; font-weight: 400;
    color: var(--gray-600);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    text-align: center;
}
.tab-btn:hover { background: var(--bg-hover); color: var(--gray-400); }
.tab-btn.active { background: var(--white); color: var(--bg); font-weight: 500; }

.right-panel-content { flex: 1; overflow-y: auto; padding: 10px; }
.right-panel-content.hidden { display: none; }

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; gap: 6px; }

.activity-empty {
    text-align: center; padding: 48px 16px; color: var(--gray-700);
}
.activity-empty i { font-size: 22px; margin-bottom: 10px; opacity: 0.3; }
.activity-empty p { font-size: 12px; margin-bottom: 3px; color: var(--gray-600); }
.activity-empty span { font-size: 11px; opacity: 0.6; }

.activity-item {
    display: flex; gap: 9px;
    padding: 9px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    animation: act-in 0.2s ease;
}
@keyframes act-in {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: translateX(0); }
}

.activity-icon {
    width: 24px; height: 24px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; flex-shrink: 0;
    border: 1px solid var(--border);
    color: var(--gray-400);
    background: var(--bg);
}
.activity-icon.tool       { color: var(--gray-300); border-color: var(--border-hi); }
.activity-icon.message    { color: var(--white); border-color: var(--white); background: var(--bg); }
.activity-icon.error      { color: var(--gray-400); border-color: var(--gray-700); }
.activity-icon.info       { color: var(--gray-500); }
.activity-icon.processing { color: var(--gray-400); animation: pulse-dot 1.5s infinite; }

.activity-info { flex: 1; min-width: 0; }
.activity-desc {
    font-size: 11px; color: var(--gray-300);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.activity-details {
    font-size: 10px; color: var(--gray-700);
    margin-top: 2px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    font-family: var(--font-mono);
}
.activity-time {
    font-size: 9px; color: var(--gray-700);
    flex-shrink: 0; margin-top: 1px;
}

/* Files tree */
.files-tree { font-family: var(--font-mono); font-size: 11px; }

.files-empty {
    text-align: center; padding: 48px 16px; color: var(--gray-700);
}
.files-empty i { font-size: 22px; margin-bottom: 10px; opacity: 0.3; }
.files-empty p { font-size: 12px; margin-bottom: 3px; color: var(--gray-600); }
.files-empty span { font-size: 11px; opacity: 0.6; }

.file-item {
    display: flex; align-items: center; gap: 7px;
    padding: 5px 8px; border-radius: var(--radius-sm);
    color: var(--gray-500); cursor: pointer;
    transition: all var(--transition);
}
.file-item:hover { background: var(--bg-hover); color: var(--gray-300); }
.file-item i { font-size: 11px; }
.file-item.folder i { color: var(--gray-600); }
.file-item.file i   { color: var(--gray-700); }

/* Tokens */
.tokens-overview { display: flex; flex-direction: column; gap: 8px; }

.token-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}
.token-label {
    font-size: 9px; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--gray-700); margin-bottom: 5px;
}
.token-value {
    font-size: 22px; font-weight: 300;
    color: var(--white); letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.token-chart {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px;
    height: 110px;
}
.token-chart canvas { width: 100% !important; height: 100% !important; }

/* ══════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════ */
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    animation: modal-bg 0.15s ease;
}
@keyframes modal-bg { from { opacity: 0; } to { opacity: 1; } }
.modal.hidden { display: none; }

.modal-content {
    background: var(--bg);
    border: 1px solid var(--border-hi);
    border-radius: var(--radius-lg);
    width: 90%; max-width: 560px;
    max-height: 82vh;
    overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 24px 60px rgba(0,0,0,0.6);
    animation: modal-in 0.2s ease;
}
.modal-large { max-width: 700px; }

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.97) translateY(16px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 {
    font-size: 13px; font-weight: 500;
    display: flex; align-items: center; gap: 9px;
    color: var(--white);
}
.modal-close {
    width: 28px; height: 28px;
    border-radius: var(--radius-sm);
    color: var(--gray-600); font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--gray-300); }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 8px;
}

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; font-size: 11px; font-weight: 500;
    color: var(--gray-500); margin-bottom: 5px;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.form-group input, .form-group textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    font-size: 13px;
    color: var(--gray-200);
    transition: border-color var(--transition);
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--gray-500); }
.form-group textarea { min-height: 70px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-hint { display: block; font-size: 10px; color: var(--gray-700); margin-top: 4px; font-family: var(--font-mono); }

/* Provider cards */
.providers-grid { display: flex; flex-direction: column; gap: 10px; }

.provider-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    transition: border-color var(--transition);
}
.provider-card:hover { border-color: var(--border-hi); }

.provider-card-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 12px;
}
.provider-logo {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
    border: 1px solid var(--border-hi);
    color: var(--gray-300);
    background: var(--bg);
}
.provider-card-title { font-weight: 500; font-size: 13px; color: var(--white); }
.custom-badge {
    font-size: 9px; font-weight: 400;
    color: var(--gray-500);
    border: 1px solid var(--border-hi);
    padding: 1px 6px; border-radius: 3px;
    margin-left: 4px; text-transform: uppercase; letter-spacing: 0.05em;
}
.provider-card-status {
    margin-left: auto; font-size: 10px;
    padding: 2px 7px; border-radius: 3px;
    border: 1px solid var(--border);
    color: var(--gray-500);
}
.provider-card-status.enabled  { color: var(--white); border-color: var(--gray-600); background: var(--bg-hover); }
.provider-card-status.disabled { color: var(--gray-700); }

.provider-card input[type="text"],
.provider-card input[type="password"] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 9px;
    font-size: 12px;
    color: var(--gray-300);
    margin-bottom: 5px;
}
.provider-card input:focus { border-color: var(--gray-500); }

.provider-models { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.model-tag {
    font-size: 10px; padding: 2px 7px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--gray-600);
    font-family: var(--font-mono);
}
.model-tag small { opacity: 0.7; margin-left: 3px; }

/* Buttons */
.btn-primary {
    background: var(--white);
    color: var(--bg);
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 500;
    transition: opacity var(--transition);
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
    background: transparent;
    color: var(--gray-500);
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 400;
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--gray-600); color: var(--gray-300); }

/* Spinner */
.spinner {
    width: 14px; height: 14px;
    border: 1.5px solid var(--gray-700);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Live badge */
.live-badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 10px; color: var(--gray-400);
    border: 1px solid var(--border);
    padding: 2px 7px; border-radius: 3px;
    font-family: var(--font-mono);
    text-transform: uppercase; letter-spacing: 0.05em;
}
.live-badge::before {
    content: '';
    width: 5px; height: 5px;
    background: var(--white);
    border-radius: 50%;
    animation: pulse-dot 1.5s infinite;
}

/* Add provider form */
.add-provider-form {
    background: var(--bg-card);
    border: 1px solid var(--border-hi);
    border-radius: var(--radius-md);
    margin-bottom: 14px;
    overflow: hidden;
    animation: slide-down 0.2s ease;
}
@keyframes slide-down {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.add-provider-form-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.add-provider-form-header h4 {
    font-size: 11px; font-weight: 500; color: var(--gray-400);
    display: flex; align-items: center; gap: 7px;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.add-provider-form-body { padding: 14px; }
.add-provider-form-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 12px; padding-top: 12px;
    border-top: 1px solid var(--border);
}

.models-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 8px; }

.model-row { display: flex; gap: 8px; align-items: center; }
.model-row input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 9px;
    font-size: 12px;
    color: var(--gray-200);
    transition: border-color var(--transition);
}
.model-row input:focus { border-color: var(--gray-500); }
.model-row .model-id {
    max-width: 190px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--gray-400);
}
.model-row .model-name { flex: 1; }

.btn-remove-model {
    width: 26px; height: 26px;
    border-radius: var(--radius-sm);
    color: var(--gray-700);
    font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: transparent;
}
.btn-remove-model:hover { border-color: var(--gray-600); color: var(--gray-400); background: var(--bg-hover); }

.btn-add-model {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; color: var(--gray-600);
    padding: 5px 10px;
    border: 1px dashed var(--border-hi);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.btn-add-model:hover { border-color: var(--gray-500); color: var(--gray-400); }

.btn-remove-provider {
    width: 26px; height: 26px;
    border-radius: var(--radius-sm);
    color: var(--gray-700);
    font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: transparent;
}
.btn-remove-provider:hover { border-color: var(--gray-600); color: var(--gray-400); }

.btn-test-provider {
    width: 26px; height: 26px;
    border-radius: var(--radius-sm);
    color: var(--gray-700);
    font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: transparent;
}
.btn-test-provider:hover { border-color: var(--gray-500); color: var(--gray-300); }
.btn-test-provider:disabled { opacity: 0.4; cursor: not-allowed; }

.provider-card-custom { border-style: dashed; border-color: var(--gray-700); }

/* Popup modale aggiungi provider */
.lm-modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.lm-modal-card { width: 100%; max-width: 540px; max-height: 88vh; overflow-y: auto; margin: 0; }

.empty-providers {
    text-align: center; padding: 48px 20px; color: var(--gray-700);
}
.empty-providers i { font-size: 26px; margin-bottom: 12px; opacity: 0.3; }
.empty-providers p { font-size: 13px; margin-bottom: 3px; color: var(--gray-600); }
.empty-providers span { font-size: 11px; opacity: 0.6; }

/* Config preview */
.config-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--gray-500);
    overflow: auto;
    max-height: 380px;
    white-space: pre;
    line-height: 1.6;
}

/* ══════════════════════════════════════════
   LMSTUDIO WORKBENCH (dashboard user/admin)
   ══════════════════════════════════════════ */
.lm-shell { display: flex; flex-direction: column; height: 100vh; background: var(--bg); }
.lm-topbar {
    height: 52px; flex-shrink: 0;
    display: flex; align-items: center; gap: 12px;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.lm-brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 13px; color: var(--white); white-space: nowrap; }
.lm-brand .logo-icon { width: 26px; height: 26px; background: var(--white); color: var(--bg); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.lm-model-pill {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-card); border: 1px solid var(--border-hi);
    border-radius: 999px; padding: 5px 6px 5px 12px;
    margin: 0 auto; max-width: 560px; flex: 1; justify-content: center;
}
.lm-model-pill select {
    background: transparent; border: none; color: var(--gray-200);
    font-size: 12px; font-weight: 500; width: auto; padding: 2px 4px;
}
.lm-model-pill select:focus { box-shadow: none; }
.lm-model-pill select option { background: var(--bg-card); }
.lm-status { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--gray-500); font-family: var(--font-mono); white-space: nowrap; }
.lm-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gray-700); }
.lm-dot.on { background: #4cc38a; box-shadow: 0 0 8px rgba(76,195,138,.6); }
.lm-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--gray-700); color: var(--white); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.lm-body { display: flex; flex: 1; min-height: 0; }
.lm-rail { width: 56px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 4px; background: var(--bg); }
.lm-rail-btn { width: 40px; height: 40px; border-radius: 10px; color: var(--gray-600); font-size: 15px; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.lm-rail-btn:hover { background: var(--bg-hover); color: var(--gray-300); }
.lm-rail-btn.active { background: var(--bg-hover); color: var(--white); border: 1px solid var(--border-hi); }
.lm-rail .spacer { flex: 1; }
.lm-convs { width: 264px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg); }
.lm-convs-head { padding: 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.lm-search { display: flex; align-items: center; gap: 8px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; color: var(--gray-600); font-size: 12px; }
.lm-search input { background: transparent; border: none; padding: 0; font-size: 12px; }
.lm-search input:focus { box-shadow: none; }
.lm-newchat { width: 100%; background: var(--white); color: var(--bg); border-radius: 8px; padding: 8px; font-size: 12px; font-weight: 600; }
.lm-newchat:hover { opacity: .88; }
.lm-conv-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.lm-conv { text-align: left; padding: 9px 10px; border-radius: 8px; color: var(--gray-500); border: 1px solid transparent; width: 100%; }
.lm-conv:hover { background: var(--bg-hover); color: var(--gray-300); }
.lm-conv.active { background: var(--bg-hover); color: var(--white); border-color: var(--border-hi); }
.lm-conv .t { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lm-conv .s { font-size: 10px; color: var(--gray-700); font-family: var(--font-mono); margin-top: 2px; }
.lm-convs-foot { padding: 10px 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--gray-600); }
.lm-meter { height: 4px; background: var(--bg-hover); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.lm-meter > div { height: 100%; background: var(--white); border-radius: 2px; }
.lm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.lm-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.lm-view.hidden { display: none; }
.lm-thread { flex: 1; overflow-y: auto; padding: 28px; display: flex; flex-direction: column; gap: 18px; max-width: 860px; width: 100%; margin: 0 auto; }
.lm-empty { margin: auto; text-align: center; max-width: 520px; padding: 40px 20px; }
.lm-empty .big { width: 56px; height: 56px; border-radius: 14px; background: var(--white); color: var(--bg); font-size: 24px; display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; }
.lm-empty h2 { color: var(--white); font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.lm-empty p { color: var(--gray-500); font-size: 13px; margin-bottom: 20px; }
.lm-sugg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.lm-sugg button { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 12px; color: var(--gray-400); font-size: 12px; }
.lm-sugg button:hover { border-color: var(--gray-600); color: var(--white); }
.lm-msg { display: flex; gap: 10px; max-width: 100%; }
.lm-msg.user { justify-content: flex-end; }
.lm-bubble { max-width: 82%; padding: 11px 15px; border-radius: 14px; font-size: 13px; line-height: 1.65; border: 1px solid var(--border); background: var(--bg-card); color: var(--gray-200); }
.lm-msg.user .lm-bubble { background: var(--white); color: var(--bg); border-color: var(--white); border-bottom-right-radius: 4px; }
.lm-msg.assistant .lm-bubble { border-bottom-left-radius: 4px; }
.lm-meta { font-size: 10px; color: var(--gray-700); margin-top: 4px; font-family: var(--font-mono); }
.lm-composer { padding: 14px 28px 18px; border-top: 1px solid var(--border); }
.lm-box { max-width: 860px; margin: 0 auto; background: var(--bg-card); border: 1px solid var(--border-hi); border-radius: 14px; padding: 8px 8px 8px 14px; }
.lm-box:focus-within { border-color: var(--gray-500); }
.lm-box textarea { background: transparent; border: none; min-height: 22px; max-height: 140px; font-size: 13px; }
.lm-box textarea:focus { box-shadow: none; }
.lm-tools { display: flex; align-items: center; gap: 6px; padding: 6px 2px 2px; }
.lm-chip { font-size: 11px; color: var(--gray-500); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; }
.lm-chip.on { color: var(--bg); background: var(--white); border-color: var(--white); }
.lm-send { width: 32px; height: 32px; border-radius: 9px; background: var(--white); color: var(--bg); display: flex; align-items: center; justify-content: center; }
.lm-send:disabled { opacity: .3; }
.lm-inspector { width: 300px; flex-shrink: 0; border-left: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg); }
.lm-inspector.hidden { display: none; }
.lm-tabs { display: flex; gap: 4px; padding: 10px 10px 0; }
.lm-tab { flex: 1; font-size: 11px; padding: 7px; border-radius: 8px; color: var(--gray-600); }
.lm-tab.active { background: var(--white); color: var(--bg); font-weight: 600; }
.lm-pane { flex: 1; overflow-y: auto; padding: 12px; display: none; }
.lm-pane.active { display: block; }
.lm-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--white); color: var(--bg); font-size: 12px; font-weight: 500; padding: 10px 18px; border-radius: 999px; z-index: 2000; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.lm-table { width: 100%; border-collapse: collapse; }
.lm-table th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-600); padding: 8px 12px; border-bottom: 1px solid var(--border); }
.lm-table td { font-size: 12px; color: var(--gray-400); padding: 9px 12px; border-bottom: 1px solid var(--border); }
@media (max-width: 1100px) { .lm-inspector { display: none; } .lm-convs { width: 220px; } }
@media (max-width: 820px) { .lm-convs { display: none; } .lm-rail { display: none; } }
