@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/vazirmatn/vazirmatn-arabic-variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE80-FEFC;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/vazirmatn/vazirmatn-latin-variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #212121;
  --bg-sidebar: #171717;
  --bg-elev: #2f2f2f;
  --bg-hover: #2a2a2a;
  --bg-composer: #303030;
  --line: #424242;
  --text: #ececec;
  --muted: #b4b4b4;
  --dim: #8f8f8f;
  --green: #10a37f;
  --green-2: #0e9271;
  --danger: #ef4444;
  --warn: #f59e0b;
  --white: #fff;
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 24px;
  --sidebar: 268px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html {
  color-scheme: dark;
  background: var(--bg);
  direction: rtl;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Vazirmatn, system-ui, sans-serif;
  letter-spacing: -0.01em;
  direction: rtl;
  text-align: right;
}

button, input, textarea { font-family: inherit; }
a {
  color: inherit;
  text-decoration: none;
}
a:hover, a:focus { text-decoration: none; }
button { cursor: pointer; }
img { max-width: 100%; }
input, textarea {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  color: inherit;
}

.hidden { display: none !important; }

/* Login */
.login-page {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  direction: rtl;
  text-align: right;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(16, 163, 127, 0.18), transparent 50%),
    var(--bg);
}
.login-card { text-align: center; }
.login-card .field { text-align: right; }

.login-card {
  width: min(420px, 100%);
  background: #1a1a1a;
  border: 1px solid #2e2e2e;
  border-radius: 28px;
  padding: 36px 28px 28px;
  box-shadow: var(--shadow);
  animation: fade-up .55s cubic-bezier(.22,1,.36,1);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}
.brand img { width: 36px; height: 36px; }
.app-logo { filter: invert(1); }
.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.login-card h2 {
  margin: 0 0 28px;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}
.phone-wrap, .otp-row input {
  background: var(--bg-elev);
  border: 1px solid var(--line);
}

.phone-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 14px;
  padding: 0 14px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.phone-wrap:focus-within {
  border-color: #6b6b6b;
  box-shadow: 0 0 0 4px rgba(255,255,255,.04);
}
.phone-wrap span {
  color: var(--dim);
  font-size: 13px;
  white-space: nowrap;
  order: 2;
}
.phone-wrap input {
  width: 100%;
  height: 52px;
  font-size: 16px;
  letter-spacing: 0.04em;
  order: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  transition: transform .18s ease, background .18s ease, opacity .18s ease, box-shadow .18s ease;
}
.btn-primary { background: var(--white); color: #111; }
.btn-primary:hover { background: #e8e8e8; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  height: auto;
  margin-top: 10px;
}
.btn-ghost:hover { color: var(--text); }

.form-error {
  min-height: 22px;
  margin: 8px 0 0;
  color: #ff8b8b;
  font-size: 13px;
  text-align: center;
}

.otp-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  direction: ltr;
}
.otp-row input {
  width: 48px;
  height: 56px;
  border-radius: 12px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.login-foot {
  margin-top: 22px;
  text-align: center;
  color: var(--dim);
  font-size: 12px;
}

/* Shell — RTL: sidebar on the right */
.app {
  display: flex;
  flex-direction: row;
  height: 100%;
  overflow: hidden;
  direction: rtl;
}

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid #202020;
  border-right: 0;
}

.side-top { padding: 12px; display: grid; gap: 8px; }
.side-btn, .chat-item, .icon-btn {
  border: 0;
  background: transparent;
  color: var(--text);
}
.side-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}
.side-btn:hover, .chat-item:hover, .icon-btn:hover { background: var(--bg-hover); }
.side-btn.active { background: var(--bg-hover); }
.side-btn, .chat-item, .icon-btn, .logout-btn, .mini, .round-btn {
  transition: background .18s ease, transform .18s ease, color .18s ease, opacity .18s ease;
}
.side-btn svg, .icon-btn svg { width: 18px; height: 18px; flex: 0 0 18px; }

