:root {
  --bg: #0f0f12;
  --bg-card: #18181c;
  --bg-hover: #222228;
  --border: #2a2a32;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #eab308;
  --info: #0ea5e9;
  --radius: 12px;
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

#app {
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Layout */
.layout {
  display: flex;
  min-height: 100vh;
}
.layout-sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
}
.layout-main {
  flex: 1;
  overflow: auto;
  padding: 1.5rem;
}

@media (max-width: 768px) {
  .layout {
    flex-direction: column;
  }
  .layout-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
  }
  .layout-main {
    padding: 1rem;
  }
}

/* Nav */
.nav-brand {
  padding: 0 1rem 1rem;
  font-weight: 700;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}
.nav-brand a {
  color: var(--text);
  text-decoration: none;
}
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-list a {
  display: block;
  padding: 0.6rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius);
  margin: 0 0.5rem;
}
.nav-list a:hover,
.nav-list a.active {
  color: var(--text);
  background: var(--bg-hover);
}
.nav-list a.active {
  color: var(--primary);
}

.nav-user {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid var(--border);
}
.nav-user .name {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.nav-user .balance {
  font-size: 0.8rem;
  color: var(--primary);
  margin-bottom: 0.35rem;
}
.nav-user .btn {
  width: 100%;
  justify-content: center;
}

/* Page */
.page {
  max-width: 1200px;
  margin: 0 auto;
}
.page h1 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
  font-weight: 600;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card h2 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--text-muted);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: var(--font);
  font-size: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-error {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.login-card h1 {
  text-align: center;
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tabs button {
  padding: 0.6rem 1rem;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs button:hover {
  color: var(--text);
}
.tabs button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Table — cloud dashboard best practice */
.table-wrap {
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  line-height: 1.5;
}
.table-wrap th,
.table-wrap td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table-wrap thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-hover);
}
.table-wrap th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}
.table-wrap tbody tr {
  transition: background 0.15s ease;
}
.table-wrap tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}
.table-wrap tbody tr:hover td {
  background: var(--bg-hover);
}
.table-wrap tbody tr:last-child td {
  border-bottom: none;
}
.table-wrap tbody td {
  color: var(--text);
}
.table-wrap .empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.table-wrap code {
  font-family: ui-monospace, 'Cascadia Code', 'SF Mono', monospace;
  font-size: 0.85em;
}
/* VPS actions: nhóm nút có màu phân biệt */
.vps-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.vps-action-group {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding-right: 0.5rem;
  border-right: 1px solid var(--border);
}
.vps-action-group:last-of-type {
  padding-right: 0;
  border-right: none;
}
.vps-actions .btn,
.vps-actions a.btn {
  white-space: nowrap;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  text-decoration: none;
}
/* Sync / cập nhật trạng thái — info */
.btn-vps-sync {
  background: rgba(14, 165, 233, 0.15);
  color: var(--info);
  border: 1px solid rgba(14, 165, 233, 0.4);
}
.btn-vps-sync:hover {
  background: rgba(14, 165, 233, 0.25);
  color: #38bdf8;
}
/* Power: Bật — success */
.btn-vps-start {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.5);
}
.btn-vps-start:hover {
  background: rgba(34, 197, 94, 0.35);
  color: #4ade80;
}
/* Power: Tắt — danger */
.btn-vps-stop {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.5);
}
.btn-vps-stop:hover {
  background: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}
