:root {
  --tm-brand: #8C1D2C;
  --tm-brand-dark: #6E1622;
  --tm-brand-light: #F8EDEE;
  --tm-wa: #25D366;
  --tm-wa-dark: #1EBE57;
  --tm-wa-light: #E8F8EF;
  --tm-surface: #F4F6F9;
  --tm-raised: #FFFFFF;
  --tm-border: #E6EBF2;
  --tm-border-strong: #CDD4DE;
  --tm-text: #1A2B3C;
  --tm-text-secondary: #5A6B7D;
  --tm-text-muted: #8A96A3;
  --tm-danger: #C0392B;
  --tm-danger-light: #FDECEC;
  --tm-warning: #D4A012;
  --tm-warning-light: #FFF8E6;
  --tm-success: #1A5C32;
  --tm-success-light: #E8F5EC;
  --tm-radius: 10px;
  --tm-radius-sm: 8px;
  --tm-shadow: 0 1px 2px rgba(140, 29, 44, 0.05);
  --tm-sidebar: 220px;
  --tm-header: 52px;
  --tm-tabbar: 64px;
  --tm-safe-top: env(safe-area-inset-top, 0px);
  --tm-safe-bottom: env(safe-area-inset-bottom, 0px);
  --tm-safe-left: env(safe-area-inset-left, 0px);
  --tm-safe-right: env(safe-area-inset-right, 0px);
  --bs-primary: #8C1D2C;
  --bs-primary-rgb: 140, 29, 44;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body.tm-body {
  margin: 0;
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  background:
    radial-gradient(1200px 500px at 10% -10%, #f3d6db 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #e8eef6 0%, transparent 50%),
    var(--tm-surface);
  color: var(--tm-text);
  -webkit-font-smoothing: antialiased;
}

/* Auth */
.tm-auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(1.25rem + var(--tm-safe-top)) 1.25rem calc(1.25rem + var(--tm-safe-bottom));
  background:
    radial-gradient(800px 400px at 0% 0%, rgba(37,211,102,.18), transparent 55%),
    linear-gradient(160deg, var(--tm-brand-light), var(--tm-surface) 45%);
}
.tm-auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--tm-raised);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
  padding: 1.5rem;
  box-shadow: var(--tm-shadow);
}
.tm-auth-brand { display: flex; gap: .85rem; align-items: center; margin-bottom: 1.25rem; }
.tm-auth-brand h1 { margin: 0; font-size: 1.35rem; color: var(--tm-brand); }
.tm-auth-brand p { margin: .15rem 0 0; color: var(--tm-text-secondary); font-size: .9rem; }

.tm-logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(145deg, var(--tm-brand) 55%, var(--tm-wa) 100%);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; letter-spacing: .02em;
}
.tm-logo-sm { width: 34px; height: 34px; border-radius: 9px; font-size: .85rem; }

