/* Seyidov Group · Строительство
   Палитра: бетон, графит и один сигнальный жёлтый (только для главного действия). */
:root {
  --bg: #F3F4F5;          /* бетон */
  --card: #FFFFFF;
  --ink: #1D2530;         /* графит */
  --ink-2: #3A4350;
  --muted: #69727D;
  --line: #E2E5E9;
  --line-2: #D3D8DE;
  --signal: #F2B705;      /* сигнальный жёлтый */
  --signal-ink: #1D2530;
  --signal-hover: #E0A800;
  --pos: #1E7A4C;
  --neg: #C0392B;
  --neg-bg: #FCEEEC;
  --pos-bg: #E8F4EE;
  --info-bg: #EAF0F6;
  --t-material: #4C6B8A;  /* сталь */
  --t-labor: #A8690F;     /* охра */
  --t-equipment: #66703A; /* олива */
  --t-other: #7A828C;
  --r-s: 6px;
  --r: 10px;
  --focus: 0 0 0 3px rgba(242, 183, 5, .45);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.015em; margin: 1.25rem 0 .75rem; line-height: 1.2; }
h2 { font-size: 1.05rem; font-weight: 650; margin: 2rem 0 .65rem; }
p { max-width: 75ch; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.r { text-align: right; white-space: nowrap; }
.dim { opacity: .55; }
.neg { color: var(--neg); }
.pos { color: var(--pos); }

/* иконки */
.ic { width: 1.2em; height: 1.2em; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.24em; }
.ic-sm { width: 1em; height: 1em; vertical-align: -.14em; }
a > .ic:first-child, .btn > .ic:first-child, .lbl-ic > .ic:first-child { margin-right: .4em; }

/* ---------- каркас: слева меню (компьютер), снизу вкладки (телефон) ---------- */
:root { --side-w: 252px; --tab-h: 62px; }
.brand-mark { display: inline-block; width: 10px; height: 20px; background: var(--signal); border-radius: 2px; flex-shrink: 0; }

/* боковое меню */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 20;
  background: var(--ink); color: #fff; display: flex; flex-direction: column; gap: 4px;
  padding: 18px 12px 12px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 2px 8px 14px; }
