/* ============================================================
   TailorMan — Design System
   Clean, sharp, professional. Apple-inspired clarity.
   ============================================================ */

/* ── Design tokens ──────────────────────────────────────────── */
:root {
  /* Layout */
  --sidebar-w: 232px;
  --topbar-h:  60px;

  /* Brand blue */
  --blue:      #0071e3;
  --blue-dark: #0063cc;
  --blue-dim:  rgba(0,113,227,0.14);

  /* Surfaces */
  --white:     #ffffff;
  --bg:        #f5f5f7;
  --bg-2:      #ebebf0;

  /* Borders */
  --border:      #d2d2d7;
  --border-soft: #e5e5ea;

  /* Text */
  --text:   #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #aeaeb2;

  /* Sidebar */
  --sb-bg:     #1c1c1e;
  --sb-hover:  rgba(255,255,255,0.07);
  --sb-active: rgba(255,255,255,0.13);
  --sb-text:   rgba(255,255,255,0.85);
  --sb-muted:  rgba(255,255,255,0.36);
  --sb-line:   rgba(255,255,255,0.09);

  /* Shadows */
  --sh-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --sh-md:  0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --sh-lg:  0 8px 32px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.05);
  --sh-xl:  0 24px 64px rgba(0,0,0,0.14), 0 8px 24px rgba(0,0,0,0.08);

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* Safe area insets — notch / home indicator on iOS/Android */
  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Bottom navigation height */
  --bn-h: 60px;
}

/* ── Base ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden; /* prevent any element causing viewport scroll */
}
html, body { font-size: 16px; }
@media (max-width: 640px) { html, body { font-size: 15px; } }

body {
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  overscroll-behavior: none; /* prevent pull-to-refresh / rubber-band bounce */
}
button, a, label, [role="button"] {
  touch-action: manipulation; /* kill 300ms tap delay on older Android */
}

/* ── Shell layout ────────────────────────────────────────────── */
body.has-shell {
  background: var(--bg);
  padding-left: var(--sidebar-w);
  padding-top: calc(var(--topbar-h) + var(--safe-top));
}
@media (max-width: 768px) {
  body.has-shell {
    padding-left: 0;
    /* Space below content for the fixed bottom nav + home indicator */
    padding-bottom: calc(var(--bn-h) + var(--safe-bottom));
  }
}

/* Main content: never overflow sideways */
body.has-shell main { min-width: 0; overflow-x: hidden; }

/* ── Sidebar ─────────────────────────────────────────────────── */
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--sb-bg);
  color: var(--sb-text);
  z-index: 40;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Logo strip */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--safe-top) 14px 0;
  height: calc(var(--topbar-h) + var(--safe-top));
  border-bottom: 1px solid var(--sb-line);
  text-decoration: none;
  flex-shrink: 0;
  user-select: none;
}
.sidebar-logo-badge {
  width: 30px;
  height: 30px;
  background: var(--blue);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.03em;
  flex-shrink: 0;
}
.sidebar-logo-name {
  font-size: 14.5px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.015em;
}

/* Nav scroll area */
.app-sidebar nav {
  flex: 1;
  overflow-y: auto;
  /* Extra bottom padding so the last menu items can scroll up clear of the
     floating "AI Voice Guide" pill, which sits over the sidebar bottom-left. */
  padding: 8px 8px 84px;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.2s;
}
@media (max-width: 768px) {
  /* On mobile the pill floats above the bottom tab bar — clear both. */
  .app-sidebar nav { padding-bottom: calc(var(--bn-h) + var(--safe-bottom) + 110px); }
}
.app-sidebar nav:hover { scrollbar-color: rgba(255,255,255,0.18) transparent; }
.app-sidebar nav::-webkit-scrollbar { width: 5px; }
.app-sidebar nav::-webkit-scrollbar-track { background: transparent; }
.app-sidebar nav::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.app-sidebar nav:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); }
.app-sidebar nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.28); }

/* Nav groups */
.nav-group { padding: 2px 0 8px; }
.nav-group + .nav-group {
  border-top: 1px solid var(--sb-line);
  margin-top: 2px;
  padding-top: 10px;
}
.nav-group-title {
  padding: 2px 10px 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--sb-muted);
}

