/* Funktionstasten-Oberfläche (keypad.js). IDENTISCHE KOPIE in admin/keypad.css und web/keypad.css. Nutzt die Variablen von style.css. */
.kp { display: block; container-type: inline-size; }
.kp .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kp-bar { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; margin: .5rem 0 1rem; }
.kp-field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.kp-field label, .kp-lbl { font-weight: 600; font-size: .9rem; }
.kp-fixed { padding: .45rem .6rem; border: 1px solid var(--border); border-radius: .45rem; background: var(--surface-alt); min-height: 2.4rem; box-sizing: border-box; }
.kp .select, .kp-in { padding: .4rem .5rem; border: 1px solid var(--border); border-radius: .45rem; background: var(--surface); color: var(--text); font: inherit; min-height: 2.4rem; box-sizing: border-box; max-width: 100%; }
.kp-in { width: 100%; }
.kp-segs { display: inline-flex; border: 1px solid var(--border); border-radius: .5rem; overflow: hidden; }
.kp-seg { border: 0; background: var(--surface); color: var(--text); padding: .45rem .9rem; font: inherit; cursor: pointer; min-height: 2.4rem; }
.kp-seg + .kp-seg { border-left: 1px solid var(--border); }
.kp-seg.on { background: var(--primary); color: var(--on-primary); }
.kp-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-left: auto; }
.kp-right { min-width: 0; }
.kp-pager { display: flex; align-items: center; justify-content: center; gap: .5rem; margin: .6rem 0 0; }
.kp-right > .kp-pager { justify-content: flex-start; margin: 0 0 .5rem; }
.kp-pageno { min-width: 6rem; text-align: center; font-weight: 600; }
.kp-msg { margin: .5rem 0 0; min-height: 1.2rem; font-size: .9rem; }
.kp-msg.error { color: var(--danger); }
.kp-hint { color: var(--muted); font-size: .85rem; margin: .3rem 0; }
.kp-dash { color: var(--muted); }
.kp-lock { display: block; font-size: .75rem; color: var(--muted); }

