/* ==========================================================
   Сервисный центр — Telegram Mini App
   Дизайн-система: тёмная и светлая темы, iOS-подобные карточки
   ========================================================== */

:root {
  --bg:            #f2f3f7;
  --bg-elev:       #ffffff;
  --bg-sunken:     #e9ebf1;
  --card:          #ffffff;
  --text:          #0f1218;
  --text-2:        #5b6472;
  --text-3:        #8b94a3;
  --line:          rgba(15, 18, 24, .08);
  --line-strong:   rgba(15, 18, 24, .14);

  --accent:        #2f80ed;
  --accent-2:      #7c5cff;
  --accent-soft:   rgba(47, 128, 237, .12);
  --grad:          linear-gradient(135deg, #2f80ed 0%, #7c5cff 100%);

  --green:  #17b26a;  --green-soft:  rgba(23, 178, 106, .13);
  --amber:  #f79009;  --amber-soft:  rgba(247, 144, 9, .14);
  --red:    #f04438;  --red-soft:    rgba(240, 68, 56, .13);
  --cyan:   #06aed4;  --cyan-soft:   rgba(6, 174, 212, .13);
  --violet: #7c5cff;  --violet-soft: rgba(124, 92, 255, .13);
  --slate:  #667085;  --slate-soft:  rgba(102, 112, 133, .13);

  --r-sm: 10px; --r: 14px; --r-lg: 20px; --r-xl: 26px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px -12px rgba(16,24,40,.18);
  --shadow-lg: 0 12px 40px -12px rgba(16,24,40,.35);
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Inter, sans-serif;
  color-scheme: light;
}

body.dark {
  --bg:          #0e1116;
  --bg-elev:     #161b22;
  --bg-sunken:   #0a0d12;
  --card:        #171d26;
  --text:        #eef2f7;
  --text-2:      #9aa4b2;
  --text-3:      #6b7482;
  --line:        rgba(255,255,255,.08);
  --line-strong: rgba(255,255,255,.14);
  --accent-soft: rgba(47, 128, 237, .2);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -14px rgba(0,0,0,.8);
  --shadow-lg: 0 18px 48px -16px rgba(0,0,0,.85);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 15px; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.02em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ------------------------------ layout ------------------------------ */
#app { max-width: 720px; margin: 0 auto; padding: 0 14px; }
.page { padding-top: 12px; animation: fade .22s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0 10px;
  background: linear-gradient(var(--bg) 72%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
}
.topbar .title { flex: 1; min-width: 0; }
.topbar h1 { font-size: 22px; }
.topbar .sub { font-size: 12.5px; color: var(--text-2); margin-top: 1px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grid { display: grid; gap: 10px; }
.grid.g2 { grid-template-columns: 1fr 1fr; }
.grid.g3 { grid-template-columns: repeat(3, 1fr); }
.spacer { height: 14px; }
.stack > * + * { margin-top: 10px; }

/* ------------------------------ cards ------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card.tight { padding: 12px; }
.card.flat { box-shadow: none; }
.card.press { cursor: pointer; transition: transform .16s cubic-bezier(.2,.8,.3,1), border-color .16s; }
.card.press:active { transform: scale(.985); border-color: var(--line-strong); }
.card-title { font-weight: 620; font-size: 15px; }
.section-title {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); font-weight: 620; margin: 18px 2px 8px;
}

.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); }
.list .item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .15s; }
.list .item:last-child { border-bottom: none; }
.list .item:active { background: var(--bg-sunken); }
.item .body { flex: 1; min-width: 0; }
.item .body .t { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .body .s { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .chev { color: var(--text-3); font-size: 18px; }

/* ------------------------------ avatar ------------------------------ */
.avatar {
  width: 40px; height: 40px; border-radius: 13px; flex: none;
  display: grid; place-items: center; font-weight: 650; font-size: 14px; color: #fff;
  background: var(--grad);
}
.avatar.sm { width: 28px; height: 28px; border-radius: 9px; font-size: 11px; }
.avatar.lg { width: 56px; height: 56px; border-radius: 18px; font-size: 19px; }
.avatar svg { width: 20px; height: 20px; }
.avatar.sm svg { width: 15px; height: 15px; }
.avatar.lg svg { width: 26px; height: 26px; }

/* ------------------------------ badges ------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 580; white-space: nowrap;
  background: var(--slate-soft); color: var(--slate);
}
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.new       { background: var(--cyan-soft);   color: var(--cyan); }
.badge.diagnostics { background: var(--violet-soft); color: var(--violet); }
.badge.approval  { background: var(--amber-soft);  color: var(--amber); }
.badge.waiting_parts { background: var(--slate-soft); color: var(--slate); }
.badge.in_repair { background: var(--accent-soft);  color: var(--accent); }
.badge.ready     { background: var(--green-soft);  color: var(--green); }
.badge.issued    { background: var(--slate-soft);  color: var(--slate); }
.badge.declined  { background: var(--red-soft);    color: var(--red); }
.badge.high      { background: var(--red-soft);    color: var(--red); }
.badge.outline   { background: transparent; border: 1px solid var(--line-strong); color: var(--text-2); }

/* ------------------------------ buttons ----------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px; border-radius: var(--r);
  border: none; background: var(--bg-sunken); color: var(--text);
  font-weight: 600; font-size: 15px; cursor: pointer;
  transition: transform .14s cubic-bezier(.2,.8,.3,1), opacity .14s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px -10px rgba(47,128,237,.9); }
.btn.ghost { background: transparent; border: 1px solid var(--line-strong); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13.5px; border-radius: 10px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.sm svg { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: none;
  background: var(--bg-sunken); color: var(--text-2);
  display: grid; place-items: center; cursor: pointer; flex: none;
  transition: transform .14s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 19px; height: 19px; }

/* ------------------------------ inputs ------------------------------ */
.field { display: block; margin-bottom: 12px; }
.field > .label { display: block; font-size: 12.5px; font-weight: 580; color: var(--text-2); margin: 0 0 6px 3px; }
.input, .select, .textarea {
  width: 100%; padding: 12px 13px;
  background: var(--bg-elev); border: 1px solid var(--line-strong);
  border-radius: var(--r); outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px;
}

.search { position: relative; }
.search .input { padding-left: 38px; border-radius: 999px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: none; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--bg-sunken); border-radius: 999px; transition: background .2s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,.25); transition: transform .2s cubic-bezier(.2,.8,.3,1); }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* --------------------------- chips / tabs --------------------------- */
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 560;
  background: var(--bg-elev); border: 1px solid var(--line); color: var(--text-2);
  white-space: nowrap; cursor: pointer; transition: all .16s;
}
.chip.on { background: var(--text); color: var(--bg-elev); border-color: var(--text); }
.chip .n { opacity: .55; margin-left: 4px; font-variant-numeric: tabular-nums; }

.segment { display: flex; background: var(--bg-sunken); padding: 3px; border-radius: 12px; gap: 3px; }
.segment button { flex: 1; padding: 8px; border: none; background: transparent; border-radius: 9px; font-weight: 580; font-size: 13.5px; color: var(--text-2); cursor: pointer; transition: all .18s; }
.segment button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

/* ---------------------------- statistics ---------------------------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 13px 14px; box-shadow: var(--shadow); }
.tile .k { font-size: 12px; color: var(--text-2); font-weight: 560; }
.tile .v { font-size: 22px; font-weight: 680; letter-spacing: -.02em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.tile .d { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.tile.accent { background: var(--grad); border: none; color: #fff; }
.tile.accent .k, .tile.accent .d { color: rgba(255,255,255,.82); }

.bar { height: 8px; border-radius: 999px; background: var(--bg-sunken); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad); border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.3,1); }

/* ------------------------------ timeline ---------------------------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); border-radius: 2px; }
.tl-item { position: relative; padding: 0 0 15px; }
.tl-item::before { content: ''; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--card); }
.tl-item .tl-t { font-size: 14px; }
.tl-item .tl-m { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* ------------------------------- фото ------------------------------- */
.shots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shot { position: relative; aspect-ratio: 1; border-radius: var(--r); overflow: hidden; background: var(--bg-sunken); cursor: pointer; }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot .del {
  position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border: none; border-radius: 8px;
  background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.shot .del svg { width: 14px; height: 14px; }
.shot.add { display: grid; place-items: center; border: 1.5px dashed var(--line-strong); color: var(--text-3); }
.shot.add svg { width: 24px; height: 24px; }
.lightbox { position: fixed; inset: 0; z-index: 150; background: rgba(6,8,12,.94); display: grid; place-items: center; animation: fadein .2s ease both; }
.lightbox img { max-width: 96vw; max-height: 88vh; border-radius: 12px; }

/* --------------------------- bottom nav ----------------------------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex; align-items: center; justify-content: space-around;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-3); font-size: 10.5px; font-weight: 560; padding: 6px 0;
  transition: color .18s;
}
.nav a.on { color: var(--accent); }
.nav a svg { width: 22px; height: 22px; }
.nav .fab {
  flex: none; width: 52px; height: 52px; border-radius: 18px; margin-top: -18px;
  background: var(--grad); color: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 24px -8px rgba(47,128,237,.85);
  transition: transform .16s cubic-bezier(.2,.8,.3,1);
}
.nav .fab:active { transform: scale(.92); }
.nav .fab svg { width: 26px; height: 26px; }
.nav .badge-n {
  position: absolute; transform: translate(13px, -8px);
  background: var(--red); color: #fff; border-radius: 999px;
  font-size: 10px; font-weight: 700; padding: 1px 5px; min-width: 16px; text-align: center;
}

/* ------------------------------ sheet ------------------------------- */
.backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8, 11, 16, .45); backdrop-filter: blur(3px);
  animation: fadein .2s ease both;
  display: flex; align-items: flex-end; justify-content: center;
}
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  width: 100%; max-width: 720px; max-height: 88vh; overflow-y: auto;
  background: var(--bg); border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 8px 16px calc(20px + var(--safe-b));
  animation: up .28s cubic-bezier(.2,.9,.3,1) both;
  box-shadow: var(--shadow-lg);
}
@keyframes up { from { transform: translateY(30px); opacity: .4 } to { transform: none; opacity: 1 } }
.sheet .handle { width: 38px; height: 4px; border-radius: 999px; background: var(--line-strong); margin: 6px auto 14px; }
.sheet h2 { margin-bottom: 12px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + var(--safe-b));
  transform: translateX(-50%); z-index: 200;
  background: var(--text); color: var(--bg-elev);
  padding: 11px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 560;
  box-shadow: var(--shadow-lg); animation: up .24s cubic-bezier(.2,.9,.3,1) both;
  max-width: 90vw; text-align: center;
}
.toast.err { background: var(--red); color: #fff; }

/* ------------------------------ misc -------------------------------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .ico { font-size: 40px; margin-bottom: 10px; opacity: .55; }
.skeleton { background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--line) 37%, var(--bg-sunken) 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: var(--r); }
@keyframes sk { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }
.sk-card { height: 76px; margin-bottom: 10px; }

.kv { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { width: 42%; color: var(--text-2); flex: none; font-size: 13.5px; }
.kv .v { flex: 1; min-width: 0; word-break: break-word; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 5px 10px; border-radius: 9px; background: var(--bg-sunken); font-size: 12.5px; color: var(--text-2); cursor: pointer; user-select: none; border: 1px solid transparent; transition: all .15s; }
.tag.on { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); font-weight: 580; }

.price { font-variant-numeric: tabular-nums; font-weight: 650; }
.hr { height: 1px; background: var(--line); margin: 14px 0; }
.link { color: var(--accent); font-weight: 560; cursor: pointer; }
.pill-master { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); }
.pill-master i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