/* Nav links */
.app-sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7.5px 10px;
  margin: 1px 0;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sb-text);
  text-decoration: none;
  transition: background 0.1s, color 0.08s;
  letter-spacing: -0.01em;
}
.app-sidebar .nav-link:hover  { background: var(--sb-hover); color: #fff; }
.app-sidebar .nav-link.is-active { background: var(--sb-active); color: #fff; font-weight: 600; }
.app-sidebar .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.app-sidebar .nav-link:hover .nav-icon,
.app-sidebar .nav-link.is-active .nav-icon { opacity: 1; }
.app-sidebar .nav-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile sidebar */
@media (max-width: 768px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.is-open { transform: translateX(0); box-shadow: var(--sh-xl); }
}

/* Backdrop */
.app-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  z-index: 35;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.app-sidebar-backdrop.is-open { display: block; }

/* ── Topbar ──────────────────────────────────────────────────── */
.app-topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) 20px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  z-index: 30;
}
@media (max-width: 768px) { .app-topbar { left: 0; } }

/* Hamburger toggle */
.app-nav-toggle { display: none; }
@media (max-width: 768px) {
  .app-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--r-sm);
    color: var(--text);
    flex-shrink: 0;
    transition: background 0.1s;
    min-height: 36px;
  }
  .app-nav-toggle:hover { background: var(--bg-2); }
}

/* Global search */
.app-search {
  position: relative;
  flex: 1;
  max-width: 460px;
}
.app-search input {
  width: 100%;
  height: 36px;
  padding: 0 14px 0 36px;
  border-radius: var(--r-full);
  border: none;
  background: var(--bg-2);
  font-size: 14px;
  color: var(--text);
  transition: background 0.15s, box-shadow 0.15s;
}
.app-search input::placeholder { color: var(--text-3); }
.app-search input:focus {
  outline: none;
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18), var(--sh-sm);
}
.app-search .app-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

/* Search dropdown */
.app-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  max-height: 68vh;
  overflow-y: auto;
  display: none;
  z-index: 50;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.app-search-results::-webkit-scrollbar { width: 5px; }
.app-search-results::-webkit-scrollbar-track { background: transparent; }
.app-search-results::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.app-search-results.is-open { display: block; }
.app-search-results .group-title {
  padding: 10px 14px 4px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-2);
  letter-spacing: 0.07em;
}
.app-search-results .result {
  display: block;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-soft);
  text-decoration: none;
  color: var(--text);
  transition: background 0.08s;
}
.app-search-results .result:last-child { border-bottom: 0; }
.app-search-results .result:hover,
.app-search-results .result.is-focused { background: var(--bg); }
.app-search-results .result .title { font-weight: 600; font-size: 14px; }
.app-search-results .result .sub { font-size: 12.5px; color: var(--text-2); margin-top: 1px; }
.app-search-results .empty {
  padding: 18px 14px;
  text-align: center;
  color: var(--text-2);
  font-size: 13.5px;
}

