/* ===== TailAdmin design tokens (xem DESIGN.md) — mobile-first ===== */
:root {
  --brand-25: #f2f7ff;
  --brand-50: #ecf3ff;
  --brand-100: #dde9ff;
  --brand-500: #465fff;
  --brand-600: #3641f5;
  --gray-25: #fcfcfd;
  --gray-50: #f9fafb;
  --gray-100: #f2f4f7;
  --gray-200: #e4e7ec;
  --gray-300: #d0d5dd;
  --gray-400: #98a2b3;
  --gray-500: #667085;
  --gray-600: #475467;
  --gray-700: #344054;
  --gray-800: #1d2939;
  --gray-900: #101828;
  --gray-950: #0c111d;
  --success-50: #ecfdf3;
  --success-500: #12b76a;
  --success-600: #039855;
  --error-50: #fef3f2;
  --error-500: #f04438;
  --error-600: #d92d20;
  --warning-50: #fffaeb;
  --warning-500: #f79009;
  --warning-600: #dc6803;

  /* semantic (light) */
  --page-bg: var(--gray-50);
  --card-bg: #fff;
  --card-border: var(--gray-200);
  --text-primary: var(--gray-800);
  --text-secondary: var(--gray-500);
  --input-bg: #fff;
  --input-border: var(--gray-300);
  --hover-bg: var(--gray-50);

  --r-lg: 8px;
  --r-xl: 12px;
  --r-2xl: 16px;
  --r-3xl: 24px;
  --r-full: 9999px;
  --shadow-xs: 0 1px 2px 0 rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(16, 24, 40, 0.1), 0 1px 2px -1px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);
  --ring: 0 0 0 3px rgba(70, 95, 255, 0.12);
}
.dark {
  --page-bg: var(--gray-950);
  --card-bg: var(--gray-900);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-primary: var(--gray-25);
  --text-secondary: var(--gray-400);
  --input-bg: var(--gray-800);
  --input-border: rgba(255, 255, 255, 0.12);
  --hover-bg: rgba(255, 255, 255, 0.04);
  --brand-50: rgba(70, 95, 255, 0.16);
  --success-50: rgba(18, 183, 106, 0.16);
  --error-50: rgba(240, 68, 56, 0.16);
  --warning-50: rgba(247, 144, 9, 0.16);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: 'Outfit', ui-sans-serif, system-ui, sans-serif;
  background: var(--page-bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  padding-bottom: env(safe-area-inset-bottom);
}
h1,
h2 {
  margin: 0;
  font-weight: 600;
}
.muted {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 18px;
  margin: 0;
}

/* ===== Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
}
.app-header__title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header__title h1 {
  font-size: 18px;
  line-height: 24px;
}
.app-header__title .dot {
  width: 10px;
  height: 10px;
  border-radius: var(--r-full);
  background: var(--brand-500);
  box-shadow: 0 0 0 4px var(--brand-50);
  flex: none;
}

/* ===== Content ===== */
.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}
.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== Card lịch ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-2xl);
  padding: 16px;
  box-shadow: var(--shadow-xs);
}
.card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.card__name {
  font-size: 16px;
  font-weight: 600;
  line-height: 22px;
  word-break: break-word;
}
.card__sub {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 2px;
}
.card__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.stat {
  background: var(--page-bg);
  border-radius: var(--r-xl);
  padding: 10px;
  text-align: center;
}
.stat__label {
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.stat__value {
  font-size: 16px;
  font-weight: 600;
  margin-top: 2px;
}
.stat__value.pos {
  color: var(--success-600);
}
.stat__value.neg {
  color: var(--error-600);
}
.card__foot {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--r-full);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge--primary {
  background: var(--brand-50);
  color: var(--brand-500);
}
.badge--success {
  background: var(--success-50);
  color: var(--success-600);
}
.badge--error {
  background: var(--error-50);
  color: var(--error-600);
}
.badge--warning {
  background: var(--warning-50);
  color: var(--warning-600);
}
.badge--muted {
  background: var(--gray-100);
  color: var(--gray-500);
}
.dark .badge--muted {
  background: rgba(255, 255, 255, 0.06);
}

/* ===== Buttons ===== */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  padding: 11px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn:active {
  opacity: 0.85;
}
.btn--primary {
  background: var(--brand-500);
  color: #fff;
}
.btn--secondary {
  background: var(--card-bg);
  border-color: var(--input-border);
  color: var(--text-primary);
}
.btn--danger {
  background: var(--error-500);
  color: #fff;
}
.btn--sm {
  padding: 8px 14px;
  font-size: 13px;
}
.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}
.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn-icon:active {
  background: var(--hover-bg);
}

/* ===== FAB ===== */
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border: none;
  border-radius: var(--r-full);
  background: var(--brand-500);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
}
.fab:active {
  background: var(--brand-600);
}