.chat-search {
  width: 100%;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: #212121;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.chat-list {
  flex: 1;
  overflow: auto;
  padding: 6px 10px 16px;
}
.chat-group {
  color: var(--dim);
  font-size: 12px;
  padding: 14px 10px 6px;
  font-weight: 600;
}
.chat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  text-align: right;
  font-size: 13.5px;
}
.chat-item.active { background: #212121; }
.chat-item .title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item .more {
  opacity: 0;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.chat-item:hover .more, .chat-item.active .more { opacity: 1; }

.side-bottom {
  padding: 10px;
  border-top: 1px solid #242424;
}
.user-chip {
  display: block;
  padding: 8px 10px;
  border-radius: 12px;
}
.user-chip:hover { background: var(--bg-hover); }
.user-chip .user-mobile {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.user-chip small,
.user-chip .pack-line {
  display: block;
  color: var(--dim);
  font-size: 11px;
  margin-top: 4px;
  line-height: 1.5;
}
.logout-btn {
  margin-top: 4px;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--muted);
  height: 36px;
  border-radius: 10px;
}
.logout-btn:hover { background: var(--bg-hover); color: var(--text); }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 14px;
  color: var(--muted);
  position: relative;
  z-index: 5;
}
.topbar-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.topbar-spacer {
  width: 36px;
  flex: 0 0 36px;
  display: none;
}
.menu-toggle {
  display: none;
  position: relative;
  z-index: 30;
  pointer-events: auto;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: 0 0 36px;
}

.thread {
  flex: 1;
  overflow: auto;
  padding: 8px 0 20px;
}

.empty {
  min-height: 70%;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 40px 16px;
  text-align: center;
}
.empty img { width: 54px; height: 54px; margin-bottom: 18px; }
.empty-copy { max-width: 640px; }
.empty-lead {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.95;
}
.empty h2 { margin: 0; font-size: 30px; font-weight: 700; }

.msg-wrap {
  width: min(768px, calc(100% - 32px));
  margin: 0 auto 22px;
  display: flex;
  gap: 14px;
  text-align: right;
}
.msg-wrap.assistant {
  flex-direction: row;
  justify-content: flex-end;
}
.msg-wrap.user { justify-content: flex-start; }
.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 32px;
  background: transparent;
  display: grid;
  place-items: center;
}
.msg-avatar img { width: 22px; height: 22px; }
.bubble {
  max-width: min(100%, 680px);
  line-height: 1.85;
  font-size: 15.5px;
  text-align: right;
}
.bubble .md,
.bubble .md p,
.bubble .md li,
.bubble .md h1,
.bubble .md h2,
.bubble .md h3 {
  text-align: right;
}
.bubble .md pre,
.bubble .md code {
  direction: ltr;
  text-align: left;
}
.user .bubble {
  background: var(--bg-elev);
  border-radius: 22px;
  padding: 10px 16px;
  max-width: min(100%, 560px);
}
.assistant .bubble { padding-top: 4px; width: 100%; }

