/* =====================================================
   FAREFLOW — GLASSMORPHISM STYLES
   Golden Theme • Light/Dark/System • Immersive Animations
   ===================================================== */

/* ============ DESIGN TOKENS ============ */
:root {
  --gold-1: #f6d365;
  --gold-2: #d4a017;
  --gold-3: #8b6914;
  --amber: #ffb347;
  --bg-1: #0b0b0f;
  --bg-2: #14141c;
  --text: #f5f1e6;
  --text-dim: #b8b0a0;
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-bd: rgba(246, 211, 101, 0.22);
  --glass-hi: rgba(255, 255, 255, 0.12);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --radius: 18px;
  --blur: 22px;
  --t-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --t-med: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  --t-spring: 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
  --green: #6ee7a8;
  --red: #ff8a8a;
}

[data-theme="light"] {
  --bg-1: #faf6ec;
  --bg-2: #f0e8d6;
  --text: #2b2418;
  --text-dim: #6b5f4a;
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bd: rgba(212, 160, 23, 0.35);
  --glass-hi: rgba(255, 255, 255, 0.85);
  --shadow: 0 8px 32px rgba(139, 105, 20, 0.18);
}

/* ============ RESET ============ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% 10%, var(--bg-2), var(--bg-1) 70%);
  background-attachment: fixed;
  transition: background var(--t-slow), color var(--t-med);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body { padding-bottom: 2rem; }

/* ============ THREE.JS CANVAS ============ */
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.75;
  transition: opacity var(--t-slow);
}

[data-theme="light"] #bg-canvas { opacity: 0.35; }

/* ============ GLASS CARD ============ */
.glass-card {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--glass-bd);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-hi);
  padding: 1.1rem 1rem;
  overflow: hidden;
  transition: transform var(--t-med), box-shadow var(--t-med), border-color var(--t-med);
  animation: cardEnter 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(246, 211, 101, 0.08));
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-med);
}

.glass-card:hover {
  transform: translateY(-3px);
  border-color: rgba(246, 211, 101, 0.45);
}

.glass-card:hover::before { opacity: 1; }

@keyframes cardEnter {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============ VIEWS ============ */
.view {
  position: relative;
  z-index: 1;
  display: none;
  padding: 1rem;
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  animation: viewEnter 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.view.active { display: block; }

@keyframes viewEnter {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ LOGIN ============ */
#login-view {
  display: none;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}
#login-view.active { display: grid; }

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 2.2rem 1.8rem;
  animation: floatIn 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes floatIn {
  from { opacity: 0; transform: scale(0.92) translateY(30px); filter: blur(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

.auth-header { text-align: center; margin-bottom: 1.8rem; }

.brand {
  font-family: 'Cinzel', serif;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2), var(--amber), var(--gold-1));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 5s linear infinite;
  background-size: 300% auto;
}

@keyframes shimmer {
  to { background-position: 300% center; }
}

.brand-small {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  color: var(--text-dim);
  font-size: 0.82rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 0.4rem;
}

/* ============ FIELDS ============ */
.field {
  position: relative;
  display: block;
  margin-bottom: 1.2rem;
}

.field input,
.field select {
  width: 100%;
  padding: 1rem 0.9rem 0.55rem;
  font-size: 0.95rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-bd);
  border-radius: 12px;
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
  font-family: inherit;
}

[data-theme="light"] .field input,
[data-theme="light"] .field select { background: rgba(255, 255, 255, 0.65); }

.field input:focus,
.field select:focus {
  border-color: var(--gold-1);
  background: rgba(246, 211, 101, 0.08);
  box-shadow: 0 0 0 3px rgba(246, 211, 101, 0.15);
}

.field input::placeholder { color: transparent; }

.field em {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 0.9rem;
  font-style: normal;
  pointer-events: none;
  transition: all var(--t-med);
}

.field input:focus + em,
.field input:not(:placeholder-shown) + em,
.field input[type="date"] + em,
.field input[type="number"] + em {
  top: 0.55rem;
  font-size: 0.68rem;
  color: var(--gold-1);
  transform: translateY(0);
}

/* ============ BUTTONS ============ */
.btn-primary, .btn-ghost {
  display: block;
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform var(--t-fast), box-shadow var(--t-med), background var(--t-med);
  margin-top: 0.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2));
  color: #1a1408;
  box-shadow: 0 6px 20px rgba(212, 160, 23, 0.35);
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(212, 160, 23, 0.5); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-primary.small { width: auto; padding: 0.6rem 1.1rem; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px dashed var(--glass-bd);
}

.btn-ghost:hover {
  background: rgba(246, 211, 101, 0.08);
  border-color: var(--gold-1);
}

.auth-msg {
  margin-top: 0.9rem;
  font-size: 0.85rem;
  text-align: center;
  color: var(--red);
  min-height: 1em;
}

/* ============ NAV ============ */
.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  animation: slideDown 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.nav-actions { display: flex; gap: 0.5rem; list-style: none; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--glass-bd);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  display: grid;
  place-items: center;
  transition: all var(--t-fast);
}

