/* ==========================================================================
   VPN Panel — monoxrom dizayn tizimi
   Butun palitra kulrang shkalada: holat rangi emas, kontrast va shakl orqali
   ifodalanadi. Shu sabab qora va oq mavzu bir xil darajada aniq ko'rinadi.
   ========================================================================== */

:root {
  --bg:        #ffffff;
  --surface:   #ffffff;
  --surface-2: #fafafa;
  --raised:    #f4f4f5;
  --text:      #09090b;
  --text-2:    #52525b;
  --text-3:    #a1a1aa;
  --border:    #e4e4e7;
  --border-2:  #d4d4d8;
  --invert-bg: #09090b;
  --invert-fg: #ffffff;
  --shadow:    0 1px 2px rgba(0,0,0,.04), 0 8px 24px -12px rgba(0,0,0,.12);
  --shadow-lg: 0 24px 64px -24px rgba(0,0,0,.28);
  --radius:    14px;
  --radius-sm: 9px;
  --ring:      0 0 0 3px rgba(9,9,11,.12);
}

:root[data-theme="dark"] {
  --bg:        #000000;
  --surface:   #0a0a0b;
  --surface-2: #0f0f11;
  --raised:    #17171a;
  --text:      #fafafa;
  --text-2:    #a1a1aa;
  --text-3:    #5b5b64;
  --border:    #1e1e22;
  --border-2:  #2a2a30;
  --invert-bg: #fafafa;
  --invert-fg: #09090b;
  --shadow:    0 1px 2px rgba(0,0,0,.6), 0 8px 24px -12px rgba(0,0,0,.9);
  --shadow-lg: 0 24px 64px -24px rgba(0,0,0,1);
  --ring:      0 0 0 3px rgba(250,250,250,.16);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}

body.theme-ready * { transition: background-color .18s ease, border-color .18s ease, color .18s ease; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { display: block; }

.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .92em;
}

/* ------------------------------------------------------------------ layout */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 244px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 14px 14px;
  z-index: 60;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 22px; }

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--invert-bg);
  color: var(--invert-fg);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 18px; height: 18px; }

.brand-text strong { display: block; font-size: 14.5px; font-weight: 650; letter-spacing: -.02em; }
.brand-text span { display: block; font-size: 11.5px; color: var(--text-3); letter-spacing: .01em; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
}
.nav a svg { width: 17px; height: 17px; opacity: .75; flex-shrink: 0; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--raised); color: var(--text); font-weight: 600; }
.nav a.active svg { opacity: 1; }
.nav a .count {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 14px; }

.side-status {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-2);
}

.main { flex: 1; margin-left: 244px; min-width: 0; }
.content { max-width: 1180px; padding: 30px 34px 64px; margin: 0 auto; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin-bottom: 26px; flex-wrap: wrap;
}
.page-head h1 { font-size: 25px; font-weight: 660; letter-spacing: -.03em; }
.page-head p { color: var(--text-3); font-size: 13.5px; margin-top: 3px; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card + .card { margin-top: 18px; }

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 13.5px; font-weight: 620; letter-spacing: -.01em; }
.card-head .sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 18px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); margin-bottom: 18px; }
.grid-2 { grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr); align-items: stretch; }
/* Chap ustundagi karta qatorning to'liq balandligini egallaydi — ro'yxat bo'sh
   bo'lganda ham ikki ustun bir tekisda tugaydi. */
.grid-2 > .card { display: flex; flex-direction: column; }
.grid-2 > .card > .card-body { flex: 1 1 auto; }
.grid-2 > .card > .card-body > .table-wrap { height: 100%; }
.grid-2 > .card .empty { padding: 72px 20px; }

