/* Servant – mobil zuerst, Hell/Dunkel */
:root {
  --bg: #f4f6f8; --surface: #ffffff; --text: #1b2430; --muted: #5d6b7a; --border: #dde3ea;
  --primary: #1f6feb; --primary-text: #fff; --ok: #1a7f37; --warn: #b26a00; --error: #c62828;
  --ok-bg: #e6f4ea; --warn-bg: #fff4e0; --error-bg: #fdecea; --badge-bg: #eef1f4;
  --radius: 12px; --shadow: 0 1px 3px rgba(0,0,0,.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141a; --surface: #18202a; --text: #e6edf3; --muted: #93a1b0; --border: #2a3542;
    --primary: #4c8dff; --ok: #3fb950; --warn: #e3a008; --error: #f47067;
    --ok-bg: #12261a; --warn-bg: #2b2210; --error-bg: #2d1517; --badge-bg: #222c37; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141a; --surface: #18202a; --text: #e6edf3; --muted: #93a1b0; --border: #2a3542;
  --primary: #4c8dff; --ok: #3fb950; --warn: #e3a008; --error: #f47067;
  --ok-bg: #12261a; --warn-bg: #2b2210; --error-bg: #2d1517; --badge-bg: #222c37; --shadow: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .9em; }
h1 { font-size: 1.5rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem;
          padding: .5rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.mainnav a { padding: .4rem .7rem; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.mainnav a[aria-current="page"] { background: var(--badge-bg); color: var(--text); font-weight: 600; }
.logo-static { margin-left: auto; }
.menu { position: relative; margin-left: auto; }
.logo-btn { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; display: block; }
.logo-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.menu-panel { position: absolute; right: 0; top: calc(100% + .5rem); min-width: 220px; background: var(--surface);
              border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.18);
              padding: .4rem; display: flex; flex-direction: column; }
.menu-panel a, .menu-panel .linklike { padding: .55rem .75rem; border-radius: 8px; color: var(--text); text-align: left; }
.menu-panel a:hover, .menu-panel .linklike:hover { background: var(--badge-bg); text-decoration: none; }
.menu-panel form { margin: 0; display: flex; }
.menu-panel form .linklike { flex: 1; }
.menu-sep { font-size: .75rem; color: var(--muted); padding: .5rem .75rem .2rem; text-transform: uppercase; letter-spacing: .05em; }
.linklike { border: 0; background: none; font: inherit; cursor: pointer; }
.linklike.danger { color: var(--error); }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 1rem; flex: 1; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-bottom: 1rem; }
.grid .card { margin: 0; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.head-row h1 { margin-bottom: .5rem; }

.kv { list-style: none; margin: 0; padding: 0; }
.kv li { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid var(--border); }
.kv li:last-child { border-bottom: 0; }
.kv li > span:first-child { color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .45rem 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
         background: var(--badge-bg); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.error { background: var(--error-bg); color: var(--error); }
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin: 0 0 1rem; border: 1px solid transparent; }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.error { background: var(--error-bg); color: var(--error); white-space: pre-wrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.stack { display: flex; flex-direction: column; gap: .9rem; }
.row2, .row3 { display: grid; gap: .9rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .row2 { grid-template-columns: 1fr 1fr; } .row3 { grid-template-columns: repeat(3, 1fr); } }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .95rem; }
label small { font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
                          border-radius: 8px; padding: .55rem .7rem; width: 100%; font-weight: 400; }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--primary); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
textarea.mono { font-family: var(--mono); font-size: .88rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; margin: 0;
           display: flex; flex-direction: column; gap: .75rem; }
legend { font-weight: 700; padding: 0 .4rem; }
.stepup input { border-color: var(--warn); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600;
       padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
       color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { background: var(--error); border-color: var(--error); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.actions form { margin: 0; }
.errbox, .detail { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .75rem;
                   overflow-x: auto; font-family: var(--mono); font-size: .8rem; white-space: pre-wrap; margin: .75rem 0 0; }
.danger-zone summary { cursor: pointer; color: var(--error); font-weight: 600; }

/* Tabellen: Desktop Tabelle, Handy Karten */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border);
         border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
@media (max-width: 719px) {
  .table.cards, .table.cards tbody, .table.cards tr, .table.cards td { display: block; width: 100%; }
  .table.cards { background: none; border: 0; }
  .table.cards thead { display: none; }
  .table.cards tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
                    margin-bottom: .75rem; padding: .4rem .2rem; box-shadow: var(--shadow); }
  .table.cards td { border: 0; padding: .3rem .8rem; display: flex; justify-content: space-between; gap: 1rem; }
  .table.cards td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; flex-shrink: 0; }
  .table.cards td > * { text-align: right; }
}

.auth { max-width: 380px; margin: 2rem auto; background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); text-align: left; }
.auth.wide { max-width: 520px; }
.auth-logo { display: block; margin: 0 auto 1rem; }
.auth h1 { text-align: center; }
.qr { display: flex; justify-content: center; margin: 1rem 0; }
.qr svg { width: 220px; height: auto; background: #fff; border-radius: 8px; }
.secret { word-break: break-all; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin: 1rem 0; }
.codes code { display: block; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .35rem; text-align: center; }

.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; padding: 1rem;
          color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); background: var(--surface); }