.icon-btn:hover {
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2));
  color: #1a1408;
  transform: rotate(15deg) scale(1.08);
}

.icon-btn:active { transform: rotate(15deg) scale(0.95); }

/* ============ TOP TABS ============ */
.tabs {
  display: flex;
  gap: 0.3rem;
  padding: 0.35rem;
  margin-bottom: 1rem;
  animation: slideDown 0.6s 0.1s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.tab {
  flex: 1;
  padding: 0.7rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--t-med);
  position: relative;
  overflow: hidden;
}

.tab::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--gold-1);
  transform: translateX(-50%);
  transition: width var(--t-med);
}

.tab:hover { color: var(--text); }
.tab:hover::after { width: 40%; }

.tab.active {
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2));
  color: #1a1408;
  box-shadow: 0 4px 14px rgba(212, 160, 23, 0.35);
  animation: tabPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab.active::after { width: 0; }

@keyframes tabPop {
  0% { transform: scale(0.92); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  animation: panelEnter 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes panelEnter {
  from { opacity: 0; transform: translateX(30px) scale(0.98); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* ============ SUB-TABS (Numbered Stepper) ============ */
.subtabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.4rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.subtabs::-webkit-scrollbar { display: none; }

.subtab {
  flex: 1 0 auto;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.6rem 0.4rem;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 500;
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--t-med);
  position: relative;
}

.subtab em {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-bd);
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 700;
  transition: all var(--t-med);
}

.subtab strong {
  font-size: 0.68rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.1;
}

.subtab:hover { color: var(--text); }
.subtab:hover em { background: rgba(246, 211, 101, 0.15); }

.subtab.active {
  color: var(--gold-1);
  background: rgba(246, 211, 101, 0.08);
}

.subtab.active em {
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2));
  color: #1a1408;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(212, 160, 23, 0.4);
  transform: scale(1.1);
}

.subtab-panel { display: none; }
.subtab-panel.active {
  display: block;
  animation: subtabEnter 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes subtabEnter {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ CARDS ============ */
.card-head { margin-bottom: 0.9rem; }

.card-head h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.card-head .hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.card-head.mt { margin-top: 1.4rem; }

.tab-panel .glass-card,
.subtab-panel .glass-card { margin-bottom: 1rem; }

/* ============ VEHICLE GRID ============ */
.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.6rem;
  list-style: none;
}

.vehicle-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem;
  border-radius: 14px;
  border: 1px solid var(--glass-bd);
  background: rgba(255, 255, 255, 0.03);
  transition: all var(--t-med);
  cursor: pointer;
  position: relative;
}

.vehicle-item input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.vehicle-item.active {
  border-color: var(--gold-1);
  background: linear-gradient(135deg, rgba(246, 211, 101, 0.15), rgba(212, 160, 23, 0.08));
  box-shadow: 0 4px 20px rgba(246, 211, 101, 0.2);
  transform: translateY(-2px);
}

.vehicle-item label {
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--t-fast);
}

.vehicle-item.active label { color: var(--gold-1); }

.vehicle-item input[type="number"] {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--glass-bd);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-family: inherit;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  transition: all var(--t-fast);
}