/* ===== States ===== */
.state {
  text-align: center;
  padding: 48px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.state--sm {
  padding: 20px;
}
.empty__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--r-2xl);
  background: var(--brand-50);
  color: var(--brand-500);
  display: flex;
  align-items: center;
  justify-content: center;
}
.spinner {
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  border: 3px solid var(--gray-200);
  border-top-color: var(--brand-500);
  animation: spin 0.7s linear infinite;
}
.spinner--sm {
  width: 18px;
  height: 18px;
  border-width: 2px;
}
.dark .spinner {
  border-color: rgba(255, 255, 255, 0.12);
  border-top-color: var(--brand-500);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Sheet (form tạo lịch) ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(16, 24, 40, 0.6);
  animation: fade 0.2s ease;
}
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  max-width: 640px;
  margin: 0 auto;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border-radius: var(--r-3xl) var(--r-3xl) 0 0;
  box-shadow: var(--shadow-lg);
  animation: slideup 0.25s ease;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes slideup {
  from {
    transform: translateY(100%);
  }
}
.sheet__handle {
  width: 40px;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--gray-300);
  margin: 10px auto 4px;
  flex: none;
}
.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--card-border);
}
.sheet__head h2 {
  font-size: 16px;
}
.sheet__body {
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
}
.sheet__foot {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--card-border);
}

/* ===== Form fields ===== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}
.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.help {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}
.help.err {
  color: var(--error-600);
}
.input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--r-lg);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}
.input::placeholder {
  color: var(--gray-400);
}
.input:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--ring);
}
.input.invalid {
  border-color: var(--error-500);
}

/* segmented (cửa / run_mode) */
.segmented {
  display: flex;
  background: var(--page-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  padding: 3px;
  gap: 3px;
}
.seg {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 6px;
  padding: 9px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}
.seg.active {
  background: var(--card-bg);
  color: var(--brand-500);
  box-shadow: var(--shadow-xs);
}

/* danh sách account */
.acc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.acc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--card-border);
  border-radius: var(--r-xl);
  background: var(--card-bg);
  cursor: pointer;
}
.acc.on {
  border-color: var(--brand-500);
  background: var(--brand-50);
}
.acc__check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--gray-300);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.acc.on .acc__check {
  background: var(--brand-500);
  border-color: var(--brand-500);
}
.acc__name {
  font-weight: 600;
  flex: 1;
}
.acc__meta {
  font-size: 12px;
  color: var(--text-secondary);
}

/* toggle */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.switch-row__title {
  font-weight: 600;
  display: block;
}
.toggle {
  position: relative;
  flex: none;
}
.toggle input {
  position: absolute;
  opacity: 0;
  width: 44px;
  height: 24px;
  margin: 0;
  cursor: pointer;
}
.toggle__track {
  display: block;
  width: 44px;
  height: 24px;
  border-radius: var(--r-full);
  background: var(--gray-200);
  transition: background 0.15s;
  position: relative;
}
.dark .toggle__track {
  background: rgba(255, 255, 255, 0.14);
}
.toggle__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: var(--r-full);
  background: #fff;
  transition: transform 0.15s;
}
.toggle input:checked + .toggle__track {
  background: var(--brand-500);
}
.toggle input:checked + .toggle__track::after {
  transform: translateX(20px);
}

/* alert */
.alert {
  border-radius: var(--r-lg);
  padding: 12px 14px;
  font-size: 13px;
  border-left: 3px solid;
}
.alert--error {
  background: var(--error-50);
  border-left-color: var(--error-500);
  color: var(--error-600);
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: 92%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  animation: fade 0.2s ease;
}
.toast.ok {
  border-left: 3px solid var(--success-500);
}
.toast.err {
  border-left: 3px solid var(--error-500);
}

/* ===== Home grid (tiles) ===== */
.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text-primary);
}
.tile:active {
  background: var(--hover-bg);
}
.tile__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-xl);
  background: var(--brand-50);
  color: var(--brand-500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.tile__label {
  font-size: 15px;
  font-weight: 600;
}
.tile__sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: -4px;
}

/* ===== Section title ===== */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 18px 2px 8px;
}
.section-title:first-child {
  margin-top: 4px;
}

/* ===== List row ===== */
.rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xs);
}
.row__main {
  flex: 1;
  min-width: 0;
}
.row__title {
  font-weight: 600;
  font-size: 15px;
  word-break: break-word;
}
.row__meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.row__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.led {
  width: 9px;
  height: 9px;
  border-radius: var(--r-full);
  flex: none;
}
.led--on {
  background: var(--success-500);
  box-shadow: 0 0 0 3px var(--success-50);
}
.led--off {
  background: var(--gray-300);
}

/* ===== Jackpot card ===== */
.jp {
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xs);
}
.jp__label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}
.jp__value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 4px;
}
.jp__meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ===== Chips ===== */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}
.chip {
  flex: none;
  padding: 8px 14px;
  border-radius: var(--r-full);
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active {
  background: var(--brand-50);
  border-color: var(--brand-500);
  color: var(--brand-500);
}

/* ===== Key-value (detail) ===== */
.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--card-border);
  font-size: 14px;
}
.kv:last-child {
  border-bottom: none;
}
.kv__k {
  color: var(--text-secondary);
}
.kv__v {
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.btn-row .btn {
  flex: 1;
  min-width: 120px;
}

/* ===== Modal (centered) ===== */
.modal {
  position: fixed;
  left: 16px;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  max-width: 480px;
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: var(--r-3xl);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  animation: fade 0.2s ease;
  max-height: 86vh;
  overflow-y: auto;
}
.modal h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

/* run badges inline */
.mini {
  font-size: 12px;
  color: var(--text-secondary);
}
.pos {
  color: var(--success-600);
}
.neg {
  color: var(--error-600);
}
.textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--r-lg);
  padding: 11px 14px;
  font-family: ui-monospace, monospace;
  font-size: 14px;
  color: var(--text-primary);
  min-height: 110px;
  resize: vertical;
}
.textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--ring);
}
