* { box-sizing: border-box; margin: 0; }
:root {
  --bg: #f2f4f8; --card: #fff; --txt: #1c2430; --mut: #7a8699;
  --acc: #2f6fed; --ok: #1f9d55; --warn: #e6a817; --err: #d64545; --line: #e3e8ef;
}
body { font: 15px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--txt); }
.hidden { display: none !important; }
header { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line);
  padding: 12px 16px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--err); display: inline-block; }
.dot.ok { background: var(--ok); }
#app { padding-bottom: 64px; }
.tab { padding: 12px; }
nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav button { flex: 1; border: 0; background: none; padding: 8px 2px 6px; font-size: 18px; color: var(--mut);
  display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
nav button span { font-size: 11px; }
nav button.active { color: var(--acc); }
.badge { position: absolute; top: 2px; right: 18%; background: var(--err); color: #fff; font-size: 10px;
  border-radius: 9px; padding: 1px 5px; }
.chips { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 6px 12px; }
.chip.active { background: var(--acc); color: #fff; border-color: var(--acc); }
.list .item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  margin-bottom: 8px; cursor: pointer; }
.item .top { display: flex; justify-content: space-between; gap: 8px; }
.item .name { font-weight: 600; }
.item.unread .name::before { content: "●"; color: var(--acc); margin-right: 6px; }
.item .prev { color: var(--mut); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .time { color: var(--mut); font-size: 12px; white-space: nowrap; }
.mess { font-size: 11px; padding: 1px 6px; border-radius: 8px; color: #fff; }
.mess.tg { background: #2aabee; } .mess.max { background: #7d4cdb; }
.thread { position: fixed; inset: 0; background: var(--bg); z-index: 10; display: flex; flex-direction: column; }
.thread-hdr { display: flex; align-items: center; gap: 8px; background: var(--card);
  border-bottom: 1px solid var(--line); padding: 10px 12px; }
.thread-hdr button { border: 0; background: none; font-size: 18px; }
.grow { flex: 1; font-weight: 600; }
.msgs { flex: 1; overflow-y: auto; padding: 12px; }
.msg { max-width: 82%; margin-bottom: 8px; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; }
.msg.client { background: var(--card); border: 1px solid var(--line); }
.msg.staff { background: #dcebff; margin-left: auto; }
.msg.bot { background: #eef2e7; font-size: 13px; color: #5c6b52; }
.msg .meta { font-size: 11px; color: var(--mut); margin-top: 3px; }
.sendbox { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); }
.sendbox textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 9px; font: inherit; }
.sendbox button { border: 0; background: var(--acc); color: #fff; border-radius: 10px; width: 44px; font-size: 17px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.card h3 { margin-bottom: 8px; font-size: 15px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { font-size: 22px; display: block; }
.stat.low b { color: var(--err); }
.row { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; align-items: center; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; max-width: 100%; }
textarea { width: 100%; }
button { cursor: pointer; }
.card button, .login-card button { background: var(--acc); color: #fff; border: 0; border-radius: 8px; padding: 9px 14px; font: inherit; }
button.ok-btn { background: var(--ok); }
button.ghost { background: var(--card); color: var(--txt); border: 1px solid var(--line); }
.tbl { overflow-x: auto; font-size: 13px; }
.tbl table { border-collapse: collapse; width: 100%; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; white-space: nowrap; }
.st { padding: 1px 7px; border-radius: 8px; font-size: 12px; color: #fff; }
.st.available { background: var(--ok); } .st.issued { background: var(--mut); }
.st.disabled { background: var(--err); } .st.activated { background: var(--mut); } .st.manual { background: var(--warn); }
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 50; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px;
  width: min(320px, 90vw); display: flex; flex-direction: column; gap: 10px; }
.err { color: var(--err); font-size: 13px; min-height: 1em; }
.muted { color: var(--mut); font-size: 13px; }
.prod { margin-bottom: 12px; }
.prod textarea { font-size: 13px; }
.pill { font-size: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 2px 8px; margin: 2px; display: inline-block; }
#previewInfo div { margin: 3px 0; }
.okline { color: var(--ok); } .warnline { color: var(--warn); } .errline { color: var(--err); }