[data-theme="light"] .vehicle-item input[type="number"] { background: rgba(255, 255, 255, 0.75); }

.vehicle-item input[type="number"]:focus {
  outline: none;
  border-color: var(--gold-1);
  box-shadow: 0 0 0 2px rgba(246, 211, 101, 0.2);
}

/* ============ BATCH TABS ============ */
.batch-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.3rem;
  margin-bottom: 0.8rem;
  overflow-x: auto;
  scrollbar-width: none;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  border: 1px solid var(--glass-bd);
}

.batch-tabs::-webkit-scrollbar { display: none; }

[data-theme="light"] .batch-tabs { background: rgba(255, 255, 255, 0.4); }

.batch-tab {
  flex: 0 0 auto;
  padding: 0.45rem 0.9rem;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
  transition: all var(--t-med);
  white-space: nowrap;
}

.batch-tab:hover { color: var(--text); background: rgba(246, 211, 101, 0.1); }

.batch-tab.active {
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2));
  color: #1a1408;
  box-shadow: 0 3px 10px rgba(212, 160, 23, 0.35);
  animation: tabPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============ BULK ACTION BAR ============ */
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.8rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(246, 211, 101, 0.08), rgba(212, 160, 23, 0.04));
  border: 1px solid var(--glass-bd);
}

.bulk-left, .bulk-right {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
  list-style: none;
}

.bulk-left small {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-left: 0.3rem;
}

.bulk-input {
  width: 72px;
  padding: 0.42rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--glass-bd);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
}

[data-theme="light"] .bulk-input { background: rgba(255, 255, 255, 0.75); }

.mini-btn {
  padding: 0.42rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--glass-bd);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}

.mini-btn:hover {
  background: rgba(246, 211, 101, 0.15);
  border-color: var(--gold-1);
  transform: translateY(-1px);
}

.mini-btn:active { transform: translateY(0) scale(0.96); }

.mini-btn.gold {
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2));
  color: #1a1408;
  border-color: transparent;
}

.mini-btn.gold:hover { box-shadow: 0 4px 14px rgba(212, 160, 23, 0.4); }

.mini-btn.red {
  color: var(--red);
  border-color: rgba(255, 138, 138, 0.35);
}

.mini-btn.red:hover { background: rgba(255, 138, 138, 0.15); }

.mini-btn.green {
  color: var(--green);
  border-color: rgba(110, 231, 168, 0.35);
}

.mini-btn.green:hover { background: rgba(110, 231, 168, 0.15); }

/* ============ BOYS LIST ============ */
.strength-list, .boys-list, .chip-list, .history-list, .summary-list, .boys-master {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Boys list row (dynamic) */
.boy-row {
  display: grid;
  grid-template-columns: 32px 1.4fr 60px 1fr 80px 36px;
  gap: 0.45rem;
  align-items: center;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-bd);
  transition: all var(--t-fast);
  animation: boyRowEnter 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes boyRowEnter {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: translateX(0); }
}

.boy-row:hover { background: rgba(246, 211, 101, 0.06); }

.boy-row.selected {
  border-color: var(--gold-1);
  background: linear-gradient(135deg, rgba(246, 211, 101, 0.14), rgba(212, 160, 23, 0.06));
}

.boy-row.absent {
  opacity: 0.45;
  text-decoration: line-through;
  filter: grayscale(0.6);
}

.boy-row .row-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold-1);
  text-align: center;
}

.boy-row .row-sel {
  width: 18px;
  height: 18px;
  accent-color: var(--gold-1);
  cursor: pointer;
  justify-self: center;
}

.boy-row .row-name {
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boy-row .row-batch {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: rgba(246, 211, 101, 0.15);
  color: var(--gold-1);
  text-align: center;
  white-space: nowrap;
}

.boy-row select,
.boy-row input {
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--glass-bd);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  width: 100%;
  transition: all var(--t-fast);
}

[data-theme="light"] .boy-row select,
[data-theme="light"] .boy-row input { background: rgba(255, 255, 255, 0.75); }

