:root {
  --g: #114749; --g2: #0b3234; --gold: #d9a066; --gl: #f5c082; --gd: #8f6230; --gs: #fbf3e6;
  --bg: #f5f2eb; --card: #fff; --line: #e4e0db; --text: #1f1d1b; --mut: #6b6661;
  --me: #d9eee8; --chatbg: #f3efe7; --err: #b3261e; --ok: #1e7b45;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.42 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--g); }

/* ---------- brána ---------- */
.gate { position: fixed; inset: 0; background: linear-gradient(160deg, var(--g), var(--g2)); display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto; z-index: 50; }
.gate-card { background: #fff; width: min(460px, 100%); border-radius: 18px; padding: 26px 24px; border-top: 4px solid var(--gold); box-shadow: 0 30px 80px rgba(0,0,0,.35); margin: 60px 0 20px; }
.gate-logo { width: 88px; height: 88px; display: block; margin: -72px auto 8px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.3)); }
.gate-card h2 { margin: 0 0 6px; text-align: center; color: var(--g); font-size: 21px; }
.gate-card .sub { text-align: center; color: var(--mut); margin-bottom: 16px; font-size: 14.5px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 11px; font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea { font-weight: 400; border: 1px solid #cfc9c2; border-radius: 10px; padding: 11px 12px; font-size: 16px; background: #fff; }
.field input:focus, .field select:focus, .field textarea:focus, .composer textarea:focus { outline: 2px solid rgba(17,71,73,.3); outline-offset: 1px; }
.code-input { text-align: center; font-size: 28px !important; letter-spacing: .4em; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { border: 1px solid #cfc9c2; background: #fff; border-radius: 10px; padding: 10px 16px; font-weight: 700; cursor: pointer; }
.btn:hover { background: #f6f3ef; }
.btn.primary { background: var(--g); border-color: var(--g); color: #fff; }
.btn.primary:hover { background: var(--g2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1d2b2a; }
.btn.danger { color: var(--err); border-color: #e8b4b0; }
.btn.small { padding: 6px 11px; font-size: 13.5px; border-radius: 8px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.err { background: #fdecea; color: var(--err); border-radius: 10px; padding: 9px 12px; margin: 8px 0; font-size: 14px; }
.hint { color: var(--mut); font-size: 13px; }
.linkbtn { background: none; border: 0; color: var(--g); text-decoration: underline; cursor: pointer; padding: 0; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.choice button { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 10px; cursor: pointer; text-align: center; }
.choice button.on { border-color: var(--g); background: #eaf2f1; }
.choice b { display: block; color: var(--g); margin: 4px 0 2px; }
.choice span { font-size: 12.5px; color: var(--mut); }
.choice .ic { font-size: 26px; }
.consent { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--mut); margin: 6px 0 12px; }
.consent input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--g); flex: none; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 4px solid var(--gs); border-top-color: var(--gold); margin: 4px auto 14px; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- rozvržení ---------- */
.app { display: flex; height: 100vh; height: 100dvh; }
.side { width: 360px; flex: none; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--g); color: #fff; border-bottom: 3px solid var(--gold); }
.side-logo { width: 38px; height: 38px; }
.side-title { flex: 1; line-height: 1.15; }
.side-title b { color: var(--gl); font-size: 16.5px; display: block; }
.side-title small { color: #b9d0cd; font-size: 12px; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 19px; padding: 6px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: rgba(0,0,0,.06); }
.side-tabs { display: flex; border-bottom: 1px solid var(--line); background: #faf9f7; }
.side-tabs button { flex: 1; border: 0; background: none; padding: 10px 4px; cursor: pointer; font-weight: 700; color: var(--mut); border-bottom: 3px solid transparent; }
.side-tabs button.on { color: var(--g); border-bottom-color: var(--gold); }
.side-body { flex: 1; overflow: auto; min-height: 0; }
.search { padding: 10px 12px; position: sticky; top: 0; background: #fff; z-index: 2; }
.search input { width: 100%; border: 1px solid var(--line); background: #f6f4f1; border-radius: 20px; padding: 9px 14px; font-size: 15px; }
.sec { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--mut); font-weight: 800; padding: 12px 14px 4px; display: flex; justify-content: space-between; align-items: center; }
.sec button { font-size: 12px; text-transform: none; letter-spacing: 0; }
.conv { display: flex; gap: 11px; padding: 10px 14px; cursor: pointer; align-items: center; border-left: 3px solid transparent; }
.conv:hover { background: #f7f4ef; }
.conv.on { background: var(--gs); border-left-color: var(--gold); }
.conv .t { flex: 1; min-width: 0; }
.conv .t b { display: flex; justify-content: space-between; gap: 6px; font-size: 15px; }
.conv .t b span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .t b time { font-weight: 400; font-size: 12px; color: var(--mut); flex: none; }
.conv .t small { display: block; color: var(--mut); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.conv.unread .t small { color: var(--text); font-weight: 600; }
.badge { background: var(--gold); color: #1d2b2a; font-size: 12px; font-weight: 800; border-radius: 10px; padding: 1px 7px; min-width: 20px; text-align: center; font-style: normal; }
.avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; position: relative; background: #cfe0de; color: var(--g); }
.avatar.sm { width: 32px; height: 32px; font-size: 12.5px; background: var(--gold); color: #1d2b2a; }
.avatar.xs { width: 30px; height: 30px; font-size: 12px; }
.avatar.grp { background: var(--g); color: var(--gl); font-size: 20px; }
.avatar.ann { background: var(--gold); color: #1d2b2a; font-size: 20px; }
.avatar.cit { background: #e7defa; color: #4b3a78; }
.avatar .dot { position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: #2fb36b; border: 2px solid #fff; }
.c1 { background: #cfe0de; color: #114749; } .c2 { background: #f3d9b8; color: #7a4b12; } .c3 { background: #dfd6ef; color: #4b3a78; }
.c4 { background: #d8e8cf; color: #335a1e; } .c5 { background: #f5d0d0; color: #7d2323; } .c6 { background: #d3e3f4; color: #1f4a78; }
.admin-link { display: block; padding: 11px 14px; border-top: 1px solid var(--line); background: #eef4f3; color: var(--g); font-weight: 700; text-decoration: none; font-size: 14px; }
.admin-link:hover { background: #e2eeec; }

.pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--chatbg); }
.empty-pane { margin: auto; text-align: center; color: var(--mut); padding: 20px; }
.empty-pane img { width: 110px; opacity: .9; }
.empty-pane h2 { color: var(--g); margin: 10px 0 4px; }
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 11px; padding: 9px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.chat-title { flex: 1; min-width: 0; line-height: 1.2; }
.chat-title b { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title small { color: var(--mut); font-size: 13px; }
.back { display: none; font-size: 22px; }
.msgs { flex: 1; overflow-y: auto; padding: 14px 16px 8px; display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.day { align-self: center; background: #fff; color: var(--mut); font-size: 12px; border-radius: 10px; padding: 3px 11px; margin: 10px 0 6px; box-shadow: 0 1px 1px rgba(0,0,0,.05); }
.sysmsg { align-self: center; background: var(--gs); color: var(--gd); font-size: 13px; border-radius: 10px; padding: 5px 12px; margin: 6px 0; text-align: center; max-width: 90%; }
.note-private { align-self: center; background: #eef1f4; color: #55606b; font-size: 12.5px; border-radius: 10px; padding: 6px 12px; margin: 4px 0 8px; text-align: center; max-width: 92%; }
.more { align-self: center; margin-bottom: 6px; }
.m { display: flex; gap: 8px; align-items: flex-end; max-width: 78%; margin-top: 2px; }
.m.first { margin-top: 8px; }
.m .av-slot { width: 30px; flex: none; }
.bub { background: #fff; border-radius: 14px 14px 14px 4px; padding: 7px 11px 5px; box-shadow: 0 1px 1px rgba(0,0,0,.07); min-width: 70px; position: relative; word-wrap: break-word; overflow-wrap: anywhere; }
.bub .who { font-size: 12.5px; font-weight: 800; margin-bottom: 1px; }
.bub .who .rl { font-weight: 600; color: var(--mut); font-size: 11.5px; margin-left: 4px; }
.bub .txt { white-space: pre-wrap; }
.bub .meta { font-size: 11.5px; color: var(--mut); text-align: right; margin-top: 2px; display: flex; justify-content: flex-end; gap: 6px; align-items: center; }
.bub .rd { color: #2a7bbf; cursor: pointer; white-space: nowrap; }
.bub .rd.none { color: var(--mut); }
.bub .del { visibility: hidden; border: 0; background: none; cursor: pointer; color: var(--mut); font-size: 13px; padding: 0 2px; }
.m:hover .del { visibility: visible; }
.m.me { align-self: flex-end; flex-direction: row-reverse; }
.m.me .bub { background: var(--me); border-radius: 14px 14px 4px 14px; }
.m.deleted .txt { color: var(--mut); font-style: italic; }
.m.ann .bub { background: var(--gs); border-left: 4px solid var(--gold); max-width: 100%; }
.att-img { display: block; max-width: 280px; max-height: 280px; border-radius: 10px; margin: 3px 0; cursor: zoom-in; }
.att-file { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.04); border-radius: 8px; padding: 7px 9px; margin: 3px 0; text-decoration: none; color: var(--text); font-size: 14px; }
.att-file small { color: var(--mut); }
.typing { height: 20px; padding: 0 18px; font-size: 12.5px; color: var(--mut); font-style: italic; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + var(--safe-b)); background: #fff; border-top: 1px solid var(--line); }
.composer-main { flex: 1; min-width: 0; }
.composer textarea { width: 100%; resize: none; border: 1px solid var(--line); border-radius: 20px; padding: 10px 14px; max-height: 140px; font-size: 15.5px; background: #f8f6f3; line-height: 1.35; }
.attach { font-size: 21px; margin-bottom: 3px; }
.send-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--g); color: #fff; font-size: 18px; cursor: pointer; flex: none; }
.send-btn:disabled { opacity: .5; }
.att-preview { display: flex; align-items: center; gap: 8px; background: var(--gs); border-radius: 10px; padding: 6px 10px; margin-bottom: 6px; font-size: 14px; }
.att-preview button { margin-left: auto; border: 0; background: none; cursor: pointer; font-size: 18px; }
.readonly-note { padding: 12px calc(16px) calc(12px + var(--safe-b)); background: #fff; border-top: 1px solid var(--line); color: var(--mut); text-align: center; font-size: 14px; }

/* tým a profil */
.pad { padding: 12px 14px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 10px 12px; }
.card h3 { margin: 0 0 8px; font-size: 15.5px; color: var(--g); }
.req { border: 2px solid var(--gold); background: var(--gs); }
.person { display: flex; gap: 11px; align-items: center; padding: 9px 14px; cursor: pointer; }
.person:hover { background: #f7f4ef; }
.person .t { flex: 1; min-width: 0; }
.person .t b { display: block; }
.person .t small { color: var(--mut); font-size: 13px; }
.role-tag { font-size: 11px; font-weight: 800; border-radius: 8px; padding: 1px 7px; background: var(--g); color: #fff; margin-left: 4px; vertical-align: 1px; }
.role-tag.sp { background: var(--gold); color: #1d2b2a; }
.req-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.stat-line { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.toggle input { width: 20px; height: 20px; accent-color: var(--g); }

/* modal, toasty */
.modal-back { position: fixed; inset: 0; background: rgba(20,20,20,.45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
.x { border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--mut); line-height: 1; }
.modal-body { padding: 14px 16px; overflow: auto; }
.modal-foot { padding: 10px 16px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-foot:empty { display: none; }
.img-full { max-width: 100%; border-radius: 10px; }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; z-index: 70; width: min(420px, 92vw); }
.toast { background: #2b2825; color: #fff; padding: 10px 14px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 14.5px; animation: tin .2s; }
.toast.err { background: var(--err); } .toast.ok { background: var(--ok); }
.toast.msg { background: var(--g); cursor: pointer; border-left: 4px solid var(--gold); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.bottom-nav { display: none; }

/* ---------- telefon ---------- */
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .side { width: 100%; flex: 1; border-right: 0; }
  .side-tabs { display: none; }
  .pane { position: fixed; inset: 0; z-index: 20; transform: translateX(100%); transition: transform .22s ease; }
  .app.chat-open .pane { transform: none; }
  .back { display: inline-flex; }
  .m { max-width: 86%; }
  .att-img { max-width: 220px; }
  .bottom-nav { display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
  .bottom-nav button { flex: 1; border: 0; background: none; padding: 7px 0 6px; font-size: 11.5px; color: var(--mut); position: relative; cursor: pointer; }
  .bottom-nav button span { display: block; font-size: 20px; line-height: 1.2; }
  .bottom-nav button.on { color: var(--g); font-weight: 800; }
  .bottom-nav .badge { position: absolute; top: 3px; left: 55%; font-size: 10.5px; padding: 0 5px; }
  .admin-link { font-size: 13.5px; }
  .toasts { bottom: calc(70px + var(--safe-b)); }
}
