:root {
  --bg: #F2F4F6; --surface: #fff; --ink: #281b15; --muted: #5A6672; --line: #DCE1E7;
  --brand: orangered; --brand-dark: #9f2200; --debt: #B0352A; --ok: #2C7A4B; --frozen: #2B5EA7; --left: #6F7882;
  --radius: 6px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 32px 0 12px; font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

body.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--ink); padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.side .brand { color: #fff; font-weight: 700; font-size: 20px; padding: 4px 12px 18px; letter-spacing: -0.01em; }
.side a:not(.brand) { color: #C9D2DB; padding: 8px 12px; border-radius: var(--radius); }
.side a:not(.brand):hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.side a.on { background: var(--brand); color: #fff; }
.side .logout { margin-top: auto; }
.linkbtn { background: none; border: 0; color: #9AA6B2; padding: 8px 12px; font: inherit; cursor: pointer; }
.linkbtn:hover { color: #fff; }

.main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; }
body.guest .main { max-width: 380px; margin: 12vh auto; }
.auth-title { font-size: 30px; margin-bottom: 20px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 .badge { vertical-align: middle; margin-left: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.figures > div { padding: 16px 18px; border-left: 1px solid var(--line); }
.figures > div:first-child { border-left: 0; }
.figures .lbl { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.figures b { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.figures b small { font-size: 13px; font-weight: 500; color: var(--muted); }
.figures b .meter-n { font-size: 13px; font-weight: 500; color: var(--muted); }
.info { display: flex; flex-wrap: wrap; gap: 8px 32px; margin: 16px 0 4px; }
.info .lbl { color: var(--muted); font-size: 13px; margin-right: 8px; }

.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-weight: 500; font-size: 13px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FAFBFC; white-space: nowrap; }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tfoot td { border-top: 2px solid var(--line); font-weight: 600; background: #FAFBFC; }
.tbl .num, .num { text-align: right; white-space: nowrap; }
.tbl.narrow, .form.narrow, .narrow { max-width: 620px; }
tr.dim td { opacity: .6; }
.scroll { overflow-x: auto; }
.strong { font-weight: 600; }
.muted { color: var(--muted); }
.debt { color: var(--debt); }
.ok { color: var(--ok); }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; max-width: 70ch; }
.empty { color: var(--muted); padding: 18px 0; }

.meter { display: inline-flex; gap: 2px; vertical-align: middle; }
.meter i { width: 6px; height: 14px; background: var(--line); border-radius: 1px; }
.meter i.on { background: var(--brand); }
.meter-n { color: var(--muted); font-size: 13px; margin-left: 4px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: #E4F0E9; color: var(--ok); }
.badge.frozen { background: #E2EAF6; color: var(--frozen); }
.badge.left { background: #ECEEF0; color: var(--left); }
.chip { display: inline-block; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px; font-size: 13px; margin: 0 4px 4px 0; }

.btn { display: inline-block; font: inherit; font-weight: 500; padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.btn:hover { background: #F5F7F9; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--debt); border-color: var(--debt); color: #fff; }
.btn.danger-ghost { color: var(--debt); border-color: #E3C3BF; background: transparent; }

.form label { display: block; font-size: 13px; color: var(--muted); }
.form input:not([type=checkbox]), .form select, .filters input:not([type=checkbox]), .filters select {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid #C5CCD4; border-radius: var(--radius); }
.form.stack { display: grid; gap: 14px; }
.form.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; max-width: 720px; }
.span2 { grid-column: 1 / -1; }
.form.inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
.form.inline h3 { flex-basis: 100%; margin: 0; }
.form.inline label { flex: 1 1 160px; }
.form.inline .muted { flex-basis: 100%; font-size: 13px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; flex: 0 0 auto; }
label.check input { width: auto; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters input:not([type=checkbox]), .filters select { width: auto; min-width: 180px; margin-top: 0; }
.filters label { font-size: 13px; color: var(--muted); }
.filters label.check { padding-bottom: 9px; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: #E8F3EC; border-color: #BBD9C6; color: #1F5A38; }
.flash.error { background: #FBEAE8; border-color: #EBC1BC; color: #8A2A20; }

@media (max-width: 860px) {
  body.app { display: block; }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; align-items: center; }
  .side .brand { padding: 4px 12px; }
  .side .logout { margin: 0 0 0 auto; }
  .main { padding: 20px 16px 48px; }
  .figures { grid-template-columns: 1fr 1fr; }
  .figures > div:nth-child(3) { border-left: 0; }
  .figures > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .form.grid2 { grid-template-columns: 1fr; }
}

.lang { display: inline-flex; border: 1px solid rgba(255,255,255,.25); border-radius: var(--radius); overflow: hidden; margin: 0 12px 8px; }
.lang a { padding: 3px 12px; font-size: 13px; font-weight: 600; color: #C9D2DB; text-decoration: none; }
.lang a.on { background: #fff; color: var(--ink); }
.side-bottom { margin-top: auto; display: flex; flex-direction: column; }
.side .logout { margin-top: 0; }
body.guest .lang { border-color: var(--line); margin: 0 0 20px; }
body.guest .lang a { color: var(--muted); }
body.guest .lang a.on { background: var(--ink); color: #fff; }
@media (max-width: 860px) { .side-bottom { margin: 0 0 0 auto; flex-direction: row; align-items: center; } .lang { margin: 0 8px 0 0; } }


/* переключатель языка: две равные половины на всю ширину меню */
.side .lang { display: flex; margin: 0 12px 10px; }
.side .lang a { flex: 1; text-align: center; padding: 5px 0; }
@media (max-width: 860px) {
  .side .lang { margin: 0 8px 0 0; }
  .side .lang a { flex: none; padding: 3px 12px; }
}

.side .brand { display: flex; align-items: center; gap: 10px; }
.side .brand img { height: 32px; width: auto; }