.md p { margin: 0 0 12px; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { padding-right: 22px; }
.md pre {
  background: #0d0d0d;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  overflow: auto;
  padding: 12px 14px;
  direction: ltr;
  text-align: left;
}
.md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.md :not(pre) > code {
  background: #2a2a2a;
  padding: 1px 6px;
  border-radius: 6px;
}
.md a { color: #7dd3fc; text-decoration: none; }
.md a:hover { color: #bae6fd; }
.code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #2a2a2a;
  border-radius: 12px 12px 0 0;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  direction: ltr;
}
.code-wrap pre { margin: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.copy-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
}

.files {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.file-chip, .file-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #3a3a3a;
  border-radius: 12px;
  padding: 8px 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.media-card {
  position: relative;
  margin: 0;
  display: grid;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
}
.media-card-sm { gap: 0; }
.thumb {
  display: block;
  max-width: min(280px, 70vw);
  border-radius: 16px;
  cursor: zoom-in;
  background: #1a1a1a;
}
.thumb-sm {
  width: 96px;
  height: 96px;
  max-width: 96px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.08);
}
.thumb-gen {
  width: min(280px, 70vw);
  max-height: 360px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 12px 32px rgba(0,0,0,.28);
}
.media-dl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: fit-content;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 700;
  transition: background .16s ease, transform .16s ease;
}
.media-dl:hover {
  background: rgba(16,163,127,.2);
  border-color: rgba(16,163,127,.45);
  transform: translateY(-1px);
}

.composer-dock {
  width: min(768px, calc(100% - 24px));
  margin: 0 auto 18px;
}
.composer-box {
  background: #303030;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 28px;
  padding: 10px 10px 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.composer-box:focus-within {
  border-color: rgba(255,255,255,.16);
  box-shadow: 0 10px 32px rgba(0,0,0,.28);
}
.composer-field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.composer-field textarea,
#prompt {
  display: block;
  width: 100%;
  min-height: 44px;
  max-height: 200px;
  margin: 0;
  padding: 11px 6px;
  resize: none;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.7;
  appearance: none;
  -webkit-appearance: none;
  overflow-y: auto;
}
#prompt::placeholder {
  color: #9a9a9a;
  opacity: 1;
}
.round-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  flex: 0 0 36px;
}
.round-btn:hover { background: #3a3a3a; color: var(--text); }
.send-btn {
  background: #fff;
  color: #111;
}
.send-btn:disabled { background: #676767; color: #111; cursor: not-allowed; }
.hint {
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  margin-top: 8px;
}
.previews {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 6px 8px 0;
}
.previews:empty { display: none; }
.preview {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  background: #3a3a3a;
  display: grid;
  place-items: center;
  font-size: 11px;
}
.preview img { width: 100%; height: 100%; object-fit: cover; }
.preview button {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: #111;
  color: #fff;
}

.thinking {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: min(280px, 80vw);
  padding: 14px 16px;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(16,163,127,.12), rgba(255,255,255,.03) 45%, rgba(16,163,127,.08));
  border: 1px solid rgba(16,163,127,.22);
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  animation: thinking-in .35s cubic-bezier(.22,1,.36,1);
}
.thinking-visual {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
}
.thinking-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(16,163,127,.35);
  animation: thinking-spin 2.4s linear infinite;
}
.thinking-ring:nth-child(2) {
  inset: 6px;
  border-color: rgba(255,255,255,.18);
  animation-duration: 1.6s;
  animation-direction: reverse;
}
.thinking-core {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #9ae6b4, #10a37f 60%, #0b7a5f);
  box-shadow: 0 0 18px rgba(16,163,127,.45);
  animation: thinking-pulse 1.8s ease-in-out infinite;
}
.thinking-copy {
  display: grid;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.thinking-label {
  font-size: 14px;
  font-weight: 700;
  color: #e8fff7;
  letter-spacing: -.01em;
}
.thinking-shimmer {
  height: 6px;
  width: 100%;
  max-width: 160px;
  border-radius: 99px;
  background: linear-gradient(90deg, rgba(255,255,255,.06), rgba(16,163,127,.45), rgba(255,255,255,.06));
  background-size: 200% 100%;
  animation: thinking-shimmer 1.4s ease-in-out infinite;
}
@keyframes thinking-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
@keyframes thinking-spin {
  to { transform: rotate(360deg); }
}
@keyframes thinking-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(.88); opacity: .85; }
}
@keyframes thinking-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.msg-wrap.is-thinking .bubble { max-width: min(100%, 360px); }

