:root {
  --bg: #0c0e12; --panel: #14171d; --panel2: #1b1f27; --line: #262b35;
  --text: #e6e8ec; --muted: #8b93a3; --accent: #f5a524; --accent-ink: #1a1200;
  --ok: #3ecf8e; --bad: #ef4444; --radius: 10px;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
input, textarea, select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font: inherit; min-width: 0; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
[hidden] { display: none !important; }

.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; font: inherit; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.btn.danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.btn.ghost { background: transparent; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.chk { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.logo { width: 44px; height: 44px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 22px; font-weight: 800; }
.logo.sm { width: 26px; height: 26px; font-size: 13px; border-radius: 7px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; padding: 28px; }
.login-card label, .form label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.err { color: var(--bad); min-height: 1em; margin: 0; }

/* layout */
#app { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 0 6px 18px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav button { display: flex; gap: 10px; align-items: center; background: none; border: 0; color: var(--muted); padding: 9px 10px; border-radius: 8px; cursor: pointer; font: inherit; text-align: left; }
nav button i { font-style: normal; width: 20px; text-align: center; font-family: var(--mono); font-size: 12px; }
nav button:hover { color: var(--text); background: var(--panel2); }
nav button.active { background: var(--panel2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding: 12px 6px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.srv { display: flex; gap: 8px; align-items: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.off { background: var(--bad); }
.dot.warn { background: var(--accent); }
main { padding: 20px 24px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

@media (max-width: 800px) {
  #app { grid-template-columns: 1fr; }
  .side { position: sticky; z-index: 10; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px 0 0; }
  nav { flex-direction: row; overflow-x: auto; flex: 1; }
  nav button { padding: 7px 9px; white-space: nowrap; }
  nav button i { display: none; }
  .side-foot { display: none; }
  main { padding: 16px; }
}

/* dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 0; }
.stat { display: grid; gap: 4px; align-content: start; }
.stat .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: 12px; }
.good { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--accent); }
.bar { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin: 2px 0; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.bar i.hi { background: var(--bad); }

/* tabelle */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
td { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--panel2); }
tr.click { cursor: pointer; }
td.null { color: var(--muted); font-style: italic; }
td.mono { font-family: var(--mono); font-size: 12px; }
th.c, td.c { width: 32px; text-align: center; padding-right: 0; }

/* console */
.console { padding: 0; overflow: hidden; display: flex; flex-direction: column; height: calc(100vh - 120px); min-height: 360px; }
#consoleOut { flex: 1; margin: 0; padding: 12px 14px; overflow: auto; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; background: #08090c; }
#consoleOut .cmd { color: var(--accent); }
#consoleOut .reply { color: #9ecbff; }
#consoleOut .e { color: #ff8080; }
#consoleOut .w { color: #ffd479; }
.cmdline { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding: 8px 12px; background: var(--panel); }
.cmdline span { color: var(--accent); font-family: var(--mono); font-weight: 700; }
.cmdline input { flex: 1; border: 0; background: transparent; font-family: var(--mono); padding: 6px 0; }
.cmdline input:focus { outline: none; }

/* file */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.crumbs { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; font-family: var(--mono); font-size: 13px; }
.crumbs a { color: var(--accent); cursor: pointer; padding: 3px 6px; border-radius: 6px; }
.crumbs a:hover, .crumbs a.over { background: var(--panel2); }
.crumbs a.over { outline: 2px dashed var(--accent); }
.selbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.files td.name { cursor: pointer; }
.files td.name:hover { color: var(--accent); }
.files td.name .ic { display: inline-block; width: 22px; }
.files tr.sel { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.files tr.over td { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.files tr.dragging { opacity: .4; }
.files td:last-child { text-align: right; }
.files td:last-child .btn { margin-left: 4px; }
.dropzone { position: relative; min-height: 120px; border-radius: 8px; }
.drophint { display: none; position: absolute; inset: 0; place-items: center; border: 2px dashed var(--accent); border-radius: 8px; background: color-mix(in srgb, var(--bg) 80%, transparent); font-weight: 600; color: var(--accent); pointer-events: none; }
.dropzone.os-over .drophint { display: grid; }
.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
#uploadProg { margin-top: 10px; display: grid; gap: 4px; font-size: 12px; color: var(--muted); }

/* editor */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(640px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.65); }
dialog.wide { width: calc(100vw - 48px); max-width: 1400px; height: calc(100vh - 48px); max-height: none; padding: 12px; display: none; flex-direction: column; }
dialog.wide[open] { display: flex; }
dialog.wide .toolbar { margin-bottom: 8px; }
#editorName { font-family: var(--mono); font-size: 13px; }
#editorHost { flex: 1; min-height: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
#editorHost .CodeMirror { height: 100%; font: 13px/1.5 var(--mono); }

/* database */
.dblayout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; align-items: start; }
.tables input { width: 100%; margin-bottom: 8px; }
.tables ul { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow-y: auto; }
.tables li { padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.tables li:hover { background: var(--panel2); }
.tables li.active { background: var(--accent); color: var(--accent-ink); }
.tables li small { opacity: .6; }
.dbmain { min-width: 0; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 10px; color: var(--muted); font-size: 12px; }
@media (max-width: 900px) { .dblayout { grid-template-columns: 1fr; } .tables ul { max-height: 200px; } }
#rowFields { display: grid; gap: 10px; max-height: 60vh; overflow-y: auto; margin-bottom: 16px; }
#rowFields label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
#rowFields textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }
#rowFields .nullbox { display: flex; gap: 6px; align-items: center; font-size: 12px; }
textarea.sql { width: 100%; min-height: 150px; font: 13px/1.5 var(--mono); margin-bottom: 10px; resize: vertical; }

/* altro */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.form { display: grid; gap: 12px; align-content: start; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); }
.tag.admin { color: var(--accent); border-color: var(--accent); }
#pickInput, #askInput { width: 100%; margin-bottom: 10px; font-family: var(--mono); }
#pickList { list-style: none; margin: 0 0 14px; padding: 0; max-height: 45vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
#pickList li { padding: 6px 10px; cursor: pointer; font-family: var(--mono); font-size: 12px; }
#pickList li:hover, #pickList li.active { background: var(--panel2); color: var(--accent); }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 100; }
#toast.show { opacity: 1; }
#toast.error { border-color: var(--bad); color: var(--bad); }
