/* Тень web: shared look for the user cabinet and the admin panel.
   Mirrors the iOS app (TenDesign.swift): black/charcoal, cyan accent, Inter + JetBrains Mono. */
@font-face { font-family: Inter; src: url(fonts/Inter-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Inter; src: url(fonts/Inter-Medium.ttf) format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: Inter; src: url(fonts/Inter-SemiBold.ttf) format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: Inter; src: url(fonts/Inter-Bold.ttf) format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url(fonts/JetBrainsMono-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }

:root {
  --bg: #000;
  --bg-raised: #080b0f;
  --card: #151b22;
  --card-2: #1b222b;
  --card-hover: #1f2731;
  --border: rgba(255, 255, 255, .11);
  --border-strong: rgba(255, 255, 255, .2);
  --ink: #f5f7fa;
  --muted: #8f9ba8;
  --faint: #5c6673;
  --cyan: #00d9ff;
  --cyan-soft: rgba(0, 217, 255, .1);
  --cyan-line: rgba(0, 217, 255, .45);
  --blue: #5bb7e1;
  --good: #3ddc84;
  --warn: #ffba59;
  --danger: #ff5a52;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .55);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 400 15px/1.5 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.label {
  font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Surfaces */
.card {
  background: rgba(21, 27, 34, .88); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px;
}
.card.flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: 0; }
.glass {
  background: rgba(25, 31, 43, .45); border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(22px) saturate(1.2); -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border-radius: var(--r-lg);
}
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: var(--r); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; font: 500 15px/1 Inter, system-ui, sans-serif; color: var(--ink);
  background: var(--card); border-color: var(--border);
  transition: transform .15s var(--ease), background .2s, border-color .2s, opacity .2s;
  white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--card-hover); border-color: var(--border-strong); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--cyan); color: #001018; border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: #3fe3ff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: rgba(255, 255, 255, .05); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: rgba(255, 90, 82, .1); border-color: rgba(255, 90, 82, .4); }
.btn.block { width: 100%; }
.btn.lg { min-height: 56px; border-radius: 17px; font-size: 16px; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center;
}
.icon-btn:hover { color: var(--ink); background: rgba(255, 255, 255, .06); }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Chips and status */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: rgba(255, 255, 255, .06); color: var(--muted); white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.plain::before { display: none; }
.chip.good { color: var(--good); background: rgba(61, 220, 132, .1); }
.chip.cyan { color: var(--cyan); background: var(--cyan-soft); }
.chip.warn { color: var(--warn); background: rgba(255, 186, 89, .1); }
.chip.danger { color: var(--danger); background: rgba(255, 90, 82, .1); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--r);
  background: var(--card); border: 1px solid var(--border); color: var(--ink); font: 400 15px Inter, system-ui, sans-serif;
  transition: border-color .2s, box-shadow .2s;
}
textarea.input { padding: 12px 14px; min-height: 90px; resize: vertical; }
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--cyan-line); box-shadow: 0 0 0 3px var(--cyan-soft); }
.input.mono { font-family: var(--mono); letter-spacing: .04em; }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search .input { padding-left: 42px; }

/* Segmented control */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.segmented button {
  appearance: none; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  height: 32px; padding: 0 12px; border-radius: 9px; font: 500 13px Inter, system-ui, sans-serif;
}
.segmented button[aria-pressed="true"] { background: var(--card-2); color: var(--ink); box-shadow: 0 1px 0 rgba(255,255,255,.06) inset; }

/* Progress */
.bar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--cyan); transition: width .8s var(--ease); }
.bar.warn > i { background: var(--warn); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); letter-spacing: .04em;
  padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg-raised);
  position: sticky; top: 0;
}
table.t td { padding: 14px 16px; border-bottom: 1px solid rgba(255, 255, 255, .06); white-space: nowrap; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr { transition: background .15s; }
table.t tbody tr.clickable { cursor: pointer; }
table.t tbody tr.clickable:hover { background: rgba(255, 255, 255, .03); }
table.t td.r, table.t th.r { text-align: right; }

/* List rows (app-style) */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 56px; }
.list-row + .list-row { border-top: 1px solid rgba(255, 255, 255, .07); }
.list-row .ico { width: 36px; height: 36px; border-radius: 10px; background: rgba(255, 255, 255, .06); display: grid; place-items: center; color: var(--ink); flex: none; }

