/* FES Sales Tracker — mobile-first industrial UI */
:root {
  --bg: #0b1220;
  --bg2: #111a2c;
  --surface: #162235;
  --surface2: #1b2a42;
  --border: #243552;
  --fg: #e8eef8;
  --muted: #8fa0b8;
  --subtle: #6b7c94;
  --primary: #3d9cf0;
  --primary-fg: #041018;
  --success: #3ecf8e;
  --warn: #f0b429;
  --danger: #f07178;
  --radius: 12px;
  --touch: 44px;
  --font: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: 72px;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(11, 18, 32, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: rgba(61, 156, 240, 0.15);
  border: 1px solid rgba(61, 156, 240, 0.35);
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px; color: var(--primary);
  flex-shrink: 0;
}
.brand-title { font-weight: 650; font-size: 14px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; gap: 6px; }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: space-around;
  gap: 2px;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: rgba(17, 26, 44, 0.96);
  border-top: 1px solid var(--border);
  max-width: 720px;
  margin: 0 auto;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
}
.bottom-nav a {
  flex: 1;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-radius: 10px;
}
.bottom-nav a.active { color: var(--primary); background: rgba(61,156,240,0.08); }
.bottom-nav .ico { font-size: 16px; line-height: 1; }

/* Layout */
main.content { padding: 16px; flex: 1; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.page-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h2, .card h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.card-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.card-row:last-child { border-bottom: 0; padding-bottom: 0; }
.card-row:first-of-type { padding-top: 0; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.stat .label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.stat .value {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat .hint { font-size: 11px; color: var(--subtle); margin-top: 2px; }
.stat.primary .value { color: var(--primary); }
.stat.success .value { color: var(--success); }
.stat.warn .value { color: var(--warn); }
.stat.danger .value { color: var(--danger); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none !important;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--border); }
.btn-outline { background: transparent; color: var(--fg); border-color: var(--border); }
.btn-danger { background: rgba(240,113,120,0.15); color: var(--danger); border-color: rgba(240,113,120,0.35); }
.btn-success { background: rgba(62,207,142,0.15); color: var(--success); border-color: rgba(62,207,142,0.35); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.btn-row .btn { flex: 1 1 auto; }

/* Forms */
label {
  display: block;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  margin: 0 0 6px;
}
input, select, textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 16px; /* avoid iOS zoom */
}
textarea { min-height: 96px; resize: vertical; }
.field { margin-bottom: 12px; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.help { font-size: 12px; color: var(--subtle); margin-top: 4px; }

/* Lists / links */
.list-link {
  display: block;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  margin-bottom: 8px;
  color: inherit;
  text-decoration: none !important;
}
.list-link:hover { border-color: #34507a; background: var(--surface); }
.list-title { font-weight: 650; font-size: 15px; }
.list-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.list-right { text-align: right; flex-shrink: 0; }
.list-flex { display: flex; gap: 10px; align-items: flex-start; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(61,156,240,0.15);
  color: var(--primary);
  white-space: nowrap;
}
.badge-muted { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.badge-success { background: rgba(62,207,142,0.15); color: var(--success); }
.badge-warn { background: rgba(240,180,41,0.15); color: var(--warn); }
.badge-danger { background: rgba(240,113,120,0.15); color: var(--danger); }

/* Overdue */
.overdue { border-color: rgba(240,113,120,0.45) !important; }
.overdue .list-meta, .text-danger { color: var(--danger); }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.tabular { font-variant-numeric: tabular-nums; }

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.filters select, .filters input {
  min-height: 40px;
  font-size: 14px;
  flex: 1 1 120px;
}

/* Login */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.error {
  background: rgba(240,113,120,0.12);
  border: 1px solid rgba(240,113,120,0.35);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}
.flash {
  background: rgba(62,207,142,0.12);
  border: 1px solid rgba(62,207,142,0.35);
  color: var(--success);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* FAB-ish primary on dashboard */
.hero-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.hero-actions .btn { min-height: 52px; }

/* Stage chips */
.stage-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}
.chip {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  text-decoration: none !important;
}
.chip.active { background: var(--primary); color: var(--primary-fg); border-color: transparent; }

/* Print quote */
@media print {
  .topbar, .bottom-nav, .no-print { display: none !important; }
  body { background: white; color: black; }
  .card { border-color: #ccc; background: white; }
  .app { padding-bottom: 0; }
}

.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.phone-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  font-weight: 650;
}