.footer a { color: var(--muted); display: inline-flex; align-items: center; gap: .3rem; }
.heart { fill: #e25555; vertical-align: -2px; }
.to-top { position: fixed; right: 1rem; bottom: 1rem; width: 44px; height: 44px; border-radius: 50%;
          border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 1.2rem;
          cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.more-btn { margin-top: .5rem; }
[hidden] { display: none !important; }
.busy { opacity: .6; pointer-events: none; }
.kv li > span:last-child, .kv li > a + span { text-align: right; overflow-wrap: anywhere; min-width: 0; }
.inline-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: flex-start; justify-content: flex-end; }
.inline-actions form { margin: 0; }
details.pop { position: relative; }
details.pop > summary { list-style: none; }
details.pop > summary::-webkit-details-marker { display: none; }
details.pop[open] > form { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 5; min-width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); text-align: left; }
.danger-text { color: var(--error); }
.small-btn { padding: .2rem .6rem; font-size: .85rem; margin-left: .5rem; }
pre.log { max-height: 420px; overflow: auto; white-space: pre; }
.kv li form { margin: 0; }
@media (max-width: 719px) {
  details.pop[open] > form { position: static; margin-top: .4rem; min-width: 0; }
  .inline-actions { justify-content: flex-start; }
}
.table { margin-bottom: 1rem; }
@media (max-width: 719px) {
  .topbar { flex-wrap: wrap; row-gap: .4rem; }
  .mainnav { order: 3; flex-basis: 100%; margin: 0 -.25rem; }
}
@media (max-width: 719px) {
  .mainnav { flex-wrap: wrap; overflow: visible; gap: .15rem; }
  .mainnav a { padding: .35rem .55rem; font-size: .95rem; }
}

/* ---------------------------------------------------- 0.4: Dateien, Logs, Statistik */
.crumbs { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; margin: 0 0 1rem;
          font-family: var(--mono); font-size: .9rem; }
.crumbs span { color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; }
.toolbar .tool { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0; flex: 1 1 300px; }
.toolbar .tool input:not([type=checkbox]) { flex: 1 1 160px; width: auto; }
.toolbar input[type=file] { padding: .35rem; }
.files .ico { display: inline-block; width: 1.3em; }
.files tr.up td { padding-top: .4rem; padding-bottom: .4rem; }
details.pop[open] > .pop-body { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 5; min-width: 320px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); text-align: left; }
.row-form { display: flex; gap: .4rem; align-items: center; margin: 0; }
.row-form input:not([type=checkbox]) { flex: 1; min-width: 0; }
.row-form .btn { white-space: nowrap; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: 1rem; }
.tabs a { padding: .4rem .8rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.tabs a[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.tabs a.muted { color: var(--muted); }
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filter-bar input { flex: 1 1 220px; width: auto; }
.filter-bar select { width: auto; }
.logview { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem;
           font-family: var(--mono); font-size: .8rem; line-height: 1.45; overflow-x: auto; max-height: 75vh; margin: 0; }
.logview span { display: block; white-space: pre; }
.logview .s4 { color: var(--warn); }
.logview .s5 { color: var(--error); font-weight: 600; }
.editor-form { display: flex; flex-direction: column; gap: .5rem; }
.editor-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; position: sticky; top: 3.4rem; z-index: 4;
              background: var(--bg); padding: .4rem 0; }
.editor-bar .spacer { flex: 1; }
.editor-text { min-height: 70vh; }
.editor-form .CodeMirror { height: 72vh; border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--mono); font-size: .88rem; }
iframe.report { width: 100%; height: 80vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
@media (max-width: 719px) {
  details.pop[open] > .pop-body { position: static; margin-top: .4rem; min-width: 0; }
  .row-form { flex-wrap: wrap; }
  .editor-form .CodeMirror { height: 65vh; font-size: .82rem; }
  .editor-bar { top: 5.6rem; }
}
.toolbar input[type=file] { max-width: 100%; min-width: 0; }
@media (max-width: 719px) {
  .table.cards td:empty { display: none; }
  .toolbar input[type=file] { width: 100%; }
}

/* --------------------------------------------- Logo + Tab-Leiste unten (wie Postamt) */
.logo-btn img, .logo-static, .auth-logo { border-radius: 50%; }
.logo-btn { box-shadow: 0 0 0 4px var(--badge-bg); }
.tabbar, .more-sheet { display: none; }
@media (max-width: 719px) {
  .mainnav { display: none; }
  .topbar { flex-wrap: nowrap; padding: .6rem 1rem; }
  .brand span { font-size: 1.2rem; }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
            z-index: 20; background: var(--surface); border-top: 1px solid var(--border);
            padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a, .tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; gap: .15rem;
            padding: .55rem 0 .5rem; color: var(--muted); font: inherit; font-size: .72rem; background: none; border: 0;
            cursor: pointer; text-decoration: none; min-width: 0; }
  .tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7;
                stroke-linecap: round; stroke-linejoin: round; }
  .tabbar svg .dot { fill: currentColor; stroke: none; }
  .tabbar [aria-current="page"] { color: var(--primary); }
  .tabbar [aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 0; right: 0; height: 3px;
            background: var(--primary); }
  .more-sheet:not([hidden]) { display: flex; flex-direction: column; position: fixed; right: .5rem; z-index: 21;
            bottom: calc(72px + env(safe-area-inset-bottom)); min-width: 200px; background: var(--surface);
            border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.25); padding: .4rem; }
  .more-sheet a { padding: .7rem .9rem; border-radius: 8px; color: var(--text); }
  .more-sheet a:hover { background: var(--badge-bg); text-decoration: none; }
  .to-top { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .footer { padding-bottom: 1rem; }
}