/* Modal sheet */
.scrim {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 16px; opacity: 0; transition: opacity .25s var(--ease);
}
.scrim.open { opacity: 1; }
.sheet {
  width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow);
  transform: translateY(16px) scale(.98); transition: transform .3s var(--ease);
}
.scrim.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.sheet-body { padding: 8px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 560px) {
  .scrim { align-items: end; padding: 0; }
  .sheet { border-radius: 24px 24px 0 0; width: 100%; max-height: 92vh; transform: translateY(40px); }
}

/* Toast */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 14px;
  animation: toast-in .35s var(--ease); pointer-events: auto;
}
.toast .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--cyan); flex: none; }
.toast.warn .dot { background: var(--warn); }
.toast.leaving { animation: toast-out .25s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* Page entry motion */
.reveal { animation: reveal .5s var(--ease) both; }
.reveal:nth-child(2) { animation-delay: .04s; }
.reveal:nth-child(3) { animation-delay: .08s; }
.reveal:nth-child(4) { animation-delay: .12s; }
.reveal:nth-child(5) { animation-delay: .16s; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Brand */
.wordmark { font-weight: 600; letter-spacing: .32em; font-size: 15px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.flag { font-size: 20px; line-height: 1; }

/* Support chat (cabinet and admin) */
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 18px 16px; scroll-behavior: smooth; }
.msg { max-width: min(78%, 520px); padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; animation: msg-in .3s var(--ease); }
.msg.theirs { align-self: flex-start; background: var(--card-2); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.msg.mine { align-self: flex-end; background: rgba(0, 217, 255, .14); border: 1px solid rgba(0, 217, 255, .28); border-bottom-right-radius: 6px; }
.msg.system { align-self: center; max-width: 90%; background: transparent; color: var(--muted); font-size: 13px; text-align: center; padding: 6px 10px; }
.msg-meta { font-size: 11px; color: var(--faint); margin: 2px 6px 8px; }
.msg-meta.mine { align-self: flex-end; }
.msg-meta.theirs { align-self: flex-start; }
.day-sep { align-self: center; font-size: 12px; color: var(--faint); margin: 10px 0; }
.typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px; border-radius: 18px; background: var(--card-2); border: 1px solid var(--border); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite both; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: rgba(8, 11, 15, .6); }
.composer textarea { flex: 1; min-height: 44px; max-height: 140px; resize: none; padding: 11px 14px; border-radius: 22px; line-height: 1.4; }
.composer .send { width: 44px; height: 44px; border-radius: 50%; padding: 0; flex: none; }
.quick { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 0 12px 12px; }
.quick::-webkit-scrollbar { display: none; }
.quick button { appearance: none; flex: none; cursor: pointer; height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--card); color: var(--ink); font: 13px Inter, system-ui, sans-serif; }
.quick button:hover { border-color: var(--cyan-line); }
.online { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(61, 220, 132, .15); flex: none; }
.badge-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--cyan); color: #001018; font: 600 11px/18px Inter, system-ui, sans-serif; text-align: center; }

/* Clickable list rows (cabinet overview) */
.row-link {
  width: 100%; appearance: none; border: 0; background: transparent; color: var(--ink); cursor: pointer;
  font: inherit; text-align: left; text-decoration: none !important; transition: background .15s;
}
.row-link:hover { background: rgba(255, 255, 255, .03); }
.row-link > svg:last-child { color: var(--faint); }
.list-row .grow { min-width: 0; overflow-wrap: anywhere; }
.row .grow { min-width: 0; }