/* Admin shell */
.tm-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.tm-sidebar {
  width: var(--tm-sidebar);
  background: var(--tm-brand);
  color: #fff;
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
.tm-sidebar-brand {
  display: flex; align-items: center; gap: .65rem;
  padding: .85rem .9rem; border-bottom: 1px solid rgba(255,255,255,.12);
}
.tm-sidebar-brand strong { display: block; font-size: .95rem; }
.tm-sidebar-brand small { opacity: .75; font-size: .75rem; }
.tm-sidebar-collapse {
  margin-left: auto; background: transparent; border: 0; color: #fff;
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
}
.tm-nav { padding: .75rem .55rem; display: flex; flex-direction: column; gap: .25rem; }
.tm-nav-link {
  color: rgba(255,255,255,.88); text-decoration: none;
  padding: .55rem .7rem; border-radius: 8px; font-size: .92rem;
}
.tm-nav-link:hover, .tm-nav-link.active { background: rgba(255,255,255,.14); color: #fff; }
.tm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tm-topbar {
  height: var(--tm-header); background: var(--tm-raised);
  border-bottom: 1px solid var(--tm-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem; position: sticky; top: 0; z-index: 20;
}
.tm-topbar-title { font-weight: 600; }
.tm-topbar-actions { display: flex; align-items: center; gap: .5rem; }
.tm-user { color: var(--tm-text-secondary); font-size: .9rem; }
.tm-content { padding: 1rem; flex: 1; }

body.tm-body-admin.tm-sidebar-collapsed .tm-sidebar { width: 0; overflow: hidden; padding: 0; }

/* Driver app */
.tm-app {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding-bottom: var(--tm-safe-bottom);
  padding-left: var(--tm-safe-left);
  padding-right: var(--tm-safe-right);
}
.tm-app-header {
  position: sticky; top: 0; z-index: 30;
  padding-top: var(--tm-safe-top);
  min-height: calc(var(--tm-header) + var(--tm-safe-top));
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--tm-border);
  display: flex; align-items: center; gap: .45rem;
  padding-left: .65rem; padding-right: .65rem;
  padding-bottom: .35rem;
}
.tm-app-brand {
  display: flex; align-items: center; gap: .45rem;
  text-decoration: none; margin-right: auto; min-width: 0;
}
.tm-app-brand strong {
  color: var(--tm-brand);
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: .95rem;
}
.tm-app-content { padding: .75rem .75rem 1.25rem; flex: 1; }

.tm-phone-row {
  display: flex; align-items: stretch;
  border: 1px solid var(--tm-border-strong);
  border-radius: var(--tm-radius-sm);
  overflow: hidden;
  background: #fff;
}
.tm-phone-prefix {
  display: inline-flex; align-items: center;
  padding: 0 .75rem;
  background: var(--tm-wa-light);
  color: #128C7E;
  font-weight: 700;
  border-right: 1px solid var(--tm-border);
  white-space: nowrap;
}
.tm-phone-input {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.tm-btn-wa {
  background: var(--tm-wa);
  color: #fff;
  border: 0;
}
.tm-btn-wa:active { background: var(--tm-wa-dark); }

.tm-modal {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 1rem;
  padding-bottom: calc(1rem + var(--tm-safe-bottom));
}
.tm-modal[hidden] { display: none !important; }
.tm-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(26, 43, 60, .45);
}
.tm-modal-panel {
  position: relative; z-index: 1;
  width: min(100%, 420px);
  background: #fff;
  border-radius: 16px 16px 12px 12px;
  padding: 1.15rem 1rem 1rem;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.tm-modal-panel h2 { margin: 0 0 .35rem; font-size: 1.1rem; }
.tm-modal-panel p { margin: 0 0 1rem; color: var(--tm-text-secondary); font-size: .9rem; }

.tm-section-title {
  margin: 0 0 .65rem;
  font-size: .95rem;
  font-weight: 700;
}
.tm-compact-card { padding: .85rem .9rem; margin-bottom: .65rem; }
.tm-create-form { display: flex; flex-direction: column; gap: .65rem; }
.tm-create-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  margin-bottom: .35rem;
}
.tm-create-head .tm-section-title { margin: 0; }
.tm-history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .65rem; }
.tm-history-list li {
  padding-bottom: .65rem;
  border-bottom: 1px solid var(--tm-border);
}
.tm-history-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.tm-history-main {
  display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start;
  font-size: .9rem;
}
.tm-history-meta { font-size: .78rem; color: var(--tm-text-muted); margin-top: .2rem; }
.tm-history-raw {
  margin: .35rem 0 0;
  padding: .45rem .55rem;
  background: #f6f7f9;
  border-radius: 6px;
  font-size: .75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.tm-shop-hero { margin-bottom: .85rem; }
.tm-shop-hero h1 { font-size: 1.35rem; margin: .15rem 0 .25rem; }
.tm-shop-hero-compact h1 { font-size: 1.2rem; }
.tm-shop-lead { font-size: .88rem; margin: 0; }

.tm-burger {
  width: 40px; height: 40px; border: 0; background: transparent;
  display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
  padding: 8px; border-radius: 10px; cursor: pointer;
}
.tm-burger span {
  display: block; height: 2px; width: 100%; background: var(--tm-text);
  border-radius: 2px; transition: transform .2s ease, opacity .2s ease;
}
.tm-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.tm-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.tm-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.tm-drawer-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(26, 43, 60, .4);
}
.tm-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 70;
  width: min(86vw, 320px);
  background: #fff;
  box-shadow: 8px 0 32px rgba(26,43,60,.18);
  display: flex; flex-direction: column;
  transform: translateX(-105%);
  transition: transform .22s ease;
}
.tm-drawer.is-open { transform: none; }
.tm-drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: calc(.85rem + var(--tm-safe-top)) 1rem .85rem;
  border-bottom: 1px solid var(--tm-border);
  background: linear-gradient(160deg, var(--tm-brand-light), #fff 70%);
}
.tm-drawer-head strong { display: block; font-size: 1rem; }
.tm-drawer-head small { color: var(--tm-text-secondary); }
.tm-drawer-close {
  border: 0; background: transparent; font-size: 1.5rem; line-height: 1;
  color: var(--tm-text-secondary); cursor: pointer;
}
.tm-drawer-nav { padding: .75rem .65rem; display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.tm-drawer-link {
  text-decoration: none; color: var(--tm-text);
  padding: .75rem .85rem; border-radius: 10px; font-weight: 600;
}
.tm-drawer-link.active, .tm-drawer-link:hover {
  background: var(--tm-brand-light); color: var(--tm-brand);
}
.tm-drawer-foot {
  padding: .85rem; border-top: 1px solid var(--tm-border);
  display: flex; flex-direction: column; gap: .45rem;
}

/* Shop / listing */
.tm-shop-hero { margin-bottom: 1rem; }
.tm-shop-hero-compact { margin-bottom: .85rem; }
.tm-shop-kicker {
  margin: 0 0 .35rem; color: var(--tm-brand); font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; font-size: .72rem;
}
.tm-shop-hero h1 {
  margin: 0 0 .4rem;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.55rem, 5vw, 1.9rem);
  line-height: 1.15;
}
.tm-shop-lead { margin: 0; color: var(--tm-text-secondary); max-width: 34ch; }

