/* WeDo VPN Admin — Clay Dark — Mobile First Redesign */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ============================================================
   Tokens (dark — default)
   ============================================================ */
:root {
  --bg:           #1e2124;
  --surface:      #2a2f35;
  --surface-2:    #313840;
  --surface-3:    #383f48;

  --orange:       #ee7623;
  --orange-glow:  rgba(238, 118, 35, 0.28);
  --orange-soft:  rgba(238, 118, 35, 0.12);
  --orange-dark:  #c8580b;

  --text:         #f0f1f2;
  --muted:        #9ea1a2;
  --muted-2:      #636870;

  --success:      #3ddc84;
  --success-glow: rgba(61, 220, 132, 0.22);
  --success-soft: rgba(61, 220, 132, 0.10);
  --danger:       #e05252;
  --danger-soft:  rgba(224, 82, 82, 0.12);
  --warning:      #f5c518;

  /* Clay shadow system — deep multi-layer */
  --shadow-clay:
    0 2px 0 rgba(255,255,255,0.06) inset,
    0 -1px 0 rgba(0,0,0,0.20) inset,
    0 10px 30px rgba(0,0,0,0.45),
    0 4px 8px rgba(0,0,0,0.30);
  --shadow-clay-hover:
    0 2px 0 rgba(255,255,255,0.08) inset,
    0 -1px 0 rgba(0,0,0,0.22) inset,
    0 14px 40px rgba(0,0,0,0.50),
    0 6px 12px rgba(0,0,0,0.35),
    0 0 0 1px rgba(238,118,35,0.12);
  --shadow-clay-pressed:
    0 1px 0 rgba(255,255,255,0.03) inset,
    0 -1px 0 rgba(0,0,0,0.25) inset,
    0 4px 12px rgba(0,0,0,0.35),
    0 2px 4px rgba(0,0,0,0.25);
  --shadow-btn:
    0 1px 0 rgba(255,255,255,0.20) inset,
    0 -2px 0 rgba(0,0,0,0.20) inset,
    0 6px 16px rgba(238,118,35,0.35),
    0 2px 4px rgba(0,0,0,0.20);
  --shadow-btn-hover:
    0 1px 0 rgba(255,255,255,0.22) inset,
    0 -2px 0 rgba(0,0,0,0.22) inset,
    0 8px 24px rgba(238,118,35,0.45),
    0 4px 8px rgba(0,0,0,0.25);
  --shadow-btn-danger:
    0 1px 0 rgba(255,255,255,0.15) inset,
    0 -2px 0 rgba(0,0,0,0.20) inset,
    0 6px 16px rgba(224,82,82,0.30),
    0 2px 4px rgba(0,0,0,0.20);
  --shadow-input:
    0 2px 8px rgba(0,0,0,0.30) inset,
    0 1px 0 rgba(255,255,255,0.04);
  --shadow-stat-orange:
    0 2px 0 rgba(255,255,255,0.22) inset,
    0 -1px 0 rgba(0,0,0,0.15) inset,
    0 10px 30px rgba(238,118,35,0.40),
    0 4px 8px rgba(0,0,0,0.20);
  --shadow-stat-green:
    0 2px 0 rgba(255,255,255,0.22) inset,
    0 -1px 0 rgba(0,0,0,0.15) inset,
    0 10px 30px rgba(61,220,132,0.30),
    0 4px 8px rgba(0,0,0,0.20);

  /* Radius scale */
  --radius-card: 24px;
  --radius-btn:  14px;
  --radius-input: 14px;
  --radius-badge: 10px;
  --radius-sm:   8px;

  /* Scroll containment */
  --card-scroll-max: 55vh;
}

/* ============================================================
   Light theme
   ============================================================ */
