/*
 * Оформление в стиле Windows 7 (Aero): стеклянное окно программы, вкладки,
 * рамки групп, списки «Таблица», кнопки, выноски с ошибками, окна сообщений.
 *
 * Классы .js-* и html.js включаются скриптом; без него всё работает
 * обычными ссылками и формами.
 */

/* ---------- Основа ---------- */

:root {
    --font: "Segoe UI", Tahoma, Arial, sans-serif;
    --text: #000;
    --muted: #6d6d6d;
    --link: #0066cc;
    --link-hover: #3399ff;
    --heading: #1e3287;
    --instruction: #003399;
    --face: #f0f0f0;

    /* Цвет стекла Aero («Небо») — у активного и неактивного окна. */
    --glass: rgba(104, 156, 218, .58);
    --glass-inactive: rgba(178, 202, 230, .5);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font: 13px/1.4 var(--font);
    color: var(--text);
    background: #0b4b90 url("wallpaper.svg") center / cover no-repeat fixed;
}

/* С 20:00 до 6:00 — ночной фон со звёздами (класс ставит скрипт в layout.php) */
html.night body {
    background-color: #020714;
    background-image: url("wallpaper-night.svg");
}

body.is-busy,
body.is-busy * {
    cursor: progress !important;
}

body.has-modal {
    overflow: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

h1,
h2,
p {
    margin: 0;
}

[hidden] {
    display: none !important;
}

.sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.ico {
    flex: none;
    display: inline-block;
    vertical-align: -3px;
}

.ico-16 { width: 16px; height: 16px; }
.ico-32 { width: 32px; height: 32px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.text-bad { color: #c00; }

/* ---------- Страница ---------- */

.page {
    padding: 14px 16px 16px;
}

.page--center {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Шапка: простая полоса цвета окон с названием, адресом и кнопками разделов */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 7px 16px;
    border-bottom: 1px solid #a0a0a0;
    background: var(--face);
    box-shadow: inset 0 -1px 0 #fff, 0 1px 6px rgba(0, 0, 0, .2);
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: #000;
    text-decoration: none;
}

.topbar__brand > span {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar__title,
.topbar__sub {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.topbar__title {
    color: var(--heading);
    font-size: 16px;
}

.topbar__sub {
    color: var(--muted);
}

.topbar__nav {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-left: auto;
}

/* Область окон: сначала сетка, затем скрипт переводит окна в свободное положение */
.desk {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 780px) 280px;
    gap: 16px;
    align-items: start;
    justify-content: center;
    max-width: 1076px;
    margin: 0 auto;
}

.desk__readings {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    width: 100%;
    max-width: 640px;
}

.desk__history {
    grid-column: 1 / -1;
    grid-row: 2;
}

.gadgets {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Свободные окна: координаты задаёт скрипт, сетка остаётся только для гаджетов */
.desk.is-free {
    display: block;
}

.desk.is-free > .gadgets {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
}

.desk.is-free > .win.is-free {
    position: absolute;
}

/* Гаджет рабочего стола: полупрозрачная панель со сведениями */
.gadget {
    padding: 10px 12px 12px;
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 8px;
    background:
        linear-gradient(rgba(255, 255, 255, .22), rgba(255, 255, 255, .06) 40px, rgba(255, 255, 255, 0)),
        rgba(8, 32, 68, .55);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 4px 14px rgba(0, 0, 0, .3);
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

.gadget__title {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 0 2px;
    font-size: 14px;
    font-weight: 600;
}

.gadget__sub {
    margin: 0 0 6px;
    color: rgba(255, 255, 255, .75);
}

.gadget .kv li {
    border-top: 1px solid rgba(255, 255, 255, .12);
    padding: 4px 0;
}

.gadget .kv__value small {
    color: rgba(255, 255, 255, .7);
}

.gadget .kv-total {
    border-top-color: rgba(255, 255, 255, .35);
}

.gadget__link {
    display: inline-block;
    margin-top: 4px;
    color: #a9dcff;
    text-decoration: none;
}

.gadget__link:hover {
    color: #fff;
    text-decoration: underline;
}

.foot {
    padding: 4px 16px 16px;
    color: rgba(255, 255, 255, .85);
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

/* ---------- Окно ---------- */

.win {
    --frame: var(--glass);
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0 7px 7px;
    border: 1px solid rgba(0, 0, 0, .72);
    border-radius: 7px;
    background:
        linear-gradient(112deg, transparent 0 18%, rgba(255, 255, 255, .16) 18.5% 21%, transparent 21.5% 27%,
            rgba(255, 255, 255, .1) 27.5% 28.5%, transparent 29% 70%, rgba(255, 255, 255, .1) 70.5% 73%, transparent 73.5%),
        linear-gradient(rgba(255, 255, 255, .5), rgba(255, 255, 255, .14) 34px, rgba(255, 255, 255, .06) 120px),
        var(--frame);
    -webkit-backdrop-filter: blur(7px) saturate(1.3);
    backdrop-filter: blur(7px) saturate(1.3);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .55),
        0 6px 26px rgba(0, 0, 0, .55);
}

/* Неактивное окно (открыт модальный диалог) — светлее и прозрачнее */
.win:not(.is-active) {
    --frame: var(--glass-inactive);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .45),
        0 3px 14px rgba(0, 0, 0, .38);
}

/* Мигание диалога при щелчке мимо него */
.win.is-flashing {
    animation: win-flash .5s steps(1) 3;
}

@keyframes win-flash {
    0% {
        --frame: var(--glass-inactive);
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45), 0 3px 14px rgba(0, 0, 0, .38);
    }
    50% {
        --frame: var(--glass);
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55), 0 6px 26px rgba(0, 0, 0, .55);
    }
}

/* Заголовок */
.win__title {
    position: relative;
    flex: none;
    display: flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 84px 0 2px;
    user-select: none;
}

.win--dialog .win__title {
    padding-right: 54px;
}

.win__caption {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 0 6px 0 2px;
    color: #000;
    /* Белое свечение под текстом, как в Aero */
    text-shadow: 0 0 9px #fff, 0 0 9px #fff, 0 0 6px #fff, 0 0 3px #fff;
}

.win:not(.is-active) .win__caption {
    color: rgba(0, 0, 0, .58);
}

.win__icon {
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, .8));
}

/* Кнопки заголовка */
.win__controls {
    position: absolute;
    top: -1px;
    right: 5px;
    display: flex;
}

html:not(.js) .win__controls {
    display: none;
}

.cb {
    position: relative;
    width: 26px;
    height: 19px;
    margin-left: -1px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 1px solid rgba(0, 0, 0, .58);
    border-top: 0;
    background: linear-gradient(rgba(255, 255, 255, .58), rgba(255, 255, 255, .3) 45%, rgba(0, 0, 0, .06) 50%, rgba(255, 255, 255, .2));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45);
}

