/* Happ VPN panel v2 — sıfır bağımlılık, açık/koyu tema, mobil-öncelikli. Panel arayüzü RUSÇA. */

/* HTML `hidden` özniteliği HER ZAMAN gizlesin (2026-07-24 hata düzeltmesi).
   Tarayıcının `[hidden]{display:none}` kuralı UA (varsayılan) stylesheet'tedir; bizim `.pane{display:flex}`
   gibi YAZAR kuralları onu KOŞULSUZ ezer. Sonuç: `hidden` işlevsiz kalıyordu ->
     • Продавцы detayında TÜM sekmeler aynı anda açılıyordu (ve «Приветствие» tıklanmadığı için
       tembel yükleyicisi hiç çalışmayıp sonsuza kadar «Загрузка…» yazıyordu),
     • login ekranında 2FA kod alanı (.field[hidden]) daima görünüyordu.
   `!important` bilinçli: `hidden` niyeti her display kuralını yenmelidir (normalize.css/Bootstrap ile aynı). */
[hidden] { display: none !important; }

/* --- Tema değişkenleri --- */
:root {
  --bg: #eef1f7; --surface: #ffffff; --surface-2: #f6f8fc; --border: #e2e7f0;
  --text: #1a2233; --muted: #64708a; --accent: #4f46e5; --accent-2: #6366f1; --on-accent: #ffffff;
  --ok: #16a34a; --warn: #d97706; --danger: #dc2626;
  --ok-bg: #dcfce7; --warn-bg: #fef3c7; --danger-bg: #fee2e2; --muted-bg: #eef1f7;
  --shadow: 0 1px 2px rgba(20,30,60,.06), 0 4px 12px rgba(20,30,60,.06);
  --radius: 14px; --radius-sm: 10px;
  --topbar-h: 63px;   /* 12px dolgu ×2 + 38px buton + 1px kenarlık — yapışkan tablo başlığı buna dayanır */
}
:root[data-theme="dark"] {
  --bg: #0d131f; --surface: #151d2b; --surface-2: #1a2333; --border: #263149;
  --text: #e6ecf7; --muted: #93a1ba; --accent: #6366f1; --accent-2: #818cf8; --on-accent: #ffffff;
  --ok: #22c55e; --warn: #f59e0b; --danger: #f05252;
  --ok-bg: #12351f; --warn-bg: #3a2c0c; --danger-bg: #3c1618; --muted-bg: #1a2333;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* --- Kabuk düzeni --- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.brand__logo { color: var(--accent); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav__item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 500; transition: background .12s;
}
.nav__item:hover { background: var(--surface-2); }
.nav__item--active { background: var(--accent); color: var(--on-accent); }
.nav__ico { width: 20px; text-align: center; }
/* Okunmamış bildirim rozeti (Уведомления) — `hidden` niteliği display'i YENMELİ (bkz. [hidden] kuralı). */
.nav__badge {
  margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; text-align: center;
  background: var(--danger, #d33); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px;
}
.row-unread > td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.sidebar__foot { margin-top: auto; font-size: 12px; padding: 8px 12px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar__spacer { flex: 1; }
.topbar__user { font-weight: 600; }
.view { padding: 22px; max-width: 1200px; width: 100%; margin-inline: auto; }
/* Ekran geçişinde içerik artık silinmiyor; yenisi kısa bir yükselişle gelir (yalnız ROTA değişiminde;
   kaydetme sonrası tazelemede animasyon YOK — göz yerini kaybetmesin). */
.view--enter > * { animation: viewIn .18s ease-out; }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* Üst ilerleme çubuğu — "yükleniyor" geri bildirimi (eski spinner sayfayı boşaltıyordu). */
#progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 200;
  background: var(--accent); transform: scaleX(0); transform-origin: left; opacity: 0;
}
#progress.progress--on { opacity: 1; transform: scaleX(.75); transition: transform 8s cubic-bezier(0,.7,.2,1), opacity .1s; }
#progress.progress--done { opacity: 0; transform: scaleX(1); transition: transform .18s ease, opacity .3s .12s; }

/* --- Sayfa --- */
.page__title { margin: 2px 0 18px; font-size: 22px; }
.note { margin-top: 22px; font-size: 13px; }

/* --- Kutucuk (tile) ızgarası --- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow); border-left: 4px solid transparent;
}
.tile__label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.tile__value { font-size: 25px; font-weight: 700; margin-top: 5px; word-break: break-word; }
.tile__sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.tile--ok { border-left-color: var(--ok); }
.tile--warn { border-left-color: var(--warn); }
.tile--danger { border-left-color: var(--danger); background: var(--danger-bg); }
.tile--danger .tile__value { color: var(--danger); }
.tile--muted { border-left-color: var(--border); }

/* --- Durum lejantı --- */
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 18px; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.chip b { margin-left: 2px; }

/* --- Kart + tablo --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.card__head { padding: 13px 16px; font-weight: 600; border-bottom: 1px solid var(--border); }
.card__head--row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card__body { padding: 14px 16px; }
.card__body p { margin: 0 0 10px; }
.expo-bad { color: var(--danger); font-weight: 600; }
.expo-ok { color: var(--ok); font-weight: 600; }
/* `overflow-y: clip` bilinçli: yalnız X ekseninde kaydırma isteriz. `overflow-x:auto` tek başınayken
   tarayıcı Y'yi de `auto` sayar ve içerideki yapışkan başlık sayfa kaydırmasına DEĞİL bu kutuya bağlanır
   (yani hiç yapışmaz). `clip` desteklenmeyen eski tarayıcıda satır düşer -> bugünkü davranışa döner. */
.table-wrap { overflow-x: auto; overflow-y: clip; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th {
  color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .3px;
  position: sticky; top: var(--topbar-h); z-index: 4; background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);   /* kaydırırken kenarlık kaybolmasın (border sticky'de kayar) */
}
/* Uzun serbest metin sütunları (заметка/событие) mobilde satır kaydırmayı tetiklemesin. */
.table td.wrap { white-space: normal; min-width: 180px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; }

/* --- Rozetler --- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--muted { background: var(--muted-bg); color: var(--muted); }
.badge--owner { background: var(--accent); color: var(--on-accent); }

/* --- Butonlar --- */
.btn { font: inherit; font-weight: 600; padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; transition: filter .12s, background .12s; }
.btn:hover { filter: brightness(.98); }
.btn:disabled { opacity: .6; cursor: default; }
/* Tek-uçuş göstergesi (lib/ui.js `busy`): işlem bitene dek buton kilitli + dönen halka. */
.btn.is-busy { cursor: progress; }
.btn.is-busy::after {
  content: ''; display: inline-block; vertical-align: -2px; margin-left: 8px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); width: 100%; padding: 11px; }
