:root {
  --bg: #0a0a0f;
  --bg2: #12121a;
  --bg3: #1a1a24;
  --bg4: #22222e;
  --bg5: #2a2a38;
  --border: rgba(255,255,255,0.06);
  --border2: rgba(255,255,255,0.1);
  --text: #eeeef5;
  --text2: #8888a8;
  --text3: #4a4a65;
  --accent: #7c6fff;
  --accent2: #9d94ff;
  --accent-glow: rgba(124,111,255,0.2);
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.1);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.1);
  --yellow: #f59e0b;
  --yellow-bg: rgba(245,158,11,0.1);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.3);
}

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

html {
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  width: 100%;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── NAVBAR ─────────────────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,10,15,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 0;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.brand-icon {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent2) 0%, #c4b5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar-tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.navbar-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text3);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  letter-spacing: 0.1px;
}
.tab-btn.active { color: var(--accent2); border-bottom-color: var(--accent2); }
.tab-btn:hover:not(.active) { color: var(--text2); }

/* ── MAIN ────────────────────────────────────────────────────────────────── */
.main { padding: 16px; max-width: 600px; margin: 0 auto; padding-bottom: 32px; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── PAGE HEADER ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}
.page-header h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.page-header > div { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.section-header { margin: 20px 0 10px; }
.section-header h2 { font-size: 12px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.8px; }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.btn-icon {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--bg4); color: var(--text); border-color: var(--border2); }

.btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); box-shadow: 0 0 20px var(--accent-glow); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-ghost {
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg4); color: var(--text); border-color: var(--border2); }
.btn-sm { padding: 7px 12px; font-size: 12px; }

/* ── STATS GRID ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  transition: border-color 0.15s;
  min-width: 0;
  overflow: hidden;
}
.stat-card:hover { border-color: var(--border2); }
.stat-icon { font-size: 20px; line-height: 1; }
.stat-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.stat-label {
  font-size: 10px;
  color: var(--text3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ── CARDS LIST ──────────────────────────────────────────────────────────── */
.cards-list { display: flex; flex-direction: column; gap: 8px; }

/* ── RENTAL CARD ─────────────────────────────────────────────────────────── */
.rental-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}
.rental-card:hover { border-color: var(--accent); background: var(--bg3); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.rental-card:active { transform: translateY(0); }
.rental-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  border-radius: 3px 0 0 3px;
}
.rental-card.shaped::before { background: linear-gradient(180deg, var(--red), #ff6b6b); }

.rental-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}
.rental-note { font-size: 15px; font-weight: 600; color: var(--text); }
.rental-no-note { font-size: 15px; font-weight: 600; color: var(--text3); }

.rental-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  flex-shrink: 0;
}
.rental-badge.shaped { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.rental-badge.ok { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }

.rental-domain {
  font-size: 12px;
  color: var(--accent2);
  font-family: 'SF Mono', 'Fira Code', monospace;
  margin-bottom: 8px;
  opacity: 0.8;
}

.rental-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.rental-meta-item {
  font-size: 11px;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.traffic-bar {
  margin-top: 10px;
  height: 3px;
  background: var(--bg5);
  border-radius: 2px;
  overflow: hidden;
}
.traffic-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.5s ease;
}
.traffic-bar-fill.warn { background: linear-gradient(90deg, var(--yellow), #fbbf24); }
.traffic-bar-fill.crit { background: linear-gradient(90deg, var(--red), #f87171); }

.traffic-label {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
}
.traffic-label span { font-size: 10px; color: var(--text3); font-weight: 500; }

/* ── SERVER CARD ─────────────────────────────────────────────────────────── */
.server-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all 0.15s;
}
.server-card:hover { border-color: var(--border2); background: var(--bg3); }

.server-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}
.server-name { font-size: 15px; font-weight: 600; }
.server-ip { font-size: 11px; color: var(--text3); font-family: monospace; margin-top: 2px; }
.server-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.server-stat { font-size: 12px; color: var(--text2); }
.server-stat strong { color: var(--text); font-weight: 600; }

/* ── DOMAIN CARD ─────────────────────────────────────────────────────────── */
.domain-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.domain-name { font-size: 13px; font-family: monospace; color: var(--text); word-break: break-all; }
.domain-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.domain-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
}
.domain-status.free { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.2); }
.domain-status.used { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }

/* ── SEARCH ──────────────────────────────────────────────────────────────── */
.search-box { margin-bottom: 12px; }
.search-box input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box input::placeholder { color: var(--text3); }
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ── FILTER TABS ─────────────────────────────────────────────────────────── */
.filter-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 12px var(--accent-glow); }
.filter-btn:hover:not(.active) { border-color: var(--border2); color: var(--text); }

