:root{
  --bg1:#dbeafe;
  --bg2:#ffffff;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#475569;
  --line:rgba(15,23,42,.10);
  --primary:#2563eb;
  --primary2:#60a5fa;
  --danger:#ef4444;
  --warn:#f59e0b;
  --ok:#10b981;
  --shadow:0 10px 30px rgba(2,6,23,.12);
  --radius:18px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif;
  color:var(--text);
  background:var(--bg2);
  position:relative;
}

/* Fixní pozadí (stejné i při scrollu) – funguje i v PWA */
body::before{
  content:"";
  position:fixed;
  inset:0;
  background:linear-gradient(180deg,var(--bg1) 0%, var(--bg2) 70%);
  z-index:-1;
}

/* Admin → Oprávnění (profi layout) */
.af-toolbar{display:flex; gap:10px; flex-wrap:wrap; align-items:center; justify-content:space-between; margin-top:10px}
.af-toolbar .af-search{flex:1; min-width:260px}
.af-toolbar .af-actions{display:flex; gap:8px; flex-wrap:wrap}
.af-groups{display:grid; grid-template-columns:1fr; gap:14px; margin-top:12px}
.af-group{background:rgba(255,255,255,.72); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); padding:14px}
.af-group-head{display:flex; align-items:flex-end; justify-content:space-between; gap:10px; flex-wrap:wrap}
.af-group-title{font-weight:900; font-size:15px; margin:0}
.af-group-sub{margin:4px 0 0; color:var(--muted); font-size:12.5px}
.af-grid{display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:10px; margin-top:12px}
.af-item{display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 12px; border-radius:16px; background:rgba(255,255,255,.85); border:1px solid rgba(15,23,42,.08); cursor:pointer; user-select:none}
.af-item:hover{background:rgba(255,255,255,.95)}
.af-item .af-title{font-weight:900; margin:0}
.af-item .af-meta{margin-top:6px; color:var(--muted); font-size:12.5px}
.af-right{display:flex; align-items:center; gap:10px}
.af-state{display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border-radius:999px; font-weight:900; font-size:11px; letter-spacing:.06em; text-transform:uppercase; border:1px solid rgba(2,6,23,.10); background:rgba(2,6,23,.06); color:rgba(2,6,23,.70)}
.af-state::before{content:""; width:8px; height:8px; border-radius:999px; background:rgba(2,6,23,.35)}
.af-state.on{border-color:rgba(16,185,129,.35); background:rgba(16,185,129,.16); color:rgba(6,95,70,.92)}
.af-state.on::before{background:rgba(16,185,129,.90); box-shadow:0 0 0 4px rgba(16,185,129,.18)}
.af-state.off{border-color:rgba(2,6,23,.10); background:rgba(2,6,23,.06); color:rgba(2,6,23,.62)}
.af-state.off::before{background:rgba(2,6,23,.35)}
.af-stickybar{position:sticky; bottom:10px; z-index:5; margin-top:14px; padding:10px; border-radius:16px; background:rgba(255,255,255,.82); border:1px solid rgba(15,23,42,.10); backdrop-filter:blur(8px); -webkit-backdrop-filter:blur(8px); display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap}
.af-stickybar .sub{margin:0}

@media (max-width: 980px){
  .af-grid{grid-template-columns:1fr}
}

a{color:inherit; text-decoration:none}
a:hover{text-decoration:underline}

.container{
  width:min(1100px, 92vw);
  margin:0 auto;
  padding:18px 0 60px;
}