.boy-row select:focus,
.boy-row input:focus {
  outline: none;
  border-color: var(--gold-1);
  box-shadow: 0 0 0 2px rgba(246, 211, 101, 0.18);
}

/* Empty state */
.boys-list .empty-state {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
  border: 1px dashed var(--glass-bd);
  border-radius: 12px;
}

/* ============ BOYS MASTER (Settings) ============ */
.boys-master .master-row {
  display: grid;
  grid-template-columns: 32px 1fr 80px 36px;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-bd);
  animation: boyRowEnter 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  transition: all var(--t-fast);
}

.boys-master .master-row:hover { background: rgba(246, 211, 101, 0.06); }

.boys-master .master-row input {
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--glass-bd);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  width: 100%;
}

[data-theme="light"] .boys-master .master-row input { background: rgba(255, 255, 255, 0.75); }

.boys-master .master-row input:focus {
  outline: none;
  border-color: var(--gold-1);
  box-shadow: 0 0 0 2px rgba(246, 211, 101, 0.18);
}

/* ============ STRENGTH ITEM (legacy — for history modal only) ============ */
.strength-item, .chip-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-bd);
  transition: all var(--t-fast);
}

.strength-item:hover { background: rgba(246, 211, 101, 0.06); }

/* ============ REMOVE BUTTON ============ */
.remove-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255, 100, 100, 0.4);
  background: rgba(255, 100, 100, 0.1);
  color: var(--red);
  cursor: pointer;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  transition: all var(--t-fast);
}

.remove-btn:hover {
  background: rgba(255, 100, 100, 0.25);
  transform: rotate(90deg) scale(1.1);
}

/* ============ SUMMARY ============ */
.summary-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.88rem;
  transition: all var(--t-fast);
  animation: boyRowEnter 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.summary-list li:hover { background: rgba(246, 211, 101, 0.06); }

.summary-list li em { color: var(--text-dim); font-style: normal; }
.summary-list li strong { font-weight: 700; }

.summary-list li.total {
  background: linear-gradient(135deg, rgba(246, 211, 101, 0.18), rgba(212, 160, 23, 0.08));
  border: 1px solid var(--glass-bd);
  font-size: 0.95rem;
}

.summary-list li.net.positive strong { color: var(--green); }
.summary-list li.net.negative strong { color: var(--red); }

#sum-net {
  font-size: 1.05rem;
  letter-spacing: 0.3px;
}

/* ============ HISTORY ============ */
.history-item {
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-bd);
  cursor: pointer;
  transition: all var(--t-med);
  animation: boyRowEnter 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  position: relative;
  overflow: hidden;
}

.history-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
  transform: scaleY(0);
  transform-origin: top;
  transition: transform var(--t-med);
}

.history-item:hover {
  transform: translateX(6px);
  border-color: var(--gold-1);
  background: rgba(246, 211, 101, 0.08);
}

.history-item:hover::before { transform: scaleY(1); }

.history-item header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  gap: 0.5rem;
}

.history-item time {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gold-1);
  letter-spacing: 0.3px;
}