.brand-text { display: grid; line-height: 1.2; }
.brand b { font-weight: 700; letter-spacing: .01em; }
.brand-sub { color: #8E98A4; font-size: .85rem; }
.side-object { display: grid; gap: 6px; padding: 12px 10px; margin: 0 0 6px; border-radius: var(--r-s); background: #252E3A; }
.side-object-name { display: flex; gap: 8px; align-items: flex-start; font-weight: 700; line-height: 1.3; }
.side-object-name .ic { color: var(--signal); margin-top: 1px; }
.side-object-name small { display: block; font-weight: 400; color: #8E98A4; }
.side-switch { color: #8E98A4; font-size: .84rem; text-decoration: none; display: inline-flex; align-items: center; padding-left: 26px; }
.side-switch:hover { color: #fff; }
.side-nav { display: grid; gap: 1px; }
.side-nav a, .side-user a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r-s);
  color: #B9C1CB; text-decoration: none; font-size: .95rem; position: relative;
}
.side-nav a .ic, .side-user a .ic { margin: 0; }
.side-nav a:hover, .side-user a:hover { background: #252E3A; color: #fff; }
.side-nav a.on { background: #2B3542; color: #fff; font-weight: 600; }
.side-nav a.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--signal); }
.side-group { color: #6F7985; font-size: .8rem; padding: 16px 10px 4px; }
.side-user { margin-top: auto; padding-top: 12px; border-top: 1px solid #2C3644; display: flex; align-items: center; gap: 4px; }
.side-user a:first-child { flex: 1; min-width: 0; }
.side-user a span { display: grid; line-height: 1.25; overflow: hidden; }
.side-user small { color: #8E98A4; font-size: .78rem; }
.side-user a.on { color: #fff; }
.side-logout { flex: 0 0 auto; }

.with-nav .shell { margin-left: var(--side-w); }
.mtop, .tabbar { display: none; }
.no-nav .mtop { display: flex; }

/* верхняя полоса телефона */
.mtop {
  position: sticky; top: 0; z-index: 15; align-items: center; gap: 4px; min-height: 52px;
  padding: 0 6px 0 16px; padding-top: env(safe-area-inset-top);
  background: var(--ink); color: #fff;
}
.mtop-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.02rem; }
.mtop-title > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mtop-plain .brand-sub { font-weight: 400; margin-left: 4px; }
.mtop-btn { display: grid; place-items: center; width: 44px; height: 44px; color: #C9D0D8; border-radius: var(--r-s); }
.mtop-btn:hover { color: #fff; }
.mtop-btn .ic { width: 22px; height: 22px; }

/* нижние вкладки */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(29, 37, 48, .06);
}
.tab {
  flex: 1 1 0; min-width: 0; display: grid; justify-items: center; align-content: center; gap: 3px;
  height: var(--tab-h); color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600; position: relative;
}
.tab .ic { width: 24px; height: 24px; margin: 0 !important; }
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.tab.on { color: var(--ink); }
.tab.on::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--signal); }

/* панель «Ещё» */
.sheet { position: fixed; inset: 0; z-index: 30; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(29, 37, 48, .45); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 80vh; overflow-y: auto;
  background: var(--card); border-radius: 14px 14px 0 0; padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
  animation: sheet-up .18s ease-out;
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 4px auto 10px; }
.sheet-nav { display: grid; }
.sheet-nav a { display: flex; align-items: center; gap: 14px; padding: 13px 10px; color: var(--ink); text-decoration: none; font-weight: 500; border-radius: var(--r-s); }
.sheet-nav a .ic { color: var(--muted); margin: 0; }
.sheet-nav a.on { background: var(--bg); font-weight: 700; }
.sheet-nav a.on .ic { color: var(--ink); }
.sheet .side-group { color: var(--muted); padding: 12px 10px 4px; border-top: 1px solid var(--line); margin-top: 6px; }
.sheet-nav:last-child { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
body.sheet-open { overflow: hidden; }

@media (max-width: 899px) {
  .side { display: none; }
  .with-nav .shell { margin-left: 0; }
  .mtop { display: flex; }
  .tabbar { display: flex; }
  .with-nav main { padding-bottom: calc(var(--tab-h) + 32px + env(safe-area-inset-bottom)); }
  .with-nav .foot { display: none; }
}
@media (min-width: 900px) {
  .sheet { display: none !important; }
  .shell .wrap { max-width: 1120px; padding: 0 28px; margin: 0; }
  .shell main { padding-top: 8px; }
}
main { padding-bottom: 48px; }
.foot { color: var(--muted); font-size: .8rem; padding: 24px 16px 40px; }

/* ---------- блоки ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 12px 0; }
.card.warn { border-left: 3px solid var(--signal); }
.flash { padding: 10px 14px; border-radius: var(--r-s); margin: 12px 0; border-left: 3px solid; max-width: 820px; }
.flash-ok { background: var(--pos-bg); color: #155C39; border-color: var(--pos); }
.flash-err { background: var(--neg-bg); color: #8E2A20; border-color: var(--neg); }
.flash-info { background: var(--info-bg); color: #2F4A66; border-color: var(--t-material); }
.flash a { color: inherit; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 16px; border-radius: var(--r-s); border: 1px solid var(--line-2);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  min-height: 44px; text-decoration: none; transition: background-color .12s, border-color .12s;
}
.btn:hover { border-color: var(--ink-2); }
.btn-primary { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn-primary:hover { background: var(--signal-hover); border-color: var(--signal-hover); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { border-color: var(--line-2); }
.btn-danger { color: var(--neg); border-color: #EDC5C0; }
.btn-danger:hover { background: var(--neg-bg); border-color: var(--neg); }
.btn-danger-text { color: var(--neg); }
.btn-wide { width: 100%; }
.btn-big { width: 100%; font-size: 1.1rem; min-height: 56px; margin-top: 16px; }
.btn.small, .tbl td .btn.small { min-height: 34px; padding: 5px 12px; font-size: .86rem; }
.btn:disabled { opacity: .6; cursor: wait; }
.actions-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0; max-width: none; }
.actions-line form { margin: 0; }

/* ---------- формы ---------- */
.form { display: grid; gap: 16px; }
.form.narrow, .narrow { max-width: 580px; }
.form label { display: grid; gap: 5px; font-weight: 600; font-size: .92rem; }
.form label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea {
  font: inherit; font-size: 16px; width: 100%; padding: 10px 12px; border: 1px solid var(--line-2);
  border-radius: var(--r-s); background: #fff; color: var(--ink); min-height: 44px;
}
input::placeholder, textarea::placeholder { color: #A3AAB3; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: var(--focus); }
.input-amount { font-size: 1.35rem; font-weight: 700; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; min-width: 0; }
legend { font-weight: 600; font-size: .92rem; padding: 0; margin-bottom: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.seg legend { grid-column: 1 / -1; }
.seg-item { position: relative; }
.seg-item input { position: absolute; opacity: 0; }
.seg-item span { display: flex; align-items: center; justify-content: center; text-align: center; height: 100%; min-height: 44px; padding: 8px; font-weight: 600; font-size: .92rem; cursor: pointer; background: #fff; color: var(--ink-2); border: 1px solid var(--line-2); }
.seg-item:first-of-type span { border-radius: var(--r-s) 0 0 var(--r-s); }
.seg-item:last-of-type span { border-radius: 0 var(--r-s) var(--r-s) 0; border-left: 0; }
.seg-item input:checked + span { border-color: var(--ink); }
.seg-item input:checked + span { background: var(--ink); color: #fff; }
.seg-item input:focus-visible + span { box-shadow: inset var(--focus); }
fieldset.seg { padding: 0; }
.seg2 { grid-template-columns: 1fr 1fr !important; }
.file-label input { padding: 8px; }
.lbl-ic { display: inline-flex; align-items: center; gap: 0; }
.lbl { font-weight: 600; font-size: .92rem; }
.auth { max-width: 400px; margin: 40px auto; }
.new-item { display: grid; gap: 12px; background: #F8F9FA; border: 1px solid var(--line); border-left: 3px solid var(--signal); border-radius: var(--r-s); padding: 12px; }
.new-item .new-item { border-left-color: var(--line-2); background: #fff; }
.debt-box { display: grid; gap: 8px; border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; }
#calc-hint { font-weight: 400; }

/* фильтры, переключатели */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select, .filters input { width: auto; flex: 1 1 180px; }
.month-switch { display: flex; align-items: center; gap: 4px; margin: 16px 0 8px; flex-wrap: wrap; }
.month-switch strong { font-size: 1.1rem; min-width: 150px; text-align: center; }
.month-switch .btn { min-width: 44px; padding: 4px 10px; }
.period-switch { margin: 14px 0; }
.period-switch select { max-width: 520px; font-weight: 600; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.tabs a { display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); font-weight: 600; font-size: .9rem; text-decoration: none; }
.tabs a:hover { border-color: var(--ink-2); }
.tabs a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.house-tabs { margin-top: 4px; }

/* ---------- цифры ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 3px; align-content: start; color: var(--ink); text-decoration: none; }
a.stat:hover { border-color: var(--ink-2); }
.stat span { color: var(--muted); font-size: .84rem; }
.stat b { font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; }
.stat em { font-style: normal; color: var(--muted); font-size: .8rem; }
.stat-main { background: var(--ink); color: #fff; border-color: var(--ink); grid-column: span 2; position: relative; overflow: hidden; }
.stat-main::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--signal); }
.stat-main span, .stat-main em { color: #AEB6C0; }
.stat-main b { font-size: 1.75rem; }
.stat-neg { border-color: #EDC5C0; }
.stat-neg b { color: var(--neg); }
.stat-main-neg::before { background: var(--neg); }
@media (max-width: 440px) { .stat-main { grid-column: 1 / -1; } .stats { grid-template-columns: 1fr 1fr; } }

.bar { display: block; height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; min-width: 60px; margin: 6px 0 2px; }
.bar i { display: block; height: 100%; background: var(--pos); }
.bar.over i { background: var(--neg); }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: .82rem; color: var(--muted); font-weight: 600; background: #FAFBFB; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #FAFBFB; }
.tbl tfoot th { color: var(--ink); font-size: .93rem; border-top: 1px solid var(--line-2); border-bottom: 0; background: #FAFBFB; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl td input { min-height: 38px; padding: 6px 10px; }
.tbl a { text-decoration: none; }
.tbl a:hover { text-decoration: underline; }
.row-common td { color: var(--muted); }

/* ---------- список расходов ---------- */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list-month { display: flex; justify-content: space-between; padding: 10px 14px; background: #FAFBFB; border-bottom: 1px solid var(--line); font-weight: 700; }
.exp { display: flex; justify-content: space-between; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.exp:last-child { border-bottom: 0; }
.exp:hover { background: #FAFBFB; }
.exp-main { display: grid; gap: 2px; min-width: 0; }
.exp-title { font-weight: 600; overflow-wrap: anywhere; }
.exp-detail { font-size: .88rem; color: var(--ink-2); }
.exp-meta { font-size: .8rem; color: var(--muted); }
.exp-sum { font-weight: 700; white-space: nowrap; }

/* категория: цветная точка + подпись */
.tag { display: inline-flex; align-items: center; gap: 6px; justify-self: start; font-size: .78rem; font-weight: 600; color: var(--muted); --c: var(--t-other); }
.tag::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c); }
.tag-material { --c: var(--t-material); }
.tag-labor { --c: var(--t-labor); }
.tag-equipment { --c: var(--t-equipment); }
.debt-badge { display: inline-block; justify-self: start; font-size: .78rem; font-weight: 600; padding: 1px 8px; border-radius: 4px; background: var(--neg-bg); color: #8E2A20; }
.debt-badge.paid { background: var(--pos-bg); color: #155C39; }

/* карточка записи */
.detail h1 { margin: .3rem 0; }
.big-sum { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 10px; }
.detail dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }
@media (max-width: 480px) { .detail dl { grid-template-columns: 1fr; gap: 0; } .detail dd { margin-bottom: 10px; } }

/* фото */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.gallery img { width: 100%; height: 220px; object-fit: cover; border-radius: var(--r-s); display: block; background: var(--line); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: var(--r-s); display: block; background: var(--line); }
.thumb-del { display: grid !important; gap: 4px; font-weight: 400 !important; font-size: .8rem !important; }
.thumb-del span { display: flex; gap: 4px; align-items: center; }
.photos-edit { display: grid; gap: 6px; }

/* ---------- выбор объекта ---------- */
.cottages { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.cottage-card { display: grid; gap: 6px; align-content: start; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; color: var(--ink); text-decoration: none; border-top: 3px solid var(--ink); }
.cottage-card:hover { border-color: var(--ink-2); border-top-color: var(--signal); }
.cc-name { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.12rem; margin-bottom: 2px; }
.cc-name .ic { color: var(--muted); }
.cc-addr, .cc-small { color: var(--muted); font-size: .85rem; }
.cc-row { display: flex; justify-content: space-between; gap: 8px; font-size: .93rem; }
.cc-row span { color: var(--muted); }
.cc-row b.neg { color: var(--neg); }

/* ---------- разделы объекта ---------- */
.sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 10px; margin: 12px 0; }
.section-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 12px; }
.sc-head { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; color: var(--ink); text-decoration: none; }
.sc-icon { grid-row: span 3; align-self: start; width: 42px; height: 42px; display: grid; place-items: center; border-radius: var(--r-s); background: color-mix(in srgb, var(--c, var(--t-other)) 12%, white); color: var(--c, var(--t-other)); }
.sc-icon .ic { width: 22px; height: 22px; }
.section-card:nth-child(1) { --c: var(--t-material); }
.section-card:nth-child(2) { --c: var(--t-labor); }
.section-card:nth-child(3) { --c: var(--t-equipment); }
.section-card:nth-child(4) { --c: var(--t-other); }
.sc-title { font-weight: 600; color: var(--ink-2); }
.sc-head b { font-size: 1.25rem; }
.sc-add { min-height: 40px; }
.sc-add.btn-primary { background: var(--card); border-color: var(--line-2); color: var(--ink); }
.sc-add.btn-primary:hover { background: var(--card); border-color: var(--ink-2); }

/* ---------- долги ---------- */
.debt-list { display: grid; }
.debt-item { margin: 0 0 10px; display: grid; gap: 12px; border-left: 3px solid var(--neg); }
.debt-top { display: flex; justify-content: space-between; gap: 12px; }
.debt-sum { font-weight: 800; font-size: 1.15rem; white-space: nowrap; color: var(--neg); }
.debt-pay { display: flex; flex-wrap: wrap; gap: 8px; }
.debt-pay select, .debt-pay input { width: auto; flex: 1 1 170px; }
form.inline { display: inline; }

@media (max-width: 560px) {
  .sections { grid-template-columns: 1fr 1fr; gap: 8px; }
  .section-card { padding: 12px; gap: 10px; }
  .sc-head { grid-template-columns: 1fr; row-gap: 2px; }
  .sc-icon { grid-row: auto; width: 34px; height: 34px; margin-bottom: 4px; }
  .sc-icon .ic { width: 19px; height: 19px; }
  .sc-head b { font-size: 1.08rem; }
  .sc-add { min-height: 36px; padding: 6px 10px; font-size: .9rem; }
  h1 { font-size: 1.35rem; }
  .tbl th, .tbl td { padding: 9px 10px; }
  .tbl td:first-child { white-space: nowrap; }
}
@media (min-width: 700px) {
  .btn-big { width: auto; padding: 0 32px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