.topbar{
  position:relative;
  padding:20px 0 8px;
}
.topbar-inner{
  display:flex;
  gap:14px;
  align-items:center;
  justify-content:space-between;
}
.brand{
  display:flex;
  gap:12px;
  align-items:center;
  min-width:0;
}
.brand-logo{
  width:44px;height:44px;
  border-radius:14px;
  background:linear-gradient(135deg,var(--primary),var(--primary2));
  box-shadow:var(--shadow);
  display:grid;place-items:center;
}
.brand-logo img{width:26px;height:26px; filter:drop-shadow(0 6px 12px rgba(0,0,0,.2))}
.brand-title{
  display:flex;
  flex-direction:column;
  min-width:0;
}
.brand-title b{
  font-size:15px;
  letter-spacing:.2px;
}
.brand-title span{
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.nav{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.pill{
  padding:10px 12px;
  background:rgba(255,255,255,.70);
  border:1px solid var(--line);
  border-radius:999px;
  box-shadow:0 8px 20px rgba(2,6,23,.06);
  font-size:13px;
  display:inline-flex;
  align-items:center;
  gap:8px;
}
.pill:hover{background:rgba(255,255,255,.92)}
.pill.primary{background:linear-gradient(135deg,var(--primary),var(--primary2)); color:white; border:none}
.pill.danger{background:rgba(239,68,68,.08); border:1px solid rgba(239,68,68,.25); color:#b91c1c}

.wave{
  position:absolute;
  inset:auto 0 -10px 0;
  height:56px;
  pointer-events:none;
  opacity:.55;
}
.wave svg{width:100%; height:100%}

.card{
  background:rgba(255,255,255,.85);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:18px;
}
.grid{
  display:grid;
  grid-template-columns:1.2fr .8fr;
  gap:16px;
}
/* Allow grid items to shrink (prevents wide tables from forcing page overflow) */
.grid > *{ min-width:0; }
@media (max-width: 900px){
  .grid{grid-template-columns:1fr}
  .nav{justify-content:flex-start}
}

.h1{
  font-size:18px;
  margin:0 0 8px;
}
.sub{
  margin:0 0 12px;
  color:var(--muted);
  font-size:13px;
}

.row{display:flex; gap:10px; flex-wrap:wrap; align-items:center}
input[type="text"], input[type="password"], input[type="number"], input[type="email"], input[type="tel"], input[type="url"], input[type="search"], textarea{
  width:100%;
  padding:12px 12px;
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
  outline:none;
  font-size:14px;
  -webkit-appearance:none;
  appearance:none;
}
select{
  width:100%;
  padding:12px 12px;
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
  outline:none;
  font-size:14px;
}
textarea{min-height:90px; resize:vertical}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
  line-height:1;
  border:0;
  border-radius:14px;
  padding:12px 14px;
  font-weight:700;
  cursor:pointer;
  background:linear-gradient(135deg,var(--primary),var(--primary2));
  color:white;
  box-shadow:0 12px 24px rgba(37,99,235,.25);
}
.btn:hover{filter:brightness(1.02)}
.btn:disabled{opacity:.55; cursor:not-allowed; filter:grayscale(.2)}
.btn.ghost{
  background:rgba(255,255,255,.70);
  color:var(--text);
  border:1px solid var(--line);
  box-shadow:none;
}
.btn.danger{
  background:linear-gradient(135deg,#ef4444,#fb7185);
}
.btn.small{
  padding:9px 10px;
  border-radius:12px;
  font-weight:700;
  font-size:13px;
}

.kpi{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}
.kpi .box{
  flex:1;
  min-width:160px;
  background:rgba(255,255,255,.78);
  border:1px solid var(--line);
  border-radius:16px;
  padding:12px 12px;
}
.kpi .box b{display:block; font-size:22px}
.kpi .box span{color:var(--muted); font-size:12px}

.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  overflow:hidden;
  border-radius:16px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.85);
}
.table th,.table td{
  text-align:left;
  padding:12px 12px;
  border-bottom:1px solid var(--line);
  font-size:13px;
}
.table th{font-size:12px; color:var(--muted); background:rgba(241,245,249,.7)}
.table tr:last-child td{border-bottom:none}

/* Admin – mail log: keep header + rows compact and readable on desktop */
.kb-maillog-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:12px;
  flex-wrap:wrap;
}
.kb-maillog-meta{
  margin-top:6px;
  line-height:1.35;
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
}
.kb-dot{ opacity:.6; }
.kb-maillog-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}
.kb-table-scroll{ width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; min-width:0; }
.kb-mail-log td{ vertical-align:top; }
.kb-mail-log{ width:100%; min-width:0; }
.kb-mail-log-to{ max-width:none; }
.kb-mail-log th:nth-child(1), .kb-mail-log td:nth-child(1){ width:155px; white-space:nowrap; }
.kb-mail-log th:nth-child(3), .kb-mail-log td:nth-child(3){ width:150px; white-space:nowrap; }
.kb-mail-log th:nth-child(4), .kb-mail-log td:nth-child(4){ width:170px; white-space:nowrap; }
.kb-mail-log .kb-mail-to{
  display:block;
  white-space:normal;
  overflow:visible;
  text-overflow:clip;
}