/* -------------------------------------------------------------- stat tiles */

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px 18px;
  position: relative;
}
.tile .label {
  font-size: 11.5px; font-weight: 550;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3);
}
.tile .value {
  font-size: 30px; font-weight: 650; letter-spacing: -.035em;
  margin-top: 8px; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.tile .value .unit { font-size: 14px; font-weight: 500; color: var(--text-3); margin-left: 3px; letter-spacing: 0; }
.tile .foot { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.tile .corner { position: absolute; top: 16px; right: 16px; color: var(--text-3); }
.tile .corner svg { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ badges */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-2);
  font-size: 11.5px; font-weight: 550;
  color: var(--text-2);
  white-space: nowrap;
}
.badge.solid { background: var(--invert-bg); color: var(--invert-fg); border-color: var(--invert-bg); }
.badge.warn { border-style: dashed; color: var(--text); }
.badge.muted { color: var(--text-3); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.dot.hollow { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }

.pulse { position: relative; }
.pulse::after {
  content: ""; position: absolute; inset: -4px;
  border-radius: 50%; border: 1px solid currentColor;
  opacity: .55; animation: pulse 1.9s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(.7); opacity: .6; }
  70%  { transform: scale(1.7); opacity: 0; }
  100% { opacity: 0; }
}

/* ------------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }

thead th {
  position: sticky; top: 0;
  background: var(--surface);
  text-align: left;
  padding: 10px 20px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
td.right, th.right { text-align: right; }
td.actions { text-align: right; white-space: nowrap; }
td.actions form { display: inline; }

.user-cell { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--raised);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 650;
  color: var(--text-2);
  flex-shrink: 0;
}
.user-cell .meta { min-width: 0; }
.user-cell .name { font-weight: 550; letter-spacing: -.01em; }
.user-cell .sub { font-size: 12px; color: var(--text-3); }

.empty { padding: 46px 20px; text-align: center; color: var(--text-3); }
.empty svg { width: 26px; height: 26px; margin: 0 auto 10px; opacity: .5; }
.empty p { font-size: 13.5px; }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px; font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--invert-bg); color: var(--invert-fg); border-color: var(--invert-bg); }
.btn-primary:hover { opacity: .87; background: var(--invert-bg); border-color: var(--invert-bg); }

.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { padding: 6px; }
.btn-icon svg { width: 15px; height: 15px; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--raised); color: var(--text); border-color: transparent; }
.btn-danger:hover { background: var(--invert-bg); color: var(--invert-fg); border-color: var(--invert-bg); }

/* ------------------------------------------------------------------- forms */

.field { margin-bottom: 15px; }
.field label {
  display: block; margin-bottom: 6px;
  font-size: 12.5px; font-weight: 550; color: var(--text-2);
}
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 6px; }

.input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
}
.input::placeholder { color: var(--text-3); }
.input:focus { border-color: var(--text-2); box-shadow: var(--ring); }

.input-group { display: flex; gap: 7px; }
.input-group .input { flex: 1; min-width: 0; }

.meter { display: flex; gap: 3px; margin-top: 7px; }
.meter i {
  height: 3px; flex: 1; border-radius: 2px;
  background: var(--border);
}
.meter i.on { background: var(--text); }

/* ------------------------------------------------------------------ flashes */

.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.flash {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--border-2);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13px;
}
.flash.error { border-left-color: var(--text); }
.flash.success { border-left-color: var(--text-3); }
.flash svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1.5px; }

/* ------------------------------------------------------------------- chart */

.chart { position: relative; height: 168px; width: 100%; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-legend {
  display: flex; gap: 18px; margin-top: 12px;
  font-size: 12px; color: var(--text-2); flex-wrap: wrap;
}
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-key { width: 14px; height: 2.5px; border-radius: 2px; background: currentColor; }
.legend-key.dashed { background: none; border-top: 2px dashed currentColor; height: 0; }

/* ------------------------------------------------------------------ modals */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  z-index: 200;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 430px;
  padding: 24px;
  animation: rise .16s ease-out;
}
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.modal h3 { font-size: 16.5px; font-weight: 620; letter-spacing: -.02em; }
.modal .modal-sub { font-size: 13px; color: var(--text-3); margin: 5px 0 18px; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 20px; }

/* -------------------------------------------------------------- timeline */