/* Trial chip — days remaining badge in topbar */
.trial-chip {
  display: none;
  align-items: center;
  padding: 4px 11px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: opacity 0.15s;
}
.trial-chip:hover { opacity: 0.8; }
.trial-chip--ok   { background: #dcfce7; color: #166534; }
.trial-chip--warn { background: #fef9c3; color: #854d0e; }
.trial-chip--grace { background: #fee2e2; color: #b91c1c; }
@media (max-width: 500px) { .trial-chip { display: none !important; } }

/* Topbar right — user */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-left: auto;
}
.topbar-user-info {
  text-align: right;
  line-height: 1.3;
}
.topbar-user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.topbar-user-role {
  font-size: 11.5px;
  color: var(--text-2);
  text-transform: capitalize;
}
.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.topbar-help {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-2);
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.topbar-help:hover {
  background: var(--bg-2);
  color: var(--text);
}
.topbar-signout {
  height: 32px;
  min-height: 32px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  padding: 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.topbar-signout:hover {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

/* ── Form controls (global) ──────────────────────────────────── */
input[type="text"],
input[type="tel"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  font-size: 15px;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.16);
}
input[readonly], input:disabled, textarea:disabled, select:disabled {
  background: var(--bg);
  color: var(--text-2);
  cursor: default;
}

/* Minimum touch target */
button, .btn { min-height: 38px; cursor: pointer; }

/* ── Toast ───────────────────────────────────────────────────── */
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.animate-fade { animation: toast-in 0.22s cubic-bezier(0.2, 0, 0, 1); }

/* ── Sticky action bar ───────────────────────────────────────── */
.sticky-actions {
  position: sticky;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border-soft);
}

/* ── FAB ─────────────────────────────────────────────────────── */
.fab { position: fixed; right: 20px; bottom: 20px; z-index: 30; }
@media (max-width: 768px) {
  .fab { bottom: calc(var(--bn-h) + var(--safe-bottom) + 16px); }
}

/* ── Kanban board ────────────────────────────────────────────── */
.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(256px, 1fr);
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
@media (max-width: 1100px) { .kanban { grid-auto-columns: 268px; } }
.kanban::-webkit-scrollbar { height: 5px; }
.kanban::-webkit-scrollbar-track { background: transparent; }
.kanban::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.kanban-col {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  min-height: 300px;
  max-height: 72vh;
}
.kanban-col-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  position: sticky;
  top: 0;
  z-index: 2;
}
.kanban-col-body {
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.kanban-col-body::-webkit-scrollbar { width: 5px; }
.kanban-col-body::-webkit-scrollbar-track { background: transparent; }
.kanban-col-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.kanban-card {
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-left-width: 3px;
  border-radius: var(--r-md);
  padding: 9px 11px;
  font-size: 13px;
  transition: transform 0.08s, box-shadow 0.08s;
}
.kanban-card:hover { transform: translateY(-1px); box-shadow: var(--sh-md); }
.kanban-card[data-item-id] { cursor: grab; }
.kanban-card[data-item-id]:active { cursor: grabbing; }

/* Drag states */
.kanban-ghost {
  opacity: 0.28;
  background: var(--blue-dim);
  border-color: var(--blue) !important;
  border-style: dashed !important;
}
.kanban-chosen {
  box-shadow: var(--sh-xl);
  transform: rotate(1.5deg) scale(1.03);
  z-index: 10;
}
.kanban-col-body.drag-over {
  background: rgba(0, 113, 227, 0.04);
  outline: 2px dashed rgba(0, 113, 227, 0.35);
  outline-offset: -4px;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.kanban-card a { color: inherit; text-decoration: none; }
.kanban-card-title { font-weight: 700; color: var(--text); font-size: 13.5px; }
.kanban-card-sub { font-size: 11.5px; color: var(--text-2); margin-top: 2px; line-height: 1.45; }
.kanban-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 7px;
  gap: 6px;
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.urg-overdue  { border-left-color: #dc2626; }
.urg-dueToday { border-left-color: #ea580c; }
.urg-urgent   { border-left-color: #d97706; }
.urg-ok       { border-left-color: var(--border-soft); }

/* ── Skeleton loading ────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -800px 0; }
  100% { background-position:  800px 0; }
}
.skeleton-wrap {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.skeleton-line {
  background: linear-gradient(90deg, var(--bg-2) 25%, #e2e2e8 50%, var(--bg-2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--r-sm);
  height: 15px;
}
.skeleton-line.tall   { height: 42px; }
.skeleton-line.short  { width: 55%; }
.skeleton-line.xshort { width: 32%; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 52px 24px;
  text-align: center;
}
.empty-state-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-2);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.empty-state-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 5px;
}
.empty-state-sub {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
  max-width: 280px;
}

/* ── Bill status stepper ─────────────────────────────────────── */
.bill-stepper {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 0;
}
.bill-stepper::-webkit-scrollbar { display: none; }
.bill-stepper-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  min-width: 80px;
}
.bill-stepper-step::after {
  content: "";
  position: absolute;
  top: 11px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border-soft);
  z-index: 0;
}
.bill-stepper-step:last-child::after { display: none; }
.bill-stepper-step.is-done::after { background: var(--blue); }
.bill-stepper-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--white);
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.bill-stepper-step.is-done .bill-stepper-dot {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.bill-stepper-step.is-current .bill-stepper-dot {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim);
}
.bill-stepper-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-align: center;
  white-space: nowrap;
}
.bill-stepper-step.is-done .bill-stepper-label,
.bill-stepper-step.is-current .bill-stepper-label { color: var(--text); }
.bill-stepper-sub {
  font-size: 10px;
  color: var(--text-3);
  text-align: center;
  margin-top: -2px;
  line-height: 1.4;
}

/* ── Toast redesign ──────────────────────────────────────────── */
.toast-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 360px;
  padding: 11px 14px;
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  animation: toast-in 0.22s cubic-bezier(0.2, 0, 0, 1);
}
.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}
.toast-msg {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
}
.toast-dismiss {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  cursor: pointer;
  border-radius: var(--r-xs);
  transition: opacity 0.1s, background 0.1s;
}
.toast-dismiss:hover { opacity: 1; background: rgba(255,255,255,0.15); }