.history-item p {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.history-item .net-badge {
  padding: 0.2rem 0.6rem;
  border-radius: 8px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.net-badge.pos { background: rgba(110, 231, 168, 0.15); color: var(--green); }
.net-badge.neg { background: rgba(255, 138, 138, 0.15); color: var(--red); }

/* ============ CHIPS (Settings) ============ */
.chip-list { flex-direction: row; flex-wrap: wrap; gap: 0.5rem; }

.chip-item {
  grid-template-columns: auto auto;
  width: auto;
  padding: 0.45rem 0.6rem 0.45rem 1rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  animation: chipEnter 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes chipEnter {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

.chip-item .remove-btn {
  width: 24px;
  height: 24px;
  font-size: 0.75rem;
}

/* ============ INLINE FORM ============ */
.inline-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.inline-form input,
.inline-form select {
  flex: 1;
  min-width: 100px;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--glass-bd);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  transition: all var(--t-fast);
}

[data-theme="light"] .inline-form input,
[data-theme="light"] .inline-form select { background: rgba(255, 255, 255, 0.75); }

.inline-form input:focus,
.inline-form select:focus {
  outline: none;
  border-color: var(--gold-1);
  box-shadow: 0 0 0 3px rgba(246, 211, 101, 0.15);
}

.inline-form .btn-primary.small {
  margin-top: 0;
  padding: 0.7rem 1.2rem;
}

/* ============ SEARCH INPUT ============ */
.search-input {
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.7rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--glass-bd);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  transition: all var(--t-fast);
}

[data-theme="light"] .search-input { background: rgba(255, 255, 255, 0.75); }

.search-input:focus {
  outline: none;
  border-color: var(--gold-1);
  box-shadow: 0 0 0 3px rgba(246, 211, 101, 0.15);
}

/* ============ MODAL ============ */
.modal {
  width: min(580px, 92vw);
  max-height: 88vh;
  padding: 1.3rem;
  border-radius: var(--radius);
  color: var(--text);
  border: 1px solid var(--glass-bd);
  background: var(--glass-bg);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  box-shadow: var(--shadow);
}

.modal[open] {
  animation: modalEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: backdropEnter 0.3s ease both;
}

@keyframes backdropEnter {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.modal-head h2 { font-size: 1rem; font-weight: 600; }

.modal-body {
  overflow-y: auto;
  max-height: 66vh;
  font-size: 0.85rem;
  padding-right: 0.3rem;
}

.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb {
  background: var(--glass-bd);
  border-radius: 4px;
}

.modal-section {
  margin-bottom: 1rem;
  padding: 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-bd);
  animation: boyRowEnter 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.modal-section h3 {
  font-size: 0.82rem;
  color: var(--gold-1);
  margin-bottom: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
}

.modal-section ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.modal-section li {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  gap: 0.5rem;
}

.modal-section li em { color: var(--text-dim); font-style: normal; }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 1.3rem;
  left: 50%;
  transform: translateX(-50%) translateY(140%);
  padding: 0.8rem 1.4rem;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2));
  color: #1a1408;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  z-index: 9999;
  transition: transform var(--t-spring);
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* =====================================================
   RESPONSIVE — MOBILE FIRST REFINEMENTS
   ===================================================== */

/* Small tablets & large phones */
@media (min-width: 481px) and (max-width: 768px) {
  .view { max-width: 680px; padding: 1rem; }
  .subtabs { gap: 0.35rem; }
  .subtab { min-width: 100px; }
}

/* TABLETS */
@media (min-width: 769px) {
  .view {
    max-width: 900px;
    padding: 1.5rem;
  }

  .vehicle-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

  .boy-row {
    grid-template-columns: 40px 1.5fr 80px 1fr 100px 40px;
    padding: 0.65rem 0.9rem;
    gap: 0.6rem;
  }

  .boy-row .row-name { font-size: 0.9rem; }

  .auth-card { padding: 2.5rem 2rem; }

  .brand { font-size: 2.6rem; }

  .tab { font-size: 0.9rem; padding: 0.75rem 0.6rem; }

  .subtab { min-width: 120px; padding: 0.7rem 0.5rem; }
  .subtab strong { font-size: 0.72rem; }
}

/* DESKTOP */
@media (min-width: 1024px) {
  .view {
    max-width: 1100px;
    padding: 2rem 1.5rem;
  }

  .app-nav { padding: 1rem 1.5rem; margin-bottom: 1.5rem; }

  .brand-small { font-size: 1.5rem; }

  .tabs { padding: 0.5rem; gap: 0.5rem; margin-bottom: 1.5rem; }
  .tab { padding: 0.85rem 1rem; font-size: 0.95rem; }

  .subtabs { padding: 0.55rem; gap: 0.4rem; }
  .subtab { min-width: 140px; padding: 0.8rem 0.7rem; }
  .subtab em { width: 30px; height: 30px; font-size: 0.8rem; }
  .subtab strong { font-size: 0.78rem; }

  .glass-card { padding: 1.6rem 1.5rem; border-radius: 22px; }

  .card-head h2 { font-size: 1.15rem; }
  .card-head .hint { font-size: 0.82rem; }

  .vehicle-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.9rem;
  }

  .vehicle-item { padding: 1rem; }
  .vehicle-item label { font-size: 0.95rem; }
  .vehicle-item input[type="number"] { font-size: 1.05rem; padding: 0.55rem; }

  .boy-row {
    grid-template-columns: 44px 1.8fr 90px 1.2fr 110px 42px;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }

  .boy-row .row-name { font-size: 0.95rem; }
  .boy-row .row-batch { font-size: 0.78rem; padding: 0.28rem 0.6rem; }
  .boy-row select, .boy-row input { font-size: 0.85rem; padding: 0.5rem 0.6rem; }

  .bulk-bar { padding: 0.8rem 1rem; }
  .mini-btn { font-size: 0.8rem; padding: 0.5rem 0.85rem; }
  .bulk-input { width: 90px; font-size: 0.9rem; }

  .summary-list li { font-size: 0.95rem; padding: 0.75rem 1rem; }

  .history-item { padding: 1.1rem 1.3rem; }
  .history-item time { font-size: 1.05rem; }
  .history-item p { font-size: 0.85rem; }

  .modal { width: min(680px, 85vw); padding: 1.6rem; }
  .modal-head h2 { font-size: 1.15rem; }
  .modal-body { font-size: 0.9rem; max-height: 68vh; }
  .modal-section { padding: 1rem; }
  .modal-section h3 { font-size: 0.88rem; }
  .modal-section li { font-size: 0.88rem; }
}

