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

:root {
    --bg:          #1e1e1e;
    --bg2:         #252526;
    --bg3:         #2d2d2d;
    --bg4:         #333333;
    --sidebar-bg:  #181818;
    --topbar-bg:   #111111;
    --border:      #3a3a3a;
    --border2:     #444;
    --text:        #d4d4d4;
    --text-muted:  #888;
    --text-dim:    #666;
    --text-bright: #ffffff;
    --accent:      #0036B0;
    --accent-h:    #002890;
    --accent-rgb:  0,54,176;
    --blue:        #569cd6;
    --green:       #4ec9b0;
    --red:         #f44747;
    --yellow:      #dcdcaa;
    --purple:      #c586c0;
    --topbar-h:    44px;
    --sidebar-w:   280px;
    --radius:      6px;
    --radius-lg:   12px;
    --radius-xl:   16px;
    --btn-radius:  8px;
    /* Method colors */
    --get:    #61affe;
    --post:   #49cc90;
    --put:    #fca130;
    --patch:  #50e3c2;
    --delete: #f93e3e;
    --head:   #9012fe;
    --options:#0d5aa7;
}

/* ========== Light Theme ========== */
[data-theme="light"] {
    --bg:          #f5f7fa;
    --bg2:         #ffffff;
    --bg3:         #f0f2f5;
    --bg4:         #e4e7ed;
    --sidebar-bg:  #eef0f5;
    --topbar-bg:   #ffffff;
    --border:      #dde1e8;
    --border2:     #c8cdd6;
    --text:        #1f2328;
    --text-muted:  #656d76;
    --text-dim:    #8c959f;
    --text-bright: #1f2328;
    --accent:      #0036B0;
    --accent-h:    #002890;
    --accent-rgb:  0,54,176;
    --red:         #d1242f;
}

[data-theme="light"] html,
[data-theme="light"] body { background: var(--bg); color: var(--text); }
[data-theme="light"] a { color: var(--accent); }
[data-theme="light"] input, [data-theme="light"] textarea, [data-theme="light"] select {
    color: var(--text); background: var(--bg2); border-color: var(--border);
}
[data-theme="light"] code { background: var(--bg3); color: var(--accent); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--border2); }

/* Topbar light */
[data-theme="light"] .topbar { background: var(--topbar-bg); border-bottom-color: var(--border); }
[data-theme="light"] .topbar-sep { color: var(--text-dim); }
[data-theme="light"] .project-title { color: var(--text); }
[data-theme="light"] .topbar-app-link { color: var(--text-muted); }
[data-theme="light"] .user-badge { background: var(--bg3); color: var(--text-muted); }

/* Sidebar light */
[data-theme="light"] .sidebar { background: var(--sidebar-bg); border-right-color: var(--border); }
[data-theme="light"] .sidebar-actions { border-bottom-color: var(--border); }
[data-theme="light"] .sidebar-search { border-bottom-color: var(--border); }
[data-theme="light"] .sidebar-search input { background: var(--bg2); }
[data-theme="light"] .folder-header { color: var(--text); }
[data-theme="light"] .folder-header:hover { background: var(--bg3); }
[data-theme="light"] .tree-request { color: var(--text-muted); }
[data-theme="light"] .tree-request:hover { background: var(--bg3); color: var(--text); }
[data-theme="light"] .tree-request.active { background: rgba(var(--accent-rgb),0.09); color: var(--text); }
[data-theme="light"] .sidebar-saved-item { color: var(--text-dim); }
[data-theme="light"] .sidebar-saved-item:hover { background: var(--bg3); color: var(--text); }

/* Request editor light */
[data-theme="light"] .request-name-bar { background: var(--bg2); border-bottom-color: var(--border); }
[data-theme="light"] .req-name-input { color: var(--text); }
[data-theme="light"] .url-bar { background: var(--bg2); border-bottom-color: var(--border); }
[data-theme="light"] .url-bar select { background: var(--bg3); }
[data-theme="light"] .req-tabs { background: var(--bg2); border-bottom-color: var(--border); }
[data-theme="light"] .tab-panel { background: var(--bg); }
[data-theme="light"] .kv-toolbar { background: var(--bg2); border-bottom-color: var(--border); }
[data-theme="light"] .kv-table thead th { background: var(--bg3); }
[data-theme="light"] .kv-table tbody tr:hover { background: var(--bg3); }
[data-theme="light"] .kv-table td { border-bottom-color: var(--border); }
[data-theme="light"] .body-type-bar { background: var(--bg2); border-bottom-color: var(--border); }
[data-theme="light"] .body-content-type-bar { background: var(--bg2); border-bottom-color: var(--border); }
[data-theme="light"] .body-textarea { background: var(--bg); color: var(--text); }