/* ── Stat card (dashboard) ───────────────────────────────────── */
.stat-card {
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--sh-sm);
  transition: box-shadow 0.12s, transform 0.12s;
}
.stat-card:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.stat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-card-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
}
.stat-card-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
}

/* ── Nav badge (low-stock alert dot) ────────────────────────── */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  margin-left: auto;
}

/* ── Print ───────────────────────────────────────────────────── */
#print-bill { display: none; }
@page { size: A4; margin: 12mm 14mm; }
@media print {
  #app-shell, .app-sidebar, .app-topbar, .app-sidebar-backdrop,
  .no-print, #toast-root { display: none !important; }
  body, body.has-shell {
    background: white !important;
    padding-left: 0 !important;
    padding-top: 0 !important;
  }
  body.bill-print main  { display: none !important; }
  body.bill-print #print-bill { display: block !important; }
  body.bill-print #print-bill table { page-break-inside: avoid; }
  body:not(.bill-print) main { max-width: 100% !important; padding: 0 !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tm-help-fab, .tm-help-panel { display: none !important; }
}

/* ── Help tips widget ────────────────────────────────────────── */
.tm-help-fab {
  position: fixed;
  left: 16px;
  bottom: 24px;
  z-index: 45;
  height: 46px;
  padding: 0 16px 0 13px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, #0071e3 0%, #7b3ff2 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  border: none;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s, filter 0.12s;
  animation: tm-fab-pulse 2.6s ease-in-out infinite;
}
.tm-help-fab svg { flex-shrink: 0; }
.tm-fab-label { line-height: 1; }
.tm-help-fab:hover {
  transform: translateY(-1px) scale(1.04);
  filter: brightness(1.07);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}
.tm-help-fab:active { transform: scale(0.97); }
@keyframes tm-fab-pulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18), 0 0 0 0 rgba(123, 63, 242, 0.45); }
  50%      { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18), 0 0 0 10px rgba(123, 63, 242, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .tm-help-fab { animation: none; }
}

.tm-help-panel {
  position: fixed;
  left: 24px;
  bottom: 80px;
  z-index: 45;
  width: 310px;
  max-height: 440px;
  background: var(--white);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  border: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* closed state */
  transform: translateY(12px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.34, 1.4, 0.64, 1),
              opacity 0.16s ease;
  transform-origin: bottom left;
}
.tm-help-panel.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 768px) {
  .tm-help-fab   { bottom: calc(var(--bn-h) + var(--safe-bottom) + 12px); }
  .tm-help-panel { bottom: calc(var(--bn-h) + var(--safe-bottom) + 66px); }
}
@media (max-width: 420px) {
  .tm-help-panel { left: 12px; width: calc(100vw - 24px); }
  .tm-help-fab   { left: 12px; }
}

.tm-help-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 10px 9px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
  flex-shrink: 0;
}
.tm-help-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
  white-space: nowrap;
}
.tm-help-langs {
  display: flex;
  gap: 3px;
  flex: 1;
  flex-wrap: nowrap;
  overflow: hidden;
}
.tm-help-lang {
  padding: 2px 7px;
  border-radius: var(--r-full);
  font-size: 10.5px;
  font-weight: 700;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  white-space: nowrap;
  line-height: 1.6;
}
.tm-help-lang:hover { background: var(--bg-2); color: var(--text); }
.tm-help-lang.is-active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.tm-help-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s;
}
.tm-help-close:hover { background: var(--bg-2); color: var(--text); }

.tm-help-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.tm-help-body::-webkit-scrollbar { width: 4px; }
.tm-help-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.tm-help-loading,
.tm-help-empty {
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
  padding: 24px 4px;
  line-height: 1.6;
}

.tm-help-list {
  margin: 0;
  padding: 0 0 0 18px;
}
.tm-help-list li {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text);
  padding: 7px 0;
  border-bottom: 1px solid var(--border-soft);
}
.tm-help-list li:last-child { border-bottom: none; }
.tm-help-list li strong { font-weight: 700; color: var(--blue); }

