:root {
  --bg: #fff7ef;
  --card: #ffffff;
  --ink: #23173d;
  --muted: #8a7f9e;
  --line: #f1e6dc;
  --soft: #fff0e4;
  --mango: #ffb020;
  --coral: #ff6b5a;
  --pink: #ff4f9a;
  --violet: #7b5cff;
  --teal: #12c2b0;
  --sky: #3fa7ff;
  --green: #1fbf6b;
  --amber: #f5a300;
  --red: #f04b4b;
  --grad: linear-gradient(135deg, #ffb020 0%, #ff6b5a 45%, #ff4f9a 75%, #7b5cff 100%);
  --grad-cool: linear-gradient(135deg, #12c2b0 0%, #3fa7ff 60%, #7b5cff 100%);
  --shadow: 0 6px 22px rgba(255, 107, 90, .12), 0 1px 3px rgba(35, 23, 61, .06);
  --r: 22px;
  --tab-h: 68px;
}
:root[data-theme="dark"] {
  --bg: #15122a;
  --card: #211c3d;
  --ink: #f6f1ff;
  --muted: #a69cc4;
  --line: #2f2852;
  --soft: #2a2350;
  --shadow: 0 6px 22px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.4;
  min-height: 100vh;
  padding: 14px 16px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--violet); }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- blobs: kreativ fon ---------- */
.blob { position: fixed; z-index: -1; border-radius: 50%; filter: blur(46px); opacity: .45; pointer-events: none; }
.blob.b1 { width: 220px; height: 220px; background: #ffd27a; top: -60px; right: -70px; }
.blob.b2 { width: 200px; height: 200px; background: #ffb3d1; top: 40%; left: -90px; }
.blob.b3 { width: 180px; height: 180px; background: #b9a8ff; bottom: 60px; right: -60px; }
:root[data-theme="dark"] .blob { opacity: .18; }

/* ---------- loading ---------- */
.splash { display: grid; place-items: center; min-height: 70vh; text-align: center; }
.splash .logo { font-size: 64px; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-6deg); } }

/* ---------- hero ---------- */
.hero {
  background: var(--grad); color: #fff; border-radius: 28px; padding: 20px 20px 18px;
  box-shadow: 0 12px 30px rgba(255, 79, 154, .3); position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,.15); right: -50px; top: -60px;
}
.hero h1 { margin: 0; font-size: 26px; font-weight: 900; letter-spacing: -.3px; }
.hero .sub { opacity: .9; font-size: 13px; margin-top: 2px; }
.rates { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; position: relative; z-index: 1; }
.rate {
  background: rgba(255,255,255,.22); backdrop-filter: blur(6px); border-radius: 999px;
  padding: 7px 12px; font-weight: 800; font-size: 14px; display: inline-flex; gap: 6px; align-items: center;
}
.rate small { font-weight: 600; opacity: .85; }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); margin-top: 14px; }
.card h2, .section-title { margin: 0 0 10px; font-size: 17px; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.section-title { margin: 22px 4px 2px; }
.section-title .more { margin-left: auto; font-size: 13px; color: var(--violet); font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.tile { background: var(--card); border-radius: 18px; padding: 12px 10px; text-align: center; box-shadow: var(--shadow); }
.tile b { display: block; font-size: 24px; font-weight: 900; }
.tile span { font-size: 12px; color: var(--muted); font-weight: 700; }
.tile.g b { color: var(--green); } .tile.y b { color: var(--amber); } .tile.r b { color: var(--red); }

.budget { display: flex; align-items: center; gap: 16px; }
.ring { width: 108px; height: 108px; flex: none; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.ring .lbl b { font-size: 20px; font-weight: 900; }
.ring .lbl span { font-size: 11px; color: var(--muted); }
.budget ul { list-style: none; margin: 0; padding: 0; font-size: 13.5px; flex: 1; }
.budget li { display: flex; justify-content: space-between; padding: 3px 0; gap: 8px; }
.budget li b { font-weight: 800; }

.pipeline { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; margin: 0 -2px; scrollbar-width: none; }
.pipeline::-webkit-scrollbar { display: none; }
.pipe { flex: none; background: var(--card); border-radius: 16px; padding: 10px 12px; min-width: 86px; box-shadow: var(--shadow); text-align: center; }
.pipe .e { font-size: 22px; } .pipe b { display: block; font-size: 18px; font-weight: 900; }
.pipe span { font-size: 11.5px; color: var(--muted); font-weight: 700; }

/* ---------- product list ---------- */
.plist { display: grid; gap: 10px; margin-top: 12px; }
.pcard {
  background: var(--card); border-radius: 20px; padding: 14px 14px 14px 18px; box-shadow: var(--shadow);
  position: relative; overflow: hidden; text-align: left; width: 100%; display: block;
  animation: pop .25s ease both;
}
.pcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--vc, var(--muted)); }
.pcard .top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.pcard .name { font-weight: 900; font-size: 16px; }
.pcard .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pcard .profit { text-align: right; white-space: nowrap; }
.pcard .profit b { font-size: 17px; font-weight: 900; color: var(--vc); display: block; }
.pcard .profit span { font-size: 12px; color: var(--muted); }
.delta { font-size: 11.5px; font-weight: 800; }
.delta.up { color: var(--green); } .delta.down { color: var(--red); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: 0 -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; background: var(--card); font-weight: 800; font-size: 13.5px;
  box-shadow: var(--shadow); transition: transform .12s;
}
.chip.on { background: var(--ink); color: var(--bg); }
.chip:active { transform: scale(.95); }

.search {
  width: 100%; border: 0; background: var(--card); border-radius: 16px; padding: 12px 14px; margin-top: 12px;
  box-shadow: var(--shadow); outline: none;
}

/* ---------- forms ---------- */
.field { margin-top: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 800; color: var(--muted); margin: 0 0 6px 4px; }
.inp {
  display: flex; align-items: center; background: var(--soft); border-radius: 16px; padding: 0 6px 0 14px;
  border: 2px solid transparent; transition: border-color .15s, background .15s;
}
.inp:focus-within { border-color: var(--coral); background: var(--card); }
.inp input, .inp textarea, .inp select {
  flex: 1; border: 0; background: transparent; padding: 12px 0; outline: none; min-width: 0; font-weight: 800; font-size: 16px;
}
.inp textarea { resize: vertical; min-height: 120px; font-weight: 600; font-size: 15px; padding-right: 8px; }
.inp .unit { color: var(--muted); font-weight: 800; font-size: 13px; padding: 0 8px; white-space: nowrap; }
.step { width: 34px; height: 34px; border-radius: 12px; background: var(--card); font-weight: 900; font-size: 18px; margin-left: 4px; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.grid3 .inp { padding-left: 10px; }

.cargo-pick { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding: 4px 2px 8px; margin: 0 -2px; }
.cargo-pick::-webkit-scrollbar { display: none; }
.cpk {
  flex: none; min-width: 128px; padding: 10px 12px; border-radius: 16px; background: var(--soft); text-align: left;
  border: 2px solid transparent; transition: all .15s;
}
.cpk b { display: block; font-weight: 900; } .cpk span { font-size: 12px; color: var(--muted); font-weight: 700; }
.cpk.on { border-color: var(--violet); background: var(--card); box-shadow: 0 6px 18px rgba(123,92,255,.25); }

details.more { margin-top: 14px; }
details.more summary { list-style: none; font-weight: 900; color: var(--violet); cursor: pointer; padding: 6px 4px; }
details.more summary::-webkit-details-marker { display: none; }

.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 4px; font-weight: 800; }
.switch { width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; width: 24px; height: 24px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: left .2s; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.switch.on { background: var(--teal); } .switch.on::after { left: 23px; }

.seg { display: flex; background: var(--soft); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 9px; border-radius: 11px; font-weight: 800; }
.seg button.on { background: var(--card); box-shadow: var(--shadow); }

/* ---------- result ---------- */
.result { position: relative; overflow: hidden; }
.verdict {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 18px; color: #fff; margin: -2px -2px 14px;
  background: var(--vbg, var(--grad)); transition: background .3s;
}
.verdict .em { font-size: 34px; line-height: 1; animation: pop .3s; }
.verdict b { font-size: 21px; font-weight: 900; display: block; letter-spacing: .3px; }
.verdict span { font-size: 13px; opacity: .92; }
.v-KIRAMIZ { --vbg: linear-gradient(135deg, #1fbf6b, #12c2b0); --vc: var(--green); }
.v-EHTIYOT { --vbg: linear-gradient(135deg, #ffb020, #ff8a3d); --vc: var(--amber); }
.v-KIRMAYMIZ { --vbg: linear-gradient(135deg, #ff6b5a, #f04b4b); --vc: var(--red); }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--soft); border-radius: 14px; padding: 10px 8px; text-align: center; }
.kpi b { display: block; font-size: 17px; font-weight: 900; }
.kpi span { font-size: 11px; color: var(--muted); font-weight: 700; }

.meter { margin-top: 12px; }
.meter .row { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 800; margin-bottom: 5px; }
.bar { height: 10px; background: var(--soft); border-radius: 999px; overflow: hidden; position: relative; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--grad); transition: width .35s cubic-bezier(.3,1.4,.5,1); }
.bar .goal { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: .5; }

.split { display: flex; height: 22px; border-radius: 10px; overflow: hidden; margin: 14px 0 8px; background: var(--soft); }
.split i { display: block; height: 100%; transition: width .35s; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 12.5px; }
.legend div { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.legend div span:first-child { display: flex; align-items: center; gap: 6px; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.slider { margin-top: 16px; }
.slider input[type=range] { width: 100%; accent-color: var(--pink); height: 28px; }
.slider .ticks { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); font-weight: 700; }

.receipt { font-size: 13.5px; margin-top: 10px; }
.receipt .ln { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); gap: 10px; }
.receipt .ln.tot { font-weight: 900; border-bottom: 0; font-size: 15px; }
.receipt .warn { color: var(--amber); font-weight: 800; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 16px; border-radius: 16px;
  font-weight: 900; background: var(--soft); transition: transform .1s; width: 100%;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px rgba(255, 79, 154, .28); }
.btn.cool { background: var(--grad-cool); color: #fff; }
.btn.danger { color: var(--red); }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.fab-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.big-action { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 20px; color: #fff; text-align: left; box-shadow: var(--shadow); }
.big-action .e { font-size: 28px; } .big-action b { display: block; font-weight: 900; font-size: 15px; }
.big-action span { font-size: 12px; opacity: .9; }

/* ---------- AI ---------- */
.modes { display: grid; gap: 10px; }
.mode { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); text-align: left; border: 2px solid transparent; }
.mode .e { font-size: 28px; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--soft); flex: none; }
.mode b { display: block; font-weight: 900; } .mode span { font-size: 12.5px; color: var(--muted); }
.mode.on { border-color: var(--pink); }
.ai-out { white-space: pre-wrap; font-size: 14.5px; line-height: 1.5; }

/* ---------- cargo cards ---------- */
.ccard { background: var(--card); border-radius: 20px; padding: 14px; box-shadow: var(--shadow); text-align: left; width: 100%; display: block; animation: pop .25s both; }
.ccard .top { display: flex; justify-content: space-between; align-items: center; }
.ccard .name { font-weight: 900; font-size: 16px; }
.ccard .tariff { font-weight: 900; font-size: 18px; background: var(--grad-cool); -webkit-background-clip: text; background-clip: text; color: transparent; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: 12px; font-weight: 800; padding: 4px 9px; border-radius: 999px; background: var(--soft); }
.badge.ok { background: rgba(31,191,107,.14); color: var(--green); }
.badge.no { background: rgba(240,75,75,.1); color: var(--red); }

/* ---------- status stepper ---------- */
.steps { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 4px 0 6px; }
.steps::-webkit-scrollbar { display: none; }
.stp { flex: none; padding: 8px 12px; border-radius: 14px; background: var(--soft); font-weight: 800; font-size: 13px; opacity: .65; }
.stp.done { opacity: 1; }
.stp.on { opacity: 1; background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(255,79,154,.3); }

/* ---------- settings ---------- */
.sgroup { margin-top: 16px; }
.sgroup h3 { margin: 0 4px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.srow { display: flex; align-items: center; gap: 10px; background: var(--card); padding: 6px 6px 6px 14px; border-radius: 16px; margin-top: 6px; box-shadow: var(--shadow); }
.srow .t { flex: 1; font-weight: 700; font-size: 14px; }
.srow .inp { width: 46%; padding: 0 4px 0 10px; }
.srow .inp input { padding: 9px 0; font-size: 15px; text-align: right; }

/* ---------- tab bar ---------- */
.tabs {
  position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); height: var(--tab-h);
  background: var(--card); border-radius: 24px; display: flex; box-shadow: 0 10px 30px rgba(35,23,61,.16); z-index: 20; padding: 6px;
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 18px; font-size: 11px; font-weight: 800; color: var(--muted); transition: all .2s; }
.tab .e { font-size: 21px; transition: transform .2s; filter: grayscale(.6); }
.tab.on { color: var(--ink); background: var(--soft); }
.tab.on .e { transform: translateY(-2px) scale(1.12); filter: none; }

/* ---------- sheet ---------- */
.overlay { position: fixed; inset: 0; background: rgba(21,18,42,.45); z-index: 40; opacity: 0; transition: opacity .2s; }
.overlay.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: var(--bg); z-index: 41;
  border-radius: 28px 28px 0 0; padding: 10px 16px calc(28px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.9,.3,1.05);
}
.sheet.show { transform: none; }
.sheet .grip { width: 42px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin: 4px 0 4px; font-size: 21px; font-weight: 900; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: 14px; transform: translate(-50%, -90px); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-weight: 800; z-index: 60; transition: transform .3s cubic-bezier(.3,1.4,.5,1);
  max-width: 90vw; text-align: center; font-size: 14px;
}
.toast.show { transform: translate(-50%, 0); }

.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.empty .e { font-size: 48px; }
.confetti { position: fixed; top: -10px; width: 9px; height: 14px; z-index: 70; border-radius: 2px; pointer-events: none; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .8; } }

@media (min-width: 560px) {
  body { max-width: 560px; margin: 0 auto; }
  .tabs { max-width: 536px; margin: 0 auto; }
}

/* grid ichidagi maydonlar torayishi mumkin bo'lsin (aks holda kartochkadan chiqib ketadi) */
.grid2 > *, .grid3 > *, .grid3 .inp { min-width: 0; }
.grid3 .inp { padding: 0 4px 0 10px; }
.grid3 .inp .unit { padding: 0 4px; }
.srow.offer.on { outline: 2px solid var(--violet); }