[data-theme="light"] {
  --bg:           #f0f1f3;
  --surface:      #ffffff;
  --surface-2:    #f4f5f7;
  --surface-3:    #e8eaed;
  --text:         #1e2124;
  --muted:        #636870;
  --muted-2:      #9ea1a2;

  --shadow-clay:
    0 2px 0 rgba(255,255,255,0.85) inset,
    0 -1px 0 rgba(0,0,0,0.04) inset,
    0 10px 30px rgba(0,0,0,0.08),
    0 4px 8px rgba(0,0,0,0.05);
  --shadow-clay-hover:
    0 2px 0 rgba(255,255,255,0.90) inset,
    0 -1px 0 rgba(0,0,0,0.05) inset,
    0 14px 40px rgba(0,0,0,0.12),
    0 6px 12px rgba(0,0,0,0.07),
    0 0 0 1px rgba(238,118,35,0.12);
  --shadow-clay-pressed:
    0 1px 0 rgba(255,255,255,0.6) inset,
    0 -1px 0 rgba(0,0,0,0.06) inset,
    0 4px 12px rgba(0,0,0,0.06),
    0 2px 4px rgba(0,0,0,0.04);
  --shadow-btn:
    0 1px 0 rgba(255,255,255,0.5) inset,
    0 -1px 0 rgba(0,0,0,0.10) inset,
    0 6px 16px rgba(238,118,35,0.28),
    0 2px 4px rgba(0,0,0,0.08);
  --shadow-btn-hover:
    0 1px 0 rgba(255,255,255,0.55) inset,
    0 -1px 0 rgba(0,0,0,0.12) inset,
    0 8px 24px rgba(238,118,35,0.35),
    0 4px 8px rgba(0,0,0,0.10);
  --shadow-btn-danger:
    0 1px 0 rgba(255,255,255,0.5) inset,
    0 -1px 0 rgba(0,0,0,0.10) inset,
    0 6px 16px rgba(224,82,82,0.22),
    0 2px 4px rgba(0,0,0,0.08);
  --shadow-input:
    0 2px 6px rgba(0,0,0,0.07) inset,
    0 1px 0 rgba(255,255,255,0.9);
  --shadow-stat-orange:
    0 2px 0 rgba(255,255,255,0.20) inset,
    0 10px 30px rgba(238,118,35,0.30),
    0 4px 8px rgba(0,0,0,0.08);
  --shadow-stat-green:
    0 2px 0 rgba(255,255,255,0.20) inset,
    0 10px 30px rgba(61,220,132,0.22),
    0 4px 8px rgba(0,0,0,0.08);
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ============================================================
   Custom scrollbar (themed)
   ============================================================ */
.scroll-container::-webkit-scrollbar {
  width: 5px;
}
.scroll-container::-webkit-scrollbar-track {
  background: transparent;
  margin: 8px 0;
}
.scroll-container::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 4px;
}
.scroll-container::-webkit-scrollbar-thumb:hover {
  background: var(--muted-2);
}
/* Firefox */
.scroll-container {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

/* ============================================================
   Topbar — mobile base
   ============================================================ */
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    0 4px 16px rgba(0,0,0,0.30);
  position: sticky;
  top: 0;
  z-index: 200;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand-img {
  height: 20px;
  width: auto;
  display: block;
}
[data-theme="light"] .brand-img {
  filter: brightness(0);
}
.brand-logo span { color: var(--orange); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--surface-3);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 3px 8px rgba(0,0,0,0.22);
  transition: color 0.2s, box-shadow 0.2s, transform 0.15s;
  text-transform: none;
  letter-spacing: 0;
}
.theme-toggle:hover {
  color: var(--orange);
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06) inset,
    0 4px 12px rgba(0,0,0,0.28);
}
.theme-toggle:active {
  transform: scale(0.94);
  box-shadow: var(--shadow-clay-pressed);
}
.theme-toggle svg { width: 16px; height: 16px; }

.btn-logout {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: none;
  cursor: pointer;
  display: inline-block;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    0 4px 8px rgba(0,0,0,0.22);
  transition: color 0.2s, box-shadow 0.2s, transform 0.15s;
  width: auto;
  margin: 0;
}
.btn-logout:hover {
  color: var(--text);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06) inset,
    0 6px 14px rgba(0,0,0,0.30);
}
.btn-logout:active {
  transform: scale(0.96);
}

/* ============================================================
   Page wrapper — mobile base
   ============================================================ */
.page {
  padding: 16px 12px 28px;
  max-width: 1340px;
  margin: 0 auto;
}

/* ============================================================
   Stats row — mobile base (horizontal scroll)
   ============================================================ */
.stats-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  padding-bottom: 4px;
  /* hide scrollbar on mobile for clean look */
  scrollbar-width: none;
}
.stats-row::-webkit-scrollbar { display: none; }

.stat-card {
  flex: 0 0 auto;
  min-width: 120px;
  padding: 14px 18px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-clay);
  transition: box-shadow 0.25s, transform 0.2s;
  scroll-snap-align: start;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-clay-hover);
}

.stat-card.orange {
  background: linear-gradient(145deg, var(--orange) 0%, var(--orange-dark) 100%);
  box-shadow: var(--shadow-stat-orange);
}
.stat-card.green {
  background: linear-gradient(145deg, #2dba70 0%, #219754 100%);
  box-shadow: var(--shadow-stat-green);
}

.stat-num {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
}
.stat-card.orange .stat-num,
.stat-card.green  .stat-num { color: #fff; }

.stat-lbl {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  margin-top: 4px;
}
.stat-card.orange .stat-lbl,
.stat-card.green  .stat-lbl { color: rgba(255,255,255,0.72); }

/* ============================================================
   Main grid — mobile base (single col)
   ============================================================ */
.main-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.col-data,
.col-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Actions first on mobile */
.col-actions { order: -1; }

/* ============================================================
   Clay card — the core component
   ============================================================ */
.clay-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-clay);
  overflow: hidden;
  transition: box-shadow 0.25s;
}

.clay-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.card-body {
  padding: 16px 18px;
}

/* ============================================================
   Scroll containment — prevents card explosion
   ============================================================ */
.scroll-container {
  max-height: var(--card-scroll-max);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Fade hint at bottom when scrollable */
.scroll-fade {
  position: relative;
}
.scroll-fade::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: linear-gradient(transparent, var(--surface));
  pointer-events: none;
  border-radius: 0 0 var(--radius-card) var(--radius-card);
  opacity: 0;
  transition: opacity 0.2s;
}
.scroll-fade.has-overflow::after {
  opacity: 1;
}

/* ============================================================
   Collapsible sections
   ============================================================ */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  border: none;
  background: transparent;
  width: 100%;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  min-height: 48px;
}
.collapsible-header:hover { background: rgba(255,255,255,0.02); }
.collapsible-header > div:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.collapsible-content {
  overflow: hidden;
  max-height: 3000px;
  opacity: 1;
  transition: max-height 0.32s ease, opacity 0.22s;
}
.collapsible-content.collapsed {
  max-height: 0 !important;
  opacity: 0;
}

.collapse-icon {
  font-size: 10px;
  color: var(--muted-2);
  width: 14px;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.collapse-icon.collapsed { transform: rotate(-90deg); }

/* ============================================================
   Forms
   ============================================================ */
input, select {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: var(--surface-2);
  border: none;
  border-radius: var(--radius-input);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  margin-top: 10px;
  box-shadow: var(--shadow-input);
  transition: box-shadow 0.18s;
  -webkit-appearance: none;
  appearance: none;
  min-height: 44px;
}
input:focus, select:focus {
  outline: none;
  box-shadow: var(--shadow-input), 0 0 0 2px var(--orange);
}
input::placeholder { color: var(--muted-2); }
select { cursor: pointer; }
select option { background: var(--surface-2); }
input[type="password"] {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.08em;
}

/* ============================================================
   Buttons — tactile clay style
   ============================================================ */
button {
  display: block;
  width: 100%;
  padding: 12px 20px;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 12px;
  box-shadow: var(--shadow-btn);
  transition: box-shadow 0.2s, transform 0.15s;
  min-height: 44px;
}
button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-btn-hover);
}
button:active:not(:disabled) {
  transform: scale(0.96) translateY(1px);
  box-shadow: var(--shadow-clay-pressed);
}
button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: var(--muted-2);
  box-shadow: none;
}

.btn-danger {
  background: var(--danger);
  box-shadow: var(--shadow-btn-danger);
}
.btn-danger:hover:not(:disabled) {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.15) inset,
    0 8px 24px rgba(224,82,82,0.40);
}

.btn-secondary {
  background: var(--surface-3);
  color: var(--muted);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    0 4px 10px rgba(0,0,0,0.25);
}
.btn-secondary:hover:not(:disabled) {
  color: var(--text);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06) inset,
    0 6px 14px rgba(0,0,0,0.30);
}