.btn--ghost { background: transparent; }
.icon-btn { font: inherit; font-size: 18px; line-height: 1; background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm); width: 38px; height: 38px; cursor: pointer; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
.only-mobile { display: none; }

/* --- Formlar --- */
.form { display: flex; flex-direction: column; gap: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; color: var(--muted); }
.field input { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 12px; }
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.form__err { color: var(--danger); font-size: 13.5px; }

/* --- Giriş ekranı --- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth__card, .login { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 26px; }
.auth__card { padding: 0; border: 0; box-shadow: none; background: transparent; }
.login__brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.login__brand .brand__logo { color: var(--accent); }
.login__title { font-size: 20px; margin: 10px 0 18px; }
.qr { display: block; width: 190px; height: 190px; margin: 12px auto; border-radius: var(--radius-sm); background: #fff; padding: 8px; }
.secret { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 14px; word-break: break-all; }
.secret code { color: var(--text); }

/* --- Durumlar --- */
.spinner { padding: 40px; text-align: center; color: var(--muted); }
.error-box { padding: 16px; border-radius: var(--radius-sm); background: var(--danger-bg); color: var(--danger); }
.empty { padding: 28px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text); background: var(--surface); }

/* --- Sayfa başı + sekmeler + form ızgaraları --- */
.page__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.page__head .page__title { margin-bottom: 8px; }
.page__title a { font-weight: 400; }
.toggle-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle-inline input { cursor: pointer; }
.mybot-stat { margin: -8px 0 16px; color: var(--muted); font-size: 14px; }
.mybot-stat b { color: var(--text); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0; }
.tab { font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.tab--active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pane { display: flex; flex-direction: column; gap: 14px; }
.form-card .card__body.form { gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.field textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 12px; resize: vertical; }
.field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.row-link { cursor: pointer; }
.danger-zone { border-color: var(--danger); }
.danger-zone .card__body { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.banner-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* --- Arama + satır içi formlar + mini butonlar --- */
.search { display: flex; gap: 8px; }
.search input { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; min-width: 220px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.inline-form input, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; }
select:focus, .search input:focus, .inline-form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn--mini { padding: 4px 10px; font-size: 12.5px; font-weight: 500; }
.row-actions { white-space: nowrap; }
.row-actions .btn--mini + .btn--mini { margin-left: 6px; }
.sub-row td { background: var(--surface-2); font-size: 13px; }
.chip .chip__x { border: 0; background: transparent; color: var(--danger); cursor: pointer; font: inherit; padding: 0 2px; }

/* --- Modal --- */
.modal-wrap { position: fixed; inset: 0; z-index: 90; background: rgba(10,14,25,.55); display: grid; place-items: center; padding: 18px; }
.modal { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.modal__title { margin: 0 0 8px; font-size: 18px; }
.modal__text { margin: 0 0 16px; color: var(--muted); }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.btn--inline { width: auto; }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }

/* --- Toast --- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  padding: 11px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); color: #fff;
  background: var(--ok); opacity: 1; transition: opacity .3s; cursor: pointer;
  animation: toastIn .18s ease-out; word-break: break-word;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast--warn { background: var(--warn); }
.toast--danger { background: var(--danger); }
.toast--out { opacity: 0; }

/* --- Ağaç (Структура) --- */
.tree, .tree ul { list-style: none; margin: 0; padding-left: 18px; }
.tree > li { padding-left: 0; }
.tree li { padding: 4px 0; border-left: 1px solid var(--border); padding-left: 14px; }
.tree > li { border-left: 0; padding-left: 0; }
.lazy-cl { margin: 4px 0 4px 12px; font-size: 13px; }

/* --- Hareket duyarlılığı --- */
/* Sistemde "animasyonları azalt" seçiliyse hepsi kapanır (geçiş anlık olur, işlev aynı kalır). */
@media (prefers-reduced-motion: reduce) {
  .view--enter > *, .toast, .btn.is-busy::after { animation: none !important; }
  #progress, .sidebar, .nav__item { transition: none !important; }
}

/* --- Mobil --- */
.scrim { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 40; width: 240px;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .shell--nav-open .sidebar { transform: translateX(0); }
  .shell--nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.4); }
  .only-mobile { display: inline-flex; align-items: center; justify-content: center; }
  .view { padding: 16px; }
}
