/* MaliMoto v1.1: high-contrast dark OLED theme, fiery orange accent */
:root {
  --bg: #0B0D10;
  --card: #14171C;
  --card-2: #1B1F26;
  --line: #262B33;
  --text: #F5F2EE;
  --muted: #A8A29E;
  --faint: #78716C;
  --accent: #F97316;
  --accent-2: #FB923C;
  --accent-ink: #1A0B02;
  --good: #22C55E;
  --bad: #EF4444;
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; min-height: 100vh; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header: centred brand, subtitle and live badge */
.top {
  position: relative; text-align: center;
  padding: calc(18px + env(safe-area-inset-top)) 56px 12px;
}
h1 { margin: 0; font-size: 26px; font-weight: 900; letter-spacing: -0.02em; line-height: 1.15; }
h1 .flame { margin-right: 6px; }
h1 .moto { color: var(--accent); }
h1 .in-country { font-weight: 700; color: var(--muted); font-size: 0.8em; letter-spacing: 0; }
.subtitle { margin: 6px 0 0; font-size: 19px; font-weight: 800; color: var(--text); }
.live-badge {
  display: inline-flex; align-items: center; gap: 8px; margin: 10px 0 0;
  padding: 5px 12px; border-radius: 999px;
  background: rgba(249, 115, 22, 0.12); border: 1px solid rgba(249, 115, 22, 0.45);
  color: var(--accent-2); font-size: 13px; font-weight: 800;
}
.live-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.7); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.7); } 70% { box-shadow: 0 0 0 8px rgba(249, 115, 22, 0); } 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); } }
.icon-btn {
  position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 12px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--line); font-size: 18px; cursor: pointer;
}

/* Top tabs: three equal tabs, identical active style */
.tabs {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 10px 16px; max-width: 640px; margin: 0 auto;
  background: rgba(11, 13, 16, 0.96);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.tab {
  min-height: 48px; border-radius: 14px; cursor: pointer;
  background: var(--card); border: 2px solid var(--line);
  color: var(--text); font-size: 16px; font-weight: 800;
}
.tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 18px rgba(249, 115, 22, 0.35); }