.status-line { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

/* Restriction / topup sheet */
.restrict {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 20px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 18%, rgba(0,0,0,.58));
  z-index: 12;
}
.restrict.hidden { display: none; }
.restrict-card {
  position: relative;
  pointer-events: auto;
  width: min(560px, 100%);
  background: linear-gradient(180deg, #2b2214, #1b1b1b);
  border: 1px solid rgba(245, 158, 11, 0.45);
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  border-radius: 22px;
  padding: 22px 22px 18px;
  text-align: right;
}
.restrict-card.blocked {
  background: linear-gradient(180deg, #2a1515, #1b1b1b);
  border-color: rgba(239, 68, 68, 0.4);
  text-align: center;
}
.restrict-card h3 { margin: 0 0 8px; font-size: 20px; }
.restrict-card p { margin: 0 0 14px; color: var(--muted); line-height: 1.8; }
.sheet-close {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 2;
}
.sheet-close:hover { background: rgba(255,255,255,.14); }
.sheet-close svg { width: 16px; height: 16px; }

.topup-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: end center;
  padding: 16px;
}
.topup-sheet.hidden { display: none; }
.topup-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
}
.topup-sheet-card {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  background: linear-gradient(165deg, #1f2a22, #171717);
  border: 1px solid rgba(16,163,127,.28);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
  padding: 20px 18px 18px;
  animation: fade-up .35s cubic-bezier(.22,1,.36,1);
}
.topbar-topup {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(16,163,127,.35);
  background: rgba(16,163,127,.14);
  color: #b7f5d8;
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
}
.topbar-topup:hover { background: rgba(16,163,127,.22); }
.phone-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  color: #111;
  text-decoration: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* Admin */
.admin-main { padding: 18px 22px 40px; overflow: auto; text-align: right; }
.admin-main h2 { margin: 8px 0 6px; text-align: right; }
.admin-main .sub { color: var(--muted); margin-bottom: 18px; text-align: right; }
th, td, .stat-card, .dossier-hero, .dossier-panel, .panel-block-head {
  text-align: right;
}
.admin-stats { margin-bottom: 18px; }
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.admin-toolbar h2 { margin: 0; }
.admin-search {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.admin-search input {
  height: 36px;
  border-radius: 10px;
  border: 1px solid #333;
  background: #141414;
  color: #fff;
  padding: 0 12px;
  min-width: 220px;
}
.usage-usd { font-weight: 700; display: inline-block; margin-inline-end: 6px; }
.dossier-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin: 8px 0 18px;
  padding: 18px;
  border: 1px solid #2c2c2c;
  border-radius: 18px;
  background: linear-gradient(145deg, #1b1b1b, #141414);
}
.dossier-identity { display: flex; gap: 14px; align-items: center; }
.dossier-avatar {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #243528;
  color: #9ae6b4;
  font-weight: 700;
  letter-spacing: .02em;
}
.dossier-title { margin: 0 0 4px; font-size: 22px; direction: ltr; text-align: right; }
.dossier-actions { justify-content: flex-end; }
.dossier-stats { margin-bottom: 16px; }
.dossier-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 18px;
  padding: 6px;
  border-radius: 14px;
  background: #151515;
  border: 1px solid #2a2a2a;
}
.dossier-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}
.dossier-tab.active {
  background: #243528;
  color: #d8f3e0;
}
.dossier-panel { display: none; }
.dossier-panel.active { display: block; }
.dossier-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.dossier-memory {
  white-space: pre-wrap;
  margin: 0;
  font: inherit;
  color: #ddd;
  line-height: 1.7;
  max-height: 220px;
  overflow: auto;
}
.dossier-chats {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 14px;
  min-height: 520px;
}
.dossier-conv-list {
  border: 1px solid #2c2c2c;
  border-radius: 16px;
  background: #161616;
  overflow: auto;
  max-height: 70vh;
}
.dossier-conv-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: right;
  border: 0;
  border-bottom: 1px solid #242424;
  background: transparent;
  color: inherit;
  padding: 14px;
  cursor: pointer;
  font: inherit;
}
.dossier-conv-item strong { font-size: 14px; }
.dossier-conv-item span { color: var(--muted); font-size: 12px; }
.dossier-conv-item.active,
.dossier-conv-item:hover { background: #1f2a22; }
.dossier-thread {
  border: 1px solid #2c2c2c;
  border-radius: 16px;
  background: #121212;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dossier-thread-empty {
  margin: auto;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}
.dossier-thread-head {
  padding: 14px 16px;
  border-bottom: 1px solid #2a2a2a;
  font-weight: 700;
  background: #171717;
}
.dossier-thread-body {
  padding: 16px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 65vh;
}
.dossier-msg {
  border: 1px solid #2a2a2a;
  border-radius: 14px;
  padding: 12px 14px;
  background: #181818;
}
.dossier-msg.user { background: #1a2430; border-color: #2a3b4d; }
.dossier-msg.assistant { background: #182018; border-color: #2c3a2c; }
.dossier-msg header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}
.dossier-msg-body { line-height: 1.75; white-space: normal; word-break: break-word; }
.dossier-attach-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.dossier-attach img {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid #333;
}
.dossier-file {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  background: #222;
  color: #9ad0ff;
  text-decoration: none;
}
.hidden { display: none !important; }
@media (max-width: 960px) {
  .dossier-split,
  .dossier-chats { grid-template-columns: 1fr; }
  .dossier-conv-list { max-height: 240px; }
}
.table-wrap {
  background: #1a1a1a;
  border: 1px solid #2c2c2c;
  border-radius: 18px;
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: right; font-size: 13.5px; }
th { color: var(--dim); font-weight: 600; background: #141414; }
tr + tr td { border-top: 1px solid #2a2a2a; }
.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}
.badge.approved { background: #123d32; color: #86efac; }
.badge.pending { background: #3a2a10; color: #fde68a; }
.badge.blocked { background: #3f1515; color: #fecaca; }
.row-actions { display: flex; gap: 6px; }
.mini {
  border: 0;
  border-radius: 9px;
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}
.mini.ok { background: #10a37f; color: #fff; }
.mini.bad { background: #7f1d1d; color: #fecaca; }
.mini.soft { background: #2a2a2a; color: var(--text); }

.menu {
  position: absolute;
  background: #2f2f2f;
  border: 1px solid #444;
  border-radius: 12px;
  min-width: 140px;
  padding: 6px;
  z-index: 20;
  box-shadow: var(--shadow);
}
.menu button {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text);
  text-align: right;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}
.menu button:hover { background: #3a3a3a; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.78);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 24px;
}
.lightbox img { max-height: 90vh; border-radius: 12px; }

.mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 15;
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    left: auto;
    width: min(var(--sidebar), 86vw);
    transform: translateX(110%);
    transition: transform .28s cubic-bezier(.22,1,.36,1);
    z-index: 40;
    box-shadow: -18px 0 40px rgba(0,0,0,.35);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: grid; }
  .topbar-spacer { display: block; }
  .mobile-backdrop {
    z-index: 35;
  }
  .mobile-backdrop.show { display: block; }
  body.sidebar-open { overflow: hidden; }
  .empty h2 { font-size: 24px; }
  .empty-lead { font-size: 14.5px; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes logo-breathe {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: .88; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes bg-shift {
  0%, 100% { background-position: 50% 0%; }
  50% { background-position: 50% 40%; }
}
@keyframes send-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,.18); }
  50% { box-shadow: 0 0 0 8px rgba(255,255,255,0); }
}

.login-card .brand img {
  animation: logo-breathe 3.2s ease-in-out infinite;
}
.empty {
  animation: fade-up .55s cubic-bezier(.22,1,.36,1);
}
.empty img {
  animation: logo-breathe 3.2s ease-in-out infinite;
}
.msg-wrap {
  animation: fade-up .35s ease;
}
.btn.is-loading,
.round-btn.is-loading {
  pointer-events: none;
  opacity: .75;
}
.btn.is-loading::after,
.round-btn.is-loading::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn.is-loading { color: transparent; }
.btn.is-loading::after {
  position: absolute;
  color: #111;
}
.btn { position: relative; }
.round-btn.is-loading svg { opacity: 0; }
.round-btn { position: relative; }

.send-btn:not(:disabled) {
  animation: send-pulse 2.4s ease-out infinite;
}

.otp-form-enter {
  animation: fade-up .4s ease;
}

.table-wrap {
  animation: fade-up .4s ease;
}
.phone-cta {
  transition: transform .18s ease, background .18s ease;
}
.phone-cta:hover { transform: translateY(-1px); }

body.g-dialog-open { overflow: hidden; }

.g-dialog-root {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
}
.g-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .58);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: g-fade .2s ease;
}
.g-dialog-card {
  position: relative;
  width: min(420px, 100%);
  background: linear-gradient(180deg, #2c2c2c 0%, #232323 100%);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 22px;
  padding: 24px 22px 18px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .04) inset;
  animation: g-dialog-in .28s cubic-bezier(.22, 1, .36, 1);
  text-align: right;
  direction: rtl;
}
.g-dialog-close {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.g-dialog-close:hover { background: rgba(255,255,255,.14); }
.g-dialog-close svg { width: 16px; height: 16px; }
.g-dialog-title {
  margin: 0 0 8px;
  padding-left: 36px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: right;
}
.g-dialog-text {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.85;
  font-size: 14.5px;
  text-align: right;
}
.g-dialog-input {
  width: 100%;
  height: 48px;
  margin: 0 0 18px;
  padding: 0 14px;
  border-radius: 14px;
  background: #1f1f1f;
  border: 1px solid rgba(255, 255, 255, .12);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.g-dialog-input:focus {
  border-color: rgba(255, 255, 255, .28);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .06);
}
.g-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.g-dialog-btn {
  height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  width: auto;
  min-width: 92px;
  transition: background .16s ease, transform .16s ease;
}
.g-dialog-btn:active { transform: scale(.97); }
.g-dialog-btn.ghost {
  background: transparent;
  color: var(--muted);
}
.g-dialog-btn.ghost:hover { background: #333; color: var(--text); }
.g-dialog-btn.primary {
  background: #fff;
  color: #111;
}
.g-dialog-btn.primary:hover { background: #e8e8e8; }
.g-dialog-btn.danger {
  background: #b42318;
  color: #fff;
}
.g-dialog-btn.danger:hover { background: #912018; }

.g-toast-root {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.g-toast {
  min-width: 220px;
  padding: 12px 18px;
  border-radius: 14px;
  background: #2c2c2c;
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(-8px);
  transition: .25s ease;
}
.g-toast.show { opacity: 1; transform: translateY(0); }
.g-toast.ok { border-color: rgba(16, 163, 127, .45); }
.g-toast.bad { border-color: rgba(239, 68, 68, .45); }

@keyframes g-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes g-dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to { opacity: 1; transform: none; }
}

.pack-line { color: #86efac; margin-top: 3px; }
.dim { color: var(--dim); font-size: 12px; }
.row-actions.wrap { flex-wrap: wrap; }
.table-wrap { overflow: auto; }
table.wide { min-width: 860px; }
.usage-bar {
  height: 6px;
  border-radius: 99px;
  background: #2a2a2a;
  overflow: hidden;
  margin-top: 6px;
}
.usage-bar i {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}
.usage-cell { min-width: 120px; }
.restrict-card.quota {
  background: linear-gradient(180deg, #1f2a22, #1b1b1b);
  border-color: rgba(16, 163, 127, .4);
}
.restrict-card.no_package {
  background: linear-gradient(180deg, #1c2422, #1b1b1b);
  border-color: rgba(16, 163, 127, .35);
  text-align: right;
}
.bill-card {
  margin-top: 8px;
  display: grid;
  gap: 10px;
}
.bill-pack {
  background: #141414;
  border-radius: 14px;
  padding: 12px 14px;
}
.bill-pack span { color: var(--dim); font-size: 12px; }
.bill-pack strong { display: block; font-size: 18px; margin: 4px 0 2px; }
.bill-pack small { color: var(--muted); }
.bill-price { color: var(--text); line-height: 1.8; }
.bill-code { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.bill-code-row { display: flex; gap: 8px; }
.bill-code-row input {
  flex: 1;
  height: 42px;
  border-radius: 12px;
  background: #303030;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,.08);
}
.bill-invoice {
  text-align: right;
  background: #141414;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}
.bill-invoice.hidden { display: none; }
.bill-invoice-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(255,255,255,.1);
}
.bill-invoice-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.bill-invoice-row b {
  color: var(--text);
  font-weight: 700;
  text-align: left;
}
.bill-invoice-row.total {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255,255,255,.1);
  color: var(--text);
  font-size: 14px;
}
.bill-invoice-row.total b { color: #10a37f; }
.bill-note { margin: 0; color: var(--dim); font-size: 12.5px; text-align: center; }
.pack-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.pack-option {
  text-align: right;
  background: #141414;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 12px 14px;
  color: inherit;
  cursor: pointer;
  display: grid;
  gap: 4px;
}
.pack-option strong { font-size: 15px; }
.pack-option b { color: #10a37f; font-size: 14px; }
.pack-option small, .pack-option span { color: var(--muted); font-size: 12px; line-height: 1.6; }
.pack-option.is-on {
  border-color: #10a37f;
  background: rgba(16,163,127,.08);
}
@media (max-width: 640px) {
  .pack-options { grid-template-columns: 1fr; }
}
.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0 22px;
}
.stat-card {
  background: #1a1a1a;
  border: 1px solid #2c2c2c;
  border-radius: 18px;
  padding: 16px;
}
.stat-card h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.stat-big { margin: 0; font-size: 22px; font-weight: 800; }
.pay-result .pay-msg { color: var(--muted); line-height: 1.8; }
.pay-result .pay-trace { color: var(--dim); }
.pay-result.ok h2 { color: #86efac; }
.pay-result.bad h2 { color: #fecaca; }
@media (max-width: 800px) {
  .account-grid { grid-template-columns: 1fr; }
}

/* Panel surfaces (admin + account) */
.panel-body {
  background:
    radial-gradient(900px 420px at 88% -8%, rgba(16, 163, 127, 0.16), transparent 55%),
    radial-gradient(700px 360px at 0% 100%, rgba(16, 163, 127, 0.08), transparent 50%),
    var(--bg);
}
.panel-main {
  position: relative;
  animation: fade-up .45s cubic-bezier(.22,1,.36,1);
}
.panel-topbar {
  background: rgba(33, 33, 33, 0.72);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.panel-sidebar .panel-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 16px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.panel-brand strong {
  display: block;
  font-size: 15px;
  font-weight: 800;
}
.panel-brand span {
  display: block;
  color: var(--dim);
  font-size: 12px;
  margin-top: 2px;
}
.panel-surface {
  background: linear-gradient(165deg, rgba(36,53,40,.55), rgba(26,26,26,.95));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,.22);
}
.panel-block { margin: 8px 0 28px; }
.panel-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-block-head h2 { margin: 0; font-size: 18px; }
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card {
  position: relative;
  overflow: hidden;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(16,163,127,.35);
  box-shadow: 0 12px 28px rgba(0,0,0,.25);
}
.stat-card-accent {
  background:
    linear-gradient(145deg, rgba(16,163,127,.18), rgba(26,26,26,.95));
  border-color: rgba(16,163,127,.28);
}
.stat-card .sub { margin: 8px 0 0; color: var(--dim); font-size: 12.5px; line-height: 1.6; }
.balance-hero {
  position: relative;
  overflow: hidden;
  padding: 28px 26px;
  margin: 8px 0 22px;
  min-height: 148px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: fade-up .55s cubic-bezier(.22,1,.36,1);
}
.balance-hero .eyebrow {
  margin: 0 0 8px;
  color: #9ae6b4;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
}
.balance-value {
  margin: 0;
  font-size: clamp(34px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -.03em;
  direction: ltr;
  text-align: right;
}
.balance-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.balance-meta span {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--muted);
  font-size: 12.5px;
}
.balance-orb {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,.28), transparent 28%),
    radial-gradient(circle at 50% 50%, rgba(16,163,127,.55), transparent 68%);
  filter: blur(2px);
  animation: logo-breathe 4.5s ease-in-out infinite;
  pointer-events: none;
}
.bill-card {
  padding: 20px;
  gap: 14px;
}
.bill-head h3 {
  margin: 0 0 4px;
  font-size: 18px;
}
.bill-head p {
  margin: 0;
  color: var(--dim);
  font-size: 13px;
}
.amount-chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.amount-chip {
  display: grid;
  gap: 2px;
  place-items: center;
  min-height: 64px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(20,20,20,.75);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.amount-chip small {
  color: var(--dim);
  font-size: 11px;
  font-weight: 600;
}
.amount-chip:hover { transform: translateY(-1px); border-color: rgba(16,163,127,.4); }
.amount-chip.is-on {
  border-color: #10a37f;
  background: rgba(16,163,127,.14);
}
.user-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
}
.user-link strong { display: block; font-size: 14px; }
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #243528;
  color: #9ae6b4;
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}
.table-wrap tr { transition: background .15s ease; }
.table-wrap tbody tr:hover { background: rgba(255,255,255,.025); }
.mono { font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.dossier-hero {
  background:
    linear-gradient(145deg, rgba(16,163,127,.12), rgba(20,20,20,.95));
  border-color: rgba(16,163,127,.18);
  box-shadow: 0 16px 40px rgba(0,0,0,.2);
}
.dossier-tabs {
  background: rgba(18,18,18,.85);
  backdrop-filter: blur(8px);
}
.dossier-tab {
  transition: background .16s ease, color .16s ease;
}
.dossier-tab:hover { color: var(--text); background: rgba(255,255,255,.04); }
.mini {
  transition: transform .15s ease, filter .15s ease, background .15s ease;
}
.mini:hover { filter: brightness(1.08); transform: translateY(-1px); }
.admin-search input {
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(20,20,20,.85);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.admin-search input:focus {
  border-color: rgba(16,163,127,.55);
  box-shadow: 0 0 0 4px rgba(16,163,127,.12);
}
@media (max-width: 1100px) {
  .stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .stats-3 { grid-template-columns: 1fr; }
  .amount-chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .balance-orb { display: none; }
}
