:root {
  --gold: #d4af37;
  --gold-dark: #b8962e;
  --bg: #f7f7f9;
  --text: #222;
  --muted: #666;
  --border: #e2e2e8;
  --danger: #c0392b;
  --success: #1a7f37;
  --info: #1d5fd4;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Thai", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--gold-dark);
  text-decoration: none;
}

/* ---- App header / nav (ported from App.vue's scoped styles) ---- */
.app-header {
  background: var(--gold);
  color: #fff;
  padding: 0.7rem 1.5rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.brand {
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
}
.header-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}
.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.nav a {
  color: #fff;
  font-weight: 500;
}
.nav a.active {
  text-decoration: underline;
}
.user-label {
  font-size: 0.9rem;
  opacity: 0.9;
}
.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }
  .header-row {
    width: 100%;
    justify-content: space-between;
  }
  .menu-toggle {
    display: block;
  }
  .nav {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    gap: 0.75rem;
  }
  .nav.open {
    display: flex;
    margin-top: 0.5rem;
  }
  .app-main {
    padding: 1rem;
  }
}

/* ---- Toasts (ported from ToastContainer.vue) ---- */
.toast-container {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.toast {
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  min-width: 200px;
  max-width: 320px;
  text-align: center;
  animation: toast-in 0.2s ease-out;
}
.toast-success {
  background: #4caf50;
}
.toast-error {
  background: var(--danger);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Reusable components ---- */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* การ์ดกว้างเต็มความกว้างหน้าจอ (แบบเดียวกับหน้าจัดการผู้ใช้) — ใช้กับหน้าหลักของแอป
   ไม่ใช้กับหน้า auth (login/register/...) ที่ต้องการการ์ดแคบตรงกลางจอ */
.card-wide {
  width: 1400px;
  max-width: calc(100vw - 3rem);
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}

.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-weight: 600;
  font-size: 0.9rem;
}

input,
select {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
}

input:focus,
select:focus {
  outline: 2px solid var(--gold);
  border-color: var(--gold);
}

.btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 6px;
  background: var(--gold);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn:hover {
  background: var(--gold-dark);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* An <a class="btn"> used as a pagination link has no native disabled state. */
.btn-disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-secondary {
  background: #eee;
  color: var(--text);
}
.btn-secondary:hover {
  background: #ddd;
}

.btn-danger {
  background: var(--danger);
}
.btn-danger:hover {
  background: #a5281b;
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
}

.btn-role {
  min-width: 6.5rem;
  text-align: center;
}

.btn-status-toggle {
  min-width: 4.5rem;
  white-space: nowrap;
  text-align: center;
}

.alert {
  padding: 0.7rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.alert-error {
  background: #fdecea;
  color: var(--danger);
}
.alert-success {
  background: #e6f4ea;
  color: var(--success);
}

table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
th {
  background: #faf8f0;
  font-size: 0.85rem;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-admin {
  background: var(--gold);
  color: #fff;
}
.badge-user {
  background: #eee;
  color: var(--muted);
}

.auth-wrap {
  max-width: 400px;
  margin: 2rem auto;
}
.muted {
  color: var(--muted);
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  z-index: 100;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal {
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.modal-header h3 {
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
}
.modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 1.2rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.card-header h2 {
  margin: 0;
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.checkbox-row input {
  width: auto;
}

/* ---- Dashboard (ported from DashboardView.vue's scoped styles) ---- */
.price-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.price-tile {
  flex: 1 1 180px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #faf8f0;
}
.price-value {
  font-size: 1.4rem;
}
.profit-up {
  color: var(--success);
}
.profit-down {
  color: var(--danger);
}
.range-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.range-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--muted);
}
.range-stats strong {
  color: inherit;
  font-size: 1rem;
  margin-left: 0.3rem;
}
.stat-label--min {
  color: var(--danger);
}
.stat-label--max {
  color: var(--success);
}
.stat-label--avg {
  color: var(--info);
}
.chart-wrap {
  height: 320px;
}

/* ---- Settings (ported from SettingsView.vue's scoped styles) ---- */
.settings-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.settings-row .form-group {
  flex: 1 1 160px;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

/* ---- Mobile (จอแคบ) ---- */
@media (max-width: 640px) {
  .card,
  .card-wide {
    padding: 1rem;
  }
  .modal-backdrop {
    padding: 0.75rem;
  }
  .modal {
    padding: 1rem;
  }
  th,
  td {
    padding: 0.45rem 0.5rem;
  }
  .hide-mobile {
    display: none;
  }
  .price-tile {
    flex-basis: 100%;
  }
  .chart-wrap {
    height: 240px;
  }
}