main { padding: 0 16px; max-width: 640px; margin: 0 auto; }
.tab-panel { display: none; padding-top: 14px; animation: fade 0.18s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-head { margin: 4px 0 10px; }
.section-head.small { margin-top: 26px; }
h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
h3 { margin: 0 0 8px; font-size: 16px; font-weight: 800; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.fine { color: var(--faint); font-size: 12px; text-align: center; margin: 18px 0 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }
.hint.center { text-align: center; }
.opt { color: var(--faint); font-weight: 400; font-size: 12px; }
.lbl { display: block; font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); margin: 12px 0 6px; }

/* Search */
.search { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 0; }
.search .btn { flex: none; padding: 0 18px; }
input[type=search]::-webkit-search-cancel-button { filter: invert(0.6); }
.search-status {
  margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 14px; color: var(--muted);
}
.search-status b { color: var(--text); }
.link-btn { background: none; border: 0; color: var(--accent-2); font-weight: 800; cursor: pointer; padding: 6px 0; font-size: 14px; }

/* Filters */
.filter-grid { display: grid; gap: 0; }
.quick-towns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.chip {
  min-height: 40px; padding: 0 6px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line);
  color: var(--muted); font-size: 14px; font-weight: 800; cursor: pointer; white-space: nowrap;
}
.chip[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.window-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.window-seg button {
  min-height: 58px; padding: 6px 4px; border-radius: 12px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1.2;
}
.window-seg b { font-size: 13px; font-weight: 800; }
.window-seg small { font-size: 11px; color: var(--faint); font-weight: 700; }
.window-seg button[aria-checked="true"] { border: 2px solid var(--accent); background: #22130A; }
.window-seg button[aria-checked="true"] small { color: var(--accent-2); }

.feed-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 14px 0 10px; }
.summary { margin: 0; font-size: 13px; color: var(--muted); }
.summary b { color: var(--text); }
.saved-toggle { flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 700; }
.saved-toggle input { accent-color: var(--accent); width: 18px; height: 18px; }

/* Cards */
.feed, .list { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.p-top { display: flex; gap: 12px; align-items: flex-start; }
.rank {
  flex: none; width: 26px; height: 26px; border-radius: 8px; margin-top: 2px;
  display: grid; place-items: center; font-size: 13px; font-weight: 900;
  background: var(--card-2); color: var(--muted);
}
.rank.first { background: var(--accent); color: var(--accent-ink); }
.p-emoji { flex: none; width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; background: var(--card-2); }
.p-title { flex: 1; min-width: 0; }
.p-cat { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-2); }
.p-name { margin: 2px 0 4px; font-size: 17px; font-weight: 800; line-height: 1.25; }
.p-price { font-size: 19px; font-weight: 900; font-variant-numeric: tabular-nums; }
.p-price small { font-size: 12px; color: var(--muted); font-weight: 600; }
.save-btn {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--card-2); border: 1px solid var(--line); font-size: 18px; cursor: pointer;
  filter: grayscale(1); opacity: 0.7;
}
.save-btn[aria-pressed="true"] { filter: none; opacity: 1; border-color: var(--accent); }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 800; line-height: 1.2;
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
}
.badge.hot { background: rgba(249, 115, 22, 0.15); border-color: rgba(249, 115, 22, 0.5); color: var(--accent-2); }
.badge.up { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.45); color: #86EFAC; }
.badge.down { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.45); color: #FCA5A5; }
.badge.pay { background: rgba(250, 204, 21, 0.1); border-color: rgba(250, 204, 21, 0.4); color: #FDE68A; }

.volume {
  margin-top: 12px; padding: 12px 14px; border-radius: 14px;
  background: linear-gradient(135deg, #1F120A, #15100C); border: 1px solid rgba(249, 115, 22, 0.35);
}
.volume .v-k { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-2); }
.volume .v-big { font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; margin: 2px 0; }
.volume .v-sub { font-size: 13px; color: var(--muted); }
.volume .v-ins { font-size: 13px; color: var(--text); margin-top: 6px; }

.intel { margin: 14px 0 0; display: grid; gap: 10px; }
.intel-row { display: grid; grid-template-columns: 26px 1fr; gap: 8px; }
.intel-ico { font-size: 17px; line-height: 1.4; text-align: center; }
.intel-k { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.intel-v { font-size: 14px; }
.intel-v .here { display: block; margin-top: 4px; color: var(--accent-2); }
.tag { display: inline-block; font-size: 12px; font-weight: 800; padding: 1px 8px; border-radius: 999px; background: rgba(249, 115, 22, 0.14); color: var(--accent-2); margin-right: 4px; }

.p-actions { display: flex; gap: 8px; margin-top: 14px; }
.p-actions .btn.primary { flex: 1; }
.note-box { margin-top: 10px; }
.note-box textarea {
  width: 100%; min-height: 70px; resize: vertical;
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; font-size: 14px;
}
.note-box textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.empty { text-align: center; color: var(--muted); padding: 26px 14px; }
.empty .btn { margin-top: 12px; }

/* Buttons */
.btn {
  min-height: 46px; padding: 0 16px; border-radius: 14px;
  background: var(--card-2); border: 1px solid var(--line);
  color: var(--text); font-weight: 800; font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active, .chip:active, .tab:active, .window-seg button:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: 0.6; }
.btn.danger { border-color: rgba(239, 68, 68, 0.5); color: #FCA5A5; }
.btn.block { width: 100%; margin-top: 14px; }
.btn.copied { background: var(--good); border-color: var(--good); color: #04130A; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Forms */
.form label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 12px 0 6px; }
.form label:first-child { margin-top: 0; }
input[type=text], input[type=search], input[type=number], input[type=tel], input[type=password], select {
  width: 100%; min-height: 48px; padding: 10px 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; font-size: 16px;
}
input::placeholder { color: var(--faint); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer; font-weight: 700;
  background-color: var(--card);
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 22px) 52%, calc(100% - 16px) 52%;
  background-size: 6px 6px; background-repeat: no-repeat;
}
select option, select optgroup { background: var(--card); color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.calc { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.calc > div { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; }
.calc .k { display: block; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.calc .v { display: block; font-size: 17px; font-weight: 900; font-variant-numeric: tabular-nums; }
.v.good { color: var(--good); } .v.bad { color: var(--bad); } .v.ok { color: var(--accent-2); }

.result { margin-top: 14px; }
.result .caption { white-space: pre-wrap; background: var(--bg); border: 1px dashed var(--accent); border-radius: 12px; padding: 12px; font-size: 15px; margin-top: 12px; }
.result .src { font-size: 12px; color: var(--faint); margin-top: 8px; }
.mini { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mini .m-name { font-weight: 800; }
.mini .m-meta { font-size: 13px; color: var(--muted); }
.mini .m-actions { display: flex; gap: 6px; flex: none; }
.mini .m-actions button { min-height: 38px; padding: 0 10px; font-size: 14px; }

/* Sourcing */
.county-card { margin: 12px 0 16px; border-color: rgba(249, 115, 22, 0.45); }
.county-card .c-type { font-size: 12px; font-weight: 800; color: var(--accent-2); text-transform: uppercase; letter-spacing: 0.06em; }
.county-card h3 { font-size: 20px; margin: 2px 0 10px; }
.county-card ul { margin: 4px 0 0; padding-left: 18px; font-size: 14px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.seg-btn { min-height: 40px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-weight: 800; font-size: 13px; cursor: pointer; }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); }
.g-card h3 { margin-bottom: 2px; }
.g-area { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.g-row { font-size: 14px; margin: 6px 0; }
.g-row b { color: var(--accent-2); font-weight: 800; }
.g-card ul, .rules ul { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.g-card li, .rules li { margin: 4px 0; }
.g-watch { margin-top: 10px; font-size: 13px; padding: 8px 10px; border-radius: 10px; background: rgba(239, 68, 68, 0.1); color: #FCA5A5; }
.rules { margin-top: 14px; border-color: rgba(249, 115, 22, 0.4); }
.cmp { width: 100%; border-collapse: collapse; font-size: 13px; }
.cmp th, .cmp td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cmp th { color: var(--accent-2); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.cmp td:first-child { font-weight: 800; white-space: nowrap; }
.cmp-wrap { overflow-x: auto; padding: 4px 10px; }

/* Settings sheet */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet-inner {
  width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); animation: up 0.2s ease;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-inner label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 12px 0 6px; }
.sheet-inner h3 { margin-top: 22px; }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); font-weight: 800; font-size: 14px;
  padding: 10px 16px; border-radius: 999px; z-index: 30; transition: all 0.2s ease;
  max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 360px) {
  h1 { font-size: 22px; }
  .subtitle { font-size: 17px; }
  .tab { font-size: 14px; }
  .window-seg b { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }