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

:root {
  --bg: #0d0f18;
  --surface: #131520;
  --surface2: #1a1d2e;
  --border: #252840;
  --accent: #6366f1;
  --accent-hover: #4f52d0;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #e2e8f0;
  --muted: #64748b;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --sidebar-w: 220px;
}

html, body { height: 100%; }
html { overflow-x: hidden; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; overflow-x: hidden; }

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

/* ── Login ────────────────────────────────────────────────────── */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,.15) 0%, transparent 70%), var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 2rem; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-logo {
  display: flex; align-items: center; gap: .6rem; justify-content: center;
  font-size: 1.3rem; font-weight: 700; margin-bottom: 1.8rem; color: var(--text);
}

/* ── App layout ───────────────────────────────────────────────── */
.app-body { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 10;
}
.sidebar-logo {
  display: flex; align-items: center; gap: .6rem; padding: 1.2rem 1.2rem 1rem;
  font-size: 1rem; font-weight: 700; border-bottom: 1px solid var(--border); color: var(--text);
}
.sidebar-nav { flex: 1; padding: .75rem .6rem; display: flex; flex-direction: column; gap: .15rem; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .75rem; border-radius: 8px;
  color: var(--muted); font-weight: 500; transition: all .15s; text-decoration: none;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(99,102,241,.15); color: var(--accent); }

.sidebar-footer {
  padding: .9rem 1rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: .5rem; justify-content: space-between;
}
.sidebar-user { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 8px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.sidebar-username { font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-role { font-size: .72rem; color: var(--muted); text-transform: capitalize; }
.btn-logout {
  background: none; border: 1px solid var(--border); border-radius: 6px; padding: .35rem;
  color: var(--muted); cursor: pointer; display: flex; align-items: center; transition: all .15s; flex-shrink: 0;
}
.btn-logout svg { width: 16px; height: 16px; }
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ── Main content ─────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w); flex: 1; padding: 2rem 2.5rem; min-height: 100vh;
  width: 0; min-width: calc(100vw - var(--sidebar-w)); overflow-x: hidden;
}
.page-header { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { color: var(--muted); font-size: .9rem; }
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-size: .75rem; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem;
  border-radius: 7px; font-size: .85rem; font-weight: 600; cursor: pointer;
  border: none; transition: all .15s; text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled)   { background: var(--accent-hover); text-decoration: none; }
.btn-success   { background: rgba(34,197,94,.15); color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.btn-success:hover:not(:disabled)   { background: rgba(34,197,94,.25); text-decoration: none; }
.btn-danger    { background: rgba(239,68,68,.15); color: var(--danger);  border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover:not(:disabled)    { background: rgba(239,68,68,.25); text-decoration: none; }
.btn-warning   { background: rgba(245,158,11,.15); color: var(--warning); border: 1px solid rgba(245,158,11,.3); }
.btn-warning:hover:not(:disabled)   { background: rgba(245,158,11,.25); text-decoration: none; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); text-decoration: none; }
.btn-sm  { padding: .35rem .7rem; font-size: .8rem; }
.btn-xs  { padding: .2rem .45rem; font-size: .75rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: .4rem; font-size: .82rem; font-weight: 600; color: var(--muted); }
.form-input {
  width: 100%; padding: .55rem .8rem; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); font-size: .9rem; transition: border-color .15s;
}
.form-input:focus { outline: none; border-color: var(--accent); }

/* ── Alerts ───────────────────────────────────────────────────── */
.alert { padding: .65rem 1rem; border-radius: 7px; margin-bottom: 1rem; font-size: .85rem; }
.alert-danger { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }

/* ── Stats grid ───────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.2rem 1.4rem; }
.stat-label { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .4rem; }
.stat-value { font-size: 1rem; font-weight: 700; font-family: var(--mono); margin-bottom: .6rem; }
.stat-bar-wrap { height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; }
.stat-bar { height: 100%; border-radius: 4px; transition: width .5s, background .5s; width: 0; }

/* ── Section header ───────────────────────────────────────────── */
.section-header { display: flex; align-items: center; gap: 1rem; margin-bottom: .85rem; }
.process-count { font-size: .78rem; color: var(--muted); background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: .15rem .6rem; }