.kb-mail-log .kb-mail-to{ font-weight:800; }
.kb-mail-log .kb-mail-sub{
  margin-top:2px;
  color:var(--muted);
  font-size:12px;
  line-height:1.35;
  overflow-wrap:break-word;
}
.kb-mail-status{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  row-gap:6px;
  align-items:center;
  line-height:1.25;
}

/* Table row actions (e.g. admin/keys) */
.table-actions{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  align-items:center;
  max-width:100%;
}
.table-actions > *{ margin:0; }
.table-actions form{ display:inline-block; margin:0; }
.table-actions .btn{ white-space:nowrap; }
.badge{
  padding:6px 10px;
  border-radius:999px;
  font-weight:800;
  font-size:12px;
  display:inline-flex;
  align-items:center;
  gap:6px;
  border:1px solid transparent;
}
.badge.ok{background:rgba(16,185,129,.10); border-color:rgba(16,185,129,.25); color:#047857}
.badge.warn{background:rgba(245,158,11,.12); border-color:rgba(245,158,11,.25); color:#92400e}
.badge.danger{background:rgba(239,68,68,.10); border-color:rgba(239,68,68,.25); color:#b91c1c}
.badge.gray{background:rgba(2,6,23,.06); border-color:rgba(2,6,23,.10); color:#334155}

.notice{
  padding:12px 12px;
  border-radius:16px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.75);
  font-size:13px;
}
.notice.ok{border-color:rgba(16,185,129,.25); background:rgba(16,185,129,.08)}
.notice.warn{border-color:rgba(245,158,11,.25); background:rgba(245,158,11,.08)}
.notice.danger{border-color:rgba(239,68,68,.25); background:rgba(239,68,68,.06)}

.footer{
  margin-top:14px;
  color:var(--muted);
  font-size:12px;
  display:flex;
  gap:10px;
  justify-content:space-between;
  flex-wrap:wrap;
}

dialog{
  border:none;
  border-radius:18px;
  padding:0;
  width:min(720px, 92vw);
  box-shadow:0 30px 80px rgba(2,6,23,.30);
}
dialog::backdrop{
  background:rgba(2,6,23,.35);
}
.modal{
  padding:18px;
  background:linear-gradient(180deg, rgba(219,234,254,.9) 0%, rgba(255,255,255,.95) 55%);
}
.modal h2{margin:0 0 10px; font-size:16px}
.modal p{margin:0 0 10px; color:var(--muted); font-size:13px; line-height:1.45}
.modal .actions{display:flex; gap:10px; justify-content:flex-end; padding-top:10px}


/* Support chat (online podpora) */
.scModal{width:100%}
.scHead{display:flex; justify-content:space-between; align-items:flex-start; gap:12px; padding-bottom:12px; border-bottom:1px solid var(--border)}
.scTitle{font-weight:950}
.scSub{font-size:12px; color:var(--muted); margin-top:4px}
.scHeadRight{display:flex; gap:10px; align-items:center; flex-wrap:wrap}

/* Flex layout: when left panel is hidden, chat naturally spans full width */
.scBody{display:flex; gap:12px; margin-top:12px; min-height: 440px; min-width:0}
@media (max-width: 900px){
  .scBody{flex-direction:column; min-height: 520px}
}

.scLeft{flex:0 0 320px; border:1px solid var(--border); border-radius:16px; background:rgba(255,255,255,.65); overflow:hidden; display:flex; flex-direction:column; min-width:0}
@media (max-width: 900px){
  .scLeft{flex:0 0 auto; max-height: 220px}
}

.scTabs{display:flex; gap:8px; padding:10px; border-bottom:1px solid var(--border); flex-wrap:wrap}
.scSessions{overflow:auto; padding:10px; display:flex; flex-direction:column; gap:8px}
.scSess{border:1px solid var(--border); border-radius:14px; background:#fff; padding:10px; cursor:pointer}
.scSess.active{outline:2px solid rgba(37,99,235,.35)}
.scSessTop{display:flex; justify-content:space-between; align-items:center; gap:10px}
.scSessName{font-weight:900}
.scSessMeta{margin-top:6px; font-size:12px; color:var(--muted); line-height:1.35}

.scChat{flex:1 1 auto; min-width:0; border:1px solid var(--border); border-radius:16px; background:rgba(255,255,255,.65); overflow:hidden; display:flex; flex-direction:column}
.scMsgs{padding:12px; overflow:auto; flex:1 1 auto; min-height:0; display:flex; flex-direction:column; gap:10px}
.scMsg{max-width: 80%; padding:10px 12px; border-radius:16px; border:1px solid var(--border); background:#fff}
.scMsg.me{margin-left:auto; background:rgba(37,99,235,.10)}
.scMsg.sys{max-width: 100%; background:rgba(0,0,0,.04)}
.scMsgTop{display:flex; justify-content:space-between; gap:10px; font-size:12px; color:var(--muted)}
.scMsgText{margin-top:6px; white-space:pre-wrap; word-break:break-word}

.scQuick{padding:10px; border-top:1px dashed var(--border); display:flex; gap:8px; flex-wrap:wrap}
.scComposer{display:flex; gap:10px; padding:10px; border-top:1px solid var(--border); background:rgba(255,255,255,.85)}
.scComposer .input{flex:1}

.scOp{display:flex; gap:8px; align-items:center}
.scSwitch{position:relative; display:inline-flex; align-items:center; width:46px; height:26px}
.scSwitch input{opacity:0; width:0; height:0}
.scSlider{position:absolute; inset:0; background:#e5e7eb; border-radius:999px; transition:.2s}
.scSlider:before{content:""; position:absolute; height:20px; width:20px; left:3px; top:3px; background:#fff; border-radius:999px; box-shadow:0 2px 10px rgba(0,0,0,.12); transition:.2s}
.scSwitch input:checked + .scSlider{background:rgba(16,185,129,.55)}
.scSwitch input:checked + .scSlider:before{transform:translateX(20px)}
.scOpLbl{font-size:13px; font-weight:900}


.loader{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(255,255,255,.55);
  backdrop-filter: blur(6px);
  z-index:9999;
}
.loader.show{display:flex}
.spinner{
  width:54px;height:54px;
  border-radius:999px;
  border:6px solid rgba(37,99,235,.18);
  border-top-color:rgba(37,99,235,.85);
  animation:spin 1s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}


/* Big cabinet key button */
.btn.bigkey{
  font-size:18px;
  padding:14px 18px;
}
.btn.bigkey .keyglyph{
  width:22px;
  height:22px;
  display:inline-block;
  background:url('../img/key.svg') no-repeat center / contain;
  margin-right:10px;
  transform:translateY(2px);
}
@media (max-width: 760px){
  .btn.bigkey{ width:100%; justify-content:center; }
}


/* Switch (aktivace uživatele) */
.switch{
  position:relative;
  display:inline-block;
  width:46px;
  height:26px;
}
.switch input{opacity:0; width:0; height:0}
.slider{
  position:absolute;
  inset:0;
  cursor:pointer;
  border-radius:999px;
  background:rgba(2,6,23,.10);
  border:1px solid var(--line);
  transition: .2s;
}
.slider:before{
  content:"";
  position:absolute;
  height:18px;
  width:18px;
  left:3px;
  top:3px;
  background:#fff;
  border-radius:999px;
  box-shadow:0 6px 16px rgba(2,6,23,.18);
  transition:.2s;
}
.switch input:checked + .slider{
  background:rgba(16,185,129,.22);
  border-color:rgba(16,185,129,.35);
}
.switch input:checked + .slider:before{
  transform: translateX(20px);
}
.switch input:disabled + .slider{
  opacity:.55;
  cursor:not-allowed;
}

/* Number stepper (idle logout minutes) */
.kb-stepper{
  display:flex;
  align-items:center;
  gap:8px;
}
.kb-stepper input[type="number"]{
  max-width:120px;
}
@media (max-width: 720px){
  .kb-stepper{ width:100%; }
  .kb-stepper input[type="number"]{ max-width:none; flex:1; }
}


/* Tables: keep inside cards without forcing horizontal scrollbars */
.table-scroll{
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  min-width:0;
}
.table-scroll .table{
  width:100%;
  min-width:0;
  table-layout:fixed;
}
.table th,.table td{
  overflow-wrap:break-word;
  word-break:normal;
}

/* 2-column grids (equal width) */
.grid.grid-2{
  grid-template-columns:1fr 1fr;
}

/* 3-column grid (admin forms) */
.grid.grid-3{
  grid-template-columns:repeat(3, minmax(0, 1fr));
}
@media (max-width: 900px){
  .grid.grid-3{ grid-template-columns:1fr; }
}

/* Tables: opt-out from fixed layout when actions have to fit */
.table-auto{
  table-layout:auto !important;
}

/* Users table: keep action buttons visible on desktop */
.users-table th:nth-child(7),
.users-table td:nth-child(7){
  width:220px;
}

/* Kiosk scan table: keep it compact, no forced horizontal scrollbar */
.table-scroll.ms-scan .table{ min-width:0; }
.table.ms-scan{ table-layout:fixed; }
.table.ms-scan th:nth-child(1), .table.ms-scan td:nth-child(1){ width:44px; }
.table.ms-scan th:nth-child(4), .table.ms-scan td:nth-child(4){ width:44px; text-align:right; }
.table.ms-scan td:nth-child(2) b{
  display:block;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.table.ms-scan td:nth-child(3) .sub{
  margin:3px 0 0;
  white-space:normal;
  overflow-wrap:anywhere;
}

/* Auto logout countdown */
.pill.danger.imminent{
  background:rgba(239,68,68,.16);
  border-color:rgba(239,68,68,.35);
}
.pill .badge{white-space:nowrap}


/* Hide the action block for normal users on mobile */
body.role-user.is-mobile .hide-user-mobile{ display:none !important; }


/* === V5.2.7.44 Mobile polish: no horizontal scrollbars inside cards/tables === */
@media (max-width: 760px){
  html, body{ overflow-x:hidden; }

  /* topbar nav: grid, no sideways scroll */
  .topbar-inner{ flex-direction:column; align-items:stretch; gap:10px; }
  .topbar .brand{ min-width:0; }
  .topbar .nav{
    display:grid;
    grid-template-columns:repeat(3, minmax(0, 1fr));
    gap:8px;
  }
  .topbar .nav .pill{
    width:100%;
    justify-content:center;
    padding:9px 8px;
    font-size:12px;
    text-align:center;
    min-width:0;
  }
  #logoutBtn{ white-space:nowrap; }

  /* grids/cards */
  .grid{ grid-template-columns:1fr !important; }
  .grid > *{ min-width:0 !important; }
  .card{ overflow:hidden; }

  /* tables: wrap content, remove horizontal scroll indicators */
  .table-scroll{
    overflow-x:hidden !important;
    -webkit-overflow-scrolling:auto !important;
    scrollbar-width:none;
  }
  .table-scroll::-webkit-scrollbar{ height:0; width:0; display:none; }

  /* mail log is allowed to scroll horizontally if needed (better than clipping) */
  .kb-table-scroll{ overflow-x:auto !important; -webkit-overflow-scrolling:touch !important; }

  /* mail log: never break emails to vertical letters */
  .kb-mail-log.table th, .kb-mail-log.table td{ overflow-wrap:normal !important; word-break:normal !important; }
  .kb-mail-log .kb-mail-to{ overflow-wrap:normal !important; word-break:normal !important; }

  .table{ width:100% !important; min-width:0 !important; table-layout:fixed !important; }
  .table th, .table td{
    white-space:normal !important;
    overflow-wrap:anywhere;
    word-break:break-word;
  }
  .mobile-skip{ display:none !important; }

  /* code-ish / monospace blocks often force overflow */
  .mono, code, pre, .nowrap{ white-space:normal !important; overflow-wrap:anywhere; word-break:break-word; }

  /* rows */
  .row{ flex-wrap:wrap; }
  .row > *{ min-width:0 !important; }
}


/* Kiosk – přihlášení kartou (autoscanner) */
.scanBox{
  border:1px dashed var(--line);
  border-radius:16px;
  padding:14px;
  background:rgba(255,255,255,.6);
  cursor:pointer;
  outline:none;
}
.scanBox:focus{ box-shadow:0 0 0 3px rgba(37,99,235,.15); }
.scanTitle{ font-weight:800; font-size:16px; margin-bottom:6px; }
.scanStatus{ font-size:13px; color:var(--muted); margin-bottom:10px; }
.scanMeta{ display:flex; gap:10px; justify-content:space-between; font-size:12px; color:var(--muted); }
.scanCountdown{ font-weight:800; }

.scanBox.ok{ border-color:rgba(16,185,129,.35); background:rgba(16,185,129,.06); }
.scanBox.warn{ border-color:rgba(245,158,11,.35); background:rgba(245,158,11,.06); }
.scanBox.danger{ border-color:rgba(239,68,68,.35); background:rgba(239,68,68,.05); }


/* kiosk card scan animation */
.scanAnim{ display:flex; justify-content:center; margin:6px 0 10px; }
.scanSvg{ width:220px; height:92px; }
.scanReader{ fill:#e9ecef; stroke:#cfd4da; stroke-width:2; }
.scanCard{ fill:#ffffff; stroke:#cfd4da; stroke-width:2; transform-origin: 70px 62px; animation: scanCardMove 1.7s infinite ease-in-out; }
.scanStripe{ fill:#e9ecef; stroke:#cfd4da; stroke-width:1; transform-origin: 70px 62px; animation: scanCardMove 1.7s infinite ease-in-out; }
.scanWave, .scanWave2{ fill:none; stroke:#9aa0a6; stroke-width:2; opacity:0; transform-origin:150px 76px; animation: scanWave 1.7s infinite; }
.scanWave2{ animation-delay: .25s; }

@keyframes scanCardMove{
  0%{ transform: translateX(0px); }
  40%{ transform: translateX(80px); }
  60%{ transform: translateX(80px); }
  100%{ transform: translateX(0px); }
}
@keyframes scanWave{
  0%{ opacity:0; transform: scale(0.6); }
  40%{ opacity:0; transform: scale(0.6); }
  55%{ opacity:.9; transform: scale(1.0); }
  70%{ opacity:0; transform: scale(1.35); }
  100%{ opacity:0; transform: scale(1.35); }
}


/* cabinets unlock overlay (variant 2) */
.unlockOverlay{
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  z-index: 9999;
}
.unlockOverlay[hidden]{ display: none !important; }
.unlockCard{
  width: min(460px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 16px;
  padding: 18px 16px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.08);
}
.lockWrap{
  color: #8a8f98;
  width: 104px;
  height: 104px;
  margin: 8px auto 12px;
}
.lockSvg{ width: 100%; height: 100%; }

.unlockTitle{ font-weight: 800; font-size: 18px; margin-top: 2px; }
.unlockHint{ color: #666; font-size: 13px; margin-top: 6px; }

.unlockSteps{ margin-top: 12px; text-align: left; }
.step{ padding: 8px 10px; border-radius: 10px; border: 1px solid #eee; color: #666; margin-top: 8px; }
.step-on{ border-color: #d7e6ff; background: #f4f8ff; color: #2f5fb8; }
.unlockFine{ margin-top: 10px; font-size: 12px; color: #777; }

@keyframes lockFloat{ 0%,100%{ transform: translateY(0); } 50%{ transform: translateY(-2px); } }
@keyframes shackleWiggle{ 0%,100%{ transform: rotate(0deg); } 50%{ transform: rotate(-2deg); } }

/* Default: unlocking */
#lockWrap:not(.unlocked) .lockSvg{ animation: lockFloat 1.1s ease-in-out infinite; }
#lockWrap:not(.unlocked) .lockShackle{
  transform-origin: 64px 40px;
  animation: shackleWiggle 0.9s ease-in-out infinite;
}

/* State: unlocked */
#lockWrap.unlocked .lockShackle{
  transform-origin: 44px 58px;
  transform: rotate(-25deg) translate(-2px,-2px);
  transition: transform 240ms ease;
}

@media (prefers-reduced-motion: reduce){
  #lockWrap .lockSvg,
  #lockWrap .lockShackle{ animation: none !important; transition: none !important; }
}


/* --- Help modal (context) --- */
.helpModal .helpTop{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.helpModal .helpTopMeta{ display:flex; gap:8px; flex-wrap:wrap; }

.helpContext{ margin-top: 8px; }
.helpHero{
  text-align:left;
  padding: 10px 12px;
  border: 1px solid #eee;
  border-radius: 14px;
  background: rgba(0,0,0,.02);
  margin-bottom: 10px;
}
.helpHeroTitle{ font-weight: 900; font-size: 16px; }
.helpHeroSub{ color:#666; font-size: 12px; margin-top: 2px; word-break: break-all; }

.helpGrid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 760px){
  .helpGrid{ grid-template-columns: 1fr 1fr; }
}
.helpCard{
  text-align:left;
  border: 1px solid #eaeaea;
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}
.helpCardTitle{
  font-weight: 800;
  margin-bottom: 6px;
}
.helpCard ul{
  margin: 0;
  padding-left: 18px;
  color:#444;
}
.helpCard li{ margin: 6px 0; }

.helpActions{ display:flex; justify-content: space-between; align-items:center; gap:10px; flex-wrap:wrap; }


/* Help: richer cards (full help + context) */
.helpHeroRow{ display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.helpHeroIcon{ display:inline-flex; align-items:center; justify-content:center; width:26px; height:26px; margin-right:6px; font-size:18px; }
.helpHeroSvg{ flex: 0 0 auto; width: 110px; height: 60px; color: #222; opacity: .9; }
.helpHeroSvg .helpSvg{ width:100%; height:100%; }

.helpCardIcon{ display:inline-flex; align-items:center; justify-content:center; width:22px; height:22px; margin-right:6px; font-size:16px; }

.helpCard.warn{ border-color:#f2d6a0; background: rgba(255, 199, 87, .12); }

.helpOl{ margin: 0; padding-left: 20px; color:#444; }
.helpOl li{ margin: 8px 0; }

.helpExample{ margin: 8px 0 0 0; padding: 10px 12px; border-radius: 12px; border:1px dashed #ddd; background: rgba(0,0,0,.02); overflow:auto; }
.helpExample code{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 12px; white-space: pre; }

.helpFigure{ text-align:left; }
.helpFigureSvg{ width:100%; height:auto; color:#222; opacity:.95; }
.helpFigureSvg .helpSvg{ width:100%; height: 86px; }
.helpFigureCap{ margin-top: 8px; color:#666; font-size: 12px; }

.helpMiniActions{ margin-top: 10px; display:flex; justify-content:flex-start; gap:8px; flex-wrap:wrap; }

/* Full help page helpers */
.helpTopic summary{ display:flex; align-items:center; gap:8px; }



/* --- PWA install (mobile app) --- */
.installGrid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
  margin:10px 0 0 0;
}
@media (max-width:720px){
  .installGrid{ grid-template-columns:1fr; }
}
.installCard{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
}
.installHead{
  display:flex;
  gap:10px;
  align-items:center;
}
.installIcon{
  width:34px;
  height:34px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:10px;
  background:rgba(37,99,235,.12);
  font-size:18px;
}
.installTitle{
  font-weight:700;
}
.installSteps{
  margin:10px 0 0 0;
  padding-left:18px;
}
.installSteps li{ margin:6px 0; }



/* PWA install UI */
.pillIcon{width:16px;height:16px;border-radius:4px;display:inline-block;}
.installH2{margin:0 0 8px 0;display:flex;align-items:center;gap:10px;}
.installLogo{border-radius:8px;box-shadow:0 6px 18px rgba(2,6,23,.12);}


/* Admin – accordions (SMTP/DNS details) */
.kb-acc summary{ cursor:pointer; }
.kb-acc summary::-webkit-details-marker{ display:none; }
.kb-acc summary:before{ content:'▸'; display:inline-block; margin-right:8px; opacity:.75; }
.kb-acc[open] summary:before{ content:'▾'; }


/* Admin users: enterprise form */
.kb-panel{
  background:rgba(255,255,255,.78);
  border:1px solid var(--line);
  border-radius:16px;
  padding:14px;
  box-shadow:none;
}
.kb-label{
  margin:0 0 6px 0;
  display:flex;
  align-items:center;
  gap:6px;
}
.kb-ico{
  width:18px;
  display:inline-flex;
  justify-content:center;
}
.kb-user-preview .kb-preview-row{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:10px 0;
  border-bottom:1px dashed rgba(15,23,42,.12);
}
.kb-user-preview .kb-preview-row:last-child{ border-bottom:none; }
.kb-user-preview .kb-preview-val{
  display:flex;
  align-items:center;
  gap:8px;
  justify-content:flex-end;
  min-width:0;
}
.kb-user-preview .kbd{
  max-width:100%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.kb-copy{ padding:8px 10px; }

@media (max-width: 720px){
  .kb-user-preview .kb-preview-row{ flex-direction:column; align-items:flex-start; }
  .kb-user-preview .kb-preview-val{ justify-content:flex-start; }
}


/* User edit (enterprise layout) */
.badge.info{background:rgba(37,99,235,.10); border-color:rgba(37,99,235,.22); color:#1d4ed8}
.muted{color:var(--muted); font-size:13px}

.ue-section{margin-top:12px; padding-top:12px; border-top:1px solid var(--line)}
.ue-section:first-of-type{margin-top:0; padding-top:0; border-top:0}
.ue-section-h{font-weight:900; letter-spacing:.2px; margin:0 0 8px; font-size:13px; color:rgba(15,23,42,.85)}
.ue-actions{position:sticky; bottom:10px; background:rgba(255,255,255,.70); border:1px solid var(--line); padding:10px; border-radius:16px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px)}
@media (max-width: 900px){ .ue-actions{position:static} }

.ue-kv{display:grid; grid-template-columns:140px 1fr; gap:8px 10px; font-size:13px; margin-top:8px}
.ue-kv .k{color:var(--muted)}
.ue-kv .v{font-weight:800}
@media (max-width: 520px){ .ue-kv{grid-template-columns:1fr; } .ue-kv .v{font-weight:700} }

.ue-divider{height:1px; background:var(--line); margin:14px 0}
.ue-mini-h{font-size:13px; margin:0 0 8px; letter-spacing:.2px}

/* Support chat: full-size dialog with inner scrolling (mobile + desktop) */
dialog#supportChat{
  width: min(980px, 96vw);
  height: min(740px, calc(100vh - 24px));
  height: min(740px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
  overflow: hidden;
}
@supports (height: 100svh){
  dialog#supportChat{
    height: min(740px, calc(100svh - 24px));
    max-height: calc(100svh - 24px);
  }
}
@media (max-width: 560px){
  dialog#supportChat{
    width: calc(100vw - 16px);
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 18px;
  }
}
dialog#supportChat .scModal{
  width: 100%;
  height: 100%;
  display:flex;
  flex-direction:column;
  max-height: 100%;
}
dialog#supportChat .scBody{
  flex: 1 1 auto;
  min-height: 0; /* critical for flex overflow */
}
dialog#supportChat .scLeft,
dialog#supportChat .scChat{
  min-height: 0;
}
dialog#supportChat .scSessions,
dialog#supportChat .scMsgs{
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
@supports (padding: max(0px)) {
  dialog#supportChat .scComposer{padding-bottom: max(10px, env(safe-area-inset-bottom));}
}


/* Support chat emoji */
.scComposer{position:relative}
.scEmojiBtn{width:44px; min-width:44px; padding:0; display:flex; align-items:center; justify-content:center}
.scEmojiPanel{position:absolute; left:10px; bottom:58px; z-index:20; background:rgba(255,255,255,.96); border:1px solid var(--border); border-radius:14px; padding:8px; box-shadow:0 10px 30px rgba(0,0,0,.12); display:grid; grid-template-columns:repeat(8, 1fr); gap:6px; max-width:min(360px, 92vw)}
.scEmojiPanel button{width:34px; height:34px; padding:0; border-radius:10px}
