:root {
  --bg: #f5f6f8; --panel: #ffffff; --panel2: #f0f2f5; --line: #e2e5ea; --text: #16191f; --muted: #667085;
  --accent: #2563eb; --accent-weak: #e8efff; --ok: #12875a; --ok-weak: #e3f5ec; --warn: #b26b00; --warn-weak: #fff3dc;
  --bad: #c9302c; --bad-weak: #fde8e7; --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --t-kritisch: #c9302c; --t-wichtig: #b26b00; --t-optional: #2563eb; --t-archiv: #7c3aed; --t-db: #0e7490; --t-neu: #667085; --t-system: #667085; --t-muell: #98a2b3;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a; --text: #e8eaee; --muted: #9aa3b2;
    --accent: #5b8cff; --accent-weak: #1c2742; --ok: #3ccf8e; --ok-weak: #13291f; --warn: #f0b354; --warn-weak: #2e2414;
    --bad: #ff6b66; --bad-weak: #351a1a; --shadow: none;
    --t-kritisch: #ff6b66; --t-wichtig: #f0b354; --t-optional: #7aa2ff; --t-archiv: #b49cff; --t-db: #4cc3d9; --t-neu: #9aa3b2; --t-system: #9aa3b2; --t-muell: #6b7280;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a; --text: #e8eaee; --muted: #9aa3b2;
  --accent: #5b8cff; --accent-weak: #1c2742; --ok: #3ccf8e; --ok-weak: #13291f; --warn: #f0b354; --warn-weak: #2e2414;
  --bad: #ff6b66; --bad-weak: #351a1a; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel2); padding: 1px 5px; border-radius: 5px; word-break: break-all; }
h1 { font-size: 22px; margin: 6px 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.mt { margin-top: 22px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 16px; }
.err { color: var(--bad); min-height: 1.2em; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: min(360px, 100%); text-align: center; box-shadow: var(--shadow); }
.login-card .logo img { width: 56px; }
.login-card input { width: 100%; margin: 14px 0 10px; }

/* Header */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 18px; padding: 10px 20px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; white-space: nowrap; }
.brand img { width: 26px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--text); background: var(--panel2); }
.tabs button.on { color: var(--accent); background: var(--accent-weak); font-weight: 600; }
main { max-width: 1240px; margin: 0 auto; padding: 18px 20px 60px; }
.tab { display: none; }
.tab.on { display: block; }

/* Cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 { margin-bottom: 16px; }
.big { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* Buttons & inputs */
.btn { font: inherit; font-weight: 550; border-radius: 9px; padding: 9px 16px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
.btn:hover { background: var(--panel2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.btn.big-btn { font-size: 16px; padding: 12px 22px; }
input[type=password], input[type=text], input[type=time], input[type=number], input:not([type]) { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; outline: none; }
input:focus { border-color: var(--accent); }
.row { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.row label { color: var(--muted); min-width: 70px; }
.row.add input { flex: 1; min-width: 0; }

/* Status banners */
.banner { border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; border: 1px solid; display: flex; gap: 14px; align-items: flex-start; }
.banner.ok { background: var(--ok-weak); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.banner.warn { background: var(--warn-weak); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.banner.bad { background: var(--bad-weak); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.banner .ico { font-size: 22px; line-height: 1; }
.banner h3 { margin: 0 0 4px; font-size: 16px; }
.banner p { margin: 4px 0; }
.banner .body { flex: 1; min-width: 0; }
.steps { margin: 8px 0 0; padding-left: 20px; }
.steps li { margin: 4px 0; }
.meter { height: 8px; background: var(--panel2); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.pill.ok { background: var(--ok-weak); color: var(--ok); }
.pill.bad { background: var(--bad-weak); color: var(--bad); }
.pill.warn { background: var(--warn-weak); color: var(--warn); }
.pill.neutral { background: var(--panel2); color: var(--muted); }

/* History */
.hist { width: 100%; border-collapse: collapse; font-size: 14px; }
.hist td, .hist th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.hist th { color: var(--muted); font-weight: 500; font-size: 12px; }
.hist tr:last-child td { border-bottom: 0; }
.hist .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Folders */
.folders { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.tree-card { padding: 0; overflow: hidden; }
.tree-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 14px; }
.crumbs button { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 2px 4px; border-radius: 5px; }
.crumbs button:hover { background: var(--accent-weak); }
.crumbs span.sep { color: var(--muted); }
.crumbs b { padding: 2px 4px; }
.tree { max-height: calc(100vh - 230px); overflow-y: auto; }
.item { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 4px; padding: 7px 14px 7px 8px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--panel2); }
.item .name { display: flex; align-items: center; gap: 8px; min-width: 0; cursor: default; }
.item.dir .name { cursor: pointer; }
.item .name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.dir .name .nm { font-weight: 550; }
.item .ic { width: 18px; flex: none; text-align: center; opacity: .75; }
.item .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .namecol { min-width: 0; }
.item .right { display: flex; align-items: center; gap: 10px; }
.item .size { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); width: 72px; text-align: right; }
.item .bar { width: 70px; height: 5px; background: var(--panel2); border-radius: 9px; overflow: hidden; }
.item .bar i { display: block; height: 100%; background: color-mix(in srgb, var(--accent) 55%, transparent); }
.item.off .nm { color: var(--muted); }
.item.patternhit .nm { text-decoration: line-through; text-decoration-color: var(--muted); }
.cb { width: 22px; height: 22px; border: 2px solid var(--line); border-radius: 6px; display: inline-grid; place-items: center; cursor: pointer; background: var(--panel); flex: none; vertical-align: middle; }
.cb:hover { border-color: var(--accent); }
.cb.on { background: var(--accent); border-color: var(--accent); }
.cb.on::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translate(0, -1px) rotate(45deg); }
.cb.mixed { border-color: var(--accent); }
.cb.mixed::after { content: ""; width: 10px; height: 2.5px; background: var(--accent); border-radius: 2px; }
.cb.inherit.on { opacity: .55; }
i.cb { width: 14px; height: 14px; border-width: 1.5px; border-radius: 4px; cursor: default; }
i.cb.on::after { width: 4px; height: 7px; border-width: 0 2px 2px 0; }
i.cb.mixed::after { width: 7px; height: 2px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--line); align-items: center; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.tag { display: inline-block; font-size: 11px; font-weight: 650; padding: 1px 7px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; line-height: 1.5; }
.tag.kritisch { color: var(--t-kritisch); } .tag.wichtig { color: var(--t-wichtig); } .tag.optional { color: var(--t-optional); }
.tag.archiv { color: var(--t-archiv); } .tag.db { color: var(--t-db); } .tag.neu { color: var(--t-neu); } .tag.system { color: var(--t-system); } .tag.muell { color: var(--t-muell); }
.tag.pattern { color: var(--muted); border-style: dashed; }
.sel-card { position: sticky; top: 70px; }
.sel-list { max-height: 46vh; overflow-y: auto; margin: 10px -6px; }
.sel-entry { display: grid; grid-template-columns: 18px minmax(0,1fr) auto auto; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 7px; font-size: 13px; }
.sel-entry:hover { background: var(--panel2); }
.sel-entry .p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; cursor: pointer; }
.sel-entry .p:hover { color: var(--accent); }
.sel-entry .s { color: var(--muted); font-variant-numeric: tabular-nums; }
.sel-entry .x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; padding: 0 4px; }
.sel-entry .x:hover { color: var(--bad); }
.sel-entry .mark.on { color: var(--ok); } .sel-entry .mark.off { color: var(--bad); }
.sel-actions { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; }
.sum-big { font-size: 24px; font-weight: 700; }

/* Databases */
.db-group { margin-top: 18px; }
.db-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 6px; }
.db { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: 6px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.db .n { font-weight: 550; }
.db .note { font-size: 13px; color: var(--muted); }
.db .s { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* Restore */
.restore { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.browse-card { padding: 0; overflow: hidden; }
.snap { padding: 9px 10px; border-radius: 9px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.snap:hover { background: var(--panel2); }
.snap.on { background: var(--accent-weak); }
.snap .d { font-weight: 600; }
.snap .m { font-size: 12px; color: var(--muted); }
#snaps { max-height: calc(100vh - 230px); overflow-y: auto; margin: 0 -8px; }
.ritem { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 10px; align-items: center; padding: 7px 14px; border-bottom: 1px solid var(--line); }
.ritem:hover { background: var(--panel2); }
.ritem .name { display: flex; gap: 8px; align-items: center; min-width: 0; }
.ritem.dir .name { cursor: pointer; font-weight: 550; }
.ritem .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ritem .acts { display: flex; gap: 4px; opacity: .0; }
.ritem:hover .acts, .ritem:focus-within .acts { opacity: 1; }
@media (hover: none) { .ritem .acts { opacity: 1; } }
.job { margin: 12px 16px; padding: 10px 12px; border-radius: 9px; background: var(--panel2); font-size: 14px; }

/* Settings */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; margin: 6px 0 4px; }
.switch input { display: none; }
.switch span { width: 40px; height: 23px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch span::after { content: ""; position: absolute; width: 17px; height: 17px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(17px); }
.ret { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 8px 0 16px; }
.ret label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.ret input { width: 100%; }
.pat { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.pat code { flex: none; }
.pat .l { flex: 1; font-size: 13px; color: var(--muted); min-width: 0; }
.pat .x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; }
.pwbox { margin-top: 14px; padding: 14px; border-radius: 10px; background: var(--warn-weak); }
.pwbox p { margin: 0 0 6px; }
.pw { font-size: 14px; padding: 6px 10px; }

/* Toast & dialog */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 22px; width: min(460px, calc(100% - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
dialog input { width: 100%; margin-top: 8px; }

/* Responsive */
@media (max-width: 960px) {
  .folders, .restore { grid-template-columns: 1fr; }
  .sel-card { position: static; }
  .tree, #snaps { max-height: none; }
}
@media (max-width: 720px) {
  .top { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 16px; }
  main { padding: 14px 16px 50px; }
  .grid2 { grid-template-columns: 1fr; }
  .item .bar { display: none; }
  .item .size { width: 58px; }
  .ret { grid-template-columns: repeat(2, 1fr); }
  .hist .hide-m { display: none; }
}

/* Datenbank-Inhalt */
.db[data-kind] { cursor: pointer; }
.db[data-kind]:hover { background: var(--panel2); }
.db .chev { display: inline-block; margin-left: 10px; transition: transform .15s; color: var(--muted); }
.db.open .chev { transform: rotate(90deg); }
.db-tables { margin: 0 0 6px 38px; border-left: 2px solid var(--line); }
.dbt { display: grid; grid-template-columns: 22px minmax(0,1fr) auto auto; gap: 10px; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.dbt:hover { background: var(--accent-weak); }
.dbt .ic { color: var(--muted); }
.dbt .tn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dbt .tm, .dbt .s { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
dialog.tbl-dlg { width: min(1300px, calc(100% - 24px)); max-height: calc(100vh - 40px); padding: 0; display: none; flex-direction: column; overflow: hidden; }
dialog.tbl-dlg[open] { display: flex; }
.tbl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.tbl-head b { word-break: break-all; }
.tbl-nav { margin-left: auto; display: flex; gap: 6px; }
.tbl-body { overflow: auto; flex: 1; min-height: 120px; }
table.grid { border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { padding: 5px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: left; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; vertical-align: top; }
table.grid th { position: sticky; top: 0; background: var(--panel2); font-weight: 600; z-index: 1; }
table.grid tr:hover td { background: var(--panel2); }
table.grid td.null { color: var(--muted); font-style: italic; }
@media (max-width: 640px) { .dbt { grid-template-columns: 22px minmax(0,1fr) auto; } .dbt .tm { display: none; } }

/* Bereiche: Server | PCs */
.areas { display: flex; gap: 4px; padding: 3px; background: var(--panel2); border: 1px solid var(--line); border-radius: 11px; overflow-x: auto; scrollbar-width: none; flex: none; max-width: 52vw; }
.areas button { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; font-weight: 550; padding: 6px 11px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.areas button:hover { color: var(--text); }
.areas button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); outline: 1px solid var(--line); }
.areas button.add { color: var(--accent); font-weight: 600; }
.areas .ai { font-size: 15px; line-height: 1; }
.areas .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .5; flex: none; }
.areas .dot.on { background: var(--ok); opacity: 1; }
.areas .pill { padding: 0 6px; font-size: 11px; }
@media (max-width: 720px) { .areas { max-width: 100%; } }
#tab-overview.pending > :not(#targetCard) { display: none; }
@media (max-width: 960px) { .tab { scroll-margin-top: 150px; } }

/* Storage Box direkt */
.box-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.quota { margin: 6px 0 10px; }
.qbar { height: 10px; border-radius: 6px; background: var(--panel2); overflow: hidden; border: 1px solid var(--line); }
.qbar i { display: block; height: 100%; background: var(--accent, #4f8cff); }
.qtxt { margin-top: 6px; font-size: 13px; }
.bitem { grid-template-columns: minmax(0,1fr) auto auto; }
.bitem .namecol { min-width: 0; }
.bitem .sub { font-size: 12px; color: var(--muted); margin-left: 26px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bitem .right { display: flex; align-items: center; gap: 8px; }
.bitem .right .bar { width: 70px; }
.bitem .size { min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
pre.peek { max-height: 50vh; overflow: auto; font-size: 11.5px; background: var(--panel2); padding: 10px; border-radius: 8px; white-space: pre-wrap; word-break: break-all; max-width: 80vw; }
@media (max-width: 600px) { .bitem .right .bar { display: none; } }
.bitem .bar { height: 5px; background: var(--panel2); border-radius: 9px; overflow: hidden; }
.bitem .bar i { display: block; height: 100%; background: color-mix(in srgb, var(--accent) 55%, transparent); }
@media (max-width: 600px) { .bitem .hide-m { display: none; } .bitem { grid-template-columns: minmax(0,1fr) auto; } }
.box-head { flex-wrap: wrap; }
.box-head h2 { margin-right: auto; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; }
.seg button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 600; }
.bitem .right .btn { white-space: nowrap; }
.peek-img { max-width: min(80vw, 900px); max-height: 65vh; display: block; margin: 0 auto; border-radius: 8px; }
