/* Giao diện chung — nền trắng, nút xanh. Dùng cho toàn bộ trang web mới. */

:root {
  --primary: #1877f2;
  --primary-dark: #166fe5;
  --primary-light: #e7f0ff;
  --bg: #ffffff;
  --bg-soft: #f5f7fb;
  --text: #1c1e21;
  --text-soft: #65676b;
  --border: #dddfe2;
  --danger: #e41e3f;
  --success: #1b7e2d;
  --success-bg: #e3f9e5;
  --danger-bg: #fdecea;
  --info-bg: #e7f0ff;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

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

/* ── Top navigation ─────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 0 1.5rem;
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav .brand {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nav .brand i {
  font-size: 1.4rem;
}
.nav-links {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  margin-left: 0.5rem;
}
.nav-links a {
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  color: var(--text-soft);
  font-weight: 600;
}
.nav-links a:hover {
  background: var(--bg-soft);
  text-decoration: none;
}
.nav-links a.active {
  color: var(--primary);
  background: var(--primary-light);
}
.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.nav-balance {
  background: var(--success-bg);
  color: var(--success);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.9rem;
}
.nav-user {
  font-weight: 600;
  color: var(--text);
}

/* Menu mobile */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text);
  cursor: pointer;
}

/* ── Layout ─────────────────────────────────────────────────── */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem;
}
.container-narrow {
  max-width: 460px;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.2rem;
}
.card h2,
.card h3 {
  margin-top: 0;
}

/* ── Forms ──────────────────────────────────────────────────── */
.field {
  margin-bottom: 1.1rem;
}
.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.45rem;
  font-size: 0.92rem;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.field textarea {
  min-height: 110px;
  resize: vertical;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.3rem;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  font-family: inherit;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
  text-decoration: none;
}
.btn-block {
  width: 100%;
}
.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover {
  background: var(--primary-light);
  text-decoration: none;
}
.btn-ghost {
  background: var(--bg-soft);
  color: var(--text);
}
.btn-ghost:hover {
  background: #e9ebee;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  font-size: 0.92rem;
  margin-bottom: 1rem;
  display: none;
}
.alert.show {
  display: block;
}
.alert-info {
  background: var(--info-bg);
  color: #1456b8;
}
.alert-ok {
  background: var(--success-bg);
  color: var(--success);
}
.alert-err {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ── Tables ─────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.table th,
.table td {
  text-align: left;
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.table th {
  color: var(--text-soft);
  font-weight: 700;
  background: var(--bg-soft);
}
.table tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 700;
}
.badge-on {
  background: var(--success-bg);
  color: var(--success);
}
.badge-off {
  background: var(--danger-bg);
  color: var(--danger);
}

.amount-plus {
  color: var(--success);
  font-weight: 700;
}
.amount-minus {
  color: var(--danger);
  font-weight: 700;
}

/* ── Misc ───────────────────────────────────────────────────── */
.muted {
  color: var(--text-soft);
}
.text-center {
  text-align: center;
}
.mt-1 {
  margin-top: 0.5rem;
}
.mt-2 {
  margin-top: 1rem;
}
.mb-2 {
  margin-bottom: 1rem;
}
.row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.row > * {
  flex: 1;
  min-width: 0;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 3px solid rgba(24, 119, 242, 0.3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Hero (trang chủ) ───────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 4rem 1.5rem 3rem;
  background: linear-gradient(180deg, var(--primary-light), #fff);
}
.hero h1 {
  font-size: 2.6rem;
  margin: 0 0 1rem;
  color: var(--text);
}
.hero h1 .accent {
  color: var(--primary);
}
.hero p {
  font-size: 1.15rem;
  color: var(--text-soft);
  max-width: 560px;
  margin: 0 auto 2rem;
}
.hero .actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
  margin-top: 2rem;
}
.feature {
  text-align: center;
  padding: 1.6rem 1.2rem;
}
.feature i {
  font-size: 2.2rem;
  color: var(--primary);
  margin-bottom: 0.8rem;
}
.feature h3 {
  margin: 0.4rem 0;
}

/* ── Plans (gói thuê) ───────────────────────────────────────── */
.plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.8rem;
}
.plan {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.plan:hover {
  border-color: var(--primary);
}
.plan.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}
.plan .plan-label {
  font-weight: 700;
}
.plan .plan-price {
  color: var(--primary);
  font-weight: 800;
  font-size: 1.1rem;
  margin-top: 0.3rem;
}

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.2rem;
}
.tab {
  flex: 1;
  padding: 0.7rem;
  font-weight: 700;
  text-align: center;
  border: 2px solid var(--primary);
  background: #fff;
  color: var(--primary);
  border-radius: 8px;
  cursor: pointer;
}
.tab.active {
  background: var(--primary);
  color: #fff;
}
.panel {
  display: none;
}
.panel.active {
  display: block;
}