/* Telefonbild: Foto mit Überlagerung (keypad.js). Die Ebene .kp-layer hat Anzeige-Koordinaten (1000 Punkte breit) und wird per matrix3d auf die Anzeige im Foto gelegt. */
.kp-body { display: block; }
.kp[data-table="1"] .kp-body { display: grid; grid-template-columns: minmax(18rem, 32rem) minmax(0, 1fr); gap: 1rem; align-items: start; }
.kp[data-table="1"][data-view="list"] .kp-body { grid-template-columns: minmax(0, 1fr); }
.kp[data-table="1"] .kp-left { border: 1px solid var(--border); border-radius: .75rem; padding: .75rem; background: var(--surface); min-width: 0; }
.kp-modelrow { display: flex; align-items: center; gap: .5rem; }
.kp-thumb { width: 3rem; height: 2.4rem; object-fit: contain; flex: none; }
.kp .btn .kp-ico, .kp-seg .kp-ico { vertical-align: -.2em; margin-right: .4rem; }
.kp-left { border: 0; padding: 0; background: transparent; }
.kp-phone { max-width: 46rem; margin: 0 auto; }
.kp-stage { position: relative; overflow: hidden; width: 100%; border-radius: .75rem; background: var(--surface-alt); }
.kp-world { position: absolute; }
.kp-photo { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.kp-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.kp-layer button { font: inherit; cursor: pointer; }
.kp-key { position: absolute; padding: 0; margin: 0; border: 0; background: transparent; color: #fff; text-align: left; }
.kp-lamp { position: absolute; width: calc(var(--kp-lr) * 2); height: calc(var(--kp-lr) * 2); border-radius: 50%; background: #9ca3af; box-shadow: 0 0 0 3px rgba(0, 0, 0, .55); }
.kp-key.on .kp-lamp { background: #22c55e; box-shadow: 0 0 0 3px rgba(0, 0, 0, .55), 0 0 14px 3px rgba(34, 197, 94, .7); }
.kp-key.on .kp-lamp.k-dnd { background: #ef4444; box-shadow: 0 0 0 3px rgba(0, 0, 0, .55), 0 0 14px 3px rgba(239, 68, 68, .7); }
.kp-key.on .kp-lamp.k-speed, .kp-key.on .kp-lamp.k-dtmf, .kp-key.on .kp-lamp.k-directory { background: #eab308; box-shadow: 0 0 0 3px rgba(0, 0, 0, .55), 0 0 14px 3px rgba(234, 179, 8, .7); }
.kp-pill { position: absolute; box-sizing: border-box; display: flex; align-items: center; gap: .2em; padding: 0 .5em; border-radius: calc(var(--kp-ph) * .2); background: rgba(15, 23, 42, .84); border: 3px solid rgba(255, 255, 255, .4); font-size: calc(var(--kp-ph) * .58); line-height: 1; overflow: hidden; }
.kp-key:not(.on) .kp-pill { background: rgba(15, 23, 42, .55); border-style: dashed; color: #cbd5e1; }
.kp-key-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-key.sel .kp-pill, .kp-tile.sel { border-color: var(--primary); border-style: solid; box-shadow: 0 0 0 4px var(--primary); }
.kp-key.inh .kp-pill { border-color: #f59e0b; }
.kp-key:hover .kp-pill, .kp-tile:hover { border-color: #fff; }
.kp-key:focus-visible, .kp-tile:focus-visible, .kp-handle:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.kp-key.over .kp-pill, .kp-tile.over { border-color: var(--primary); }
.kp-key.drag, .kp-tile.drag { opacity: .5; }
.kp-badge { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 1.3em; padding: 0 .3em; border-radius: .6em; background: #f59e0b; color: #1f1300; font-weight: 700; font-size: .78em; line-height: 1.3; }
.kp-legend { display: flex; align-items: center; justify-content: center; gap: .5rem; color: var(--muted); font-size: .85rem; margin: .4rem 0 0; }
.kp-legend .kp-badge { font-size: .8rem; }

/* Touch: Kacheln auf dem Bildschirm */
.kp-tscreen { position: absolute; inset: 0; box-sizing: border-box; padding: 26px 34px 14px; color: #fff; background: radial-gradient(ellipse at 30% 115%, #6aa6d9 0%, rgba(106, 166, 217, 0) 55%), linear-gradient(165deg, #0f2a5c 0%, #1f4f93 48%, #3f7fbd 100%); display: flex; flex-direction: column; overflow: hidden; }
.kp-top { display: flex; justify-content: space-between; align-items: flex-start; }
.kp-clk { display: flex; flex-direction: column; }
.kp-date { font-size: 32px; font-weight: 400; margin-top: 6px; }
.kp-time { font-size: 92px; line-height: 1; font-weight: 300; text-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
.kp-ext { display: inline-flex; align-items: center; gap: 12px; font-size: 34px; font-weight: 600; text-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.kp-on { width: 18px; height: 18px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.kp-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 12px; margin-top: 14px; }
.kp-tile { position: relative; box-sizing: border-box; display: flex; align-items: center; gap: 14px; padding: 0 16px; min-height: 0; background: rgba(255, 255, 255, .20); color: #fff; border: 3px solid rgba(255, 255, 255, .26); border-radius: 14px; text-align: left; backdrop-filter: blur(3px); }
.kp-tile.free { color: #d1d5db; background: rgba(255, 255, 255, .08); border-style: dashed; }
.kp-tile.add { justify-content: center; }
.kp-tile .kp-ico { flex: none; width: 52px; height: 52px; }
.kp-tile-x { display: flex; flex-direction: column; min-width: 0; gap: 3px; }
.kp-tile-t { font-weight: 700; font-size: 34px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-tile-l { font-size: 27px; line-height: 1.1; color: #e5e7eb; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-tile .kp-badge { position: absolute; top: -10px; right: -6px; font-size: 22px; }
.kp-tile.inh { border-color: #f59e0b; }
.kp-plus { font-size: 60px; line-height: 1; }
.kp-dots { display: flex; justify-content: center; gap: 12px; padding-top: 8px; }
.kp-dot { width: 14px; height: 14px; border-radius: 50%; background: rgba(255, 255, 255, .4); }
.kp-dot.cur { background: #ef4444; }
.kp-tile.on.k-blf .kp-ico { color: #4ade80; }
.kp-ico { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Dialog «Taste bearbeiten» */
.kp-dlg { width: min(30rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); border: 1px solid var(--border); border-radius: .75rem; padding: 1.1rem 1.25rem; background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgb(0 0 0 / .35); }
.kp-dlg::backdrop { background: rgb(0 0 0 / .5); }
.kp-dlg h3 { margin: 0 0 .8rem; }
.kp-dlg-form { display: grid; gap: .35rem; }
.kp-dlg-form[hidden] { display: none; }
.kp-dlg-form > label { font-weight: 600; font-size: .9rem; margin-top: .4rem; }
.kp-dlg-row { display: flex; align-items: center; gap: .6rem; }
.kp-dlg-row .select { flex: 1; min-width: 0; }
.kp-dlg-ico { display: inline-flex; width: 2.4rem; height: 2.4rem; align-items: center; justify-content: center; border-radius: .5rem; background: var(--surface-alt); border: 1px solid var(--border); }
.kp-dlg-ico .kp-ico { width: 1.4rem; height: 1.4rem; }
.kp-dlg .select, .kp-dlg .kp-in { width: 100%; }
.kp-dlg-target .kp-hint { margin: 0; }
.kp-status { margin: .2rem 0 0; min-height: 1.1rem; font-size: .85rem; color: var(--danger); }
.kp-dlg-btns { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; align-items: center; }
.kp-dlg-clear { margin-left: auto; }
.kp-dlg-inh p { margin: .2rem 0; }
.kp-dlg-sum { font-weight: 600; }

/* Tabelle */
.kp-tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: .75rem; background: var(--surface); }
.kp-tbl { width: 100%; border-collapse: collapse; }
.kp-tbl th, .kp-tbl td { padding: .4rem .5rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.kp-tbl thead th { background: var(--surface-alt); font-size: .85rem; }
.kp-tbl tbody tr:last-child > * { border-bottom: 0; }
.kp-tbl tr.sel > * { background: var(--primary-soft); }
.kp-tbl tr.over > * { background: var(--primary-faint); }
.kp-tbl tr.drag { opacity: .5; }
.kp-c-h { width: 2rem; }
.kp-c-no { width: 2.5rem; font-weight: 700; }
.kp-c-kind .select, .kp-c-target .select { width: 100%; }
.kp-c-menu { width: 2.6rem; }
.kp-handle { border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; cursor: grab; min-width: 2rem; min-height: 2.2rem; }
.kp-handle:disabled { cursor: default; opacity: .35; }
.kp-status.bad { display: block; color: var(--danger); font-size: .8rem; }
.kp-menu { position: relative; }
.kp-pop { position: absolute; right: 0; top: 100%; z-index: 20; min-width: 12rem; display: flex; flex-direction: column; gap: .35rem; padding: .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: .5rem; box-shadow: 0 4px 14px rgb(0 0 0 / .25); }
.kp-pop[hidden] { display: none; }
.kp-mi { text-align: left; border: 0; background: transparent; color: var(--text); font: inherit; padding: .4rem .5rem; border-radius: .35rem; cursor: pointer; min-height: 2.2rem; }
.kp-mi:hover:not(:disabled) { background: var(--surface-alt); }
.kp-mi:disabled { color: var(--muted); cursor: default; }
[aria-invalid="true"] { border-color: var(--danger) !important; }

@container (max-width: 52rem) {
  .kp[data-table="1"] .kp-body { grid-template-columns: minmax(0, 1fr); }
  .kp-actions { margin-left: 0; }
  .kp-tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .kp-tbl, .kp-tbl tbody, .kp-tbl tr { display: block; }
  .kp-tbl tr { display: grid; grid-template-columns: 2rem 2.5rem minmax(0, 1fr) 2.6rem; gap: .25rem .4rem; padding: .5rem; border-bottom: 1px solid var(--border); align-items: center; }
  .kp-tbl th, .kp-tbl td { display: block; border: 0; padding: 0; }
  .kp-c-kind { grid-column: 3 / 4; }
  .kp-c-target, .kp-c-label { grid-column: 2 / 4; }
  .kp-c-menu { grid-column: 4; grid-row: 1; }
}
@media (prefers-reduced-motion: no-preference) { .kp-key, .kp-tile { transition: border-color .12s; } }

.kp-c-kind { min-width: 9.5rem; }
.kp-c-target { min-width: 8.5rem; }
.kp-c-label { min-width: 8rem; }

/* Anzeige der Tastentelefone: deckt den Original-Bildschirminhalt des Fotos ab */
.kp-lcd { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 110%, #5fb3d9 0%, rgba(95, 179, 217, 0) 60%), linear-gradient(170deg, #12356b 0%, #1d6fb0 55%, #19a3b5 100%); color: #fff; overflow: hidden; }
.kp-lcd.mono { background: linear-gradient(180deg, #f1f4f7, #dfe5ea); color: #111827; }
.kp-lcd-clk { position: absolute; left: 0; right: 0; top: 28%; display: flex; flex-direction: column; align-items: center; }
.kp-lcd .kp-time { font-size: 120px; }
.kp-lcd .kp-date { font-size: 44px; }
.kp-lcd-soft { position: absolute; left: 0; right: 0; bottom: 0; height: 15%; display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(0, 0, 0, .55); color: #fff; font-size: 40px; }
.kp-lcd.mono .kp-lcd-soft { background: #111827; }
.kp-lcd-soft span { display: flex; align-items: center; justify-content: center; border-left: 3px solid rgba(255, 255, 255, .2); }
.kp-lcd-soft span:first-child { border-left: 0; }
.kp-lcd .kp-time, .kp-lcd .kp-date { text-shadow: none; }

/* Tabelle: Spaltenbreiten wie im Mockup */
.kp-tbl { table-layout: fixed; }
.kp-tbl .kp-c-kind, .kp-tbl .kp-c-target, .kp-tbl .kp-c-label { min-width: 0; }
.kp-tbl th:nth-child(1) { width: 2rem; }
.kp-tbl th:nth-child(2) { width: 4.2rem; }
.kp-tbl th:nth-child(3) { width: 28%; }
.kp-tbl th:nth-child(4) { width: 22%; }
.kp-tbl th:nth-child(6) { width: 2.4rem; }
.kp-tbl .select, .kp-tbl .kp-in { font-size: .85rem; min-height: 2.1rem; padding: .25rem .4rem; }
.kp-tbl th, .kp-tbl td { padding: .3rem .4rem; }
.kp-c-no { width: auto; }
.kp[data-table="1"] .kp-left { padding: .35rem; }
.kp[data-table="1"] .kp-stage { border-radius: .6rem; }
