/* Iskra Desk — тёмная тема по логотипу: глубокий синий и бирюзовая искра. */
:root {
  --bg: #0b1422;
  --bg-2: #0f1b2d;
  --card: #132339;
  --card-2: #182b45;
  --line: rgba(148, 197, 255, 0.09);
  --text: #e6eef8;
  --muted: #8fa3bd;
  --faint: #5f7590;
  --accent: #2dd4bf;
  --accent-2: #5eead4;
  --accent-ink: #052e2b;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --violet: #a78bfa;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--accent-2); text-decoration: none; }

.boot { height: 100vh; display: grid; place-items: center; }
.bolt-spin {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--card-2); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- каркас --- */
.shell { display: flex; min-height: 100vh; }
.side { display: none; }
.main { flex: 1; min-width: 0; padding: 14px 16px calc(var(--tabbar-h) + var(--safe-b) + 18px); }
.page { max-width: 760px; margin: 0 auto; animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.topbar { display: flex; align-items: center; gap: 10px; margin: 2px 0 16px; }
.logo {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(145deg, #12324a, #0f1b2d); box-shadow: inset 0 0 0 1px var(--line);
}
.logo svg { width: 18px; height: 18px; fill: var(--accent); filter: drop-shadow(0 0 6px rgba(45, 212, 191, .55)); }
.topbar h1 { font-size: 21px; margin: 0; letter-spacing: -.01em; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .grow { flex: 1; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: var(--card); color: var(--muted);
}
.icon-btn:active { transform: scale(.95); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: rgba(11, 20, 34, .92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--faint); font-size: 11px; font-weight: 600;
}
.tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.9; }
.tab.on { color: var(--accent); }

@media (min-width: 900px) {
  .tabbar { display: none; }
  .side {
    display: flex; flex-direction: column; gap: 4px; width: 230px; padding: 22px 14px;
    position: sticky; top: 0; height: 100vh; background: var(--bg-2); border-right: 1px solid var(--line);
  }
  .side .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; font-weight: 700; font-size: 17px; }
  .side .tab { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 12px; border-radius: 12px; font-size: 14px; }
  .side .tab.on { background: rgba(45, 212, 191, .1); }
  .main { padding: 26px 32px 40px; }
}

/* --- карточки и плитки --- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: inset 0 0 0 1px var(--line); margin-bottom: 12px;
}
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; font-weight: 700; }
.card h2 .count { color: var(--faint); font-weight: 600; margin-left: 4px; }
.hint { color: var(--faint); font-size: 13px; margin: -6px 0 10px; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
  background: var(--card); border-radius: var(--radius); padding: 14px; text-align: left;
  box-shadow: inset 0 0 0 1px var(--line); position: relative; overflow: hidden;
}
.tile .v { font-size: 28px; font-weight: 750; letter-spacing: -.02em; }
.tile .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tile::after {
  content: ""; position: absolute; right: -18px; top: -18px; width: 64px; height: 64px; border-radius: 50%;
  background: var(--glow, rgba(45, 212, 191, .12)); filter: blur(4px);
}
.tile.g { --glow: rgba(52, 211, 153, .14); } .tile.g .v { color: var(--green); }
.tile.a { --glow: rgba(251, 191, 36, .14); } .tile.a .v { color: var(--amber); }
.tile.r { --glow: rgba(248, 113, 113, .14); } .tile.r .v { color: var(--red); }
.tile.t .v { color: var(--accent-2); }
button.tile:active { transform: scale(.98); }

.money { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.money .big { font-size: 30px; font-weight: 750; letter-spacing: -.02em; }
.delta { font-size: 13px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.delta.up { color: var(--green); background: rgba(52, 211, 153, .12); }
.delta.down { color: var(--red); background: rgba(248, 113, 113, .12); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

.rows { display: flex; flex-direction: column; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.kv:first-child { border-top: 0; padding-top: 0; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; font-weight: 600; word-break: break-word; }

/* --- список клиентов --- */
.search {
  position: sticky; top: 0; z-index: 5; padding: 8px 0 10px; background: var(--bg); margin-top: -8px;
}
.search input {
  width: 100%; padding: 13px 14px 13px 42px; border-radius: 14px; border: 0; outline: 0;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238fa3bd' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 14px center / 18px;
  color: var(--text); font-size: 16px; box-shadow: inset 0 0 0 1px var(--line);
}
.search input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 13px; border-radius: 999px; background: var(--card); color: var(--muted);
  font-size: 13px; font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); white-space: nowrap;
}
.chip.on { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.list-meta { display: flex; justify-content: space-between; align-items: center; color: var(--faint); font-size: 13px; margin: 6px 2px 8px; }
.sort { color: var(--accent-2); font-weight: 600; font-size: 13px; }

.client {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 12px; border-radius: 14px; background: var(--card); margin-bottom: 8px;
  box-shadow: inset 0 0 0 1px var(--line);
}
.client:active { background: var(--card-2); }
.ava {
  flex: none; width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: #dff; position: relative;
  background: linear-gradient(145deg, hsl(var(--h, 180) 45% 32%), hsl(var(--h, 180) 50% 22%));
}
.ava .dot {
  position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 0 2.5px var(--card);
}
.client .who { flex: 1; min-width: 0; }
.client .login { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client .name { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client .side-info { text-align: right; flex: none; }
.days { font-weight: 750; font-size: 15px; }
.days.ok { color: var(--green); } .days.soon { color: var(--amber); } .days.gone { color: var(--red); }
.days-l { color: var(--faint); font-size: 11px; }
.badges { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.badge { font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; letter-spacing: .02em; }
.badge.prem { color: #fde68a; background: rgba(251, 191, 36, .13); }
.badge.bot { color: #c4b5fd; background: rgba(167, 139, 250, .14); }
.badge.nolink { color: var(--muted); background: rgba(143, 163, 189, .12); }
.badge.off { color: var(--red); background: rgba(248, 113, 113, .12); }

.empty { text-align: center; color: var(--faint); padding: 40px 10px; }
.empty .e { font-size: 34px; margin-bottom: 6px; }

/* --- карточка клиента --- */
.hero { padding: 18px; background: linear-gradient(160deg, #17324a 0%, var(--card) 60%); }
.hero .row { display: flex; gap: 14px; align-items: center; }
.hero .ava { width: 54px; height: 54px; border-radius: 17px; font-size: 18px; }
.hero .login { font-size: 18px; font-weight: 750; word-break: break-all; }
.hero .name { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; margin-top: 6px; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ACTIVE { color: var(--green); background: rgba(52, 211, 153, .12); }
.pill.EXPIRED { color: var(--red); background: rgba(248, 113, 113, .12); }
.pill.DISABLED, .pill.LIMITED { color: var(--muted); background: rgba(143, 163, 189, .12); }
.term { display: flex; align-items: baseline; gap: 8px; margin-top: 16px; }
.term .big { font-size: 34px; font-weight: 800; letter-spacing: -.03em; }
.bar { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .06); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.tag { font-size: 12.5px; padding: 3px 9px; border-radius: 8px; background: var(--card-2); color: var(--text); font-weight: 600; }

.copy {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px; border-radius: 12px;
  background: var(--bg-2); text-align: left; box-shadow: inset 0 0 0 1px var(--line);
}
.copy code { flex: 1; min-width: 0; font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--accent-2); word-break: break-all; }
.copy .ic { color: var(--muted); font-size: 12px; font-weight: 700; flex: none; }

.pay { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.pay:first-child { border-top: 0; padding-top: 0; }
.pay .amt { font-weight: 750; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 13px 16px; border-radius: 14px; font-weight: 700;
  background: var(--accent); color: var(--accent-ink);
}
.btn.ghost { background: var(--card-2); color: var(--text); }
.btn:active { transform: scale(.985); }
.note-box { white-space: pre-wrap; color: var(--text); background: var(--bg-2); border-radius: 12px; padding: 12px; font-size: 14px; }

.node { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.node:first-child { border-top: 0; padding-top: 0; }
.node .st { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px currentColor; color: var(--red); }
.node .st.on { background: var(--green); color: var(--green); }
.node .nm { flex: 1; font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); transform: translateX(-50%);
  background: #1f3550; color: var(--text); padding: 10px 16px; border-radius: 12px; font-weight: 600;
  box-shadow: var(--shadow); z-index: 20; animation: rise .2s ease-out;
}
.error-card { border-left: 3px solid var(--red); }
.skeleton { height: 64px; border-radius: 14px; margin-bottom: 8px; background: linear-gradient(90deg, var(--card) 0%, var(--card-2) 50%, var(--card) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* --- действия в карточке --- */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.q {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 11px 4px;
  border-radius: 14px; background: rgba(255, 255, 255, .05); font-size: 12px; font-weight: 650; color: var(--text);
}
.q b { font-size: 19px; line-height: 1; }
.q:active { background: rgba(45, 212, 191, .14); transform: scale(.97); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.btn-col { display: flex; flex-direction: column; gap: 8px; }
.btn-col + .btn-col, .btn-col + .btn, .btn-col + .inline, .btn + .btn, .inline + .btn, .btn + .inline, .inline + .inline { margin-top: 8px; }
.btn.danger { background: rgba(248, 113, 113, .12); color: var(--red); }
.btn.small { width: auto; padding: 8px 12px; font-size: 13px; border-radius: 10px; flex: none; }
.btn.busy { opacity: .55; pointer-events: none; }
.btn:disabled { cursor: default; }
.kv.edit { width: 100%; text-align: left; align-items: center; }
.kv.edit .v { flex: 1; }
.kv.edit .pen { color: var(--faint); font-size: 14px; flex: none; }
.kv.edit:active .pen { color: var(--accent); }
button.note-box { width: 100%; text-align: left; margin-top: 12px; display: block; }
.pay-r { text-align: right; }
.undo { color: var(--faint); font-size: 12px; font-weight: 600; padding: 2px 0; }
.undo:active { color: var(--red); }
.sales { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.sales-head { font-weight: 750; margin-bottom: 8px; }
.sales .btn-col { margin-top: 12px; }
.skeleton.small { height: 38px; }

/* --- всплывающее окно снизу --- */
body.locked { overflow: hidden; }
.sheet-wrap {
  position: fixed; inset: 0; z-index: 30; background: rgba(3, 8, 16, .55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease-out;
}
.sheet-wrap.out { opacity: 0; transition: opacity .18s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column;
  background: var(--bg-2); border-radius: 22px 22px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .45);
  padding: 8px 16px calc(18px + var(--safe-b)); animation: up .24s cubic-bezier(.2, .9, .3, 1);
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 900px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 22px; } }
.grip { width: 38px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .14); margin: 0 auto 8px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-head h3 { flex: 1; margin: 0; font-size: 18px; word-break: break-word; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.sheet .hint { margin: 0 0 12px; }
.sheet .money { margin-bottom: 6px; }

.input {
  width: 100%; padding: 13px 14px; border-radius: 13px; border: 0; outline: 0;
  background: var(--card); color: var(--text); font: inherit; font-size: 16px; box-shadow: inset 0 0 0 1px var(--line);
}
.input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.input.area { resize: vertical; min-height: 120px; line-height: 1.45; }
.sheet .input { margin-bottom: 8px; }
select.input { appearance: none; -webkit-appearance: none; }
input[type="date"].input { color-scheme: dark; }
.inline { display: flex; gap: 8px; align-items: stretch; }
.inline .input { margin: 0; flex: 1; min-width: 0; }
.inline .btn { width: auto; flex: none; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }

.msg { white-space: pre-wrap; background: var(--card); border-radius: 14px; padding: 13px; font-size: 14px; line-height: 1.45; margin-bottom: 12px; max-height: 38vh; overflow-y: auto; }
.qr { display: grid; place-items: center; margin-bottom: 12px; }
.qr img { width: 180px; height: 180px; border-radius: 14px; background: #fff; padding: 6px; }

.check { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 14px; border-radius: 13px; background: var(--card); font-weight: 600; text-align: left; }
.check .box { width: 22px; height: 22px; border-radius: 7px; box-shadow: inset 0 0 0 2px var(--faint); flex: none; display: grid; place-items: center; }
.check.on .box { background: var(--accent); box-shadow: none; }
.check.on .box::after { content: "✓"; color: var(--accent-ink); font-weight: 800; font-size: 14px; }
.device { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.device > div:first-child { flex: 1; min-width: 0; }
.dv-name { font-weight: 650; }
.sheet .device:first-of-type { border-top: 0; }
/* Внутри сеток и колонок расстояние задаёт gap — внешние отступы кнопок не нужны. */
.grid3 > *, .btn-col > *, .btn-row > *, .inline > * { margin-top: 0 !important; }