/* Response section light */
[data-theme="light"] .response-section { background: var(--bg); border-top-color: var(--border); }
[data-theme="light"] .response-header { background: var(--bg2); border-bottom-color: var(--border); }
[data-theme="light"] .res-tabs { background: var(--bg2); border-bottom-color: var(--border); }
[data-theme="light"] .res-body-toolbar { background: var(--bg2); border-bottom-color: var(--border); }
[data-theme="light"] .response-body-pre { color: var(--text); }
[data-theme="light"] .json-key { color: #0550ae; }
[data-theme="light"] .json-string { color: #0a3069; }
[data-theme="light"] .json-number { color: #953800; }
[data-theme="light"] .json-boolean, [data-theme="light"] .json-null { color: #0036B0; }

/* Docs editor light */
[data-theme="light"] .docs-toolbar { background: var(--bg2); border-bottom-color: var(--border); }
[data-theme="light"] .docs-btn { background: var(--bg3); color: var(--text); border-color: var(--border); }
[data-theme="light"] .docs-btn:hover { background: var(--bg4); }
[data-theme="light"] .docs-editor { background: var(--bg); color: var(--text); }
[data-theme="light"] .docs-editor pre, [data-theme="light"] .docs-editor code { background: var(--bg3); color: var(--text); }

/* Saved list light */
[data-theme="light"] .saved-item { border-color: var(--border); }
[data-theme="light"] .saved-item:hover { background: var(--bg3); }

/* Modal light */
[data-theme="light"] .modal { background: var(--bg2); border-color: var(--border2); }
[data-theme="light"] .modal-header { border-bottom-color: var(--border); }
[data-theme="light"] .modal-header h3 { color: var(--text); }
[data-theme="light"] .modal-footer { border-top-color: var(--border); }
[data-theme="light"] .modal-close { color: var(--text-muted); }
[data-theme="light"] .modal-close:hover { color: var(--text); background: var(--bg3); }
[data-theme="light"] .modal-overlay { background: rgba(0,0,0,0.35); }

/* Context menu light */
[data-theme="light"] .context-menu { background: var(--bg2); border-color: var(--border2); box-shadow: 0 4px 16px rgba(0,0,0,0.15); }
[data-theme="light"] .ctx-item { color: var(--text); }
[data-theme="light"] .ctx-item:hover { background: var(--bg3); }
[data-theme="light"] .ctx-sep { background: var(--border); }

/* Console / auth light */
[data-theme="light"] .console-page { background: var(--bg); }
[data-theme="light"] .console-sidebar { background: var(--sidebar-bg); border-right-color: var(--border); }
[data-theme="light"] .cs-logo { color: var(--text); border-bottom-color: var(--border); }
[data-theme="light"] .cs-nav-item { color: var(--text-muted); }
[data-theme="light"] .cs-nav-item:hover { background: var(--bg3); color: var(--text); }
[data-theme="light"] .cs-nav-item.active { background: rgba(var(--accent-rgb),0.09); color: var(--accent); }
[data-theme="light"] .cs-sidebar-footer { border-top-color: var(--border); }
[data-theme="light"] .cs-username { color: var(--text); }
[data-theme="light"] .console-topbar { background: var(--bg2); border-bottom-color: var(--border); }
[data-theme="light"] .console-title { color: var(--text); }
[data-theme="light"] .app-tile { background: var(--bg2); border-color: var(--border); color: var(--text); }
[data-theme="light"] .app-tile:hover { background: var(--bg3); }
[data-theme="light"] .app-tile-body h3 { color: var(--text); }
[data-theme="light"] .project-card { background: var(--bg2); border-color: var(--border); }
[data-theme="light"] .project-meta h3 { color: var(--text); }

[data-theme="light"] .auth-page { background: var(--bg3); }
[data-theme="light"] .auth-card { background: var(--bg2); border-color: var(--border); }
[data-theme="light"] .auth-card h2 { color: var(--text); }
[data-theme="light"] .auth-logo { color: var(--text); }

/* Admin light */
[data-theme="light"] .admin-table-wrap { background: var(--bg2); border-color: var(--border); }
[data-theme="light"] .admin-table thead th { background: var(--bg3); }
[data-theme="light"] .admin-table tbody tr { border-bottom-color: var(--border); }
[data-theme="light"] .admin-table tbody tr:hover { background: var(--bg3); }
[data-theme="light"] .team-member { background: var(--bg3); border-color: var(--border); }
[data-theme="light"] .aab { background: var(--bg3); border-color: var(--border); color: var(--text-muted); }
[data-theme="light"] .aab.active { background: rgba(var(--accent-rgb),0.09); border-color: var(--accent); color: var(--accent); }
[data-theme="light"] .app-access-toolbar { background: var(--bg3); border-bottom-color: var(--border); }
[data-theme="light"] .uap-row { border-bottom-color: var(--border); }
[data-theme="light"] .uap-app-name { color: var(--text); }

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 13px; color: var(--text); background: var(--bg); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, textarea, select { font-family: inherit; font-size: 13px; color: var(--text); background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
button { cursor: pointer; font-family: inherit; font-size: 13px; border: none; border-radius: var(--btn-radius); outline: none; }
code { font-family: 'Menlo', 'Consolas', monospace; font-size: 12px; background: var(--bg4); padding: 1px 4px; border-radius: 3px; color: var(--accent); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ========== Buttons ========== */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 16px; border-radius: var(--btn-radius); font-size: 13px; font-weight: 500; transition: background 0.15s, opacity 0.15s, box-shadow 0.15s, transform 0.1s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(var(--accent-rgb),0.35); }
.btn-primary:hover { background: var(--accent-h); box-shadow: 0 4px 10px rgba(var(--accent-rgb),0.45); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border2); }
.btn-ghost:hover { background: var(--bg4); border-color: var(--accent); color: var(--text-bright); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(var(--accent-rgb),0.35); }
.btn-accent:hover { background: var(--accent-h); box-shadow: 0 4px 10px rgba(var(--accent-rgb),0.45); }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-xs { padding: 3px 9px; font-size: 11px; border-radius: 5px; }
.btn-block { width: 100%; justify-content: center; }
.btn-send { background: var(--accent); color: #fff; padding: 0 22px; border-radius: 0 var(--btn-radius) var(--btn-radius) 0; font-weight: 600; font-size: 13px; height: 36px; white-space: nowrap; box-shadow: none; }
.btn-send:hover { background: var(--accent-h); }
.btn-icon { background: transparent; color: var(--text-muted); padding: 5px; border-radius: var(--btn-radius); display: inline-flex; align-items: center; justify-content: center; transition: color 0.15s, background 0.15s; }
.btn-icon:hover { color: var(--text); background: var(--bg4); }


/* ========== Topbar ========== */
.topbar { height: var(--topbar-h); background: var(--topbar-bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 12px; gap: 12px; flex-shrink: 0; z-index: 100; }
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--text-bright); }
.logo-link { display: flex; align-items: center; opacity: 0.9; }
.logo-link:hover { opacity: 1; }
.topbar-sep { color: var(--text-dim); font-size: 16px; }
.project-title { font-weight: 600; color: var(--text); font-size: 14px; }
.user-badge { color: var(--text-muted); font-size: 12px; padding: 3px 8px; background: var(--bg3); border-radius: 12px; }

/* ========== Auth Pages ========== */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #141414; }
.auth-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 36px 32px; width: 100%; max-width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,0.35); }
.auth-logo { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; color: var(--text-bright); margin-bottom: 24px; }
.auth-card h2 { font-size: 20px; font-weight: 600; color: var(--text-bright); margin-bottom: 20px; }
.auth-error { background: rgba(249,62,62,0.12); border: 1px solid rgba(249,62,62,0.3); color: #f93e3e; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.auth-success { background: rgba(73,204,144,0.12); border: 1px solid rgba(73,204,144,0.3); color: #49cc90; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.auth-footer { margin-top: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 8px 10px; }
.form-group textarea { resize: vertical; }

/* ========== Dashboard ========== */
.dashboard-page { display: flex; flex-direction: column; height: 100vh; }
.dashboard-page .topbar { position: sticky; top: 0; }
.dashboard-body { flex: 1; overflow-y: auto; padding: 32px 40px; max-width: 1100px; margin: 0 auto; width: 100%; }
.dashboard-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.dashboard-header h1 { font-size: 22px; font-weight: 700; color: var(--text-bright); }
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.project-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; cursor: pointer; transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s; position: relative; }
.project-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(var(--accent-rgb),0.15); }
.project-card-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.project-icon { width: 40px; height: 40px; background: var(--accent); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: #fff; flex-shrink: 0; }
.project-meta { flex: 1; min-width: 0; }
.project-meta h3 { font-size: 14px; font-weight: 600; color: var(--text-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.owner-tag { font-size: 11px; color: var(--text-dim); }
.project-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-stats { display: flex; gap: 14px; font-size: 11px; color: var(--text-dim); border-top: 1px solid var(--border); padding-top: 10px; }
.delete-project-btn { opacity: 0; transition: opacity 0.15s; color: var(--red) !important; }
.project-card:hover .delete-project-btn { opacity: 1; }
.empty-state { grid-column: 1/-1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 80px 20px; color: var(--text-dim); }
.empty-state p { font-size: 14px; }

/* ========== Project Page Layout ========== */
.project-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.workspace { display: flex; flex: 1; overflow: hidden; }

/* ========== Sidebar ========== */
.sidebar { width: var(--sidebar-w); min-width: 180px; max-width: 480px; background: var(--sidebar-bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; }
.sidebar-actions { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--border); }
.sidebar-btn { flex: 1; justify-content: center; gap: 4px; }
.sidebar-search { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.sidebar-search input { width: 100%; padding: 5px 8px; background: var(--bg3); }
.sidebar-tree { flex: 1; overflow-y: auto; padding: 4px 0; }
.loading-spinner { color: var(--text-dim); padding: 20px; text-align: center; font-size: 12px; }

/* Folder/Request items */
.tree-folder { }
.folder-header { display: flex; align-items: center; gap: 4px; padding: 5px 8px; cursor: pointer; border-radius: 3px; user-select: none; color: var(--text); }
.folder-header:hover { background: var(--bg3); }
.folder-icon { font-size: 11px; transition: transform 0.15s; display: inline-block; color: var(--text-muted); }
.folder-icon.open { transform: rotate(90deg); }
.folder-name { flex: 1; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-actions { display: none; gap: 2px; }
.folder-header:hover .folder-actions { display: flex; }
.folder-children { padding-left: 14px; }
.folder-children.collapsed { display: none; }

.tree-request { display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px 10px; cursor: pointer; border-radius: 3px; color: var(--text-muted); user-select: none; position: relative; }
.tree-request:hover { background: var(--bg3); color: var(--text); }
.tree-request.active { background: rgba(var(--accent-rgb),0.10); color: var(--text); border-right: 2px solid var(--accent); }
.req-method-badge { font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 2px; flex-shrink: 0; letter-spacing: 0.3px; min-width: 36px; text-align: center; }
.req-name { flex: 1; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.req-actions { display: none; gap: 2px; }
.tree-request:hover .req-actions { display: flex; }

/* Method badge colors */
.m-GET    { background: rgba(97,175,254,0.15); color: var(--get); }
.m-POST   { background: rgba(73,204,144,0.15); color: var(--post); }
.m-PUT    { background: rgba(252,161,48,0.15); color: var(--put); }
.m-PATCH  { background: rgba(80,227,194,0.15); color: var(--patch); }
.m-DELETE { background: rgba(249,62,62,0.15);  color: var(--delete); }
.m-HEAD   { background: rgba(144,18,254,0.15); color: var(--head); }
.m-OPTIONS{ background: rgba(13,90,167,0.15);  color: var(--options); }

/* Root-level requests (no folder) */
.root-requests { }

/* Saved responses in sidebar */
.tree-req-container { display: flex; flex-direction: column; }
.tree-req-saved { padding-left: 0; }
.tree-req-saved.collapsed { display: none; }
.sidebar-saved-item { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 28px; cursor: pointer; color: var(--text-dim); font-size: 11px; border-radius: 3px; }
.sidebar-saved-item:hover { background: var(--bg3); color: var(--text); }
.sidebar-saved-item .si-icon { flex-shrink: 0; opacity: 0.7; }
.sidebar-saved-item .si-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-saved-item .si-del { opacity: 0; color: var(--text-dim); }
.sidebar-saved-item:hover .si-del { opacity: 1; }
.saved-toggle { background: transparent; color: var(--text-dim); border: none; padding: 2px 3px; font-size: 9px; cursor: pointer; border-radius: 2px; transition: transform 0.15s; display: inline-block; flex-shrink: 0; }
.saved-toggle.open { transform: rotate(90deg); }
.saved-toggle:hover { color: var(--text); }

/* Drag & Drop */
.tree-request.dragging { opacity: 0.4; }
.folder-header.drag-over { background: rgba(var(--accent-rgb),0.15) !important; outline: 1px dashed var(--accent); }
.sidebar-tree.drag-over-root { background: rgba(var(--accent-rgb),0.06); outline: 1px dashed var(--border2); }
.drag-handle { cursor: grab; color: var(--text-dim); padding: 0 2px; opacity: 0; flex-shrink: 0; }
.tree-request:hover .drag-handle { opacity: 1; }

/* ========== Resize Handle ========== */
.resize-handle { width: 4px; background: transparent; cursor: col-resize; flex-shrink: 0; transition: background 0.15s; }
.resize-handle:hover, .resize-handle.dragging { background: var(--accent); }

/* ========== Right Panel ========== */
.right-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

/* Empty state */
.empty-request { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 12px; color: var(--text-dim); text-align: center; }
.empty-request h3 { font-size: 18px; font-weight: 600; color: var(--text-muted); }
.empty-request p { font-size: 13px; max-width: 300px; line-height: 1.5; }

/* ========== Request Editor ========== */
.request-editor { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.request-name-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg2); }
.req-name-input { flex: 1; background: transparent; border: none; font-size: 14px; font-weight: 600; color: var(--text); padding: 2px 0; }
.req-name-input:focus { border-bottom: 1px solid var(--accent); }
.req-name-actions { display: flex; align-items: center; gap: 6px; }

/* URL Bar */
.url-bar-wrap { position: relative; border-bottom: 1px solid var(--border); background: var(--bg2); }
.url-bar { display: flex; align-items: center; padding: 8px 12px; gap: 0; }
.url-bar select { border-radius: var(--radius) 0 0 var(--radius); border-right: none; padding: 0 8px; height: 36px; font-weight: 700; min-width: 90px; background: var(--bg3); }
.url-bar input { flex: 1; border-radius: 0; border-left: none; border-right: none; height: 36px; padding: 0 10px; font-family: 'Menlo', 'Consolas', monospace; font-size: 13px; }
.url-bar input:focus { z-index: 1; }

/* Resolved URL preview strip */
.url-resolved { display: none; align-items: center; gap: 6px; padding: 4px 12px 6px 14px; font-family: 'Menlo','Consolas',monospace; font-size: 11px; color: var(--text-dim); border-top: 1px dashed var(--border); overflow: hidden; }
.url-resolved.visible { display: flex; }
.url-resolved-label { font-family: inherit; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-dim); opacity: 0.7; flex-shrink: 0; }
.url-resolved-value { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); }
.url-resolved-value .rv-var { color: var(--accent); font-weight: 600; }
.url-resolved-value .rv-missing { color: var(--red); text-decoration: underline dashed; }

/* Variable suggestion dropdown */
.url-var-suggest { position: absolute; left: 12px; top: calc(100% + 2px); min-width: 260px; max-width: 400px; background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-lg); box-shadow: 0 8px 24px rgba(0,0,0,0.35); z-index: 600; overflow: hidden; display: none; }
.url-var-suggest.open { display: block; }
.url-var-suggest-header { padding: 7px 12px 5px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); border-bottom: 1px solid var(--border); }
.url-var-item { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px; cursor: pointer; font-size: 12px; gap: 10px; transition: background 0.1s; }
.url-var-item:hover, .url-var-item.selected { background: rgba(var(--accent-rgb),0.1); }
.url-var-item-key { font-family: 'Menlo','Consolas',monospace; font-weight: 600; color: var(--blue); }
.url-var-item-val { color: var(--text-dim); font-family: 'Menlo','Consolas',monospace; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.url-var-suggest-empty { padding: 10px 12px; font-size: 12px; color: var(--text-dim); text-align: center; }

/* Light theme */
[data-theme="light"] .url-bar-wrap { background: var(--bg2); border-bottom-color: var(--border); }
[data-theme="light"] .url-var-suggest { box-shadow: 0 8px 24px rgba(0,0,0,0.12); }

/* Method colors in select */
#req-method.m-GET    { color: var(--get); }
#req-method.m-POST   { color: var(--post); }
#req-method.m-PUT    { color: var(--put); }
#req-method.m-PATCH  { color: var(--patch); }
#req-method.m-DELETE { color: var(--delete); }
#req-method.m-HEAD   { color: var(--head); }
#req-method.m-OPTIONS{ color: var(--options); }

/* Request Tabs */
.req-tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--bg2); padding: 0 12px; }
.tab-btn { background: transparent; color: var(--text-muted); padding: 8px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 12px; font-weight: 500; border-radius: 0; display: flex; align-items: center; gap: 4px; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-badge { background: var(--accent); color: #fff; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 8px; min-width: 16px; text-align: center; }
.tab-badge:empty { display: none; }

/* Tab Panels */
.tab-panel { display: none; flex-direction: column; overflow: hidden; background: var(--bg); max-height: 220px; }
.tab-panel.active { display: flex; overflow-y: auto; }
.kv-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg2); }
.kv-hint { color: var(--text-dim); font-size: 11px; }

/* KV Table */
.kv-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.kv-table thead th { background: var(--bg2); color: var(--text-dim); padding: 6px 10px; text-align: left; font-weight: 500; font-size: 11px; border-bottom: 1px solid var(--border); }
.kv-table tbody tr:hover { background: var(--bg3); }
.kv-table td { padding: 3px 4px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.kv-table td:first-child { padding-left: 8px; }
.kv-table input { background: transparent; border: none; width: 100%; padding: 4px 6px; font-family: 'Menlo', 'Consolas', monospace; font-size: 12px; }
.kv-table input:focus { background: var(--bg4); border-radius: 2px; }
.col-check { width: 32px; }
.col-del { width: 32px; }
.kv-table input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }
.kv-del-btn { background: transparent; color: var(--text-dim); font-size: 14px; padding: 2px 6px; border-radius: 2px; }
.kv-del-btn:hover { color: var(--red); background: rgba(249,62,62,0.1); }

/* Body Tab */
.body-type-bar { display: flex; gap: 16px; padding: 10px 14px; background: var(--bg2); border-bottom: 1px solid var(--border); }
.body-type-bar label { display: flex; align-items: center; gap: 5px; color: var(--text-muted); cursor: pointer; font-size: 12px; }
.body-type-bar input[type="radio"] { accent-color: var(--accent); }
.body-content-type-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--bg2); border-bottom: 1px solid var(--border); }
.body-content-type-bar select { padding: 3px 6px; }
.body-textarea { flex: 1; width: 100%; border: none; border-radius: 0; background: var(--bg); color: var(--text); font-family: 'Menlo', 'Consolas', monospace; font-size: 12px; padding: 12px; resize: none; min-height: 120px; line-height: 1.6; }
.body-none-msg { padding: 24px; color: var(--text-dim); font-size: 12px; text-align: center; }
#body-raw-panel { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

