:root {
  --bg: #0d0e11; --card: #16181d; --card2: #1e2128; --line: #262a32;
  --text: #f3f4f6; --muted: #8a909c; --faint: #5c6270;
  --accent: #c8102e; --grad: linear-gradient(100deg, #c8174a 0%, #b80000 55%, #7a0000 100%); --ink: #ffffff; --accent-text: #ff5a6e;
  --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --info: #7dd3fc;
  --ok-bg: rgba(74,222,128,.12); --warn-bg: rgba(251,191,36,.13); --bad-bg: rgba(248,113,113,.13); --info-bg: rgba(125,211,252,.12);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --r: 20px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f4f6; --card: #ffffff; --card2: #f1f2f5; --line: #e4e6eb;
    --text: #12141a; --muted: #6a7080; --faint: #a2a7b3;
    --accent: #c8102e; --grad: linear-gradient(100deg, #c8174a 0%, #b80000 55%, #7a0000 100%); --ink: #ffffff; --accent-text: #b00020;
    --ok: #16a34a; --warn: #b45309; --bad: #dc2626; --info: #0369a1;
    --ok-bg: #dcfce7; --warn-bg: #fef3c7; --bad-bg: #fee2e2; --info-bg: #e0f2fe;
    --shadow: 0 10px 30px rgba(20,25,40,.10);
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums; min-height: 100dvh; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }

#app { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 96px); }

/* шапка */
.top { display: flex; align-items: center; gap: 12px; margin: 4px 2px 18px; }
.top h1 { font-size: 26px; line-height: 1.15; margin: 0; letter-spacing: -.02em; font-weight: 750; }
.top .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.top .grow { flex: 1; min-width: 0; }
.iconbtn {
  width: 42px; height: 42px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.iconbtn svg { width: 20px; height: 20px; }

/* карточки */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.hero {
  border-radius: 24px; padding: 20px; margin-bottom: 14px; color: var(--ink);
  background: var(--grad);
  box-shadow: 0 14px 40px rgba(184, 0, 0, .28); position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -40px; bottom: -60px; width: 180px; height: 180px; border-radius: 50%;
  border: 26px solid rgba(255,255,255,.08);
}
.hero .label { font-size: 13px; font-weight: 600; opacity: .8; }
.hero .big { font-size: 44px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; margin: 4px 0 2px; }
.hero .meta { font-size: 14px; font-weight: 600; opacity: .8; }
.hero .row3 { display: flex; gap: 10px; margin-top: 16px; position: relative; z-index: 1; }
.hero .pill { background: rgba(255,255,255,.14); border-radius: 14px; padding: 9px 12px; flex: 1; min-width: 0; }
.hero .pill b { display: block; font-size: 18px; letter-spacing: -.01em; }
.hero .pill span { font-size: 12px; font-weight: 600; opacity: .7; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px; min-width: 0; }
.tile b { display: block; font-size: 20px; font-weight: 750; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile span { color: var(--muted); font-size: 12px; }
.tile.bad b { color: var(--bad); } .tile.ok b { color: var(--ok); } .tile.warn b { color: var(--warn); }

h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; margin: 22px 4px 10px; display: flex; align-items: center; gap: 8px; }
h2 .count { background: var(--card2); color: var(--text); border-radius: 99px; padding: 1px 8px; font-size: 12px; letter-spacing: 0; }

/* списки */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 14px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%; background: none; border: 0; text-align: left; cursor: pointer; }
a.item { color: var(--text); }
.item + .item { border-top: 1px solid var(--line); }
.item:active { background: var(--card2); }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .r { text-align: right; flex: none; font-weight: 650; }
.time { width: 54px; flex: none; font-weight: 750; font-size: 17px; letter-spacing: -.02em; }
.time small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: 0; text-transform: uppercase; }
.chev { color: var(--faint); flex: none; width: 18px; height: 18px; }

.ava {
  width: 42px; height: 42px; border-radius: 14px; flex: none; display: grid; place-items: center;
  font-weight: 750; font-size: 15px; color: #10131a;
}

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; border-radius: 99px; padding: 3px 9px; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); } .b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); } .b-info { background: var(--info-bg); color: var(--info); }
.b-mute { background: var(--card2); color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 26px 16px; }
.empty .e { font-size: 34px; margin-bottom: 6px; }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer;
  height: 48px; padding: 0 18px; border-radius: 15px; font-weight: 700; font-size: 15px;
  background: var(--card2); color: var(--text); transition: transform .08s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--grad); color: #fff; }
