:root {
    --bg: #f4f6f5;
    --card: #ffffff;
    --ink: #16211c;
    --muted: #6b7a73;
    --line: #e2e8e5;
    --accent: #0f7a4d;
    --accent-ink: #ffffff;
    --warn: #c2410c;
    --danger: #b91c1c;
    --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overscroll-behavior-y: contain;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
}

/* ─────────── шапка ─────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
    background: var(--accent);
    color: var(--accent-ink);
}

.topbar h1 {
    flex: 1;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    color: inherit;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.icon-btn:active { background: rgba(255, 255, 255, .3); }

/* ─────────── контент ─────────── */

main {
    flex: 1;
    padding: 12px 12px 88px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: 0 1px 2px rgba(16, 32, 24, .06);
}

.card h2 {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
}

.empty,
.hint {
    color: var(--muted);
    font-size: 14px;
    text-align: center;
    padding: 24px 8px;
}

.row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

.muted { color: var(--muted); font-size: 13px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }

/* ─────────── заявки ─────────── */

.ticket {
    display: block;
    background: var(--card);
    border-radius: var(--radius);
    padding: 12px 14px;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 2px rgba(16, 32, 24, .06);
}

.ticket:active { background: #eef3f0; }

.ticket .head {
    display: flex;
    gap: 8px;
    align-items: baseline;
    justify-content: space-between;
}

.ticket .num { font-weight: 700; font-size: 15px; }
.ticket .addr { font-size: 15px; margin-top: 2px; }
.ticket .sub { font-size: 13px; color: var(--muted); margin-top: 2px;
    overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: #eef3f0;
    color: var(--accent);
    white-space: nowrap;
}

.badge.new { background: #e0f2fe; color: #075985; }
.badge.in_progress { background: #fef3c7; color: #92400e; }
.badge.closed { background: #e5e7eb; color: #4b5563; }
.badge.emergency { background: #fee2e2; color: var(--danger); }
.badge.urgent { background: #ffedd5; color: var(--warn); }

/* ─────────── вкладки и поиск ─────────── */

.segmented {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: #e8edea;
    border-radius: 999px;
    overflow-x: auto;
    scrollbar-width: none;
}

.segmented::-webkit-scrollbar { display: none; }

.segmented button {
    flex: 1;
    min-width: max-content;
    padding: 8px 12px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.segmented button.active {
    background: var(--card);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(16, 32, 24, .12);
}

input, textarea, select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    color: var(--ink);
    font: inherit;
    font-size: 16px;
}

textarea { min-height: 96px; resize: vertical; }

input:focus, textarea:focus, select:focus {
    outline: 2px solid rgba(15, 122, 77, .35);
    border-color: var(--accent);
}

label.field {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin: 10px 0 4px;
}

/* ─────────── кнопки ─────────── */

button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 14px 16px;
    border: 0;
    border-radius: 14px;
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

button.btn:active { filter: brightness(.94); }
button.btn.ghost { background: #e8edea; color: var(--ink); }
button.btn.danger { background: #fde8e8; color: var(--danger); }
button.btn:disabled { opacity: .55; }

button.btn.small {
    width: auto;
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 10px;
}

/* ─────────── финансы ─────────── */

.money {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.money .cell {
    background: var(--card);
    border-radius: 14px;
    padding: 12px;
}

.money .cell span { display: block; color: var(--muted); font-size: 12px; }
.money .cell b { font-size: 18px; }

ul.list { list-style: none; margin: 0; padding: 0; }

ul.list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}

ul.list li:last-child { border-bottom: 0; }

/* ─────────── фото ─────────── */

.gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.gallery a {
    display: block;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    background: #e8edea;
}

.gallery img { width: 100%; height: 100%; object-fit: cover; }

/* ─────────── нижние вкладки ─────────── */

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    background: var(--card);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 20;
}

.tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 10px;
    color: var(--muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
}

.tabbar a span { font-size: 20px; line-height: 1; }
.tabbar a.active { color: var(--accent); }

/* ─────────── тост ─────────── */

.toast {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(80px + env(safe-area-inset-bottom));
    max-width: 88vw;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(22, 33, 28, .92);
    color: #fff;
    font-size: 14px;
    z-index: 50;
    transition: opacity .2s;
}

/* ─────────── вход ─────────── */

.login {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 24px;
}

.login .chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.login .chips button {
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    color: var(--ink);
    font: inherit;
    font-size: 15px;
    cursor: pointer;
}

.login .chips button.active {
    border-color: var(--accent);
    background: #e6f4ec;
    color: var(--accent);
    font-weight: 600;
}