/* ========== Docs Tab ========== */
#tab-docs { max-height: none; flex: 1; flex-direction: column; }
#tab-docs.active { display: flex; overflow: hidden; }
.docs-toolbar { display: flex; align-items: center; gap: 3px; padding: 6px 10px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.docs-btn { background: transparent; color: var(--text-muted); border: 1px solid transparent; border-radius: 3px; padding: 3px 7px; font-size: 12px; cursor: pointer; transition: background 0.12s, color 0.12s; }
.docs-btn:hover { background: var(--bg4); color: var(--text); border-color: var(--border2); }
.docs-sep { width: 1px; height: 16px; background: var(--border2); margin: 0 3px; flex-shrink: 0; }
.docs-editor { flex: 1; overflow-y: auto; padding: 16px 20px; color: var(--text); line-height: 1.7; font-size: 13px; outline: none; min-height: 120px; }
.docs-editor:empty::before { content: attr(data-placeholder); color: var(--text-dim); pointer-events: none; display: block; }
.docs-editor h1 { font-size: 20px; font-weight: 700; color: var(--text); margin: 12px 0 8px; }
.docs-editor h2 { font-size: 16px; font-weight: 600; color: var(--text); margin: 12px 0 6px; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.docs-editor h3 { font-size: 14px; font-weight: 600; color: var(--text); margin: 10px 0 4px; }
.docs-editor p { margin: 0 0 8px; }
.docs-editor ul, .docs-editor ol { padding-left: 20px; margin: 0 0 8px; }
.docs-editor li { margin-bottom: 2px; }
.docs-editor a { color: var(--accent); }
.docs-editor pre { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; font-family: 'Menlo', 'Consolas', monospace; font-size: 12px; overflow-x: auto; margin: 8px 0; white-space: pre-wrap; }
.docs-editor code { font-family: 'Menlo', 'Consolas', monospace; font-size: 12px; background: var(--bg4); padding: 1px 4px; border-radius: 3px; }
.docs-editor blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-muted); margin: 8px 0; }
.docs-editor strong { font-weight: 700; }
.docs-editor em { font-style: italic; }
.docs-editor u { text-decoration: underline; }