.btn-small {
  display: inline-flex;
  align-items: center;
  width: auto;
  padding: 6px 14px;
  font-size: 11px;
  margin: 0;
  border-radius: var(--radius-sm);
  min-height: 32px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 6px 12px;
  min-height: 36px;
  background: var(--surface-3);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--muted-2);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    0 3px 8px rgba(0,0,0,0.22);
  transition: color 0.15s, box-shadow 0.15s, transform 0.15s;
  text-transform: none;
  letter-spacing: 0;
}
.btn-icon:hover:not(:disabled) {
  color: var(--orange);
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 4px 12px rgba(0,0,0,0.28);
}
.btn-icon:active:not(:disabled) {
  transform: scale(0.94);
}

.btn-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 4px 10px;
  min-height: 28px;
  font-size: 10px;
  background: var(--surface-3);
  border: none;
  color: var(--muted-2);
  border-radius: 7px;
  margin: 0 0 0 8px;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: color 0.15s, box-shadow 0.15s, transform 0.15s;
  letter-spacing: 0.03em;
}
.btn-edit:hover:not(:disabled) {
  color: var(--orange);
  box-shadow: 0 3px 8px rgba(238,118,35,0.25);
}
.btn-edit:active:not(:disabled) {
  transform: scale(0.92);
}

/* ============================================================
   Tables — mobile: stacked card layout
   ============================================================ */
table {
  width: 100%;
  border-collapse: collapse;
}

/* Mobile: each row becomes a card */
thead { display: none; }

tbody tr {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  align-items: center;
  transition: background 0.12s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

td {
  font-size: 13px;
  padding: 0;
  border: none;
}

/* Mobile: cells get labels via data-label */
td[data-label]::before {
  content: attr(data-label);
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 2px;
}

/* Mobile connected clients: specific layout */
td.td-name { flex: 1 1 100%; font-weight: 600; }
td.td-group { flex: 0 0 auto; }
td.td-vpn-ip { flex: 0 0 auto; font-family: 'JetBrains Mono', monospace; font-size: 12px; }
td.td-real-ip { flex: 0 0 auto; font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--muted); }
td.td-since { flex: 0 0 auto; font-size: 11px; color: var(--muted); }
td.td-traffic { flex: 0 0 auto; font-size: 11px; }

/* Single-col placeholder rows */
td[colspan] {
  flex: 1 1 100%;
  text-align: center;
  color: var(--muted-2);
  padding: 20px 0;
}
td[colspan]::before { display: none; }

/* Rejected rows */
tr.rejected-row {
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
tr.rejected-row td.td-name { color: var(--danger); }

/* ============================================================
   Badges & Counts
   ============================================================ */
.count-badge {
  display: inline-block;
  min-width: 20px;
  padding: 2px 8px;
  background: var(--surface-3);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25) inset;
}
.count-badge.count-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-badge);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  vertical-align: middle;
  white-space: nowrap;
}
.badge-online {
  background: var(--success-soft);
  color: var(--success);
  box-shadow: 0 0 8px var(--success-glow);
}
.badge-offline {
  background: rgba(255,255,255,0.04);
  color: var(--muted-2);
}
.badge-admin {
  background: var(--orange-soft);
  color: var(--orange);
  box-shadow: 0 0 8px var(--orange-glow);
}
.badge-group {
  background: var(--surface-3);
  color: var(--muted);
}

/* ============================================================
   Status messages
   ============================================================ */
.status {
  display: none;
  padding: 10px 14px;
  border-radius: var(--radius-input);
  margin-top: 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}
.loading {
  background: var(--orange-soft);
  color: var(--orange);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.success {
  background: var(--success-soft);
  color: var(--success);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.error {
  background: var(--danger-soft);
  color: var(--danger);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.info-text {
  font-size: 12px;
  color: var(--muted-2);
  line-height: 1.5;
}

/* ============================================================
   Group cards (rendered by app.js → #groupsList)
   ============================================================ */
.group-card {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.12s;
}
.group-card:last-child { border-bottom: none; }
.group-card:hover { background: rgba(255,255,255,0.025); }

.group-card.admin .group-icon {
  background: linear-gradient(145deg, var(--orange) 0%, var(--orange-dark) 100%);
  box-shadow: 0 2px 8px var(--orange-glow), 0 1px 0 rgba(255,255,255,0.2) inset;
  color: #fff;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.group-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--surface-3);
  border-radius: 11px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: -0.5px;
  flex-shrink: 0;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06) inset,
    0 3px 8px rgba(0,0,0,0.25);
}

.group-info {
  flex: 1;
  min-width: 0;
}

.group-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.group-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.group-usage {
  font-size: 11px;
  color: var(--muted);
}

.group-range {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted-2);
}

/* ============================================================
   Client rows (rendered by app.js)
   ============================================================ */
.client-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.12s;
}
.client-row:last-child { border-bottom: none; }
.client-row:hover { background: rgba(255,255,255,0.025); }