.tm-product-card {
  background: #fff;
  border: 1px solid var(--tm-border);
  border-radius: 16px;
  padding: 1.15rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 30px rgba(26,43,60,.06);
}
.tm-product-card-active {
  border-color: #efd0d5;
  background: linear-gradient(180deg, #fff 0%, #fcf6f7 100%);
}
.tm-product-badge {
  display: inline-flex; padding: .2rem .55rem; border-radius: 999px;
  background: var(--tm-success-light); color: var(--tm-success);
  font-size: .72rem; font-weight: 700; margin-bottom: .55rem;
}
.tm-product-title {
  margin: 0 0 .9rem;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.25rem;
}
.tm-product-route {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: .55rem;
  align-items: start; margin-bottom: .9rem;
}
.tm-product-label {
  display: block; font-size: .72rem; color: var(--tm-text-muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: .35rem;
}
.tm-product-arrow {
  margin-top: 1.35rem; color: var(--tm-brand); font-weight: 700; font-size: 1.1rem;
}
.tm-chip-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.tm-chip {
  background: var(--tm-brand-light); color: var(--tm-brand);
  border-radius: 999px; padding: .25rem .55rem; font-size: .8rem; font-weight: 600;
}
.tm-product-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: .65rem;
  margin: 0 0 1rem; padding: .75rem 0 0; border-top: 1px solid var(--tm-border);
}
.tm-product-meta dt { font-size: .72rem; color: var(--tm-text-muted); margin: 0; }
.tm-product-meta dd { margin: .15rem 0 0; font-weight: 600; }
.tm-scan-pulse {
  display: flex; align-items: center; gap: .5rem;
  margin: 0 0 1rem; color: var(--tm-text-secondary); font-size: .88rem;
}
.tm-scan-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--tm-brand);
  box-shadow: 0 0 0 0 rgba(140,29,44,.45);
  animation: tm-pulse 1.4s ease-out infinite;
}
@keyframes tm-pulse {
  0% { box-shadow: 0 0 0 0 rgba(140,29,44,.45); }
  70% { box-shadow: 0 0 0 10px rgba(140,29,44,0); }
  100% { box-shadow: 0 0 0 0 rgba(140,29,44,0); }
}

.tm-product-empty {
  text-align: center; padding: 2rem 1.1rem;
  background: #fff; border: 1px dashed var(--tm-border-strong);
  border-radius: 16px;
}
.tm-product-empty-visual {
  width: 56px; height: 56px; margin: 0 auto .75rem;
  border-radius: 16px; background: var(--tm-brand-light); color: var(--tm-brand);
  display: grid; place-items: center; font-size: 1.8rem; font-weight: 700;
}
.tm-product-empty h2 {
  margin: 0 0 .35rem; font-family: "Fraunces", Georgia, serif; font-size: 1.3rem;
}
.tm-product-empty p { color: var(--tm-text-secondary); margin: 0 0 1rem; }