/* ========== Response Section ========== */
.response-section { border-top: 2px solid var(--border); display: flex; flex-direction: column; background: var(--bg); flex: 1; min-height: 200px; overflow: hidden; }
.response-header { display: flex; align-items: center; gap: 12px; padding: 7px 12px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.response-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.response-meta { display: flex; gap: 10px; align-items: center; flex: 1; }
.status-badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 3px; }
.status-2xx { background: rgba(73,204,144,0.15); color: #49cc90; }
.status-3xx { background: rgba(97,175,254,0.15); color: #61affe; }
.status-4xx { background: rgba(249,62,62,0.15); color: #f93e3e; }
.status-5xx { background: rgba(249,62,62,0.2); color: #ff6b6b; }
.meta-time, .meta-size { font-size: 11px; color: var(--text-dim); }
.response-loading { display: flex; align-items: center; gap: 10px; padding: 20px; color: var(--text-muted); flex: 1; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.res-tabs { display: flex; padding: 0 12px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
#response-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.res-tab-panel { display: none; flex: 1; overflow: auto; width: 100%; }
.res-tab-panel.active { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
#rtab-body.active { overflow: hidden; }
#rtab-res-headers.active, #rtab-saved.active { overflow-y: auto; }
.response-body-pre { flex: 1; padding: 12px; font-family: 'Menlo', 'Consolas', monospace; font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; color: var(--text); overflow-y: auto; overflow-x: auto; width: 100%; min-height: 0; }
.res-body-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 5px 12px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.res-format-btns { display: flex; gap: 2px; }
.rbtn { background: transparent; color: var(--text-dim); padding: 2px 8px; font-size: 11px; border-radius: 3px; border: 1px solid transparent; }
.rbtn.active { background: var(--bg4); color: var(--text); border-color: var(--border2); }
.rbtn:hover { color: var(--text); }
.res-headers-table { width: 100%; margin: 0; }
.res-headers-table td { font-family: 'Menlo', 'Consolas', monospace; font-size: 11px; padding: 5px 10px; }
.res-headers-table td:first-child { color: var(--text-muted); white-space: nowrap; }
.response-empty { display: flex; align-items: center; justify-content: center; flex: 1; color: var(--text-dim); font-size: 13px; }

/* JSON Syntax Highlight */
.json-string  { color: #ce9178; }
.json-number  { color: #b5cea8; }
.json-boolean { color: #569cd6; }
.json-null    { color: #569cd6; }
.json-key     { color: #9cdcfe; }

/* Saved responses list in response panel */
.saved-list { padding: 8px; }
.saved-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 6px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.saved-item:hover { border-color: var(--accent); background: var(--bg3); }
.saved-item-meta { flex: 1; }
.saved-item-name { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 3px; }
.saved-item-meta .si-time { font-size: 11px; color: var(--text-dim); }
.saved-empty-msg { padding: 24px; color: var(--text-dim); font-size: 12px; text-align: center; }

/* ========== Modals ========== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-lg); width: 480px; max-width: 95vw; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 16px 48px rgba(0,0,0,0.5); }
.modal-lg { width: 640px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; font-weight: 600; color: var(--text-bright); }
.modal-close { background: transparent; color: var(--text-muted); font-size: 20px; padding: 2px 6px; border-radius: 3px; line-height: 1; }
.modal-close:hover { color: var(--text-bright); background: var(--bg4); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Team Modal */
.add-member-row { display: flex; gap: 8px; margin-bottom: 16px; }
.add-member-row input { flex: 1; padding: 7px 10px; }
.add-member-row select { padding: 7px 8px; }
.flex-1 { flex: 1; }
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-member { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg3); border-radius: var(--radius); border: 1px solid var(--border); }
.member-avatar { width: 32px; height: 32px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.member-info { flex: 1; }
.member-name { font-size: 13px; font-weight: 500; color: var(--text); }
.member-email { font-size: 11px; color: var(--text-dim); }
.member-role { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 3px; text-transform: uppercase; }
.role-owner  { background: rgba(var(--accent-rgb),0.15); color: var(--accent); }
.role-admin  { background: rgba(97,175,254,0.15); color: var(--blue); }
.role-member { background: var(--bg4); color: var(--text-muted); }

/* Context Menu */
.context-menu { position: fixed; background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,0.4); z-index: 2000; min-width: 160px; overflow: hidden; }
.ctx-item { display: flex; align-items: center; gap: 8px; padding: 8px 14px; color: var(--text); cursor: pointer; font-size: 12px; }
.ctx-item:hover { background: var(--bg4); }
.ctx-item.danger { color: var(--red); }
.ctx-item.danger:hover { background: rgba(249,62,62,0.1); }
.ctx-sep { height: 1px; background: var(--border); margin: 3px 0; }

/* ========== Misc ========== */
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-red { color: var(--red) !important; }

/* ========== Console Layout ========== */
.console-page { height: 100vh; overflow: hidden; background: #141414; }
.console-layout { display: flex; height: 100%; }

/* Console Sidebar */
.console-sidebar { width: 240px; background: #111; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.cs-logo { display: flex; align-items: center; gap: 10px; padding: 18px 16px; font-size: 15px; font-weight: 700; color: var(--text-bright); border-bottom: 1px solid var(--border); }
.cs-nav { padding: 8px 8px; flex: 1; }
.cs-nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius); color: var(--text-muted); font-size: 13px; font-weight: 500; text-decoration: none; transition: background 0.12s, color 0.12s; margin-bottom: 2px; }
.cs-nav-item:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.cs-nav-item.active { background: rgba(var(--accent-rgb),0.12); color: var(--accent); }
.cs-nav-item.active svg { stroke: var(--accent); }
.cs-sidebar-footer { padding: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.cs-user { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.cs-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.cs-user-info { display: flex; flex-direction: column; min-width: 0; }
.cs-username { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-role { font-size: 10px; color: var(--text-dim); }
.cs-logout { color: var(--text-dim); padding: 6px; border-radius: var(--radius); display: flex; align-items: center; flex-shrink: 0; }
.cs-logout:hover { color: var(--red); background: rgba(249,62,62,0.1); }

/* Console Main */
.console-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.console-topbar { display: flex; align-items: flex-start; justify-content: space-between; padding: 28px 32px 20px; border-bottom: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; }
.console-title { font-size: 22px; font-weight: 700; color: var(--text-bright); margin-bottom: 4px; }
.console-subtitle { font-size: 13px; color: var(--text-muted); }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }

/* Application Tiles */
.app-tiles { display: flex; flex-direction: column; gap: 12px; padding: 24px 32px; overflow-y: auto; flex: 1; }
.app-tile { display: flex; align-items: center; gap: 20px; background: var(--bg2); border: 1px solid var(--border); border-left: 3px solid var(--app-color, var(--accent)); border-radius: var(--radius-lg); padding: 20px 24px; text-decoration: none; color: var(--text); transition: border-color 0.2s, background 0.15s, transform 0.15s, box-shadow 0.2s; }
.app-tile:hover { background: var(--bg3); border-color: var(--app-color, var(--accent)); transform: translateX(3px); text-decoration: none; box-shadow: 0 4px 16px rgba(0,0,0,0.2); }
.app-tile-icon { width: 52px; height: 52px; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: rgba(var(--accent-rgb),0.12); color: var(--accent); }
.app-tile-body { flex: 1; min-width: 0; }
.app-tile-body h3 { font-size: 15px; font-weight: 600; color: var(--text-bright); margin-bottom: 4px; }
.app-tile-body p { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.app-tile-stats { display: flex; gap: 14px; font-size: 11px; color: var(--text-dim); align-items: center; }
.app-role-tag { background: rgba(var(--accent-rgb),0.12); color: var(--accent); font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 3px; text-transform: uppercase; }
.app-tile-arrow { color: var(--text-dim); flex-shrink: 0; transition: transform 0.15s, color 0.15s; }
.app-tile:hover .app-tile-arrow { color: var(--app-color, var(--accent)); transform: translateX(4px); }

.console-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 12px; color: var(--text-dim); text-align: center; padding: 60px; }
.console-empty p { font-size: 15px; color: var(--text-muted); }
.console-empty span { font-size: 13px; }

/* Topbar app breadcrumb */
.topbar-app-link { color: var(--text-muted); font-size: 13px; text-decoration: none; }
.topbar-app-link:hover { color: var(--accent); }

/* Projects grid (used in app.php) */
.console-main .projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; padding: 24px 32px; overflow-y: auto; flex: 1; align-content: start; }

/* ========== Admin Panel ========== */
.admin-section { padding: 24px 32px; }
.admin-section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.admin-section-header h2 { font-size: 16px; font-weight: 600; color: var(--text-bright); }
.section-count { font-size: 11px; background: var(--bg4); color: var(--text-muted); padding: 2px 8px; border-radius: 10px; }
.section-hint { font-size: 12px; color: var(--text-dim); }
.console-main { overflow-y: auto; }

/* Admin table */
.admin-table-wrap { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table thead th { background: var(--bg3); color: var(--text-dim); padding: 10px 14px; text-align: left; font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
.admin-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.admin-table tbody tr:last-child { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--bg3); }
.admin-table td { padding: 12px 14px; vertical-align: middle; }
.admin-table .col-actions { width: 200px; text-align: right; }
.admin-table select { padding: 4px 6px; font-size: 12px; }
.table-loading { text-align: center; color: var(--text-dim); padding: 24px; font-size: 13px; }

.user-cell { display: flex; align-items: center; gap: 8px; }
.user-av { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0; }
.app-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.app-tag { font-size: 10px; background: rgba(var(--accent-rgb),0.12); color: var(--accent); padding: 2px 6px; border-radius: 3px; white-space: nowrap; }
.no-access { font-size: 11px; color: var(--text-dim); }
.badge-admin  { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 3px; background: rgba(97,175,254,0.12); color: var(--blue); text-transform: uppercase; }
.badge-member { font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 3px; background: var(--bg4); color: var(--text-muted); text-transform: uppercase; }

/* App access tabs */
.app-access-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.aab { background: var(--bg3); color: var(--text-muted); border: 1px solid var(--border); padding: 7px 14px; border-radius: var(--radius); font-size: 12px; font-weight: 500; transition: all 0.15s; }
.aab:hover { border-color: var(--app-color, var(--accent)); color: var(--text); }
.aab.active { background: rgba(var(--accent-rgb),0.10); border-color: var(--app-color, var(--accent)); color: var(--app-color, var(--accent)); }
.app-access-toolbar { display: flex; gap: 8px; padding: 12px 14px; background: var(--bg3); border-bottom: 1px solid var(--border); }
.app-access-toolbar select { flex: 1; padding: 6px 8px; }

/* Per-user app access modal rows */
.uap-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.uap-row:last-child { border-bottom: none; }
.uap-app-name { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text); }
.uap-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.uap-controls { display: flex; align-items: center; gap: 8px; }
.uap-role-sel { padding: 4px 6px; font-size: 12px; }

/* ========== Settings Page ========== */
.settings-main { overflow-y: auto; }
.settings-body { padding: 28px 32px; display: flex; flex-direction: column; gap: 20px; max-width: 800px; }

.settings-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.settings-card-header { display: flex; align-items: flex-start; gap: 14px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.settings-card-icon { width: 36px; height: 36px; border-radius: var(--radius); background: rgba(var(--accent-rgb),0.12); color: var(--accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.settings-card-header h2 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.settings-card-header p { font-size: 12px; color: var(--text-muted); }
.settings-card-body { padding: 24px; }

.settings-form { display: flex; flex-direction: column; gap: 16px; }
.settings-form .form-group { margin-bottom: 0; }
.settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.readonly-tag { font-size: 10px; font-weight: 500; background: var(--bg4); color: var(--text-dim); padding: 1px 6px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.3px; margin-left: 6px; vertical-align: middle; }

.settings-status { font-size: 12px; min-height: 18px; transition: color 0.2s; }
.status-ok  { color: #49cc90; }
.status-err { color: var(--red); }

/* Theme picker */
.theme-picker { display: flex; gap: 20px; margin-bottom: 16px; }
.theme-option { cursor: pointer; display: flex; flex-direction: column; gap: 10px; }
.theme-option input[type="radio"] { display: none; }
.theme-preview { width: 160px; height: 100px; border-radius: var(--radius-lg); overflow: hidden; border: 2px solid var(--border); transition: border-color 0.15s, box-shadow 0.15s; }
.theme-option.selected .theme-preview,
.theme-option input:checked ~ .theme-preview { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.2); }
.theme-option-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text-muted); }
.theme-check { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border2); display: flex; align-items: center; justify-content: center; background: transparent; transition: background 0.15s, border-color 0.15s; color: transparent; flex-shrink: 0; }
.theme-option.selected .theme-check,
.theme-option input:checked ~ * .theme-check { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Dark preview */
.theme-preview-dark { background: #1e1e1e; }
.theme-preview-dark .tp-topbar { height: 18px; background: #111; border-bottom: 1px solid #333; }
.theme-preview-dark .tp-body { display: flex; height: 82px; }
.theme-preview-dark .tp-sidebar { width: 38px; background: #181818; border-right: 1px solid #333; }
.theme-preview-dark .tp-content { flex: 1; padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; }
.theme-preview-dark .tp-line { height: 6px; border-radius: 3px; background: #333; }
.theme-preview-dark .tp-line-long  { width: 80%; }
.theme-preview-dark .tp-line-short { width: 45%; }
.theme-preview-dark .tp-line-med   { width: 65%; }

/* Light preview */
.theme-preview-light { background: #f5f7fa; }
.theme-preview-light .tp-topbar { height: 18px; background: #fff; border-bottom: 1px solid #dde1e8; }
.theme-preview-light .tp-body { display: flex; height: 82px; }
.theme-preview-light .tp-sidebar { width: 38px; background: #eef0f5; border-right: 1px solid #dde1e8; }
.theme-preview-light .tp-content { flex: 1; padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; }
.theme-preview-light .tp-line { height: 6px; border-radius: 3px; background: #dde1e8; }
.theme-preview-light .tp-line-long  { width: 80%; }
.theme-preview-light .tp-line-short { width: 45%; }
.theme-preview-light .tp-line-med   { width: 65%; }

/* Light overrides for settings page */
[data-theme="light"] .settings-card { background: var(--bg2); border-color: var(--border); }
[data-theme="light"] .settings-card-header { border-bottom-color: var(--border); }
[data-theme="light"] .settings-card-icon { background: rgba(var(--accent-rgb),0.10); }
[data-theme="light"] .readonly-tag { background: var(--bg3); color: var(--text-dim); }

/* ========== Environment Selector (topbar) ========== */
.env-selector { position: relative; }
.env-selector-btn { display: flex; align-items: center; gap: 5px; background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--radius); padding: 4px 10px; color: var(--text-muted); font-size: 12px; font-weight: 500; cursor: pointer; transition: border-color 0.15s, color 0.15s; white-space: nowrap; }
.env-selector-btn:hover { border-color: var(--accent); color: var(--text); }
.env-selector.env-active .env-selector-btn { border-color: var(--accent); color: var(--text); }
.env-active-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.env-dropdown { position: absolute; top: calc(100% + 4px); right: 0; min-width: 200px; background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-lg); box-shadow: 0 8px 24px rgba(0,0,0,0.3); z-index: 500; overflow: hidden; }
.env-drop-list { padding: 4px; }
.env-drop-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius); cursor: pointer; font-size: 12px; font-weight: 500; color: var(--text); transition: background 0.1s; }
.env-drop-item:hover { background: var(--bg3); }
.env-drop-item.active { background: rgba(var(--accent-rgb),0.10); color: var(--accent); }
.env-drop-item.active svg { stroke: var(--accent); margin-left: auto; }
.env-drop-none { color: var(--text-muted); }
.env-drop-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.env-drop-divider { height: 1px; background: var(--border); margin: 4px 0; }
.env-drop-empty { padding: 12px; text-align: center; font-size: 12px; color: var(--text-dim); }
.env-drop-footer { border-top: 1px solid var(--border); padding: 6px; }
.env-manage-btn { display: flex; align-items: center; gap: 7px; width: 100%; padding: 7px 10px; background: transparent; color: var(--text-muted); font-size: 12px; border-radius: var(--radius); cursor: pointer; text-align: left; transition: background 0.1s, color 0.1s; }
.env-manage-btn:hover { background: var(--bg3); color: var(--text); }

/* Light overrides */
[data-theme="light"] .env-dropdown { box-shadow: 0 8px 24px rgba(0,0,0,0.12); }

/* ========== Environments Modal ========== */
.modal-env { width: 860px; max-width: 96vw; max-height: 90vh; }
.env-modal-body { display: flex; flex: 1; overflow: hidden; min-height: 0; }

/* Left: list panel */
.env-list-panel { width: 240px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.env-list-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.env-list-head span { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* Add env form */
.env-add-form { padding: 12px; border-bottom: 1px solid var(--border); background: rgba(var(--accent-rgb),0.04); display: flex; flex-direction: column; gap: 10px; }
.env-add-form input { padding: 7px 10px; width: 100%; border-radius: var(--btn-radius); }
.env-color-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.env-color-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.env-color-swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.color-swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; transition: transform 0.12s, box-shadow 0.12s; }
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.selected { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,0.5), 0 0 0 3px var(--border2); transform: scale(1.15); }
#env-color-custom { width: 26px; height: 26px; padding: 0; border: 1px solid var(--border2); border-radius: 6px; background: transparent; cursor: pointer; }
.env-add-actions { display: flex; justify-content: flex-end; gap: 6px; }

/* Env list items */
.env-list-items { flex: 1; overflow-y: auto; padding: 6px; }
.env-list-item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: var(--btn-radius); cursor: pointer; font-size: 13px; color: var(--text); transition: background 0.12s; }
.env-list-item:hover { background: var(--bg3); }
.env-list-item.active { background: rgba(var(--accent-rgb),0.10); }
.env-list-item.active .env-item-name { color: var(--accent); font-weight: 600; }
.env-item-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.env-item-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.env-item-count { font-size: 10px; color: var(--text-dim); background: var(--bg4); padding: 1px 6px; border-radius: 8px; flex-shrink: 0; }
.env-list-empty { padding: 20px 14px; font-size: 12px; color: var(--text-dim); text-align: center; line-height: 1.7; }
.env-presets-hint { font-size: 10px; font-weight: 600; color: var(--text-dim); padding: 10px 10px 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.env-preset-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; background: transparent; border: none; color: var(--text-muted); font-size: 12px; cursor: pointer; border-radius: var(--btn-radius); text-align: left; transition: background 0.1s, color 0.1s; }
.env-preset-btn:hover { background: var(--bg3); color: var(--text); }

/* Right: vars panel */
.env-vars-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.env-vars-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-dim); text-align: center; padding: 32px; }
.env-vars-empty svg { opacity: 0.35; }
.env-vars-empty p { font-size: 14px; color: var(--text-muted); }
.env-vars-empty span { font-size: 12px; color: var(--text-dim); }
#env-vars-editor { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

/* Vars header */
.env-vars-header { display: flex; align-items: center; justify-content: space-between; padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; gap: 10px; }
.env-vars-title-row { display: flex; align-items: center; gap: 8px; }
.env-vars-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.env-vars-title { font-size: 14px; font-weight: 600; color: var(--text); }
.env-vars-count { font-size: 11px; background: var(--bg4); color: var(--text-muted); padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.env-vars-actions { display: flex; gap: 6px; align-items: center; }
.btn-env-delete { background: transparent; color: var(--text-dim); border: 1px solid var(--border2); }
.btn-env-delete:hover { background: rgba(249,62,62,0.1); color: var(--red); border-color: rgba(249,62,62,0.4); }

/* Search + add bar */
.env-vars-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg); flex-shrink: 0; }
.env-search-wrap { position: relative; flex: 1; display: flex; align-items: center; }
.env-search-wrap svg { position: absolute; left: 9px; pointer-events: none; color: var(--text-dim); }
.env-search-wrap input { width: 100%; padding: 6px 10px 6px 30px; background: var(--bg3); border-radius: var(--btn-radius); font-size: 12px; }

/* Variable table */
.env-kv-table { flex: 1; }
.env-kv-table thead th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 12px; background: var(--bg2); }
.env-kv-table thead th:first-child { width: 40%; }
.env-kv-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.env-kv-table tbody tr:last-child { border-bottom: none; }
.env-kv-table tbody tr:hover { background: var(--bg3); }
.env-kv-table td { padding: 3px 4px; vertical-align: middle; }
.env-kv-table td:first-child { padding-left: 10px; }
.env-kv-table td:last-child { padding-right: 8px; width: 36px; }
.env-key-input { font-family: 'Menlo', 'Consolas', monospace !important; color: var(--blue) !important; font-weight: 600 !important; letter-spacing: 0.2px; background: transparent; border: none; width: 100%; padding: 6px 8px; border-radius: var(--radius); }
.env-key-input:focus { background: var(--bg4); border-radius: var(--radius); }
.env-key-input::placeholder { font-family: inherit; font-weight: 400; color: var(--text-dim); letter-spacing: 0; text-transform: none; }
.env-val-input { font-family: 'Menlo', 'Consolas', monospace !important; font-size: 12px; background: transparent; border: none; width: 100%; padding: 6px 8px; color: var(--text); border-radius: var(--radius); }
.env-val-input:focus { background: var(--bg4); }
.env-var-hidden .env-val-input { color: var(--text-dim); letter-spacing: 2px; }
#env-vars-table { display: block; flex: 1; overflow-y: auto; }
#env-vars-table thead, #env-vars-table tbody, #env-vars-table tr { display: table; width: 100%; table-layout: fixed; }

/* Sticky footer */
.env-vars-footer { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--bg2); flex-shrink: 0; }
.env-save-hint { font-size: 11px; color: var(--text-dim); }
.env-save-hint kbd { font-family: inherit; font-size: 10px; background: var(--bg4); border: 1px solid var(--border2); border-radius: 3px; padding: 1px 4px; color: var(--text-muted); }

/* Light overrides for env modal */
[data-theme="light"] .env-list-panel { border-right-color: var(--border); }
[data-theme="light"] .env-list-head { border-bottom-color: var(--border); }
[data-theme="light"] .env-add-form { background: rgba(var(--accent-rgb),0.04); border-bottom-color: var(--border); }
[data-theme="light"] .env-vars-header { background: var(--bg2); border-bottom-color: var(--border); }
[data-theme="light"] .env-vars-toolbar { background: var(--bg3); border-bottom-color: var(--border); }
[data-theme="light"] .env-vars-footer { background: var(--bg2); border-top-color: var(--border); }
[data-theme="light"] .env-kv-table thead th { background: var(--bg3); }