/* ── Bottom navigation tab bar ───────────────────────────────── */
.app-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 45;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.06);
  /* Home indicator safe area */
  padding-bottom: var(--safe-bottom);
}
@media (max-width: 768px) { .app-bottom-nav { display: flex; } }

.bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 3px;
  height: var(--bn-h);
  padding: 8px 4px 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
  font-size: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: color 0.15s, transform 0.1s;
}
.bn-item:active { transform: scale(0.86); opacity: 0.7; }
.bn-item.is-active { color: var(--blue); }

.bn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 28px;
  border-radius: 14px;
  font-size: 20px;   /* emoji render size */
  line-height: 1;
  transition: background 0.18s;
}
.bn-item.is-active .bn-icon { background: var(--blue-dim); }
.bn-icon svg { width: 22px; height: 22px; }

.bn-label {
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1;
  letter-spacing: 0.01em;
}

/* ── Sticky action bar offset for bottom nav ─────────────────── */
@media (max-width: 768px) {
  .sticky-actions { bottom: calc(var(--bn-h) + var(--safe-bottom)); }
}

/* ── Prevent iOS auto-zoom on inputs ─────────────────────────── */
@media (max-width: 768px) {
  input, select, textarea { font-size: 16px !important; }
}

/* ── Voice guide ─────────────────────────────────────────────── */
/* Panel section (sits inside the help panel, above the tips) */
.tm-voice-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
}
.tm-voice-start {
  width: 100%;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s;
}
.tm-voice-start:hover:not(:disabled) { background: var(--blue-dark); }
.tm-voice-start:disabled { opacity: 0.5; cursor: default; }
.tm-voice-auto {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
}
.tm-voice-auto input { width: 16px; height: 16px; accent-color: var(--blue); flex-shrink: 0; }
.tm-voice-na { font-size: 12px; color: var(--text-3); line-height: 1.5; }

/* Highlight ring on the field currently being narrated */
.tm-voice-target {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
  border-radius: 8px;
  box-shadow: 0 0 0 6px var(--blue-dim);
  scroll-margin: 90px;
  transition: outline-color 0.15s, box-shadow 0.15s;
}

/* Floating control bar */
.tm-voice-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 20px;
  z-index: 60;
  width: min(440px, calc(100vw - 24px));
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  padding: 12px 14px 10px;
}
@media (max-width: 768px) {
  .tm-voice-bar { bottom: calc(var(--bn-h) + var(--safe-bottom) + 12px); }
}
.tm-voice-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.tm-voice-prog {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--blue);
}
.tm-voice-x {
  border: none; background: transparent; color: var(--text-3);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.tm-voice-x:hover { color: var(--text); }
.tm-voice-text {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 6px;
}
.tm-voice-note {
  font-size: 12px;
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--r-sm);
  padding: 6px 8px;
  margin-bottom: 8px;
  line-height: 1.45;
}
.tm-voice-ctrls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.tm-voice-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--white);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, border-color 0.1s, transform 0.08s;
}
.tm-voice-btn:hover:not(:disabled) { background: var(--bg-2); }
.tm-voice-btn:active { transform: scale(0.92); }
.tm-voice-btn:disabled { opacity: 0.35; cursor: default; }
.tm-voice-btn--main {
  width: 50px; height: 50px;
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-size: 19px;
}
.tm-voice-btn--main:hover:not(:disabled) { background: var(--blue-dark); }

/* Opt-in auto-play banner (top-centered) */
.tm-voice-banner {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(var(--topbar-h) + var(--safe-top) + 10px);
  z-index: 60;
  width: min(420px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-full);
  box-shadow: var(--sh-lg);
  padding: 7px 8px 7px 14px;
  animation: toast-in 0.22s cubic-bezier(0.2, 0, 0, 1);
}
.tm-voice-banner-msg {
  flex: 1; font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tm-voice-banner-go {
  background: var(--blue); color: #fff; border: none;
  border-radius: var(--r-full); padding: 6px 12px;
  font-size: 12.5px; font-weight: 700; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.tm-voice-banner-go:hover { background: var(--blue-dark); }
.tm-voice-banner-no {
  background: transparent; border: none; color: var(--text-2);
  font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 6px 8px; flex-shrink: 0;
}
.tm-voice-banner-no:hover { color: var(--text); }

@media print { .tm-voice-bar, .tm-voice-banner { display: none !important; } }