.tm-select-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .45rem;
}
.tm-select-tile {
  display: flex; align-items: center; gap: .45rem;
  min-height: 44px; padding: .45rem .6rem;
  border: 1px solid var(--tm-border-strong); border-radius: 10px;
  background: #fff; cursor: pointer; font-weight: 500;
}
.tm-select-tile:has(input:checked) {
  border-color: var(--tm-brand); background: var(--tm-brand-light); color: var(--tm-brand);
}
.tm-select-tile input { accent-color: var(--tm-brand); }

.tm-match-card {
  border-color: #cfe6d6;
  background: linear-gradient(180deg, #f3faf5 0%, #fff 55%);
}
.tm-match-divider {
  margin: .85rem 0 .65rem;
  padding-top: .65rem;
  border-top: 1px dashed #cfe6d6;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #2f7a4a;
}
.tm-match-line { font-size: 1.05rem; margin: 0 0 .45rem; }
.tm-match-summary {
  display: flex; flex-direction: column; gap: .4rem;
  margin: 0 0 .85rem;
  padding: .65rem .7rem;
  background: rgba(255,255,255,.7);
  border: 1px solid #e3eee6;
  border-radius: 10px;
}
.tm-match-summary-row {
  display: flex; justify-content: space-between; gap: .75rem; align-items: baseline;
  font-size: .92rem;
}
.tm-match-phone-block { margin: 0 0 .85rem; }
.tm-wa-link {
  display: flex; align-items: center; gap: .55rem;
  margin-top: .35rem;
  padding: .7rem .8rem;
  border-radius: 10px;
  background: #e8f7ee;
  border: 1px solid #b7e0c5;
  color: #176b3a;
  text-decoration: none;
  font-weight: 600;
}
.tm-wa-link small { margin-left: auto; font-weight: 500; opacity: .75; }
.tm-wa-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.7rem; height: 1.7rem; border-radius: 999px;
  background: #25D366; color: #fff; font-size: .65rem; font-weight: 700;
}
.tm-match-msg-block { margin: 0 0 .85rem; }
.tm-match-msg-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  margin-bottom: .35rem;
}
.tm-match-raw {
  margin: 0;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .82rem;
  background: #f4f6f9;
  border-radius: 8px;
  padding: .65rem .75rem;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}
.tm-match-actions {
  display: flex; flex-direction: column; gap: .5rem;
  margin-top: .25rem;
}
.tm-field legend {
  font-weight: 600; font-size: .88rem; margin-bottom: .35rem;
}
.tm-field legend small { color: var(--tm-text-muted); font-weight: 500; }

/* Components */
.tm-page-head { margin-bottom: .85rem; }
.tm-page-head h1, .tm-h1 { margin: 0 0 .25rem; font-size: 1.25rem; }
.tm-muted { color: var(--tm-text-secondary); }
.tm-card {
  background: var(--tm-raised);
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius);
  padding: 1rem;
  margin-bottom: .85rem;
  box-shadow: var(--tm-shadow);
}
.tm-card h2 { margin: 0 0 .65rem; font-size: 1.05rem; }
.tm-card-muted { background: var(--tm-brand-light); border-color: #efd5d9; }
.tm-kpi-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; margin-bottom: .85rem;
}
.tm-kpi {
  background: var(--tm-raised); border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-sm); padding: .75rem;
  display: flex; flex-direction: column; gap: .35rem;
}
.tm-kpi-label { color: var(--tm-text-muted); font-size: .78rem; }
.tm-kpi strong { font-size: 1.15rem; }