/* ── Process cards (dashboard) ────────────────────────────────── */
.process-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.process-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.3rem; }
.process-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.process-name { font-weight: 700; font-size: .95rem; }
.process-meta { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.process-stats { display: flex; gap: 1.5rem; margin-bottom: 1rem; }
.pstat { display: flex; flex-direction: column; }
.pstat span { font-size: .72rem; color: var(--muted); }
.pstat strong { font-family: var(--mono); font-size: .9rem; }
.process-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Status badges ────────────────────────────────────────────── */
.status-badge { padding: .2rem .6rem; border-radius: 20px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.status-online  { background: rgba(34,197,94,.15); color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.status-offline { background: rgba(239,68,68,.15); color: var(--danger);  border: 1px solid rgba(239,68,68,.3); }

/* ── Table ────────────────────────────────────────────────────── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th { padding: .7rem 1rem; text-align: left; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.table td { padding: .65rem 1rem; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface2); }

/* ── Service page layout ──────────────────────────────────────── */
.service-layout { display: grid; grid-template-columns: 360px 1fr; gap: 1.5rem; align-items: start; }
.control-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.4rem; }
.control-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.25rem; }
.control-name { font-weight: 700; font-size: 1rem; }
.control-path { font-size: .78rem; color: var(--muted); margin-top: .15rem; font-family: var(--mono); }
.metrics-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1.25rem; }
.metric { background: var(--surface2); border-radius: 8px; padding: .7rem .9rem; }
.metric-label { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .2rem; }
.metric-value { font-family: var(--mono); font-size: .95rem; font-weight: 700; }
.action-row { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.website-link { margin-bottom: 1rem; }
.action-status { font-size: .82rem; padding: .4rem 0; min-height: 1.5rem; }
.status-pending { color: var(--muted); }
.status-ok  { color: var(--success); }
.status-err { color: var(--danger); }

/* ── Log viewer ───────────────────────────────────────────────── */
.log-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.log-header { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1rem; border-bottom: 1px solid var(--border); font-size: .82rem; font-weight: 600; }
.log-controls { display: flex; align-items: center; gap: .75rem; }
.log-toggle { display: flex; align-items: center; gap: .3rem; color: var(--muted); cursor: pointer; }
.log-body {
  font-family: var(--mono); font-size: .78rem; padding: .75rem 1rem; overflow-y: auto; height: 520px;
  background: #0a0b12; white-space: pre-wrap; word-break: break-all; color: #94a3b8;
}
.log-line { line-height: 1.6; border-bottom: 1px solid rgba(255,255,255,.02); }
.log-line:last-child { border-bottom: none; }

/* ── File manager ─────────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: .3rem; margin-bottom: 1rem; font-size: .85rem; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: .5rem .85rem; }
.breadcrumb-item { color: var(--accent); font-weight: 500; }
.breadcrumb-sep { color: var(--muted); }
.file-toolbar { display: flex; gap: .6rem; margin-bottom: .85rem; }
.upload-form { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; margin-bottom: .85rem; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.file-list { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.file-row { display: grid; grid-template-columns: 28px 1fr auto auto; gap: .75rem; align-items: center; padding: .55rem .9rem; border-bottom: 1px solid var(--border); }
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--surface2); }
.file-icon { display: flex; align-items: center; justify-content: center; }
.dir-icon svg { stroke: var(--warning); }
.file-icon-plain svg { stroke: var(--muted); }
.file-name { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.file-name-clickable { cursor: pointer; }
.file-name-clickable:hover { color: var(--accent); }
a.file-name:hover { color: var(--accent); text-decoration: none; }
.file-meta { font-size: .75rem; color: var(--muted); text-align: right; white-space: nowrap; }
.file-actions { display: flex; gap: .3rem; justify-content: flex-end; }
.file-empty { padding: 2rem; text-align: center; color: var(--muted); }

/* ── Modal (shared) ───────────────────────────────────────────── */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.65); }
.modal-content { position: relative; z-index: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; width: 90vw; max-width: 900px; max-height: 90vh; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1.2rem; border-bottom: 1px solid var(--border); font-weight: 700; gap: 1rem; }

