/* Kelistik UI: дизайн-система поверх Pico */
:root {
  --k-bg: #f4f6fa; --k-card: #ffffff; --k-ink: #14181f; --k-muted: #6b7482; --k-line: #e6eaf0; --k-soft: #f0f3f8;
  --k-blue: #2563eb; --k-blue-dark: #1d4ed8; --k-blue-soft: #e8efff; --k-green: #16a34a; --k-green-soft: #e7f7ec;
  --k-orange: #f59e0b; --k-orange-soft: #fff3dc; --k-orange-ink: #b45309; --k-red: #dc2626; --k-red-soft: #fdecec;
  --k-violet: #7c3aed; --k-violet-soft: #f0e9ff; --k-gray: #64748b; --k-gray-soft: #eef2f6;
  --k-shadow: 0 6px 24px rgba(20,24,31,.06); --k-radius: 18px;
  --pico-font-size: 16px; --pico-border-radius: 12px; --pico-primary: var(--k-blue); --pico-primary-hover: var(--k-blue-dark);
  --pico-primary-background: var(--k-blue); --pico-primary-hover-background: var(--k-blue-dark); --pico-background-color: var(--k-bg);
  --pico-color: var(--k-ink); --pico-muted-color: var(--k-muted); --pico-muted-border-color: var(--k-line); --pico-card-background-color: var(--k-card);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --k-bg: #0f1319; --k-card: #171c24; --k-ink: #e9edf3; --k-muted: #98a2b3; --k-line: #262d38; --k-soft: #1d2430;
    --k-blue-soft: rgba(37,99,235,.2); --k-green-soft: rgba(22,163,74,.2); --k-orange-soft: rgba(245,158,11,.2); --k-orange-ink: #fbbf24;
    --k-red-soft: rgba(220,38,38,.2); --k-violet-soft: rgba(124,58,237,.22); --k-gray-soft: #232b37; --k-shadow: 0 6px 24px rgba(0,0,0,.35);
  }
}
html { background: var(--k-bg); }
body { background: var(--k-bg); color: var(--k-ink); }
main.container { padding-top: 1.2rem; padding-bottom: 5.5rem; max-width: 1080px; }
h2 { font-size: 1.6rem; letter-spacing: -.01em; margin-bottom: .6rem; }
h3 { font-size: 1.15rem; margin-bottom: .5rem; }
h4 { font-size: 1rem; margin: 0 0 .7rem; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--k-muted); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; word-break: break-all; }
.inline { display: inline; margin: 0; }
button.linklike { background: none; border: 0; padding: 0; color: var(--k-blue); cursor: pointer; font: inherit; width: auto; box-shadow: none; }
button.linklike:hover { text-decoration: underline; }
button.danger { color: var(--k-red); font-size: .8rem; }

/* --- шапка --- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--k-card); border-bottom: 1px solid var(--k-line); box-shadow: 0 2px 12px rgba(20,24,31,.04); }
.topbar-in { max-width: 1080px; margin: 0 auto; padding: 0 1rem; height: 60px; display: flex; align-items: center; gap: 1.2rem; }
.brand { font-weight: 800; font-size: 1.25rem; color: var(--k-blue); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.topnav { display: flex; gap: .2rem; margin-left: .5rem; }
.topnav a { padding: .45rem .8rem; border-radius: 10px; color: var(--k-muted); font-weight: 500; font-size: .95rem; }
.topnav a:hover { background: var(--k-soft); text-decoration: none; color: var(--k-ink); }
.topnav a.on { background: var(--k-blue-soft); color: var(--k-blue); font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .cta { padding: .5rem 1rem; border-radius: 10px; background: var(--k-blue); color: #fff; font-weight: 600; font-size: .92rem; white-space: nowrap; }
.topbar .cta:hover { background: var(--k-blue-dark); text-decoration: none; }
.topbar .user { display: flex; align-items: center; gap: .6rem; font-size: .9rem; color: var(--k-muted); }
.topbar .user:hover { text-decoration: none; color: var(--k-ink); }
.topbar .user .ava { width: 32px; height: 32px; font-size: .8rem; }
@media (max-width: 860px) { .topnav, .topbar .user span:not(.ava), .topbar .cta { display: none; } }

/* нижняя навигация на телефоне */
.bottomnav { display: none; }
@media (max-width: 860px) {
  .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--k-card); border-top: 1px solid var(--k-line); padding: .35rem 0 max(.35rem, env(safe-area-inset-bottom)); }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; color: var(--k-muted); padding: .2rem 0; }
  .bottomnav a svg { width: 22px; height: 22px; }
  .bottomnav a.on { color: var(--k-blue); }
  .bottomnav a.plus span.i { width: 44px; height: 44px; border-radius: 14px; background: var(--k-blue); color: #fff; display: grid; place-items: center; margin-top: -14px; box-shadow: 0 6px 16px rgba(37,99,235,.35); }
  .bottomnav a.plus span.i svg { width: 24px; height: 24px; }
  .bottomnav a:hover { text-decoration: none; }
}