/* ── MODAL ───────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; }
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-sheet {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--border2);
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  -webkit-overflow-scrolling: touch;
}
.modal-sheet-sm { max-height: 55vh; }

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 32px; height: 4px;
  background: var(--bg5);
  border-radius: 2px;
  margin: 10px auto 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 8px;
  gap: 8px;
}
.modal-header h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }

.modal-body { padding: 8px 20px 12px; }

.modal-actions {
  display: flex;
  gap: 8px;
  padding: 8px 20px 28px;
  flex-wrap: wrap;
}
.modal-actions .btn { flex: 1 1 auto; min-width: 0; }

/* ── MODAL DETAILS ───────────────────────────────────────────────────────── */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.detail-row:last-child { border-bottom: none; }
.detail-key { font-size: 12px; color: var(--text3); font-weight: 500; flex-shrink: 0; }
.detail-val {
  font-size: 12px;
  color: var(--text);
  font-family: 'SF Mono', monospace;
  text-align: right;
  word-break: break-all;
  max-width: 65%;
}

.modal-traffic {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.modal-traffic-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
  flex-wrap: wrap;
}
.modal-traffic-header span { font-size: 12px; color: var(--text3); font-weight: 500; }
.modal-traffic-header strong { font-size: 13px; color: var(--text); }

/* ── MODAL INPUT ─────────────────────────────────────────────────────────── */
.modal-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-hint { font-size: 12px; color: var(--text3); line-height: 1.4; }

/* ── FORMS ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.form-group input,
.form-group select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-group input::placeholder { color: var(--text3); }
.form-group select option { background: var(--bg3); color: var(--text); }

/* ── SERVER SYS STATS ────────────────────────────────────────────────────── */
.server-sys-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.sys-stat {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}
.sys-stat-label { font-size: 10px; color: var(--text3); margin-bottom: 5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.sys-stat-value { font-size: 17px; font-weight: 700; line-height: 1; }
.sys-stat-sub { font-size: 10px; color: var(--text3); margin-top: 3px; }

.sys-bar {
  height: 3px;
  background: var(--bg5);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.sys-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.5s ease;
}
.sys-bar-fill.warn { background: var(--yellow); }
.sys-bar-fill.crit { background: var(--red); }

/* ── SERVER RENTALS ──────────────────────────────────────────────────────── */
.server-rentals-list { margin-top: 4px; }
.server-rental-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.server-rental-item:hover { background: var(--bg4); border-color: var(--border2); }
.server-rental-name { font-size: 13px; font-weight: 600; }
.server-rental-meta { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── TOAST ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg4);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  z-index: 300;
  white-space: nowrap;
  animation: toastIn 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.hidden { display: none; }
.toast.success { background: rgba(34,197,94,0.15); border-color: rgba(34,197,94,0.3); color: var(--green); }
.toast.error { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.3); color: var(--red); }

@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(12px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ── EMPTY STATE ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text3);
  font-size: 14px;
}
.empty-state-icon { font-size: 36px; margin-bottom: 14px; opacity: 0.6; }

/* ── LOADING ─────────────────────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 36px;
  color: var(--text3);
  font-size: 13px;
}
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--bg5);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── EXPIRES ─────────────────────────────────────────────────────────────── */
.expires-soon { color: var(--yellow); font-weight: 600; }
.expires-today { color: var(--red); font-weight: 600; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 380px) {
  .stat-value { font-size: 18px; }
  .modal-actions { gap: 6px; }
  .modal-actions .btn { padding: 9px 8px; font-size: 11px; }
  .server-sys-stats { gap: 6px; }
  .rental-meta { gap: 6px; }
}

@media (max-width: 320px) {
  .main { padding: 10px; }
  .navbar { padding: 10px 10px 0; }
  .modal-header { padding: 12px 14px 6px; }
  .modal-body { padding: 6px 14px 10px; }
  .modal-actions { padding: 6px 14px 24px; gap: 5px; }
  .modal-actions .btn { font-size: 11px; padding: 8px 6px; }
  .stats-grid { gap: 6px; }
  .stat-card { padding: 10px; }
}