.qr-box {
  text-align: center;
  margin-top: 1.2rem;
}
.qr-box img {
  width: 220px;
  height: 220px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 720px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem;
  }
  .nav-links.open {
    display: flex;
  }
  .nav-toggle {
    display: block;
    order: -1;
  }
  .hero h1 {
    font-size: 2rem;
  }
}

/* ══════════════════════════════════════════════════════════════
   DASHBOARD SHELL — sidebar trái + topbar + nội dung
   ══════════════════════════════════════════════════════════════ */
.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.3rem 1.4rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.sidebar-brand small {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 1px;
}
.sidebar-nav {
  padding: 0.8rem 0.8rem 1.5rem;
  flex: 1;
}
.sidebar-section {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-soft);
  padding: 1rem 0.8rem 0.4rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.8rem;
  border-radius: 9px;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 0.93rem;
  margin-bottom: 0.15rem;
}
.sidebar-link:hover {
  background: var(--bg-soft);
  text-decoration: none;
  color: var(--text);
}
.sidebar-link.active {
  background: var(--primary-light);
  color: var(--primary);
}
.sidebar-link i {
  width: 18px;
  text-align: center;
  font-size: 1rem;
}

/* Nhóm menu gập được */
.sidebar-group > .sidebar-link {
  justify-content: flex-start;
  cursor: pointer;
  width: 100%;
}
.sidebar-group > .sidebar-link .chevron {
  margin-left: auto;
  width: auto;
  font-size: 0.8rem;
  transition: transform 0.2s;
}
.sidebar-group.open > .sidebar-link .chevron {
  transform: rotate(180deg);
}
.sidebar-sub {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
}
.sidebar-group.open .sidebar-sub {
  max-height: 400px;
}
.sidebar-sub .sidebar-link {
  padding-left: 2.6rem;
  font-size: 0.9rem;
}
.sidebar-sub .sidebar-link i {
  font-size: 0.9rem;
}

/* Vùng nội dung bên phải */
.main {
  flex: 1;
  min-width: 0;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.4rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .crumb {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-soft);
}
.topbar .crumb b {
  color: var(--text);
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.topbar .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.content {
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
}

/* Nút mở sidebar trên mobile */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text);
  cursor: pointer;
}

/* Banner chào mừng */
.welcome {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.welcome .w-text {
  flex: 1;
  min-width: 240px;
}
.welcome h1 {
  margin: 0 0 0.3rem;
  font-size: 1.7rem;
}
.welcome p {
  margin: 0;
  color: var(--text-soft);
}

/* Lưới thẻ thống kê */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.2rem;
}
.stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
}
.stat .stat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.stat .stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-soft);
}
.stat .stat-value {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 0.4rem;
}
.stat .stat-action {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
}

/* Lưới tiện ích nhanh */
.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.tile {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 0.8rem;
  text-align: center;
  font-weight: 600;
  color: var(--text);
  background: #fff;
}
.tile:hover {
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}
.tile i {
  display: block;
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

/* Dòng hoạt động gần đây */
.activity {
  display: flex;
  gap: 0.8rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}
.activity:last-child {
  border-bottom: none;
}
.activity i {
  color: var(--primary);
  margin-top: 0.2rem;
}
.activity .a-time {
  font-size: 0.8rem;
  color: var(--text-soft);
}

/* Layout 2 cột cho dashboard (nội dung chính + cột phụ) */
.cols {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.2rem;
  align-items: start;
  margin-top: 1.2rem;
}

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

@media (max-width: 760px) {
  .sidebar {
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: var(--shadow);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-toggle {
    display: block;
  }
}
