* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --tm-bg: #f0f2f5;
  --tm-card: #ffffff;
  --tm-text: #1a1d21;
  --tm-muted: #6b7280;
  --tm-border: #e8eaed;
  --tm-primary: #0f4c9a;
  --tm-primary-dark: #0a3d7a;
  --tm-error: #dc2626;
  --tm-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  --tm-safe-bottom: env(safe-area-inset-bottom, 0px);
  --tm-header-h: 72px;
  --tm-nav-h: 52px;
  --tm-tile-accent: #1e40af;
  --tm-tile-icon-bg: #e2e8f0;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --tm-bg: #111827;
  --tm-card: #1f2937;
  --tm-text: #f9fafb;
  --tm-muted: #9ca3af;
  --tm-border: #374151;
  --tm-primary: #3b82f6;
  --tm-primary-dark: #2563eb;
  --tm-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--tm-bg);
  color: var(--tm-text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  font-size: 16px;
  line-height: 1.4;
}

.tm-page {
  min-height: 100dvh;
  padding-bottom: calc(var(--tm-nav-h) + var(--tm-safe-bottom) + 16px);
}

/* —— Login —— */
.tm-login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px;
  background: var(--tm-bg);
}

.tm-login-card {
  width: min(400px, 100%);
  background: var(--tm-card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--tm-shadow);
}

.tm-login-logo {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  object-fit: contain;
}

.tm-login-card h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 700;
}

.tm-login-card .tm-subtitle {
  margin: 0 0 20px;
  color: var(--tm-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.tm-eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--tm-primary);
}

.tm-primary-btn {
  width: 100%;
  background: var(--tm-primary);
  color: #fff;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  min-height: 48px;
}

.tm-primary-btn:active {
  background: var(--tm-primary-dark);
}

/* —— Header (banking) —— */
.tm-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--tm-primary);
  color: #fff;
}

.tm-header-inner {
  padding: 12px 16px 16px;
  max-width: 560px;
  margin: 0 auto;
}

.tm-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.tm-header-prefs {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: #fff;
  text-decoration: none;
  font-size: 1.25rem;
  background: rgba(255, 255, 255, 0.15);
}

.tm-header-prefs:active {
  background: rgba(255, 255, 255, 0.28);
}

.tm-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
  flex: 1;
}

.tm-brand-mark,
.tm-brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  object-fit: contain;
}

.tm-brand-mark {
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.tm-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tm-greeting {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
}

.tm-meta {
  font-size: 0.8rem;
  opacity: 0.85;
}

.tm-signout-link {
  flex-shrink: 0;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.tm-signout-link:active {
  background: rgba(255, 255, 255, 0.25);
}

/* —— Main —— */
.tm-main {
  padding: 16px;
  max-width: 560px;
  margin: 0 auto;
}

.tm-section-title {
  margin: 0 0 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--tm-muted);
}

/* —— Menu tiles (BRImo / Livin' style) —— */
.tm-menu-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tm-menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--tm-card);
  border-radius: 14px;
  box-shadow: var(--tm-shadow);
  text-decoration: none;
  color: inherit;
  min-height: 72px;
  transition: transform 0.12s ease;
}

.tm-menu-item:active {
  transform: scale(0.98);
}

.tm-menu-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--tm-tile-icon-bg);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.tm-menu-icon-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.tm-menu-icon-fallback {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--tm-tile-accent);
}

.tm-menu-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tm-menu-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--tm-text);
}

.tm-menu-stat {
  font-size: 0.82rem;
  color: var(--tm-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tm-menu-chevron {
  flex-shrink: 0;
  font-size: 1.35rem;
  font-weight: 300;
  color: #c4c9d0;
  line-height: 1;
}

/* —— Product detail —— */
.tm-page--detail .tm-header {
  background: var(--tm-primary);
}

.tm-detail-hero {
  background: var(--tm-primary);
  color: #fff;
  padding: 0 16px 20px;
  max-width: 560px;
  margin: 0 auto;
}

.tm-back {
  display: inline-block;
  color: rgba(255, 255, 255, 0.95);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 14px;
}

.tm-detail-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tm-detail-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--tm-tile-icon-bg, rgba(255, 255, 255, 0.2));
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.tm-detail-icon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.tm-detail-icon-fallback {
  font-weight: 700;
  color: var(--tm-tile-accent, #fff);
}

.tm-detail-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.tm-detail-sub {
  margin: 4px 0 0;
  font-size: 0.85rem;
  opacity: 0.88;
}

.tm-panel {
  background: var(--tm-card);
  border-radius: 14px;
  padding: 4px 0;
  margin-bottom: 12px;
  box-shadow: var(--tm-shadow);
  overflow: hidden;
}

.tm-panel--flat .tm-section-title {
  padding: 14px 16px 0;
}

.tm-stat-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tm-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--tm-border);
}

.tm-stat-row:last-child {
  border-bottom: none;
}

.tm-stat-label {
  font-size: 0.9rem;
  color: var(--tm-muted);
}

.tm-stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--tm-text);
  text-align: right;
}

.tm-refresh-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 12px 16px 16px;
  padding: 12px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--tm-primary);
  background: transparent;
  border: 1px solid var(--tm-border);
  border-radius: 10px;
  cursor: pointer;
}

.tm-refresh-btn:active {
  background: var(--tm-bg);
}

.tm-detail-loading {
  padding: 16px;
}

/* —— Bottom nav —— */
.tm-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  background: var(--tm-card);
  border-top: 1px solid var(--tm-border);
  padding-bottom: var(--tm-safe-bottom);
  min-height: calc(var(--tm-nav-h) + var(--tm-safe-bottom));
  box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.04);
}

.tm-nav-item {
  flex: 1;
  max-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  text-decoration: none;
  color: var(--tm-muted);
  font-size: 0.7rem;
  font-weight: 500;
}

.tm-nav-item.active {
  color: var(--tm-primary);
  font-weight: 700;
}

.tm-nav-icon {
  font-size: 1.15rem;
}

.tm-bottom-nav--single .tm-nav-item {
  max-width: 140px;
}

/* —— Misc —— */
.tm-muted {
  color: var(--tm-muted);
}

.tm-error {
  color: var(--tm-error);
  margin: 0;
  padding: 16px;
}

.tm-empty {
  text-align: center;
  color: var(--tm-muted);
  padding: 32px 16px;
  font-size: 0.9rem;
}

.tm-msg {
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--tm-muted);
  min-height: 1.2em;
}

.tm-phone-hint {
  margin-top: 14px;
  padding: 12px;
  font-size: 0.85rem;
  line-height: 1.45;
  background: var(--tm-bg);
  border-radius: 10px;
  color: var(--tm-text);
}

.tm-phone-hint a {
  color: var(--tm-primary);
  word-break: break-all;
}

.tm-pref-card {
  background: var(--tm-card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--tm-shadow);
}

.tm-pref-heading {
  margin: 0 0 8px;
  font-size: 1rem;
}

.tm-pref-hint {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--tm-muted);
  line-height: 1.45;
}

.tm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

.tm-select,
.tm-btn {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--tm-border);
  padding: 12px 14px;
  background: var(--tm-card);
  color: var(--tm-text);
  min-height: 48px;
}

.tm-btn {
  width: 100%;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.tm-btn-primary {
  background: var(--tm-primary);
  color: #fff;
}

.tm-btn-primary:disabled {
  opacity: 0.55;
}

.tm-btn-primary:active:not(:disabled) {
  background: var(--tm-primary-dark);
}

.tm-link {
  color: var(--tm-primary);
}
