/* Kundenportal Buhl IT – Farben aus dem Logo */
:root {
  --green: #16b18b;
  --green-dark: #0e8a6b;
  --green-light: #e8f7f2;
  --ink: #231f20;
  --muted: #6b6b6b;
  --line: #e3e7e5;
  --bg: #f6f8f7;
  --white: #ffffff;
  --red: #c0392b;
  --red-light: #fdecea;
  --amber: #a66a00;
  --amber-light: #fff4df;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.5;
}
a { color: var(--green-dark); }
a:hover { color: var(--green); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .8rem; }
code { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: .05rem .35rem; font-size: .92em; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }
main.wrap { flex: 1; padding-top: 2rem; padding-bottom: 3rem; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* Kopfzeile */
.topbar { background: var(--white); border-bottom: 3px solid var(--green); }
.topbar-inner { display: flex; align-items: center; gap: 1.5rem; min-height: 72px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .8rem; text-decoration: none; color: var(--ink); }
.brand img { height: 44px; width: auto; }
.brand span { font-weight: 600; font-size: 1.05rem; border-left: 1px solid var(--line); padding-left: .8rem; }
.mainnav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.mainnav a { text-decoration: none; color: var(--ink); padding: .5rem .8rem; border-radius: 6px; font-weight: 500; }
.mainnav a:hover { background: var(--green-light); color: var(--green-dark); }
.mainnav a.active { background: var(--green); color: var(--white); }
.logout { display: flex; align-items: center; gap: .6rem; margin: 0; }
.who { color: var(--muted); font-size: .9rem; }

/* Fußzeile */
.footer { background: var(--white); border-top: 1px solid var(--line); padding: 1rem 0; font-size: .875rem; color: var(--muted); }
.footer .wrap { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.footer a { color: var(--muted); }

/* Karten & Raster */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem; }
.card.narrow, .narrow { max-width: 560px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + .grid-2 { margin-top: 1.5rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.lead { color: var(--muted); font-size: 1.05rem; margin-top: -.5rem; }

/* Kacheln */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; margin-top: 1.5rem; }
.tile { display: flex; flex-direction: column; gap: .4rem; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem; text-decoration: none; color: var(--ink); border-top: 4px solid var(--green); transition: transform .15s, box-shadow .15s; }
a.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(22,177,139,.18); color: var(--ink); }
.tile-icon svg { width: 40px; height: 40px; fill: var(--green); }
.tile-title { font-weight: 700; font-size: 1.15rem; }
.tile-text { color: var(--muted); font-size: .95rem; }
.tile-disabled { opacity: .6; border-top-color: var(--line); }
.tile-disabled .tile-icon svg { fill: var(--muted); }
.ext { color: var(--green); font-weight: 400; }

/* Buttons */
.btn { display: inline-block; font: inherit; font-weight: 600; font-size: .95rem; padding: .55rem 1rem; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--white); color: var(--ink); text-decoration: none; line-height: 1.3; }
.btn:hover { border-color: var(--green); color: var(--green-dark); }
.btn-primary { background: var(--green); border-color: var(--green); color: var(--white); }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); color: var(--white); }
.btn-danger { color: var(--red); border-color: #f0c4bf; }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: var(--white); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-small { padding: .3rem .65rem; font-size: .85rem; }
.btn-block { display: block; width: 100%; }
.button-row { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0 .5rem; }
.button-row form { margin: 0; }
.actions { text-align: right; white-space: nowrap; }
.actions .button-row { justify-content: flex-end; margin: 0; }

/* Formulare */
.form label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 1rem; }
.form input[type=text], .form input[type=password], .form input[type=email], .form input[type=url], .form textarea, .form select,
.search input {
  display: block; width: 100%; margin-top: .35rem; font: inherit; font-weight: 400; padding: .6rem .75rem; border: 1px solid #cfd6d3;
  border-radius: 6px; background: var(--white); color: var(--ink);
}
.form input:focus, .form textarea:focus, .form select:focus, .search input:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: var(--green); }
.form textarea { font-family: ui-monospace, Consolas, monospace; font-size: .92rem; }
.form .hint { display: block; font-weight: 400; margin-top: .3rem; }
.form-actions { display: flex; gap: .75rem; align-items: center; }
.form-wide { max-width: 900px; }
.hint { color: var(--muted); font-size: .875rem; }
.code-input { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.search { display: flex; gap: .5rem; max-width: 520px; margin-bottom: 1rem; }
.search input { margin-top: 0; }
form.inline { margin: 0; }
form.inline select { padding: .3rem; font: inherit; border: 1px solid var(--line); border-radius: 6px; }

/* Meldungen */
.alert { padding: .8rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid; }
.alert-success { background: var(--green-light); border-color: #b4e6d6; color: #0b5e49; }
.alert-error { background: var(--red-light); border-color: #f3c1bb; color: #8e2a1f; }
.alert-info { background: #eef5fb; border-color: #c9dff1; color: #1f4b6e; }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600;
  padding: .6rem .75rem; border-bottom: 2px solid var(--line); }
.table td { padding: .7rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafcfb; }
.table .num { text-align: right; white-space: nowrap; }
.table.log td { font-size: .88rem; }
.table .details { word-break: break-word; }
.empty { color: var(--muted); text-align: center; padding: 1.5rem 0; margin: 0; }
.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: .2rem .6rem; border-radius: 999px; white-space: nowrap; }
.badge-ok { background: var(--green-light); color: #0b5e49; }
.badge-warn { background: var(--amber-light); color: var(--amber); }
.badge-bad { background: var(--red-light); color: var(--red); }

/* Dateien */
.crumbs { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: 1rem; font-size: .95rem; }
.crumbs span { color: var(--muted); }
.files-card { padding: .5rem 1rem; }
.item { display: inline-flex; align-items: center; gap: .55rem; }
.item::before { content: ""; width: 20px; height: 20px; flex: none; background-repeat: no-repeat; background-size: contain; }
.item-dir { font-weight: 600; text-decoration: none; color: var(--ink); }
.item-dir:hover { color: var(--green-dark); }
.item-dir::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2316b18b' d='M3 6.5A1.5 1.5 0 0 1 4.5 5H9l2 2h8.5A1.5 1.5 0 0 1 21 8.5v9a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 17.5z'/%3E%3C/svg%3E"); }
.item-file::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23888' d='M6 2h8l5 5v14a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1zm7 1.5V8h4.5z'/%3E%3C/svg%3E"); }

.dropzone { display: flex; flex-direction: column; align-items: center; gap: .4rem; text-align: center; padding: 2rem 1rem; border: 2px dashed #b7dccf;
  border-radius: var(--radius); background: var(--green-light); cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--green); background: #d8f2e9; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone strong { color: var(--green-dark); }
.upload-list { list-style: none; padding: 0; margin: 1rem 0 0; }
.upload-list li { display: grid; grid-template-columns: 1fr 180px 170px; gap: 1rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.upload-list li.reload { display: block; border: 0; }
.upload-list progress { width: 100%; height: 10px; accent-color: var(--green); }
.upload-list .up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-list .done .up-status { color: var(--green-dark); font-weight: 600; }
.upload-list .error progress { visibility: hidden; }
.upload-list .error .up-status { color: var(--red); font-weight: 600; }

/* Fakten-Listen */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.2rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.facts.big dd { font-size: 1.1rem; }
.secret { font-size: 1.15rem; letter-spacing: .05em; user-select: all; }
.danger-zone { border-color: #f3c1bb; }

/* Anmeldeseiten */
body.auth { align-items: center; justify-content: flex-start; background: linear-gradient(160deg, var(--green-light) 0%, var(--bg) 45%); }
.auth-box { width: 100%; max-width: 440px; margin: 6vh auto 2rem; background: var(--white); border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.08);
  padding: 2.2rem 2rem; border-top: 5px solid var(--green); }
body.auth .footer { width: 100%; margin-top: auto; }
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo img { height: 70px; width: auto; }
.auth h1 { font-size: 1.35rem; text-align: center; }
.steps { padding-left: 1.3rem; }
.steps li { margin-bottom: .5rem; }
.qr { text-align: center; margin: .5rem 0 1rem; }
.qr svg { max-width: 230px; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.manual { margin-bottom: 1rem; font-size: .92rem; }
.manual summary { cursor: pointer; color: var(--green-dark); }
.manual code { display: block; text-align: center; padding: .6rem; margin-top: .4rem; word-break: break-all; }

@media (max-width: 720px) {
  .topbar-inner { padding: .6rem 0; gap: .6rem; }
  .who { display: none; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
  .upload-list li { grid-template-columns: 1fr; gap: .3rem; }
  .auth-box { margin-top: 1rem; padding: 1.6rem 1.2rem; }
}

/* Passwort-Tresor */
[hidden] { display: none !important; }
.busy { display: flex; align-items: center; gap: .8rem; margin: 0; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--green-light); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.vault-layout { display: grid; grid-template-columns: 280px 1fr; gap: 1.5rem; align-items: start; }
.vnav { padding: .8rem; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; margin: 0; }
.vnav-head { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin: 1rem .5rem .3rem; }
.vnav-empty { color: var(--muted); font-size: .85rem; padding: .2rem .8rem; }
.vnav-item { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; font: inherit; font-size: .93rem;
  background: none; border: 0; border-radius: 6px; padding: .45rem .8rem; cursor: pointer; color: var(--ink); }
.vnav-item:hover { background: var(--green-light); }
.vnav-item.active { background: var(--green); color: var(--white); }
.vnav-item .count { font-size: .8rem; opacity: .7; }
.vault-toolbar { display: flex; gap: .75rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.vault-toolbar h2 { margin: 0; flex: 1; }
.vault-toolbar input { font: inherit; padding: .5rem .75rem; border: 1px solid #cfd6d3; border-radius: 6px; min-width: 240px; }
.vitem { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: .8rem; box-shadow: var(--shadow); }
.vitem-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: .5rem; }
.vitem-rows { display: grid; grid-template-columns: 130px 1fr; gap: .4rem 1rem; margin: 0; font-size: .93rem; }
.vitem-rows dt { color: var(--muted); }
.vitem-rows dd { margin: 0; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; word-break: break-all; }
.vitem-rows code.masked { letter-spacing: .1em; }
.vnotes { white-space: pre-wrap; font-family: inherit; background: var(--bg); padding: .6rem; border-radius: 6px; margin: .4rem 0 0; }
@media (max-width: 860px) { .vault-layout { grid-template-columns: 1fr; } .vnav { position: static; max-height: none; } }

/* Anlagen-Monitoring */
.gtoolbar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.granges { display: inline-flex; background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 3px; flex-wrap: wrap; }
.grange { font: inherit; font-size: .88rem; font-weight: 600; border: 0; background: none; padding: .4rem .75rem; border-radius: 6px; cursor: pointer; color: var(--muted); }
.grange:hover { color: var(--green-dark); background: var(--green-light); }
.grange.active { background: var(--green); color: var(--white); }
.gstamp { color: var(--muted); font-size: .88rem; margin-left: auto; }
.gsection { margin-bottom: 1.25rem; }
.gsection-head { display: flex; align-items: center; gap: .5rem; font: inherit; font-weight: 700; font-size: 1.05rem; color: var(--ink);
  background: none; border: 0; padding: .3rem 0; margin-bottom: .6rem; cursor: pointer; }
.gsection-head .gsection-caret { color: var(--green); transition: transform .15s; display: inline-block; }
.gsection-head[aria-expanded="false"] .gsection-caret { transform: rotate(-90deg); }
.ggrid24 { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); grid-auto-rows: 30px; gap: 8px 16px; }
.gpanel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; border-top: 3px solid var(--green); }
.gpanel-head { display: flex; align-items: center; gap: .4rem; padding: .7rem 1rem .4rem; }
.gpanel-head h3 { margin: 0; font-size: .98rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ginfo { color: var(--muted); cursor: help; font-size: .9rem; }
.gpanel-body { flex: 1; min-height: 0; padding: .3rem 1rem .9rem; display: flex; flex-direction: column; overflow: auto; position: relative; }
.gloading { flex: 1; display: flex; align-items: center; justify-content: center; }
.gempty { color: var(--muted); text-align: center; margin: auto; padding: 1rem; font-size: .92rem; }
.gerror { color: var(--red); }
.gtext { white-space: pre-wrap; font-size: .95rem; }

/* Tabellen */
.gtable-wrap { overflow: auto; }
.gtable { width: 100%; border-collapse: collapse; font-size: .9rem; }
.gtable th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700;
  padding: .45rem .6rem; border-bottom: 2px solid var(--line); position: sticky; top: 0; background: var(--white); white-space: nowrap; }
.gtable td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.gtable tr:last-child td { border-bottom: 0; }
.gtable tbody tr:hover { background: #fafcfb; }
.gcell-chip { padding-top: .3rem !important; padding-bottom: .3rem !important; }
.gchip { display: inline-block; min-width: 4.5rem; text-align: center; font-weight: 700; font-size: .82rem; padding: .22rem .7rem; border-radius: 999px; background: var(--bg); }
.gbar-cell { display: flex; align-items: center; gap: .6rem; min-width: 150px; }
.gbar { flex: 1; height: 8px; background: #edf1ef; border-radius: 999px; overflow: hidden; min-width: 60px; }
.gbar-lg { height: 12px; }
.gbar-fill { display: block; height: 100%; border-radius: 999px; transition: width .4s ease; }
.gbar-text { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 4.2rem; text-align: right; }

/* Zeitreihen */
.gchart { position: relative; flex: 1; min-height: 140px; }
.gsvg { display: block; width: 100%; height: 100%; }
.ggrid { stroke: #edf1ef; stroke-width: 1; }
.ggrid-v { stroke-dasharray: 2 4; }
.gaxis { fill: var(--muted); font-size: 11px; font-family: inherit; }
.gcursor { stroke: #9aa5a1; stroke-width: 1; stroke-dasharray: 3 3; }
.gtip { position: absolute; z-index: 3; background: rgba(35,31,32,.94); color: #fff; border-radius: 8px; padding: .5rem .7rem; font-size: .82rem;
  pointer-events: none; min-width: 180px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.gtip-time { color: #c9d1ce; margin-bottom: .3rem; font-size: .78rem; }
.gtip-row { display: flex; align-items: center; gap: .45rem; white-space: nowrap; }
.gtip-name { flex: 1; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.gdot { width: 10px; height: 10px; border-radius: 3px; flex: none; display: inline-block; }
.glegend { margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .85rem; }
.glegend-item { display: inline-flex; align-items: center; gap: .4rem; }
.glegend-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.glegend-table th { text-align: right; color: var(--muted); font-weight: 600; font-size: .75rem; padding: .2rem .5rem; }
.glegend-table td { padding: .25rem .5rem; text-align: right; font-variant-numeric: tabular-nums; border-top: 1px solid var(--line); white-space: nowrap; }
.glegend-table td:first-child { text-align: left; display: flex; align-items: center; gap: .45rem; white-space: normal; }

/* Stat / Gauge / Balken */
.gstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; flex: 1; align-content: center; }
.gstat { text-align: center; border-radius: 8px; padding: .6rem; display: flex; flex-direction: column; justify-content: center; }
.gstat.filled .gstat-name { color: inherit; opacity: .85; }
.gstat-value { font-size: 2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.gstat-name { color: var(--muted); font-size: .85rem; margin-top: .3rem; }
.gspark { width: 100%; height: 34px; margin-top: .4rem; }
.ggauge { width: 100%; max-width: 220px; margin: 0 auto; }
.ggauge-bg { fill: none; stroke: #edf1ef; stroke-width: 10; stroke-linecap: round; }
.ggauge-fg { fill: none; stroke-width: 10; stroke-linecap: round; }
.ggauge-text { font-size: 15px; font-weight: 800; fill: var(--ink); font-family: inherit; }
.gbars { display: flex; flex-direction: column; gap: .55rem; }
.gbars-row { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; gap: .7rem; align-items: center; font-size: .9rem; }
.gbars-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gbars-val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 900px) {
  .ggrid24 { grid-template-columns: 1fr; grid-auto-rows: auto; }
  .gpanel { grid-column: 1 / -1 !important; grid-row: auto !important; min-height: 260px; max-height: 520px; }
  .gpanel-table { max-height: none; }
  .gstamp { margin-left: 0; }
}

/* Feinschliff Navigation & Legenden */
.topbar-inner { flex-wrap: nowrap; }
.mainnav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.mainnav a { padding: .45rem .7rem; white-space: nowrap; font-size: .95rem; }
@media (max-width: 1100px) { .brand span { display: none; } .who { display: none; } }
@media (max-width: 720px) { .topbar-inner { flex-wrap: wrap; } }
.glegend-table { font-size: .8rem; }
.glegend-table th, .glegend-table td { padding: .2rem .4rem; }
.glegend-table td:first-child { max-width: 1px; width: 100%; display: table-cell; white-space: nowrap; }
.glegend-name { display: inline-block; max-width: calc(100% - 18px); overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.glegend-table td:first-child .gdot { vertical-align: middle; margin-right: .4rem; }
.gtable th, .gtable td { padding-left: .5rem; padding-right: .5rem; }
.glegend-stacked { display: block; }
.glegend-stack { padding: .3rem 0; border-top: 1px solid var(--line); font-size: .82rem; }
.glegend-stack-name { display: flex; align-items: center; gap: .45rem; font-weight: 600; }
.glegend-stack-vals { display: flex; flex-wrap: wrap; gap: .1rem .9rem; padding-left: 1.1rem; font-variant-numeric: tabular-nums; }