/* ── VS Code-style editor modal ───────────────────────────────── */
.editor-modal-content {
  width: 96vw; height: 92vh; max-width: none; max-height: none;
  background: #1e1e1e; border-color: #3c3c3c; border-radius: 8px;
  display: flex; flex-direction: column;
}
.editor-titlebar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .45rem .75rem .45rem 1rem;
  background: #323233; border-bottom: 1px solid #3c3c3c; flex-shrink: 0;
  gap: 1rem;
}
.editor-titlebar-left { display: flex; align-items: center; gap: .6rem; }
.editor-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.editor-dot.red    { background: #ff5f57; }
.editor-dot.yellow { background: #febc2e; }
.editor-dot.green  { background: #28c840; }
.editor-filename { font-size: .85rem; font-weight: 500; color: #cccccc; font-family: var(--mono); margin-left: .25rem; }
.editor-titlebar-right { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.editor-lang-label { font-size: .73rem; color: #858585; text-transform: capitalize; background: #2d2d2d; padding: .15rem .5rem; border-radius: 4px; border: 1px solid #3c3c3c; }
.monaco-container { flex: 1; min-height: 0; }
.editor-statusbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .2rem .9rem; background: #007acc; flex-shrink: 0;
  font-size: .72rem; color: #fff; font-family: var(--mono);
}
#editor-save-status { font-weight: 600; }

/* ── Services dashboard (flareadmin) ──────────────────────────── */
.services-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.svc-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.4rem; display: flex; flex-direction: column; gap: 1.1rem; }
.svc-top { display: flex; align-items: center; gap: .85rem; }
.svc-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.svc-icon-bot { background: rgba(99,102,241,.15); border: 1px solid rgba(99,102,241,.25); color: #818cf8; }
.svc-icon-web { background: rgba(34,211,238,.1); border: 1px solid rgba(34,211,238,.2); color: #22d3ee; }
.svc-info { flex: 1; min-width: 0; }
.svc-name { font-weight: 700; font-size: .95rem; }
.svc-desc { font-size: .75rem; color: var(--muted); margin-top: .1rem; }
.svc-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.svc-metric { background: var(--surface2); border-radius: 8px; padding: .55rem .7rem; }
.svc-metric span { display: block; font-size: .68rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .2rem; }
.svc-metric strong { font-family: var(--mono); font-size: .88rem; }
.svc-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.svc-status-msg { font-size: .78rem; margin-left: .25rem; }
.msg-pending { color: var(--muted); }
.msg-ok  { color: var(--success); }
.msg-err { color: var(--danger); }

/* ── Log tabs ─────────────────────────────────────────────────── */
.log-tabs { display: flex; gap: .25rem; }
.log-tab { background: none; border: 1px solid transparent; border-radius: 6px; padding: .3rem .8rem; font-size: .82rem; font-weight: 600; color: var(--muted); cursor: pointer; transition: all .15s; }
.log-tab:hover { color: var(--text); background: var(--surface2); }
.log-tab.active { color: var(--accent); background: rgba(99,102,241,.12); border-color: rgba(99,102,241,.25); }

/* ── Database viewer ──────────────────────────────────────────── */
.db-icon svg { stroke: #818cf8; }
.db-name:hover { color: #818cf8; }

.db-modal-content {
  width: 96vw; height: 92vh; max-width: none; max-height: none;
  background: #1e1e1e; border-color: #3c3c3c; border-radius: 8px;
  display: flex; flex-direction: column;
}
.db-body { display: flex; flex: 1; min-height: 0; }

/* Sidebar */
.db-sidebar { width: 190px; flex-shrink: 0; background: #252526; border-right: 1px solid #3c3c3c; display: flex; flex-direction: column; overflow: hidden; }
.db-sidebar-header { padding: .5rem .8rem; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #858585; border-bottom: 1px solid #3c3c3c; flex-shrink: 0; }
.db-table-list { flex: 1; overflow-y: auto; padding: .3rem 0; }
.db-table-list::-webkit-scrollbar { width: 4px; }
.db-table-list::-webkit-scrollbar-thumb { background: #424242; border-radius: 4px; }
.db-table-item { display: flex; align-items: center; gap: .5rem; padding: .35rem .8rem; font-size: .82rem; color: #cccccc; cursor: pointer; transition: background .1s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-table-item:hover { background: #2a2d2e; }
.db-table-item.active { background: #094771; color: #fff; }
.db-view-item { color: #9cdcfe; }

/* Main */
.db-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Toolbar */
.db-toolbar { display: flex; justify-content: space-between; align-items: center; padding: .5rem 1rem; background: #252526; border-bottom: 1px solid #3c3c3c; flex-shrink: 0; gap: 1rem; }
.db-toolbar-left { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.db-toolbar-right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.db-table-title { font-weight: 700; font-size: .9rem; color: #e2e8f0; font-family: var(--mono); white-space: nowrap; }
.db-row-count { font-size: .75rem; color: #858585; background: #3c3c3c; padding: .15rem .5rem; border-radius: 4px; white-space: nowrap; }
.db-page-label { font-size: .8rem; color: #cccccc; white-space: nowrap; }

/* Grid */
.db-grid-wrap { flex: 1; overflow: auto; background: #1e1e1e; min-height: 0; }
.db-grid-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.db-grid-wrap::-webkit-scrollbar-track { background: #2d2d2d; }
.db-grid-wrap::-webkit-scrollbar-thumb { background: #555; border-radius: 4px; }
.db-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; color: #555; font-size: .9rem; }
.db-loading { color: #858585; }
.db-table { border-collapse: collapse; font-size: .8rem; font-family: var(--mono); min-width: 100%; }
.db-table thead { position: sticky; top: 0; z-index: 2; }
.db-table th { background: #252526; color: #9cdcfe; font-weight: 600; padding: .5rem .8rem; text-align: left; border-bottom: 1px solid #3c3c3c; border-right: 1px solid #3c3c3c; white-space: nowrap; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.db-table td { padding: .38rem .8rem; border-bottom: 1px solid #2d2d2d; border-right: 1px solid #2a2a2a; color: #d4d4d4; white-space: nowrap; max-width: 300px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.db-table tr:hover td { background: #2a2d2e; }
.db-null { color: #569cd6; font-style: italic; opacity: .7; }

/* Query panel */
.db-query-panel { flex-shrink: 0; border-top: 1px solid #3c3c3c; background: #252526; padding: .6rem .85rem .7rem; }
.db-query-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .45rem; }
.db-query-label { font-size: .75rem; font-weight: 700; color: #858585; text-transform: uppercase; letter-spacing: .05em; }
.db-sql-input { width: 100%; background: #1e1e1e; border: 1px solid #3c3c3c; border-radius: 4px; color: #d4d4d4; font-family: var(--mono); font-size: .82rem; padding: .5rem .75rem; resize: vertical; min-height: 56px; max-height: 160px; line-height: 1.5; }
.db-sql-input:focus { outline: none; border-color: #007acc; }
.db-query-error { font-size: .78rem; color: #f48771; margin-top: .35rem; font-family: var(--mono); }

/* ── Upload modal ─────────────────────────────────────────────── */
.upload-modal-content { width: 100%; max-width: 540px; max-height: 90vh; display: flex; flex-direction: column; }
.upload-modal-title { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; padding: .25rem; display: flex; border-radius: 6px; transition: all .15s; }
.modal-close:hover { color: var(--text); background: var(--surface2); }

.drop-zone {
  margin: 1.25rem 1.25rem 0;
  border: 2px dashed var(--border); border-radius: 12px; padding: 2.5rem 1rem;
  text-align: center; cursor: pointer; transition: all .2s; user-select: none;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent); background: rgba(99,102,241,.06);
}
.drop-zone.drag-over .drop-icon { stroke: var(--accent); transform: translateY(-4px); }
.drop-zone-inner { display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.drop-icon { stroke: var(--muted); transition: all .2s; }
.drop-text { font-weight: 600; font-size: .95rem; color: var(--text); }
.drop-subtext { font-size: .8rem; color: var(--muted); }

.file-queue { margin: 1rem 1.25rem 0; }
.file-queue-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; font-size: .82rem; }
.file-queue-header span { font-weight: 600; color: var(--muted); }
.btn-text-danger { background: none; border: none; color: var(--danger); font-size: .8rem; cursor: pointer; padding: 0; opacity: .7; }
.btn-text-danger:hover { opacity: 1; }

.file-queue-list { display: flex; flex-direction: column; gap: .4rem; max-height: 260px; overflow-y: auto; padding-right: .25rem; }
.file-queue-list::-webkit-scrollbar { width: 4px; }
.file-queue-list::-webkit-scrollbar-track { background: transparent; }
.file-queue-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.queue-item { display: flex; align-items: flex-start; gap: .7rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; }
.qi-icon { flex-shrink: 0; margin-top: .1rem; }
.qi-info { flex: 1; min-width: 0; }
.qi-name { font-size: .83rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qi-size { font-size: .73rem; color: var(--muted); margin-top: .1rem; }
.qi-bar-wrap { height: 3px; background: var(--border); border-radius: 3px; margin-top: .45rem; overflow: hidden; }
.qi-bar { height: 100%; border-radius: 3px; transition: width .15s; }
.qi-bar-uploading { background: var(--accent); }
.qi-bar-done { background: var(--success); }
.qi-error { font-size: .73rem; color: var(--danger); margin-top: .25rem; }
.qi-remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: .8rem; flex-shrink: 0; padding: .1rem .2rem; line-height: 1; border-radius: 4px; }
.qi-remove:hover { color: var(--danger); }

.upload-footer { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem; border-top: 1px solid var(--border); margin-top: 1.25rem; }
.upload-summary { font-size: .83rem; font-weight: 600; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .8s linear infinite; }

/* ── Tab nav ──────────────────────────────────────────────────── */
.tab-nav { display: flex; gap: .25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: .5rem; }
.tab-btn {
  background: none; border: 1px solid transparent; border-radius: 6px 6px 0 0;
  padding: .4rem 1rem; font-size: .85rem; font-weight: 600; color: var(--muted);
  cursor: pointer; transition: all .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); background: rgba(99,102,241,.1); border-color: rgba(99,102,241,.25); border-bottom-color: transparent; }
.tab-panel { }

/* ── Env vars editor ──────────────────────────────────────────── */
.env-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.env-toolbar { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1rem; border-bottom: 1px solid var(--border); gap: 1rem; flex-wrap: wrap; }
.env-file-path { font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.env-rows { padding: .5rem; display: flex; flex-direction: column; gap: .35rem; }
.env-row { display: grid; grid-template-columns: 1fr 16px 2fr 32px; gap: .4rem; align-items: center; }
.env-key { font-family: var(--mono); font-size: .82rem; }
.env-val { font-family: var(--mono); font-size: .82rem; }
.env-eq { text-align: center; color: var(--muted); font-weight: 700; font-size: .9rem; }
.form-label { display: block; margin-bottom: .35rem; font-size: .8rem; font-weight: 600; color: var(--muted); }

/* ── Deploy ───────────────────────────────────────────────────── */
.deploy-card { }
.deploy-info { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.2rem; display: flex; flex-direction: column; gap: .55rem; max-width: 560px; }
.deploy-stat-row { display: flex; align-items: center; gap: 1rem; font-size: .88rem; }
.deploy-stat-row span { color: var(--muted); width: 100px; flex-shrink: 0; }
.deploy-stat-row code { font-family: var(--mono); font-size: .83rem; background: var(--surface2); padding: .15rem .5rem; border-radius: 4px; }
.deploy-dirty { font-family: var(--mono); font-size: .75rem; color: var(--warning); background: var(--surface2); border-radius: 6px; padding: .5rem .75rem; margin-top: .25rem; white-space: pre-wrap; }

/* ── Charts ───────────────────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 2rem; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.1rem 1.4rem; }
.chart-title { font-size: .72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .75rem; }

/* ── Nginx manager ────────────────────────────────────────────── */
.nginx-msg { padding: .6rem 1rem; border-radius: 8px; font-size: .85rem; margin-bottom: 1rem; }
.nginx-msg-pending { background: var(--surface2); color: var(--muted); }
.nginx-msg-ok  { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.25); color: var(--success); }
.nginx-msg-err { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25); color: var(--danger); }
.nginx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.nginx-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.2rem 1.4rem; }
.nginx-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .75rem; }
.nginx-site-name { font-weight: 700; font-size: .95rem; font-family: var(--mono); }
.nginx-domains { font-size: .78rem; color: var(--muted); margin-top: .2rem; }
.nginx-meta { font-size: .8rem; color: var(--muted); }

/* ── Backups ──────────────────────────────────────────────────── */
.backup-sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; margin-bottom: .5rem; }
.backup-source-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.1rem 1.3rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.bsrc-name { font-weight: 700; font-size: .9rem; }
.bsrc-path { font-family: var(--mono); font-size: .73rem; color: var(--muted); margin-top: .2rem; }

/* ── Panel users / inline modals ─────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.modal-close:hover { color: var(--text); background: var(--surface2); }

/* ── Settings card ────────────────────────────────────────────── */
.settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.settings-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 2rem; padding: 1.2rem 1.4rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.settings-row:last-child { border-bottom: none; }
.settings-label { font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.settings-hint { font-size: .78rem; color: var(--muted); max-width: 380px; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .process-grid { grid-template-columns: 1fr; }
  .service-layout { grid-template-columns: 1fr; }
  .settings-row { flex-direction: column; gap: .75rem; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .main-content { padding: 1rem; }
  .env-row { grid-template-columns: 1fr 12px 1fr 28px; }
}

/* ── Light theme ──────────────────────────────────────────────── */
[data-theme="light"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --accent: #4f52d0;
  --accent-hover: #3b3eb8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --text: #0f172a;
  --muted: #64748b;
  --fg: #0f172a;
}
[data-theme="light"] .sidebar { box-shadow: 2px 0 8px rgba(0,0,0,.07); }
[data-theme="light"] .login-body { background: radial-gradient(ellipse at 50% 0%, rgba(79,82,208,.1) 0%, transparent 70%), var(--bg); }

/* ── Nav groups ───────────────────────────────────────────────── */
.nav-group-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: .65rem .75rem .2rem; margin-top: .2rem;
}

/* ── Theme toggle + icon btn ──────────────────────────────────── */
.btn-icon {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: .4rem; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--surface2); color: var(--text); }

/* ── Sidebar close btn (mobile) ───────────────────────────────── */
.sidebar-close-btn {
  display: none; background: none; border: none; color: var(--muted); cursor: pointer;
  padding: .3rem; border-radius: 6px; margin-left: auto;
}

/* ── Hamburger btn ────────────────────────────────────────────── */
.hamburger-btn {
  display: none; position: fixed; top: .85rem; left: .85rem; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: .45rem; cursor: pointer; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

/* ── Sidebar overlay ──────────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9;
}

/* ── Mobile sidebar ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 15;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close-btn { display: flex; }
  .hamburger-btn { display: flex; }
  .sidebar-overlay.active { display: block; }
  .main-content { margin-left: 0 !important; padding-top: 4rem; }
}

/* ── Uptime heatmap ───────────────────────────────────────────── */
.heatmap-legend {
  display: flex; align-items: center; gap: .5rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.heatmap-key { display: inline-block; width: 14px; height: 14px; border-radius: 3px; }
.heatmap-key-label { font-size: .78rem; color: var(--muted); margin-right: .4rem; }
.heatmap-table-wrap { overflow-x: auto; }
.heatmap-table { border-collapse: collapse; white-space: nowrap; }
.heatmap-table th, .heatmap-table td { padding: 3px 4px; }
.heatmap-process-col { text-align: left; padding-right: 1rem; min-width: 140px; font-weight: 600; font-size: .82rem; }
.heatmap-day-col { font-size: .68rem; color: var(--muted); text-align: center; min-width: 36px; }
.heatmap-process-name { font-size: .82rem; padding-right: 1rem; font-weight: 600; }
.heatmap-cell {
  width: 28px; height: 22px; border-radius: 4px; cursor: default;
  transition: transform .1s; display: block;
}
.heatmap-cell:hover { transform: scale(1.25); z-index: 1; position: relative; }

/* ── Audit log ────────────────────────────────────────────────── */
.audit-filters { display: flex; gap: .5rem; flex-wrap: wrap; }
.audit-action {
  display: inline-block; padding: .15rem .55rem; border-radius: 5px;
  background: rgba(99,102,241,.12); color: var(--accent); font-size: .78rem; font-weight: 600;
}
.audit-pagination {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: .75rem; flex-wrap: wrap; gap: .5rem;
}

/* ── Permissions UI ───────────────────────────────────────────── */
.perm-groups { display: flex; flex-direction: column; gap: .6rem; }
.perm-group { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .85rem; }
.perm-group-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: .4rem; }
.perm-row {
  display: flex; align-items: flex-start; gap: .6rem; padding: .3rem 0;
  cursor: pointer; border-radius: 5px;
}
.perm-row input[type="checkbox"] { margin-top: .2rem; accent-color: var(--accent); flex-shrink: 0; }
.perm-row strong { display: block; font-size: .85rem; }
.perm-desc { font-size: .78rem; color: var(--muted); }

/* ── Notes ────────────────────────────────────────────────────── */
.notes-wrap { display: flex; gap: 1rem; height: calc(100vh - 220px); min-height: 360px; }
.notes-editor {
  flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: var(--mono); font-size: .85rem; padding: 1rem;
  resize: none; outline: none; line-height: 1.6;
}
.notes-editor:focus { border-color: var(--accent); }
.notes-preview {
  flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.2rem 1.4rem; overflow-y: auto; line-height: 1.7;
}
.notes-split .notes-editor, .notes-split .notes-preview { flex: 1; }
.notes-preview h1,.notes-preview h2,.notes-preview h3 { margin: 1rem 0 .5rem; font-weight: 700; }
.notes-preview p { margin-bottom: .75rem; }
.notes-preview ul,.notes-preview ol { margin: .5rem 0 .5rem 1.5rem; }
.notes-preview li { margin-bottom: .25rem; }
.notes-preview code { background: var(--surface2); padding: .1rem .35rem; border-radius: 4px; font-family: var(--mono); font-size: .85em; }
.notes-preview pre { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: .85rem 1rem; overflow-x: auto; margin: .75rem 0; }
.notes-preview pre code { background: none; padding: 0; }
.notes-preview blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; color: var(--muted); margin: .75rem 0; }
.notes-preview a { color: var(--accent); }
.notes-preview hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ── Log search bar ───────────────────────────────────────────── */
.log-search-bar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .25rem; }

/* ── Deploy stat row ──────────────────────────────────────────── */
.deploy-stat-row { display: flex; align-items: center; justify-content: space-between; padding: .5rem 0; border-bottom: 1px solid var(--border); gap: 1rem; font-size: .88rem; }
.deploy-stat-row:last-child { border-bottom: none; }
.deploy-dirty { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: .6rem .9rem; font-size: .78rem; color: var(--warning); margin-top: .5rem; overflow-x: auto; }

/* ── Env Vars — grouped layout ────────────────────────────────── */
.env-group { margin-bottom: 1.5rem; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.env-group-header { background: var(--surface2); padding: .6rem 1rem; font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
.env-row-grouped { display: flex; align-items: flex-start; gap: 1rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.env-row-grouped:last-child { border-bottom: none; }
.env-row-meta { min-width: 180px; max-width: 220px; flex-shrink: 0; }
.env-row-label { display: block; font-size: .88rem; font-weight: 600; color: var(--text); }
.env-row-key { display: block; font-size: .75rem; font-family: var(--mono); color: var(--muted); margin-top: .1rem; }
.env-row-desc { display: block; font-size: .75rem; color: var(--muted); margin-top: .2rem; line-height: 1.4; }
.env-row-inputs { display: flex; align-items: center; gap: .4rem; flex: 1; min-width: 200px; }
.env-row-inputs .form-input { flex: 1; min-width: 0; font-family: var(--mono); font-size: .83rem; }