.client-row > div:first-child {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1;
}

.client-name { font-size: 13px; font-weight: 500; }
.client-ip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted-2);
}

/* Group headers in clients section */
.group-header-collapsible {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  min-height: 44px;
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  user-select: none;
  border-top: 1px solid rgba(255,255,255,0.04);
  transition: background 0.12s;
}
.group-header-collapsible:first-child { border-top: none; }
.group-header-collapsible:hover { background: rgba(255,255,255,0.04); }

.group-clients {
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.28s ease;
}
.group-clients.collapsed { max-height: 0 !important; }

/* ============================================================
   Modals
   ============================================================ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px);
  z-index: 9999;
  justify-content: center;
  align-items: flex-end;
  padding: 0;
}

/* Mobile: bottom sheet style */
.modal-content {
  background: var(--surface);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow:
    0 2px 0 rgba(255,255,255,0.05) inset,
    0 -4px 40px rgba(0,0,0,0.50);
}

/* Bottom sheet drag handle */
.modal-content::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background: var(--muted-2);
  border-radius: 2px;
  margin: 10px auto 0;
  opacity: 0.5;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.modal-header h2 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin: 0;
}
.modal-body { padding: 20px 20px 28px; }

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3) !important;
  border: none !important;
  color: var(--muted-2) !important;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 6px 12px !important;
  margin: 0 !important;
  width: auto !important;
  min-height: 36px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: color 0.15s;
}
.modal-close:hover {
  color: var(--text) !important;
  background: var(--surface-3) !important;
  transform: none !important;
}

/* Monogram */
.monogram-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
}
.monogram-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  background: linear-gradient(145deg, var(--orange) 0%, var(--orange-dark) 100%);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  border-radius: 14px;
  letter-spacing: -0.5px;
  flex-shrink: 0;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.2) inset,
    0 4px 14px var(--orange-glow);
}
.range-preview {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-top: 8px;
  box-shadow: var(--shadow-input);
}

/* Empty state */
.empty-state {
  padding: 28px;
  text-align: center;
  color: var(--muted-2);
  font-size: 13px;
}
.empty-state .icon { display: none; }

/* ============================================================
   Login
   ============================================================ */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  background: var(--bg);
  max-width: 100% !important;
  margin: 0 !important;
  padding: 16px !important;
  /* Subtle radial glow behind card */
  background-image: radial-gradient(
    ellipse 600px 400px at 50% 40%,
    rgba(238,118,35,0.06) 0%,
    transparent 70%
  );
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 28px;
  overflow: hidden;
  box-shadow:
    0 2px 0 rgba(255,255,255,0.06) inset,
    0 -1px 0 rgba(0,0,0,0.15) inset,
    0 30px 70px rgba(0,0,0,0.50),
    0 8px 20px rgba(0,0,0,0.30);
}

/* Brand area — logo + VPN */
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 24px 24px;
}
.login-logo {
  height: 28px;
  width: auto;
  display: block;
}
[data-theme="light"] .login-logo {
  filter: brightness(0);
}
.login-vpn {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--orange);
  letter-spacing: -0.02em;
  line-height: 1;
}

/* Divider line */
.login-divider {
  height: 1px;
  margin: 0 28px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.06) 30%,
    rgba(238,118,35,0.15) 50%,
    rgba(255,255,255,0.06) 70%,
    transparent 100%
  );
}
[data-theme="light"] .login-divider {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0,0,0,0.06) 30%,
    rgba(238,118,35,0.20) 50%,
    rgba(0,0,0,0.06) 70%,
    transparent 100%
  );
}

/* Lock icon */
.login-lock {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  background: var(--orange-soft);
  border-radius: 16px;
  color: var(--orange);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.08) inset,
    0 4px 12px rgba(238,118,35,0.15);
}
.login-lock svg { width: 22px; height: 22px; }