.tm-pill {
  display: inline-flex; align-items: center;
  padding: .15rem .5rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; width: fit-content;
}
.tm-pill-ok { background: var(--tm-success-light); color: var(--tm-success); }
.tm-pill-warn { background: var(--tm-warning-light); color: #8a6a00; }
.tm-pill-danger { background: var(--tm-danger-light); color: var(--tm-danger); }
.tm-pill-muted { background: #eef1f5; color: var(--tm-text-secondary); }

.tm-form { display: flex; flex-direction: column; gap: .85rem; }
.tm-field { display: flex; flex-direction: column; gap: .3rem; }
.tm-field label { font-weight: 600; font-size: .88rem; }
.tm-input {
  width: 100%; min-height: 44px; padding: .55rem .75rem;
  border: 1px solid var(--tm-border-strong); border-radius: var(--tm-radius-sm);
  background: #fff; font-size: 16px; color: var(--tm-text);
}
.tm-input:focus {
  outline: none; border-color: var(--tm-brand);
  box-shadow: 0 0 0 3px rgba(140, 29, 44, .12);
}
.tm-field-error { color: var(--tm-danger); font-size: .8rem; }
.tm-hint { color: var(--tm-text-muted); font-size: .78rem; }
.tm-check, .tm-check-row {
  display: flex; align-items: center; gap: .55rem; min-height: 44px;
}
.tm-check-list { list-style: none; margin: 0; padding: 0; }
.tm-check-list li { border-bottom: 1px solid var(--tm-border); }
.tm-check-list li:last-child { border-bottom: 0; }

.tm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 44px; padding: .45rem .9rem; border-radius: var(--tm-radius-sm);
  border: 1px solid transparent; font-weight: 600; font-size: .92rem;
  text-decoration: none; cursor: pointer; background: transparent; color: var(--tm-text);
  transition: background-color .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease, opacity .15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tm-btn-sm { min-height: 34px; padding: .25rem .65rem; font-size: .82rem; }
.tm-btn-block { width: 100%; }
.tm-btn-primary { background: var(--tm-brand); color: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.08); }
.tm-btn-primary:hover { background: var(--tm-brand-dark); color: #fff; }
.tm-btn-primary:active { background: #5a121c; transform: translateY(1px); box-shadow: none; }
.tm-btn-danger { background: var(--tm-danger); color: #fff; }
.tm-btn-danger:active { background: #9b2e22; transform: translateY(1px); }
.tm-btn-ghost { border-color: var(--tm-border-strong); background: #fff; }
.tm-btn-ghost:active { background: var(--tm-brand-light); border-color: var(--tm-brand); transform: translateY(1px); }
.tm-btn:disabled,
.tm-btn.is-busy {
  opacity: .55; cursor: not-allowed; pointer-events: none;
  transform: none !important;
}

/* Global loading overlay */
.tm-loading {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(26, 43, 60, .45);
  backdrop-filter: blur(2px);
  padding: 1.25rem;
}
.tm-loading[hidden] { display: none !important; }
.tm-loading-panel {
  width: min(100%, 280px);
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--tm-border);
  box-shadow: 0 12px 40px rgba(26, 43, 60, .22);
  padding: 1.35rem 1.1rem;
  text-align: center;
}
.tm-loading-panel p {
  margin: .85rem 0 0;
  color: var(--tm-text);
  font-weight: 600;
  font-size: .95rem;
}
.tm-spinner {
  width: 36px; height: 36px; margin: 0 auto;
  border: 3px solid var(--tm-brand-light);
  border-top-color: var(--tm-brand);
  border-radius: 50%;
  animation: tm-spin .7s linear infinite;
}
@keyframes tm-spin { to { transform: rotate(360deg); } }
body.tm-is-loading { overflow: hidden; }

.tm-alert {
  padding: .7rem .85rem; border-radius: var(--tm-radius-sm);
  margin-bottom: .75rem; border: 1px solid transparent;
}
.tm-alert-success { background: var(--tm-success-light); color: var(--tm-success); border-color: #c6e4d0; }
.tm-alert-danger { background: var(--tm-danger-light); color: var(--tm-danger); border-color: #f3c4bf; }
.tm-alert-warning { background: var(--tm-warning-light); color: #8a6a00; border-color: #f0e0a8; }

.tm-pairing {
  text-align: center; padding: 1rem .5rem 1.25rem;
  background: var(--tm-brand-light); border-radius: var(--tm-radius-sm); margin-bottom: 1rem;
}
.tm-pairing-code-row {
  display: flex; align-items: center; justify-content: center; gap: .65rem;
  flex-wrap: wrap; margin-bottom: .55rem;
}
.tm-pairing-code {
  font-size: 2rem; font-weight: 700; letter-spacing: .18em;
  color: var(--tm-brand); font-variant-numeric: tabular-nums;
}
.tm-icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: transparent; color: var(--tm-text);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.tm-icon-btn:hover { background: var(--tm-brand-light); color: var(--tm-brand); }
.tm-icon-btn.is-spinning svg { animation: tm-spin .7s linear infinite; }

.tm-groups-panel {
  background: #fff; border: 1px solid var(--tm-border); border-radius: 16px;
  padding: .85rem; box-shadow: 0 8px 24px rgba(26,43,60,.05);
}
.tm-groups-toolbar { display: flex; flex-direction: column; gap: .65rem; margin-bottom: .85rem; }
.tm-groups-toolbar-meta {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.tm-search .tm-input { background: var(--tm-surface); }
.tm-groups-section { margin-bottom: .85rem; }
.tm-groups-section-title {
  margin: 0 0 .45rem; font-size: .78rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: var(--tm-text-muted);
  display: flex; align-items: center; gap: .4rem;
}
.tm-groups-section-title span {
  background: var(--tm-brand-light); color: var(--tm-brand);
  border-radius: 999px; padding: .1rem .45rem; font-size: .72rem;
}
.tm-group-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.tm-group-item { border-radius: 12px; border: 1px solid var(--tm-border); background: #fff; }
.tm-group-row {
  display: flex; align-items: center; gap: .65rem;
  padding: .65rem .7rem; min-height: 56px; cursor: pointer; margin: 0;
}
.tm-group-row input { accent-color: var(--tm-brand); width: 18px; height: 18px; flex-shrink: 0; }
.tm-group-avatar {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: var(--tm-brand-light); color: var(--tm-brand);
  display: grid; place-items: center; font-weight: 700;
}
.tm-group-meta { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.tm-group-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-group-sub { font-size: .75rem; color: var(--tm-text-muted); }
#selectedList .tm-group-item {
  border-color: #efd0d5; background: linear-gradient(180deg, #fcf6f7, #fff);
}

.tm-status-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .85rem;
}
.tm-ok-text { margin-bottom: 1rem; }
.tm-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.tm-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: .75rem; margin-bottom: .85rem; flex-wrap: wrap;
}
.tm-list { list-style: none; margin: 0; padding: 0; }
.tm-list-item {
  display: flex; justify-content: space-between; align-items: center;
  gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--tm-border);
}
.tm-list-item:last-child { border-bottom: 0; }
.tm-table-wrap { overflow: auto; }
.tm-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tm-table th, .tm-table td {
  text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--tm-border);
  white-space: nowrap;
}
.tm-table th {
  color: var(--tm-text-secondary); font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .03em;
}
.tm-actions, .tm-actions-inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

@media (max-width: 991px) {
  .tm-shell { flex-direction: column; }
  .tm-sidebar {
    width: 100%; position: fixed; inset: 0 auto 0 0; z-index: 50;
    transform: translateX(-105%); transition: transform .2s ease;
  }
  body.tm-sidebar-open .tm-sidebar { transform: none; }
  .tm-kpi-grid { grid-template-columns: 1fr; }
  .tm-grid-2 { grid-template-columns: 1fr; }
}

@media (min-width: 992px) {
  body.tm-body-driver .tm-app {
    max-width: 480px; margin: 0 auto;
    border-left: 1px solid var(--tm-border);
    border-right: 1px solid var(--tm-border);
    background: rgba(255,255,255,.35);
    min-height: 100vh;
  }
}

.tm-scan-log-list { display: flex; flex-direction: column; gap: .65rem; padding-bottom: 2rem; }
.tm-scan-log-item {
  background: #fff;
  border: 1px solid var(--tm-border);
  border-radius: var(--tm-radius-sm);
  padding: .75rem .85rem;
}
.tm-scan-log-ok { border-color: rgba(46, 125, 50, .35); }
.tm-scan-log-warn { border-color: rgba(180, 140, 0, .35); }
.tm-scan-log-danger { border-color: rgba(180, 40, 40, .3); }
.tm-scan-log-top {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  margin-bottom: .35rem; font-size: .78rem; color: var(--tm-text-muted);
}
.tm-scan-log-meta { font-size: .82rem; margin-bottom: .35rem; }
.tm-scan-log-body {
  margin: .35rem 0;
  padding: .55rem .65rem;
  background: #f6f7f9;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  color: var(--tm-text);
}
.tm-scan-log-detail {
  margin: .25rem 0 0;
  font-size: .82rem;
  color: var(--tm-text-secondary);
}