/* LARGE DESKTOP */
@media (min-width: 1440px) {
  .view { max-width: 1280px; }

  .brand { font-size: 3rem; }
  .brand-small { font-size: 1.6rem; }

  .glass-card { padding: 1.8rem 1.6rem; }

  .vehicle-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  }
}

/* ============ MOBILE (Small) ============ */
@media (max-width: 480px) {
  .view { padding: 0.7rem; }
  .glass-card { padding: 0.95rem 0.85rem; border-radius: 15px; }
  .brand { font-size: 1.9rem; }
  .auth-card { padding: 1.8rem 1.3rem; }

  .vehicle-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .vehicle-item { padding: 0.6rem; }

  .tab { font-size: 0.72rem; padding: 0.6rem 0.3rem; }

  .subtabs { gap: 0.2rem; padding: 0.35rem; }
  .subtab { min-width: 78px; padding: 0.5rem 0.3rem; }
  .subtab em { width: 24px; height: 24px; font-size: 0.68rem; }
  .subtab strong { font-size: 0.62rem; }

  /* Boy row — stack into 2 rows on mobile */
  .boy-row {
    grid-template-columns: 28px 1fr auto;
    grid-template-areas:
      "num name batch"
      "num veh  fare"
      "sel sel  sel";
    gap: 0.4rem;
    padding: 0.6rem;
  }

  .boy-row .row-num { grid-area: num; }
  .boy-row .row-name { grid-area: name; }
  .boy-row .row-batch { grid-area: batch; }
  .boy-row select { grid-area: veh; }
  .boy-row input { grid-area: fare; }
  .boy-row .row-sel { grid-area: sel; justify-self: start; }

  .bulk-bar { flex-direction: column; align-items: stretch; }
  .bulk-left, .bulk-right { justify-content: center; }
  .bulk-right { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; }
  .bulk-input { grid-column: span 2; width: 100%; }
  .mini-btn { font-size: 0.72rem; padding: 0.45rem 0.5rem; }

  .inline-form { flex-direction: column; }
  .inline-form input,
  .inline-form select { min-width: 100%; }
  .inline-form .btn-primary.small { width: 100%; }

  .modal { width: 95vw; padding: 1rem; }
  .modal-section { padding: 0.7rem; }
}

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ============ TOUCH DEVICE ============ */
@media (hover: none) {
  .glass-card:hover { transform: none; }
  .glass-card:hover::before { opacity: 0; }
  .vehicle-item.active { transform: none; }
  .history-item:hover { transform: none; }
  .icon-btn:hover { transform: none; }
}