.cb:first-child {
    border-bottom-left-radius: 5px;
}

.cb:last-child {
    border-bottom-right-radius: 5px;
}

.cb--close {
    width: 45px;
    background: linear-gradient(#ebac9c, #d77d67 45%, #c23a1f 50%, #c64b32 75%, #dd917d);
}

.win--dialog .cb--close {
    width: 43px;
}

.cb:hover {
    z-index: 1;
    background: linear-gradient(#cbe5fc, #a2ccf3 45%, #4a8cd8 50%, #5aa6ea 80%, #a4e3fc);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5), 0 0 9px 2px rgba(120, 200, 255, .75);
}

.cb--close:hover {
    background: linear-gradient(#fbc6b7, #ef8e74 45%, #e3391a 50%, #ea5b3c 75%, #f7b19d);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5), 0 0 11px 3px rgba(255, 120, 80, .75);
}

.cb:active {
    background: linear-gradient(#93b7dd, #6e98c8 45%, #23579a 50%, #2f6fb4 80%, #6db6e6);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, .45);
}

.cb--close:active {
    background: linear-gradient(#d99485, #c3644d 45%, #a2230b 50%, #ab3219 75%, #cc7863);
}

.cb:focus-visible {
    outline: 1px dotted #000;
    outline-offset: -3px;
}

.win:not(.is-active) .cb:not(:hover) {
    background: linear-gradient(rgba(255, 255, 255, .45), rgba(255, 255, 255, .22) 45%, rgba(255, 255, 255, .05) 50%, rgba(255, 255, 255, .15));
    border-color: rgba(0, 0, 0, .35);
}

.win:not(.is-active) .cb__glyph {
    opacity: .6;
}

.cb__glyph {
    width: 12px;
    height: 10px;
    pointer-events: none;
}

/* Клиентская область */
.win__client {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid rgba(40, 60, 90, .75);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .45);
}

.win__client--face {
    background: var(--face);
}

/* ---------- Вкладки ---------- */

.tabs {
    display: flex;
    flex-direction: column;
}

.tabs__list {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    padding-left: 2px;
    margin-bottom: -1px;
}

.tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 23px;
    margin-top: 2px;
    margin-right: -1px;
    padding: 0 9px;
    border: 1px solid #898c95;
    border-bottom: 0;
    border-radius: 3px 3px 0 0;
    background: linear-gradient(#f3f3f3 0%, #ebebeb 49%, #dddddd 50%, #d0d0d0 100%);
    color: #000;
    text-decoration: none;
    white-space: nowrap;
    cursor: default;
}

.tab:hover {
    z-index: 1;
    border-color: #3c7fb1;
    background: linear-gradient(#eaf6fd 0%, #d9f0fc 49%, #bee6fd 50%, #a7d9f5 100%);
}

.tab[aria-selected="true"] {
    z-index: 2;
    height: 26px;
    margin: 0 -3px 0 -2px;
    padding: 0 11px;
    border-color: #898c95;
    background: #fff;
}

.tab:first-child[aria-selected="true"] {
    margin-left: 0;
}

.tab:focus-visible {
    outline: none;
}

.tab:focus-visible::after {
    content: "";
    position: absolute;
    inset: 3px 4px 3px;
    outline: 1px dotted #000;
}

/* Вкладки диалога в одной ячейке сетки — размер окна не зависит от выбранной */
.tabs--stack {
    display: grid;
    grid-template-rows: auto 1fr;
}

.tabs--stack > .tabs__panel {
    grid-row: 2;
    grid-column: 1;
}

.tabs__panel.is-off {
    visibility: hidden;
}

.tabs__panel {
    flex: 1;
    min-width: 0;
    padding: 14px 16px 10px;
    border: 1px solid #898c95;
    background: #fff;
}

/* ---------- Элементы управления ---------- */

/* Кнопка */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 75px;
    height: 23px;
    padding: 0 12px;
    border: 1px solid #707070;
    border-radius: 3px;
    background: linear-gradient(#f2f2f2 0%, #ebebeb 49%, #dddddd 50%, #cfcfcf 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .75);
    color: #000;
    text-decoration: none;
    white-space: nowrap;
    cursor: default;
}

.btn:hover {
    border-color: #3c7fb1;
    background: linear-gradient(#eaf6fd 0%, #d9f0fc 49%, #bee6fd 50%, #a7d9f5 100%);
}

.btn:active {
    border-color: #2c628b;
    background: linear-gradient(#e5f4fc 0%, #c4e5f6 49%, #98d1ef 50%, #68b3db 100%);
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, .25), inset 0 0 0 1px rgba(255, 255, 255, .3);
}

.btn:focus-visible {
    outline: 1px dotted #000;
    outline-offset: -4px;
}

/* Крупная кнопка главного действия — «Отправить показания» */
.btn--lg {
    height: 32px;
    padding: 0 20px;
}

/* Кнопка по умолчанию: синяя рамка и плавная «пульсация» */
.btn--default {
    border-color: #3c7fb1;
    box-shadow: inset 0 0 0 1px #c3e3f7;
    animation: btn-pulse 1.8s ease-in-out infinite alternate;
}

.win:not(.is-active) .btn--default {
    animation: none;
}

@keyframes btn-pulse {
    from { background: linear-gradient(#eef7fd 0%, #e2eef6 49%, #d3e4f0 50%, #c4d9e9 100%); }
    to { background: linear-gradient(#e6f5fd 0%, #d3eefb 49%, #b4e0f9 50%, #9bd2f2 100%); }
}

.btn:disabled {
    border-color: #adb2b5;
    background: #f4f4f4;
    box-shadow: none;
    color: #838383;
    animation: none;
}

/* Ссылка-команда */
.link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--link);
    text-decoration: none;
    cursor: pointer;
}

.link:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* Поле ввода */
.tb {
    height: 23px;
    padding: 1px 4px;
    border: 1px solid;
    border-color: #abadb3 #dbdfe6 #e3e9ef #e2e3ea;
    border-radius: 2px;
    background: #fff;
    color: #000;
}

.tb:hover {
    border-color: #5794bf #b7d5ea #c7e2f1 #c5daed;
}

.tb:focus {
    outline: none;
    border-color: #3d7bad #a4c9e3 #b7d9ed #b5cfe7;
}

.tb--date {
    width: 140px;
}

.tb--price {
    width: 110px;
    text-align: right;
}

.field {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.field__unit {
    color: var(--muted);
    white-space: nowrap;
}

.field.is-invalid .tb {
    border-color: #d06060 #e4a5a5 #e8b4b4 #e4a5a5;
    background: #fffafa;
}

/* Выноска с ошибкой под полем — видна, пока поле в фокусе */
.fballoon {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 2px;
    z-index: 6;
    width: 250px;
    padding: 7px 10px 9px;
    border: 1px solid #767676;
    border-radius: 4px;
    background: linear-gradient(#fff, #e4e5f0);
    box-shadow: 2px 3px 6px rgba(0, 0, 0, .35);
    color: #575757;
    white-space: normal;
    text-align: left;
}

.fballoon::before,
.fballoon::after {
    content: "";
    position: absolute;
    border-style: solid;
    border-color: transparent;
}

.fballoon::before {
    top: -10px;
    left: 14px;
    border-width: 0 9px 10px;
    border-bottom-color: #767676;
}

.fballoon::after {
    top: -8px;
    left: 15px;
    border-width: 0 8px 9px;
    border-bottom-color: #fff;
}

.field.is-invalid:focus-within .fballoon {
    display: block;
}

html:not(.js) .field.is-invalid .fballoon {
    display: block;
    position: static;
    margin-top: 12px;
}

html:not(.js) .field.is-invalid {
    flex-wrap: wrap;
}

.fballoon__title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
    color: #000;
    font-weight: 600;
}

.fballoon__text {
    display: block;
}

/* Флажок */
.cbx {
    display: inline-flex;
    align-items: flex-start;
    gap: 6px;
    cursor: default;
}

.cbx--block {
    display: flex;
    margin: 10px 0 6px;
}

.cbx > span {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cbx input {
    appearance: none;
    flex: none;
    width: 13px;
    height: 13px;
    margin: 2px 0 0;
    border: 1px solid #8e8f8f;
    background: linear-gradient(135deg, #dcdcdc, #fbfbfb);
    box-shadow: inset 0 0 0 1px #f4f4f4;
}

.cbx:hover input {
    border-color: #3c7fb1;
    background: linear-gradient(135deg, #b9dff9, #eaf6fd);
    box-shadow: inset 0 0 0 1px #def2fd;
}

.cbx input:checked {
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 13'%3E%3Cpath d='M2.5 6.5l2.6 2.8L10.5 3' fill='none' stroke='%234a5f97' stroke-width='1.8'/%3E%3C/svg%3E"),
        linear-gradient(135deg, #dcdcdc, #fbfbfb);
}

.cbx:hover input:checked {
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 13'%3E%3Cpath d='M2.5 6.5l2.6 2.8L10.5 3' fill='none' stroke='%234a5f97' stroke-width='1.8'/%3E%3C/svg%3E"),
        linear-gradient(135deg, #b9dff9, #eaf6fd);
}

.cbx input:focus-visible {
    outline: 1px dotted #000;
    outline-offset: 1px;
}

/* Рамка группы */
.group {
    margin: 0 0 12px;
    padding: 6px 10px 10px;
    min-width: 0;
    border: 1px solid #d5dfe5;
    border-radius: 3px;
    box-shadow: inset 0 0 0 1px #fff, 0 0 0 1px #fff;
}

.group > legend {
    padding: 0 3px;
}

/* Сообщение со значком */
.note {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin: 4px 0;
}

.note .ico {
    vertical-align: 0;
}

/* Жёлтая информационная полоса */
.infobar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #ffffe1;
    border-bottom: 1px solid #c8c8a8;
}

.dlg-body .infobar {
    margin: 0 0 9px;
    border: 1px solid #c8c8a8;
}

/* ---------- Список «Таблица» (как в Проводнике) ---------- */

.lv {
    border: 1px solid #828790;
    background: #fff;
    overflow: auto;
    font-size: 14px;
}

.lv__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 1px;
    margin-top: -1px;
}

.lv__table th {
    position: sticky;
    top: 0;
    z-index: 1;
    height: 28px;
    padding: 0 10px 0 8px;
    border-right: 1px solid #e3e8ef;
    border-bottom: 1px solid #d5d5d5;
    background: linear-gradient(#fff 0%, #fff 55%, #f7f8f9 100%);
    color: #4c607a;
    font-weight: 400;
    text-align: left;
    white-space: nowrap;
}

.lv__table th.num {
    text-align: right;
}

.lv__table th .ico {
    margin-right: 4px;
}

.lv__table td {
    height: 27px;
    padding: 2px 10px 2px 8px;
    border: 1px solid transparent;
    border-width: 1px 0;
    vertical-align: middle;
}

.lv__table td:first-child {
    border-left-width: 1px;
    border-radius: 3px 0 0 3px;
}

.lv__table td:last-child {
    border-right-width: 1px;
    border-radius: 0 3px 3px 0;
}

.lv__table td .ico {
    margin-right: 5px;
}

.lv__row:hover td {
    background: linear-gradient(#fafbfd, #ebf3fd);
    border-color: #b8d6fb;
}

/* Выбранная строка (история цен — выбор для удаления) */
.lv__row:has(input:checked) td {
    background: linear-gradient(#dcebfc, #c1dbfc);
    border-color: #7da2ce;
}

.lv__row:has(input:checked):hover td {
    background: linear-gradient(#d3e6fc, #b6d4fa);
}

.lv__row.is-replaced td,
.lv__row.is-past td {
    color: #8d8d8d;
}

.lv__row.is-failed td {
    color: #b3261e;
}

.lv__note {
    margin-left: 4px;
    color: #8d8d8d;
    font-size: 12px;
}

.lv__note--info {
    color: #1e6ac8;
}

.lv__note--bad {
    color: #c00;
}

.lv__delta {
    margin-left: 3px;
    color: #4f8a10;
    font-size: 12px;
}

.lv__row.is-replaced .lv__delta {
    color: inherit;
}

.td-detail {
    display: none;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.lv--detail .td-detail {
    display: block;
}

.lv__pick {
    display: inline-flex;
    align-items: center;
    cursor: default;
}

.lv__pick input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.table-tools {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 6px;
}

.tm + .table-tools {
    margin-top: 10px;
}

.meters + .group {
    margin: 16px 0 0;
}

.table-more {
    margin-top: 8px;
}

.table-note {
    margin-top: 8px;
}

.panel-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.panel-foot__hint {
    flex: 1;
    min-width: 0;
}

/* Тело и подвал окна */
.win__body {
    padding: 12px 14px;
}

/* Окно «Вся история»: высота по экрану, прокручивается только таблица */
.win__body--scroll {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.win__body--scroll > * {
    flex: none;
}

.win__body--scroll > .js-history-table {
    flex: 1;
    min-height: 140px;
    overflow: auto;
}

.win__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 9px 12px;
    background: var(--face);
    border-top: 1px solid #dfdfdf;
}

.win__footer-hint {
    flex: 1;
    min-width: 0;
    color: #575757;
}

.win__footer-line {
    display: block;
}

.email {
    text-decoration: underline;
}

/* ---------- Окно «Показания счётчиков» ---------- */

.cp-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.cp-head__title {
    margin: 2px 0 4px;
    color: var(--heading);
    font-size: 16px;
    font-weight: 400;
}

/* Ширина колонок задана заранее — при вводе расчёт не сдвигает таблицу */
.meters {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.meters__prev { width: 80px; }
.meters__input { width: 172px; }
.meters__delta { width: 112px; }

.meters thead th {
    padding: 0 8px 4px 0;
    color: var(--muted);
    font-weight: 400;
    text-align: left;
    white-space: nowrap;
}

.meters thead th.num {
    text-align: right;
}

.meters tbody th,
.meters tbody td {
    padding: 4px 8px 4px 0;
    font-weight: 400;
    text-align: left;
    white-space: nowrap;
}

.meters tbody td.num {
    text-align: right;
}

.meters label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.meters .tb {
    width: 106px;
    text-align: right;
}

.delta {
    color: #4f8a10;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meters tbody th {
    overflow: hidden;
    text-overflow: ellipsis;
}

.delta.is-bad {
    color: #c00;
}

.est {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.est__name { width: 210px; }
.est__sum { width: 120px; }

.est th,
.est td {
    padding: 3px 6px 3px 0;
    font-weight: 400;
    text-align: left;
    white-space: nowrap;
}

.est th .ico {
    margin-right: 7px;
}

.est td.num {
    text-align: right;
}

.est .js-calc {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Воздух перед чертой «Итого по тарифам» */
.est tbody tr:last-child th,
.est tbody tr:last-child td {
    padding-bottom: 10px;
}

.est tfoot th,
.est tfoot td {
    padding-top: 7px;
    border-top: 1px solid #d5dfe5;
}

.est tfoot th {
    font-weight: 600;
}

.est .js-total {
    font-size: 14px;
}

.kv {
    list-style: none;
    margin: 6px 0;
    padding: 0;
}

.kv li {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 2px 0;
}

.kv__name {
    flex: 1;
}

.kv__value {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.kv__value small {
    color: var(--muted);
    font-size: 12px;
}

.kv-total {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 6px 0 2px;
    padding-top: 6px;
    border-top: 1px solid #d5dfe5;
}

/* ---------- История ---------- */

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 32px;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat strong {
    color: var(--heading);
    font-size: 16px;
    font-weight: 400;
}

/* График в стиле «Диспетчера задач» */
.tm {
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: 240px;
    margin-top: 4px;
    padding: 6px 6px 4px;
    background: #000;
    border: 1px solid #6f6f6f;
    box-shadow: inset 1px 1px 0 #404040;
}

.tm__plot {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: stretch;
    gap: 6px;
    padding: 0 6px;
    background-color: #000;
    background-image:
        linear-gradient(#008040 1px, transparent 1px),
        linear-gradient(90deg, #008040 1px, transparent 1px);
    background-size: 100% 10%, 12px 100%;
    border: 1px solid #008040;
}

.tm__col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 2px;
}

.tm__value {
    color: #00ff00;
    font: 12px/1 Consolas, "Lucida Console", monospace;
    white-space: nowrap;
}

.tm__bar {
    width: 72%;
    max-width: 36px;
    background:
        repeating-linear-gradient(to top, #00ff00 0 2px, #000 2px 3px) left / calc(50% - 1px) 100% no-repeat,
        repeating-linear-gradient(to top, #00ff00 0 2px, #000 2px 3px) right / calc(50% - 1px) 100% no-repeat;
}

.tm__col:hover .tm__bar {
    background:
        repeating-linear-gradient(to top, #b6ffb6 0 2px, #000 2px 3px) left / calc(50% - 1px) 100% no-repeat,
        repeating-linear-gradient(to top, #b6ffb6 0 2px, #000 2px 3px) right / calc(50% - 1px) 100% no-repeat;
}

.tm__labels {
    display: flex;
    gap: 6px;
    padding: 0 7px;
}

.tm__labels span {
    flex: 1;
    min-width: 0;
    color: #00ff00;
    font: 12px/1.2 Consolas, "Lucida Console", monospace;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
}

/* ---------- Диалоги ---------- */

/* Слой модального окна: прозрачный, щелчок мимо окна — мигание окна */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    overflow: auto;
    padding: 40px 12px;
}

.modal.is-open {
    display: flex;
}

.modal > .win {
    margin: auto;
}

.win--dialog {
    width: 740px;
    max-width: 100%;
}

.win--task {
    width: 440px;
}

.win--wide {
    width: 1180px;
    height: calc(100vh - 80px);
}

.win--wide > .win__client {
    min-height: 0;
}

.win--wide .win__body {
    background: #fff;
}

.login-win {
    width: 420px;
}

.win--dialog .win__client {
    background: var(--face);
}

.dlg-body {
    padding: 9px 10px 10px;
}

.dlg-body .tabs__panel {
    padding: 12px 12px 10px;
}

.dlg-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 7px;
    padding: 2px 11px 10px;
}

.props-head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.props-sep {
    height: 0;
    margin: 10px 0;
    border: 0;
    border-top: 1px solid #a0a0a0;
    border-bottom: 1px solid #fff;
}

.props-dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 5px 14px;
    margin: 0;
}

.props-dl dt {
    white-space: nowrap;
}

.props-dl dd {
    margin: 0;
    min-width: 0;
}

.prices {
    border-collapse: collapse;
}

.prices th,
.prices td {
    padding: 3px 10px 3px 0;
    font-weight: 400;
    text-align: left;
    white-space: nowrap;
}

.prices label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.lv--prices {
    max-height: 300px;
}

.login-fields {
    margin-top: 12px;
}

.login-fields .tb {
    width: 200px;
}

/* Окно сообщения (TaskDialog) */
.td {
    background: #fff;
}

.td__main {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px 18px 12px;
}

.td__text {
    flex: 1;
    min-width: 0;
}

.td__instruction {
    margin: 4px 0 9px;
    color: var(--instruction);
    font-size: 16px;
    font-weight: 400;
}

.td__content > * + * {
    margin-top: 8px;
}

.td__footer {
    display: flex;
    justify-content: flex-end;
    gap: 7px;
    padding: 10px 12px;
    background: var(--face);
    border-top: 1px solid #dfdfdf;
}

.td-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid #d5dfe5;
    border-radius: 3px;
}

.td-list li {
    display: flex;
    gap: 12px;
    padding: 4px 8px;
}

.td-list li + li {
    border-top: 1px solid #edf1f4;
}

.td-list span {
    flex: 1;
}

.td-total {
    font-weight: 600;
}

/* Модальное окно после перетаскивания — в своих координатах внутри слоя */
.modal > .win.is-placed {
    position: absolute;
    margin: 0;
}

.win.is-dragging {
    user-select: none;
}

/* ---------- Узкий экран: окна и гаджеты друг под другом ---------- */

@media (max-width: 760px) {
    .page {
        padding: 10px 6px;
    }

    .topbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 6px 10px;
    }

    .topbar__nav {
        margin-left: 0;
    }

    .desk {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

    .desk__readings,
    .desk__history,
    .gadgets {
        grid-column: 1;
        grid-row: auto;
    }

    .win__body {
        padding: 10px;
    }

    /* Показания: название счётчика строкой выше, под ним поле и расход */
    .meters,
    .est {
        table-layout: auto;
    }

    .meters col,
    .est col {
        width: auto;
    }

    .meters thead {
        display: none;
    }

    .meters tbody tr {
        display: grid;
        grid-template-columns: auto 1fr;
        align-items: center;
        column-gap: 10px;
        padding: 6px 0;
        border-bottom: 1px solid #edf1f4;
    }

    .meters tbody th {
        grid-column: 1 / -1;
        padding-bottom: 4px;
        white-space: normal;
    }

    .meters tbody td {
        padding: 0;
    }

    .meters tbody td.num.muted {
        display: none;
    }

    /* Поля ввода крупнее — под палец; 16px не даёт телефону увеличивать страницу при фокусе */
    .tb {
        height: 36px;
        padding: 2px 8px;
        font-size: 16px;
    }

    .meters .tb {
        width: 150px;
    }

    .tb--price {
        width: 130px;
    }

    .tb--date {
        width: 170px;
    }

    .login-fields {
        width: 100%;
    }

    .login-fields td {
        flex: 1;
        padding-right: 0;
    }

    .login-fields .tb {
        width: 100%;
    }

    /* Кнопки диалогов выше — под палец */
    .dlg-buttons .btn,
    .td__footer .btn,
    .panel-foot .btn {
        height: 32px;
    }

    .field__unit {
        font-size: 14px;
    }

    .delta {
        white-space: nowrap;
    }

    /* Расчёт по тарифам: формула под названием статьи, сумма справа */
    .est tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        column-gap: 10px;
        padding: 3px 0;
    }

    .est tbody th {
        grid-column: 1;
        grid-row: 1;
        padding: 0;
    }

    .est tbody .js-calc {
        grid-column: 1 / -1;
        grid-row: 2;
        padding: 0 0 0 23px;
        font-size: 12px;
    }

    .est tbody .js-sum {
        grid-column: 2;
        grid-row: 1;
        padding: 0;
    }

    .est tbody tr:last-child th,
    .est tbody tr:last-child td {
        padding-bottom: 0;
    }

    .est tbody tr:last-child {
        padding-bottom: 10px;
    }

    .est tfoot tr {
        display: flex;
        justify-content: space-between;
        border-top: 1px solid #d5dfe5;
    }

    .est tfoot th,
    .est tfoot td {
        border-top: 0;
    }

    /* Подвал окна: подсказка сверху, кнопка на всю ширину */
    .win__footer {
        flex-direction: column;
        align-items: stretch;
    }

    .win__footer .btn {
        height: 30px;
    }

    .win__footer-hint:empty {
        display: none;
    }

    .prices tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        padding: 2px 0;
    }

    .prices th {
        flex-basis: 100%;
    }

    .modal {
        padding: 12px 8px;
    }

    .win--wide {
        height: calc(100vh - 24px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