.login-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  text-align: center;
  margin-bottom: 18px;
}

.login-body {
  padding: 24px 28px 20px;
}

/* Input with icon */
.login-input-wrap {
  position: relative;
}
.login-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted-2);
  pointer-events: none;
  margin-top: 5px;
}
.login-input-wrap input {
  padding-left: 40px;
}

.login-error {
  margin-top: 12px;
  font-size: 12px;
  color: var(--danger);
  padding: 10px 14px;
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
  text-align: center;
}

/* Footer hint */
.login-footer {
  padding: 12px 28px 18px;
  text-align: center;
  font-size: 10px;
  color: var(--muted-2);
  letter-spacing: 0.03em;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  padding: 20px 16px;
  text-align: center;
  color: var(--muted-2);
  font-size: 11px;
  letter-spacing: 0.02em;
  margin-top: 8px;
}
.footer strong { color: var(--orange); font-weight: 600; }

/* ============================================================
   Icon library (Lucide) helpers
   ============================================================ */
.btn-icon svg, .btn-edit svg { width: 14px; height: 14px; pointer-events: none; }
.theme-toggle svg { width: 16px; height: 16px; }
.group-section-name { color: var(--text); font-weight: 600; }
.download-link { color: var(--orange); font-weight: 600; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }

/* ============================================================
   VPN IP link
   ============================================================ */
.vpn-ip-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--orange);
  text-decoration: none;
  border-bottom: 1px dashed rgba(238,118,35,0.4);
  transition: color 0.15s, border-color 0.15s;
}
.vpn-ip-link:hover {
  color: var(--text);
  border-color: var(--text);
}
.vpn-ip-dynamic {
  color: var(--muted-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ============================================================
   ▲ BREAKPOINT: sm (640px+) — larger phones / small tablets
   ============================================================ */
@media (min-width: 640px) {
  .topbar {
    padding: 0 24px;
    height: 56px;
    border-radius: 0 0 16px 16px;
  }
  .brand-logo { font-size: 18px; }

  .page { padding: 20px 20px 32px; }

  .stats-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: visible;
  }
  .stat-card {
    flex: 1 1 0;
    min-width: 0;
    padding: 16px 22px;
  }
  .stat-num { font-size: 32px; }

  /* Tables: restore traditional layout */
  thead { display: table-header-group; }
  tbody tr {
    display: table-row;
  }
  td {
    display: table-cell;
    padding: 11px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
  }
  td[data-label]::before { display: none; }
  td.td-name,
  td.td-group,
  td.td-vpn-ip,
  td.td-real-ip,
  td.td-since,
  td.td-traffic { flex: unset; }
  thead tr {
    display: table-row;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  th {
    padding: 10px 18px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--muted-2);
    white-space: nowrap;
  }
  tr:last-child td { border-bottom: none; }

  /* Scrollable table container */
  .table-scroll-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Modals: center dialog instead of bottom sheet */
  .modal {
    align-items: center;
    padding: 16px;
  }
  .modal-content {
    border-radius: var(--radius-card);
    width: 440px;
    max-width: 92vw;
    max-height: 85vh;
  }
  .modal-content::before { display: none; }

  /* Rejected rows in table mode */
  tr.rejected-row {
    border-radius: 0;
    margin-bottom: 0;
  }
}

/* ============================================================
   ▲ BREAKPOINT: md (900px+) — tablets / small desktops
   ============================================================ */
@media (min-width: 900px) {
  .page { padding: 24px 28px 32px; }

  .main-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
  }
  .col-actions { order: 0; }
  .col-data, .col-actions { gap: 18px; }

  .collapsible-header { padding: 16px 20px; }
  .clay-card-header { padding: 16px 20px 14px; }
  .card-body { padding: 18px 20px; }

  .client-row { padding: 10px 18px; }
  .group-header-collapsible { padding: 12px 18px; }

  /* Scroll containment adjusts for desktop */
  .scroll-container {
    --card-scroll-max: 60vh;
  }
}

/* ============================================================
   ▲ BREAKPOINT: lg (1100px+) — desktops
   ============================================================ */
@media (min-width: 1100px) {
  .main-grid {
    grid-template-columns: 1fr 380px;
  }

  .topbar { padding: 0 28px; }
}