/* --- сообщения --- */
.msg { padding: .7rem 1rem; margin-bottom: .9rem; border-radius: 12px; background: var(--k-card); border: 1px solid var(--k-line); border-left: 4px solid var(--k-blue); box-shadow: var(--k-shadow); }
.msg-success { border-left-color: var(--k-green); }
.msg-warning { border-left-color: var(--k-orange); }
.msg-error { border-left-color: var(--k-red); }
.msg-info { border-left-color: var(--k-blue); }

/* --- карточки --- */
.card, main article { background: var(--k-card); border: 1px solid var(--k-line); border-radius: var(--k-radius); box-shadow: var(--k-shadow); padding: 1.1rem 1.25rem; margin: 0 0 1rem; }
main article.msg { padding: .7rem 1rem; }
.card h4, main article h4 { display: flex; align-items: center; gap: .5rem; font-size: 1.02rem; }
.card h4 .sub { margin-left: auto; font-weight: 400; color: var(--k-muted); font-size: .82rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem; margin: .2rem 0 1rem; }
.page-head h2 { margin: 0; flex: 1; }
.page-head .sub { color: var(--k-muted); font-size: .92rem; width: 100%; margin-top: -.4rem; }
.page-head [role=button] { margin: 0; width: auto; padding: .5rem 1rem; }
.cards { display: grid; gap: .7rem; }
.section-title { display: flex; align-items: center; gap: .5rem; margin: 1.4rem 0 .6rem; font-size: 1rem; font-weight: 700; }
.section-title .cnt { background: var(--k-gray-soft); color: var(--k-muted); border-radius: 999px; padding: .05rem .55rem; font-size: .78rem; }
.section-title.overdue { color: var(--k-red); } .section-title.overdue .cnt { background: var(--k-red-soft); color: var(--k-red); }
.section-title.today { color: var(--k-orange-ink); } .section-title.today .cnt { background: var(--k-orange-soft); color: var(--k-orange-ink); }
.empty { color: var(--k-muted); text-align: center; padding: 1.5rem 1rem; margin: 0; }
.empty b { display: block; color: var(--k-ink); margin-bottom: .3rem; }

/* --- пилюли статусов --- */
.badge, .pill { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; vertical-align: middle; white-space: nowrap; }
.badge-draft { background: var(--k-gray-soft); color: var(--k-gray); }
.badge-pending { background: var(--k-orange-soft); color: var(--k-orange-ink); }
.badge-active { background: var(--k-green-soft); color: var(--k-green); }
.badge-overdue { background: var(--k-red-soft); color: var(--k-red); }
.badge-closed { background: var(--k-gray-soft); color: var(--k-gray); }
.badge-info { background: var(--k-blue-soft); color: var(--k-blue); }

