/* Konto, Projekte, Teilen, Versionen, Kommentare (js/account.js, js/sync.js, js/versions.js, js/comments.js).
   Eigene Datei, damit die Gestaltung der übrigen Oberfläche (css/style.css) unberührt bleibt. */

/* ---------- Kopfleiste ---------- */
.acc-btn { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; }
.acc-btn .lbl { overflow: hidden; text-overflow: ellipsis; }
.acc-avatar { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; flex: none; }
.acc-avatar::before { content: attr(data-ini); }   /* Initialen als Bild: gehören nicht zum sichtbaren Namen des Knopfs (2.5.3) */
.tb-tools { display: inline-flex; gap: 4px; }
.tb-tools .count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.tb-tools .count[hidden] { display: none; }
@media (max-width: 900px) { .acc-btn .lbl, .tb-tools .lbl { display: none; } .acc-btn, .tb-tools button { min-width: 40px; justify-content: center; } }

/* Online-Zustand am Speichern-Knopf (js/sync.js, data-sync): kleine Markierung oben rechts */
.tb-actions [data-act="save"][data-sync] { position: relative; }
.tb-actions [data-act="save"]:is([data-sync="saved"]:not(.dirty), [data-sync="offline"], [data-sync="queued"], [data-sync="conflict"], [data-sync="error"], [data-sync="saving"])::after {
  position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--bg, #fff); content: ''; background: var(--ok); }
/* Zustand nicht nur über die Farbe: gespeichert = Punkt, wartet = Ring, Fehler = Quadrat */
.tb-actions [data-act="save"]:is([data-sync="offline"], [data-sync="queued"], [data-sync="conflict"])::after { background: var(--panel, #fff); border-color: var(--warn); border-width: 3px; }
.tb-actions [data-act="save"][data-sync="error"]::after { background: var(--err); border-radius: 2px; }
.tb-actions [data-act="save"][data-sync="saving"]::after { background: #94a3b8; }
body.project-readonly .file-name { color: #1f6fd1; font-weight: 600; }

/* Nur ansehen/kommentieren (Konto-Projekt): Bearbeiten ausblenden, Öffnen bleibt */
body.project-readonly [data-act="save"]:not(#menuPanel *), body.project-readonly #btnUndo, body.project-readonly #btnRedo,
body.project-readonly .panel-tools, body.project-readonly .panel-lib, body.project-readonly [data-act="addFloor"], body.project-readonly #selBar,
body.project-readonly .mobile-nav :is([data-sheet="tools"], [data-sheet="library"]) { display: none !important; }
/* Start während eines Deploys (js/sync.js, server-wait): nur ansehen, bis der Server wieder da ist */
body.server-wait :is([data-act="save"], [data-act="saveAs"], [data-act="new"], #btnUndo, #btnRedo, .panel-tools, .panel-lib, [data-act="addFloor"], #selBar) { display: none !important; }
body.server-wait .canvas-wrap { opacity: .85; }
.srv-wait { z-index: 60; }

/* ---------- Dialoge ---------- */
.acc-dlg .dlg { max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); overflow-y: auto; }
/* Fehlerbericht (js/bugreport.js): Vorschau des Bildschirmfotos, technische Angaben */
.bug-dlg { max-width: 620px; }
.bug-shot { display: flex; flex-direction: column; gap: 6px; }
.bug-shot img { max-width: 100%; max-height: 220px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; align-self: flex-start; }
.bug-tech summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.bug-tech dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 6px 0 0; font-size: 12px; max-height: 220px; overflow: auto; }
.bug-tech dt { color: var(--muted); } .bug-tech dd { margin: 0; overflow-wrap: anywhere; }
/* „Meine Anfragen“ im Konto */
.acc-tickets { display: flex; flex-direction: column; gap: 6px; }
.acc-ticket { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.acc-ticket summary { cursor: pointer; } .acc-ticket .msg { margin: 6px 0 0; padding: 6px 8px; border-left: 3px solid var(--accent); background: var(--accent-soft); white-space: pre-wrap; }
.acc-big { min-height: 44px; font-size: 15px; }
.acc-or { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.acc-or::before, .acc-or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.acc-links { color: var(--muted); }
.acc-links a { color: var(--accent); }
.acc-sub { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 6px 0 -4px; }
.acc-list { display: flex; flex-direction: column; gap: 6px; }
.acc-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.acc-row > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.acc-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.acc-link-btn { display: inline-block; padding: 5px 10px; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; }
.acc-link-btn:hover { background: #1d4fd8; }
.acc-inline { display: flex; gap: 6px; flex-wrap: wrap; }
.acc-inline input { flex: 1 1 180px; min-width: 0; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; }
.acc-inline select { padding: 4px; border: 1px solid var(--line); border-radius: 6px; }
.acc-ok { color: #166534; font-weight: 600; }
.acc-warn { color: #92400e; font-weight: 600; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 9px; background: #f1f5f9; color: var(--muted); font-size: 11px; }
.badge.cm { background: #fef3c7; color: #92400e; }
.badge.on { background: var(--accent-soft); color: var(--accent); }

/* Projektübersicht: Karten mit Vorschaubild */
.projects-dlg { max-width: 920px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.pcard { position: relative; display: flex; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.pcard[hidden] { display: none; }
.pcard.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.pcard-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 8px; border: 0; border-radius: 10px 0 0 10px;
  background: transparent; text-align: left; white-space: normal; }
.pcard-main:hover:not(:disabled) { background: #f8faff; }
.pcard-main img { width: 100%; height: 110px; object-fit: contain; background: #f8fafc; border-radius: 6px; }
.pcard-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pcard-txt b { overflow-wrap: anywhere; }
.pcard-txt .plan-desc { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pcard-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.pcard .plan-more > summary { border-radius: 0 10px 10px 0; }
.acc-trash > summary { cursor: pointer; color: var(--muted); margin: 6px 0; }
@media (max-width: 900px) {
  .projects-dlg { width: 100%; max-width: none; height: 100vh; height: 100dvh; max-height: none; margin: 0; border-radius: 0; }
  .pgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .acc-row button, .acc-inline button, .acc-inline select, .acc-inline input { min-height: 44px; }
}

/* ---------- Seitenpanel (Versionen, Kommentare) ---------- */
.side-panel { position: fixed; top: calc(var(--top, 52px) + 8px); right: 8px; bottom: 8px; z-index: 30; width: min(380px, calc(100% - 16px));
  display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.side-panel[hidden] { display: none; }
.side-panel > header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.side-panel > header h2 { flex: 1; margin: 0; font-size: 16px; }
.side-panel .sp-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.side-panel .sp-foot { padding: 8px 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 700px) { .side-panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 70vh; height: 70dvh; border-radius: 14px 14px 0 0; } }

.ver { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; align-items: start; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.ver.sel { border-color: var(--accent); background: #f8faff; }
.ver input { margin-top: 3px; }
.ver .v-sum { grid-column: 2 / 4; overflow-wrap: anywhere; }
.ver .v-acts { grid-column: 2 / 4; display: flex; gap: 6px; flex-wrap: wrap; }
.diff-floor { font-weight: 600; margin-top: 6px; }
.diff-row { display: flex; gap: 6px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.diff-row:hover { background: #f2f6ff; }
.diff-row .act { flex: none; width: 18px; text-align: center; font-weight: 700; }
.diff-row[data-action="added"] .act { color: var(--ok-text); } .diff-row[data-action="removed"] .act { color: var(--err-text); } .diff-row .act { color: var(--warn-text); }

/* Kommentare */
.cm-thread { border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.cm-thread.resolved { opacity: .65; }
.cm-thread.active { border-color: #f59e0b; box-shadow: 0 0 0 1px #f59e0b; }
.cm-head { display: flex; align-items: center; gap: 6px; }
.cm-num { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 50%; background: #f59e0b; color: #fff; font-size: 12px; font-weight: 700; }
.cm-thread.resolved .cm-num { background: #9ca3af; }
.cm-msg { white-space: pre-wrap; overflow-wrap: anywhere; }
.cm-reply { padding-left: 12px; border-left: 2px solid var(--line); }
.cm-form { display: flex; flex-direction: column; gap: 6px; }
.cm-form textarea { width: 100%; min-height: 60px; resize: vertical; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; box-sizing: border-box; }
.cm-pins { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.cm-pin { position: absolute; transform: translate(-2px, -100%); pointer-events: auto; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px 13px 13px 2px;
  background: #f59e0b; border: 2px solid #fff; color: #fff; font-weight: 700; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.cm-pin:hover { background: #d97706; }
.cm-pin.resolved { background: #9ca3af; }
.cm-pin.active { outline: 3px solid rgba(245,158,11,.45); }
.cm-place { position: absolute; inset: 0; z-index: 5; cursor: crosshair; background: rgba(245,158,11,.05); }
.cm-place-hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 6; padding: 6px 12px; border-radius: 8px; background: #78350f; color: #fff; }
@media (pointer: coarse) { .cm-pin { min-width: 34px; height: 34px; border-radius: 17px 17px 17px 3px; font-size: 14px; } }

/* Hinweis „Neue Version der App“ (js/sync.js): unter einem evtl. gleichzeitigen Server-Fassungs-Hinweis */
.srv-newer.app-update { top: calc(var(--top, 52px) + 64px); }

/* Tarife im Konto-Menü */
.acc-plans { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.acc-plans button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px; white-space: normal; text-align: left; border-radius: 10px; }
.acc-plans button.primary .muted { color: rgba(255,255,255,.85); }
.acc-plans s { font-weight: normal; }
.acc-modiv { margin-top: 8px; }
.adm-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin: 8px 0; }
.adm-kpi { display: flex; flex-direction: column; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.adm-kpi b { font-size: 18px; }
.adm-kpi span { font-size: 12px; color: var(--muted); }
.adm-table { flex: none; overflow-x: auto; max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; }
.adm-table table { border-collapse: collapse; width: 100%; font-size: 12px; }
.adm-table th, .adm-table td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.adm-table th { position: sticky; top: 0; background: var(--panel, #fff); }
.acc-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }   /* Honigtopf gegen Bots */
.acc-logo { align-items: center; }
.acc-logo img { max-height: 36px; max-width: 140px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 2px; }
.acc-file { position: relative; overflow: hidden; display: inline-block; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 13px; }
.acc-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dlg label.inline.acc-consent, .acc-consent { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.45; margin: 6px 0; }
.dlg label.inline.acc-consent > input, .acc-consent input { margin-top: 3px; flex: none; }
.acc-consent a { color: var(--accent); }
.acc-book { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.acc-book-price { font-size: 16px; font-weight: 600; }
.acc-mods { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin: 6px 0; }
.acc-mod { display: flex; flex-direction: column; gap: 3px; padding: 10px; border: 1px solid var(--line, #d0d5dd); border-radius: 10px; }
.acc-mod > span:last-child { margin-top: auto; padding-top: 4px; }
.acc-mod.focus { outline: 2px solid var(--accent, #2563eb); outline-offset: 1px; }
.acc-inline input[type=color] { flex: 0 0 44px; padding: 2px; height: 34px; }

/* Kostenschätzung im Dialog Mengen (js/costs.js) */
.qt-raw table { margin-bottom: 12px; }
.cost-sum { font-size: 15px; margin: 4px 0 8px; }
.cost-opts { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-end; margin: 8px 0; }
.cost-opts label { display: flex; flex-direction: column; gap: 2px; color: var(--muted); }
.cost-opts input { width: 90px; }
.cost-prices input[type=number] { width: 90px; text-align: right; padding: 2px 4px; border: 1px solid var(--line); border-radius: 4px; }
.cost-prices input.own { border-color: var(--accent); background: var(--accent-soft); }
.cost-prices tr.cost-zero td { color: var(--muted); }
@media (pointer: coarse) { .cost-prices input[type=number], .cost-opts input { min-height: 40px; font-size: 16px; } }
.qt-raw { overflow-x: auto; }
.qt-raw td:first-child { white-space: normal; min-width: 140px; }   /* lange Positionsnamen umbrechen, Beträge bleiben sichtbar */
@media (max-width: 600px) {
  .cost-prices :is(td, th):nth-child(3), .cost-prices :is(td, th):nth-child(6), .cost-kg :is(td, th):nth-child(3) { display: none; }
  .cost-prices input[type=number] { width: 60px; }
  .qt-raw :is(td, th) { padding: 4px 5px; }
  .qt-raw td:first-child { min-width: 100px; }
}
.boot-error { flex-wrap: wrap; max-width: min(640px, calc(100% - 24px)); background: #fee2e2; border-color: #dc2626; color: #7f1d1d; }
.boot-error details { flex-basis: 100%; }
.boot-error textarea { width: 100%; font: 12px ui-monospace, monospace; }

/* Skizze erkennen (js/recognize.js) */
.rec-dlg { width: min(1240px, 96vw); max-width: none; }
.rec-body { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 14px; min-height: 0; }
.rec-view { border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.rec-view svg { width: 100%; height: min(70vh, 760px); display: block; touch-action: none; }
.rec-room { cursor: pointer; }
.rec-room.off text { opacity: 0.4; }
.rec-v { cursor: move; }
.rec-side { overflow-y: auto; max-height: min(74vh, 800px); }
.rec-floor { margin: 10px 0; }
.rec-floor .rec-c0 { color: #2563eb; } .rec-floor .rec-c1 { color: #ea580c; } .rec-floor .rec-c2 { color: #16a34a; }
.rec-floor .rec-c3 { color: #9333ea; } .rec-floor .rec-c4 { color: #0891b2; } .rec-floor .rec-c5 { color: #be123c; }
.dlg label.rec-row, .rec-row { display: flex; flex-direction: row; align-items: center; gap: 6px; margin: 3px 0; }
.dlg label.rec-row > input.rec-name:not([type=checkbox]) { width: 9em; flex: none; min-width: 0; min-height: 0; }
.dlg .rec-row input[type=checkbox] { width: auto; flex: none; margin: 0; }
.rec-row > span { flex: 1; min-width: 0; }
.dlg .rec-row.unsure input.rec-name { border-style: dashed; }
.rec-prog { display: flex; gap: 14px; align-items: center; }
.rec-prog img { width: 120px; max-height: 160px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; }
.rec-prog progress { width: 100%; }
@media (max-width: 760px) { .rec-body { grid-template-columns: 1fr; } .rec-view svg { height: 50vh; } }
.rec-e { cursor: copy; pointer-events: stroke; }
.dlg .rec-row input.rec-area { width: 4.5em; min-width: 0; min-height: 0; padding: 1px 4px; text-align: right; }