.timeline { display: flex; flex-direction: column; }
.timeline li { display: flex; gap: 13px; padding: 12px 20px; border-bottom: 1px solid var(--border); list-style: none; }
.timeline li:last-child { border-bottom: none; }
.timeline .tl-icon {
  width: 26px; height: 26px; border-radius: 8px;
  border: 1px solid var(--border-2);
  display: grid; place-items: center;
  color: var(--text-2); flex-shrink: 0;
}
.timeline .tl-icon svg { width: 13px; height: 13px; }
.timeline .tl-body { flex: 1; min-width: 0; }
.timeline .tl-title { font-size: 13px; }
.timeline .tl-title b { font-weight: 600; }
.timeline .tl-meta { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.timeline .tl-time { font-size: 12px; color: var(--text-3); white-space: nowrap; }

/* --------------------------------------------------------------- info list */

.info-list { display: flex; flex-direction: column; }
.info-list div {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.info-list div:last-child { border-bottom: none; }
.info-list dt { color: var(--text-3); }
.info-list dd { font-weight: 550; text-align: right; }

/* ------------------------------------------------------------------- login */

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.login-box { width: 100%; max-width: 372px; }
.login-box .brand { justify-content: center; padding-bottom: 26px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 19px; font-weight: 640; letter-spacing: -.025em; }
.login-card > p { color: var(--text-3); font-size: 13px; margin: 4px 0 22px; }
.login-foot { text-align: center; margin-top: 18px; font-size: 12px; color: var(--text-3); }

/* ------------------------------------------------------------------ mobile */

.mobile-bar { display: none; }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    inset: auto 0 0 0; width: 100%; height: auto;
    flex-direction: row; align-items: center;
    border-right: none; border-top: 1px solid var(--border);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  }
  .brand, .sidebar-foot .side-status { display: none; }
  .nav { flex-direction: row; flex: 1; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 8px; }
  .nav a .count { display: none; }
  .sidebar-foot { margin: 0; padding: 0; flex-direction: row; }
  .main { margin-left: 0; padding-bottom: 74px; }
  .content { padding: 20px 16px 40px; }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--bg); z-index: 50;
  }
  .page-head h1 { font-size: 21px; }
  .grid-stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .tile { padding: 14px; }
  .tile .value { font-size: 24px; }

  /* Pastki panelda faqat belgilar qoladi — matn joyni yeb, kesilib ketardi.
     Ma'no title= atributida saqlanadi. */
  .sidebar-foot .btn span:not(.dot) { display: none; }
  .sidebar-foot .btn { padding: 6px 9px; width: auto !important; }
  .sidebar-foot form { flex: 0 0 auto; }
  .sidebar-foot .btn svg { margin: 0; }
}

/* Kichik telefonlar (iPhone SE va h.k.) — pastki panel sig'masdi. */
@media (max-width: 380px) {
  .sidebar { padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); gap: 2px; }
  .nav { gap: 0; }
  .nav a { padding: 5px 4px; font-size: 9.5px; gap: 2px; letter-spacing: -.01em; }
  .nav a svg { width: 17px; height: 17px; }
  .sidebar-foot { gap: 2px; }
  .sidebar-foot .btn { padding: 5px 6px; }
  .content { padding: 16px 12px 36px; }
  .grid-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .page-head h1 { font-size: 19px; }
}

/* ------------------------------------------------- jadval -> karta (mobil) */
/* Telefonda 5 ustunli jadval gorizontal aylantirishni talab qiladi va amal
   tugmalari ekrandan chiqib ketadi. Shu kenglikdan pastda har bir qator
   alohida kartaga aylanadi — hamma narsa barmoq yetadigan joyda turadi. */
@media (max-width: 720px) {
  .table-wrap { overflow-x: visible; }
  table { min-width: 0; display: block; }
  thead { display: none; }
  tbody, tr, td { display: block; width: 100%; }

  tbody tr {
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
  }
  tbody tr:last-child { border-bottom: none; }

  tbody td {
    padding: 0;
    border: none;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    min-height: 30px;
  }
  /* Birinchi katak — kartaning sarlavhasi (avatar + ism). */
  tbody td:first-child { display: block; margin-bottom: 10px; }

  tbody td[data-label]::before {
    content: attr(data-label);
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-3);
    flex: 0 0 auto;
  }
  tbody td[data-label] > * { text-align: right; }

  tbody td.actions {
    justify-content: flex-start; flex-wrap: wrap; gap: 8px;
    margin-top: 12px; padding-top: 12px;
    border-top: 1px solid var(--border);
  }
  /* Tugmalar barmoq uchun yetarli kattalikda bo'lsin. */
  tbody td.actions .btn { min-width: 40px; min-height: 36px; justify-content: center; }

  tbody td .empty { padding: 40px 16px; }
}