.btn.dark { background: #fff; color: #b80000; }
.btn.ok { background: var(--ok-bg); color: var(--ok); }
.btn.bad { background: var(--bad-bg); color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { height: 36px; padding: 0 12px; border-radius: 11px; font-size: 13px; }
.btn svg { width: 18px; height: 18px; }
.btns { display: flex; gap: 10px; }
.btns > * { flex: 1; }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.action {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px 4px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 620; color: var(--text);
}
.action i { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--card2); }
.action:first-child i { background: var(--grad); color: #fff; }
.action svg { width: 19px; height: 19px; }

/* нижнее меню */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 12px);
  width: min(528px, calc(100% - 24px)); display: flex; padding: 6px; gap: 4px; z-index: 20;
  background: color-mix(in srgb, var(--card) 82%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px; border-radius: 16px;
  color: var(--muted); font-size: 11px; font-weight: 650; position: relative;
}
.tabs a svg { width: 22px; height: 22px; }
.tabs a.on { color: #fff; background: var(--grad); }
.tabs .dot { position: absolute; top: 4px; right: calc(50% - 18px); width: 8px; height: 8px; border-radius: 50%; background: var(--bad); border: 2px solid var(--card); }

.fab {
  position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(env(safe-area-inset-bottom) + 92px); z-index: 19;
  width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--grad); color: #fff;
  display: grid; place-items: center; box-shadow: 0 10px 28px rgba(184,0,0,.4); cursor: pointer;
}
.fab svg { width: 26px; height: 26px; }

/* формы */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin: 0 2px 6px; font-weight: 600; }
.input {
  width: 100%; height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--card2);
  padding: 0 14px; outline: none; font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.seg { display: flex; background: var(--card2); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; height: 40px; border: 0; background: none; border-radius: 11px; font-weight: 650; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.days button { height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); font-weight: 700; cursor: pointer; text-transform: uppercase; font-size: 13px; }
.days button.on { background: var(--grad); color: #fff; border-color: transparent; }
.photo-pick {
  display: flex; align-items: center; gap: 12px; padding: 12px; border: 1.5px dashed var(--line); border-radius: 16px;
  cursor: pointer; margin-bottom: 14px; color: var(--muted); font-weight: 600;
}
.photo-pick img { width: 56px; height: 56px; object-fit: cover; border-radius: 12px; }
.photo-pick i { width: 56px; height: 56px; border-radius: 12px; display: grid; place-items: center; background: var(--card2); flex: none; }
.search { position: relative; margin-bottom: 14px; }
.search svg { position: absolute; left: 14px; top: 15px; width: 20px; height: 20px; color: var(--muted); }
.search .input { padding-left: 44px; }

/* шторка снизу */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; opacity: 0; transition: opacity .2s; }
.backdrop.show { opacity: 1; }
.sheet {
  position: fixed; left: 50%; bottom: 0; width: min(560px, 100%); z-index: 41; max-height: 92dvh; overflow-y: auto;
  background: var(--card); border-radius: 26px 26px 0 0; padding: 10px 18px calc(env(safe-area-inset-bottom) + 20px);
  transform: translate(-50%, 100%); transition: transform .26s cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow);
}
.sheet.show { transform: translate(-50%, 0); }
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.01em; }
.sheet .hint { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.sheet .stack { display: grid; gap: 10px; }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 14px); transform: translate(-50%, calc(-100% - 40px)); visibility: hidden;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 650; z-index: 60;
  transition: transform .25s cubic-bezier(.2,.8,.2,1); width: max-content; max-width: calc(100% - 32px); text-align: center; box-shadow: var(--shadow);
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }

/* клиент */
.ringwrap { display: flex; align-items: center; gap: 18px; }
.ring { width: 96px; height: 96px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .v { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1; }
.ring .v b { font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.ring .v span { display: block; font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 3px; }
.next { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.next .cal {
  width: 64px; height: 68px; border-radius: 18px; background: rgba(255,255,255,.14); display: flex; flex-direction: column;
  align-items: center; justify-content: center; flex: none; line-height: 1.05;
}
.next .cal b { font-size: 26px; font-weight: 800; }
.next .cal span { font-size: 12px; font-weight: 700; text-transform: uppercase; opacity: .75; }
.chart { width: 100%; height: 150px; display: block; }
.delta { font-size: 12px; font-weight: 700; }
.delta.down { color: var(--ok); } .delta.up { color: var(--bad); }
.thumb { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; flex: none; background: var(--card2); cursor: zoom-in; }
.viewer { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 20px; }
.viewer img { max-width: 100%; max-height: 100%; border-radius: 12px; }

.login { min-height: 80dvh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 10px; padding: 0 24px; }
.login .logo { width: 88px; height: 88px; border-radius: 26px; margin-bottom: 8px; box-shadow: 0 14px 40px rgba(184, 0, 0, .3); }
.login h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.login p { color: var(--muted); margin: 0; max-width: 320px; }

.copy { display: flex; gap: 8px; align-items: center; background: var(--card2); border-radius: 14px; padding: 10px 10px 10px 14px; margin-bottom: 10px; }
.copy code { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.muted { color: var(--muted); }
.mt0 { margin-top: 0; }
.fade { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.skeleton { height: 120px; border-radius: var(--r); background: linear-gradient(90deg, var(--card) 0%, var(--card2) 50%, var(--card) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

.plain { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: inherit; }
.top h1.greet { font-size: 21px; line-height: 1.25; letter-spacing: -.01em; }