/* Power: Restart — warning */
.btn-vps-restart {
  background: rgba(234, 179, 8, 0.2);
  color: var(--warning);
  border: 1px solid rgba(234, 179, 8, 0.5);
}
.btn-vps-restart:hover {
  background: rgba(234, 179, 8, 0.35);
  color: #facc15;
}
/* Rebuild — warning outline (thao tác cẩn trọng) */
.btn-vps-rebuild {
  background: rgba(234, 179, 8, 0.12);
  color: var(--warning);
  border: 1px solid rgba(234, 179, 8, 0.4);
}
.btn-vps-rebuild:hover {
  background: rgba(234, 179, 8, 0.22);
  color: #facc15;
}
/* Gia hạn — primary CTA */
.btn-vps-renew {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
}
.btn-vps-renew:hover {
  background: var(--primary-hover);
  color: #fff;
  border-color: var(--primary-hover);
}
/* Chi tiết — ghost/secondary */
.btn-vps-detail {
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-vps-detail:hover {
  background: var(--border);
  color: var(--text);
}
.vps-actions .btn:disabled {
  opacity: 0.5;
}
.vps-user-pass {
  font-size: 0.85em;
}
.vps-user-pass .vps-copy-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}
.vps-user-pass .vps-copy-row:last-child {
  margin-bottom: 0;
}
.vps-user-pass code {
  flex: 1;
  min-width: 0;
  word-break: break-all;
  background: var(--bg);
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
}
.btn-copy {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-copy:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-copy svg {
  width: 0.9rem;
  height: 0.9rem;
}
@media (max-width: 900px) {
  .vps-action-group {
    padding-right: 0.35rem;
  }
  .vps-actions .btn,
  .vps-actions a.btn {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
  }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0.2s, opacity 0.2s;
}
.modal.is-open {
  visibility: visible;
  opacity: 1;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  cursor: pointer;
}
.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}
.modal-close {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
}
.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.modal-body {
  padding: 1.25rem;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}
.renew-options {
  margin: 0.75rem 0;
}
.renew-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  cursor: pointer;
  font-size: 0.9rem;
}
.renew-option input {
  margin: 0;
}
.renew-option span {
  flex: 1;
}

/* Grid */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.stat-card .value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary);
}
.stat-card .label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Alert */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}
.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  color: #fca5a5;
}
.alert-success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid var(--success);
  color: #86efac;
}

/* Loading */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}
.loading::after {
  content: '';
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-left: 0.5rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Text muted */
.text-muted {
  color: var(--text-muted);
}

/* Empty */
.empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

/* Detail dl */
.detail-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1.5rem;
  margin: 0;
  font-size: 0.9rem;
}
.detail-dl dt {
  color: var(--text-muted);
  font-weight: 500;
}
.detail-dl dd {
  margin: 0;
}
.detail-dl code {
  background: var(--bg);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
}
.password-mask.reveal { font-family: monospace; }

/* Badge */
.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
}
.badge-success { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge-warn { background: rgba(234, 179, 8, 0.2); color: #eab308; }
.badge-muted { background: var(--bg-hover); color: var(--text-muted); }

/* Toast notification */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 2rem));
}
.toast {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast--visible {
  opacity: 1;
  transform: translateX(0);
}
.toast--success {
  background: var(--success);
  color: #fff;
  border: 1px solid rgba(34, 197, 94, 0.5);
}
.toast--error {
  background: var(--danger);
  color: #fff;
  border: 1px solid rgba(239, 68, 68, 0.5);
}

/* Pagination info */
.pagination-info {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Catalog list */
.catalog-list { list-style: none; margin: 0; padding: 0; }
.catalog-list > li { margin-bottom: 0.75rem; }
.catalog-list > li > ul { margin: 0.25rem 0 0 1rem; padding-left: 0; color: var(--text-muted); font-size: 0.9rem; }
.actions-card { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.product-card { background: var(--bg); border-radius: 8px; padding: 1rem; border: 1px solid var(--border); }
.product-card h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.product-spec { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 0.5rem; }
.price-list { list-style: none; margin: 0 0 0.75rem; padding: 0; font-size: 0.875rem; }
.price-list li { padding: 0.2rem 0; }
.bank-list { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.bank-list li { padding: 0.35rem 0; }
.form-hint { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; }
.topup-detail { margin: 0.75rem 0; }
.topup-qr { margin-top: 0.5rem; }
.topup-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; align-items: center; }
.profile-avatar { margin-bottom: 0.75rem; }
.profile-avatar img { border-radius: 50%; object-fit: cover; }