/* --- аватары --- */
.ava { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: #fff; flex: 0 0 auto; overflow: hidden; }
.ava img { width: 100%; height: 100%; object-fit: cover; }
.ava.lg { width: 64px; height: 64px; font-size: 1.2rem; border-radius: 16px; }
.avatar { width: 72px; height: 96px; object-fit: cover; border-radius: 12px; }

/* --- карточка аренды --- */
.rc { display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; align-items: center; padding: .9rem 1.1rem; }
.rc .rc-title { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }
.rc .rc-title a { font-weight: 700; color: var(--k-ink); }
.rc .meta { color: var(--k-muted); font-size: .85rem; margin: .15rem 0 0; }
.rc .amt { font-weight: 700; white-space: nowrap; text-align: right; }
.rc .amt small { display: block; font-weight: 400; color: var(--k-muted); font-size: .76rem; }
.rc .bar { grid-column: 1 / -1; height: 5px; border-radius: 999px; background: var(--k-line); overflow: hidden; margin-top: -.3rem; }
.rc .bar div { height: 100%; border-radius: 999px; background: var(--k-green); }
.rc.overdue .bar div { background: var(--k-red); }
@media (max-width: 520px) { .rc { grid-template-columns: auto 1fr; } .rc .amt { grid-column: 2; text-align: left; } .rc .amt small { display: inline; margin-left: .4rem; } }

/* --- KPI (главная) --- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: 1rem; }
@media (max-width: 860px) { .kpis { grid-template-columns: 1fr 1fr; } }
.kpi { padding: .9rem 1rem; margin: 0; }
.kpi small { display: block; color: var(--k-muted); font-size: .78rem; }
.kpi b { display: block; font-size: 1.45rem; line-height: 1.2; margin-top: .15rem; white-space: nowrap; }
.kpi.red b { color: var(--k-red); } .kpi.orange b { color: var(--k-orange-ink); } .kpi.green b { color: var(--k-green); } .kpi.blue b { color: var(--k-blue); }
.hero-cta { display: flex; gap: .8rem; align-items: center; padding: 1rem 1.25rem; margin-bottom: 1rem; background: linear-gradient(135deg, #2563eb, #4f46e5); color: #fff; border: 0; }
.hero-cta .t { flex: 1; }
.hero-cta .t b { display: block; font-size: 1.15rem; }
.hero-cta .t small { opacity: .85; }
.hero-cta a { background: #fff; color: var(--k-blue); font-weight: 700; padding: .6rem 1.1rem; border-radius: 12px; white-space: nowrap; }
.hero-cta a:hover { text-decoration: none; opacity: .92; }

/* --- кнопки --- */
button, [role=button], input[type=submit] { border-radius: 12px; font-weight: 600; }
[role=button].secondary, button.secondary { background: var(--k-soft); color: var(--k-ink); border-color: var(--k-soft); }
[role=button].secondary:hover, button.secondary:hover { background: var(--k-line); border-color: var(--k-line); }
[role=button].outline, button.outline { background: transparent; color: var(--k-ink); border: 1px solid var(--k-line); }
[role=button].contrast, button.contrast { background: var(--k-ink); border-color: var(--k-ink); color: var(--k-card); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .6rem 0 1rem; }
.actions a, .actions button, .actions form { margin: 0; }
.actions form { display: inline; }
.actions [role=button], .actions button { padding: .5rem .95rem; font-size: .92rem; width: auto; }
.big-cta { font-size: 1.05rem; padding: .9rem; }

/* --- формы --- */
label { font-weight: 500; font-size: .92rem; }
input, select, textarea { border-radius: 12px; }
input:not([type=checkbox]):not([type=radio]), select, textarea { background: var(--k-card); }
label.check { display: flex; gap: .55rem; align-items: center; margin-bottom: .8rem; font-weight: 400; }
.req { color: var(--k-red); }
small.err { color: var(--k-red); display: block; margin-top: -.6rem; margin-bottom: .8rem; }
label > small { color: var(--k-muted); font-weight: 400; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
.who-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 1rem; margin-bottom: 1rem; }
.step-card h4 .n { width: 26px; height: 26px; border-radius: 50%; background: var(--k-blue); color: #fff; display: inline-grid; place-items: center; font-size: .82rem; }
.equip-list label { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .8rem; border: 1px solid var(--k-line); border-radius: 12px; margin-bottom: .45rem; font-weight: 500; cursor: pointer; }
.equip-list label:has(input:checked) { border-color: var(--k-blue); background: var(--k-blue-soft); }
.equip-list label input { margin-top: .2rem; flex: 0 0 auto; }
.equip-list small { display: block; color: var(--k-muted); font-weight: 400; }
.copybox { display: flex; gap: .5rem; }
.copybox input { margin: 0; }
.kv { width: 100%; }
.kv th { text-align: left; width: 38%; font-weight: 500; color: var(--k-muted); font-size: .88rem; }
.kv td, .kv th { padding: .35rem .3rem; border-bottom: 1px solid var(--k-line); vertical-align: top; }
.kv tr:last-child td, .kv tr:last-child th { border-bottom: 0; }
details summary { cursor: pointer; font-weight: 500; }
table { font-size: .92rem; }
thead th { color: var(--k-muted); font-weight: 500; font-size: .82rem; }

/* --- каталог / клиенты --- */
.item { display: flex; gap: .9rem; align-items: center; padding: .9rem 1.1rem; }
.item .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--k-blue-soft); color: var(--k-blue); display: grid; place-items: center; flex: 0 0 auto; font-weight: 700; font-size: .85rem; }
.item .b { flex: 1; min-width: 0; }
.item .b a { font-weight: 700; color: var(--k-ink); }
.item .meta { color: var(--k-muted); font-size: .84rem; margin: .1rem 0 0; overflow: hidden; text-overflow: ellipsis; }
.item .r { text-align: right; white-space: nowrap; font-weight: 700; }
.item .r small { display: block; color: var(--k-muted); font-size: .76rem; font-weight: 400; }
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.filters a { padding: .35rem .8rem; border-radius: 999px; background: var(--k-card); border: 1px solid var(--k-line); color: var(--k-muted); font-size: .86rem; }
.filters a.on { background: var(--k-blue); border-color: var(--k-blue); color: #fff; }
.filters a:hover { text-decoration: none; }
.search { display: flex; gap: .5rem; margin-bottom: .8rem; }
.search input { margin: 0; }
.search button { width: auto; margin: 0; }

/* --- фото --- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.photo-item { margin: 0; }
.photo-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; border: 1px solid var(--k-line); }
.photo-item figcaption { display: flex; justify-content: space-between; gap: .4rem; font-size: .78rem; margin-top: .2rem; }
.photo-form input[type=file] { margin-top: .3rem; }

/* --- карточка договора --- */
.rental-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.rental-hero .t { flex: 1; min-width: 200px; }
.rental-hero .t h2 { margin: 0 0 .2rem; }
.rental-hero .t .meta { color: var(--k-muted); font-size: .9rem; }
.rental-hero .money { text-align: right; }
.rental-hero .money b { display: block; font-size: 1.5rem; }
.rental-hero .money small { color: var(--k-muted); }
.rental-hero .timeline { width: 100%; }
.rental-hero .timeline .bar { height: 8px; border-radius: 999px; background: var(--k-line); overflow: hidden; }
.rental-hero .timeline .bar div { height: 100%; background: var(--k-green); }
.rental-hero .timeline.overdue .bar div { background: var(--k-red); }
.rental-hero .timeline .lbl { display: flex; justify-content: space-between; font-size: .78rem; color: var(--k-muted); margin-top: .25rem; }
.evidence { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .6rem; margin-bottom: .8rem; }
.evidence .ev { border: 1px solid var(--k-line); border-radius: 12px; padding: .6rem .8rem; font-size: .84rem; }
.evidence .ev small { display: block; color: var(--k-muted); font-size: .74rem; }
.evidence .ev b { display: block; margin-top: .1rem; }
.evidence .ev img { max-height: 70px; margin-top: .3rem; border-radius: 8px; background: #fff; border: 1px solid var(--k-line); }
.send-box { background: var(--k-blue-soft); border-color: transparent; }

/* --- вход / регистрация --- */
.auth { max-width: 440px; margin: 2.5rem auto; }
.auth .brand-big { text-align: center; margin-bottom: 1rem; }
.auth .brand-big .brand { font-size: 1.7rem; }
.auth .brand-big small { display: block; color: var(--k-muted); }
.auth h3 { text-align: center; }
.auth .foot { text-align: center; color: var(--k-muted); font-size: .88rem; margin-top: .8rem; }

/* --- подписание --- */
.steps-bar { list-style: none; display: flex; gap: .4rem; padding: 0; margin: .6rem 0 1rem; }
.steps-bar li { flex: 1; display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--k-muted); border-bottom: 3px solid var(--k-line); padding-bottom: .4rem; }
.steps-bar li span { width: 22px; height: 22px; border-radius: 50%; background: var(--k-line); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
.steps-bar li.cur { color: var(--k-blue); border-color: var(--k-blue); font-weight: 600; } .steps-bar li.cur span { background: var(--k-blue); }
.steps-bar li.done { color: var(--k-green); border-color: var(--k-green); } .steps-bar li.done span { background: var(--k-green); }
.contract-preview { background: #fff; color: #111; padding: 1rem 1.2rem; border-radius: 14px; border: 1px solid var(--k-line); font-size: .95rem; }
.contract-preview .photo { width: 60px; height: 78px; }
.contract-preview table { font-size: .85rem; }
.sig-pad { border: 2px dashed #9aa4b2; border-radius: 14px; background: #fff; touch-action: none; width: 100%; height: 180px; display: block; }
.sig-pad-big { height: 240px; }
.sig-tools { display: flex; justify-content: space-between; align-items: center; margin: .3rem 0 1rem; font-size: .9rem; }
.code-input { font-size: 1.6rem; letter-spacing: .4rem; text-align: center; }
.cam-box { position: relative; width: 100%; max-width: 360px; margin: 0 auto 1rem; aspect-ratio: 3/4; background: #111; border-radius: 16px; overflow: hidden; }
.cam-box video, .cam-box img { width: 100%; height: 100%; object-fit: cover; display: block; transform: scaleX(-1); }
.cam-box img { transform: none; }
.done-card { text-align: center; max-width: 520px; margin: 2rem auto; }
.done-card .ok { width: 64px; height: 64px; border-radius: 50%; background: var(--k-green-soft); color: var(--k-green); display: grid; place-items: center; margin: 0 auto .8rem; font-size: 1.8rem; }

.util { width: 80px; height: 8px; background: var(--k-line); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: .3rem; }
.util div { height: 100%; background: var(--k-green); }

/* --- ЭЦП через eGov mobile --- */
.eds-card { text-align: center; }
.eds-mobile { margin-bottom: 1rem; }
.eds-mobile small, .eds-qr small { display: block; margin-top: .4rem; }
.eds-qr img { width: 220px; height: 220px; border-radius: 12px; border: 1px solid var(--k-line); background: #fff; }
.eds-status { margin: 1rem 0 .3rem; color: var(--k-muted); }
.eds-status:not(:empty)::before { content: ""; display: inline-block; width: 12px; height: 12px; border: 2px solid var(--k-blue); border-right-color: transparent; border-radius: 50%; margin-right: .5rem; vertical-align: -1px; animation: eds-spin .8s linear infinite; }
@keyframes eds-spin { to { transform: rotate(360deg); } }
@media (min-width: 761px) { .eds-mobile { display: none; } }
@media (max-width: 760px) { .eds-qr { display: none; } }

button.outline.danger { color: var(--k-red); border-color: var(--k-red-soft); font-size: .92rem; padding: .5rem .95rem; width: auto; }
