/* Шрифт Montserrat (переменный, кириллица), лицензия SIL OFL — fonts/OFL.txt */
@font-face {
  font-family: "Montserrat";
  src: url(fonts/Montserrat.ttf) format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e1e5ec;
  --border-strong: #c9cfda;
  --text: #0a0a0c;
  --text-muted: #667085;
  --accent: #0a0a0c;          /* чёрный знака ARCHI: шапка таблицы, главные кнопки */
  --accent-soft: #eceff5;
  --link: #0033A0;            /* синий флага: ссылки */
  --neg: #b42318;
  --ok: #0f7b4f;
  --ok-soft: #e6f4ec;
  --now: #158060;   /* текущий период */
  --warn-soft: #fdf4e3;
  --warn-border: #e8c06a;
  --error-soft: #fdecea;
  --radius: 8px;
  --font: "Montserrat", "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ------------------------------------------------------------------ header */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 56px;
  background: var(--accent);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; flex-direction: column; line-height: 1.2; }
.brand-mark { font-weight: 700; letter-spacing: .08em; font-size: 15px; }
.brand-sub { font-size: 11px; opacity: .7; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: rgba(255, 255, 255, .78);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 6px;
  font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .17); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right .muted { color: rgba(255, 255, 255, .6); }
.user { font-weight: 600; }
.logout { color: rgba(255, 255, 255, .7); text-decoration: none; font-size: 12px; }
.logout:hover { color: #fff; text-decoration: underline; }

/* -------------------------------------------------------------------- page */
.page { padding: 24px 20px 64px; max-width: 100%; }
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 15px; margin: 0 0 10px; }
.lead { color: var(--text-muted); margin: 0 0 20px; max-width: 78ch; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
code { font-family: var(--mono); font-size: 12px; background: var(--accent-soft);
       padding: 1px 5px; border-radius: 4px; }

/* ----------------------------------------------------------------- toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px;
        color: var(--text-muted); font-weight: 500; }
label.checkbox { flex-direction: row; align-items: center; gap: 7px; font-size: 13px; }
.hint { font-size: 11px; color: var(--text-muted); font-weight: 400; }

input[type=text], input[type=date], input[type=month], input[type=password], select {
  font: inherit;
  color: var(--text);
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
  min-width: 150px;
}
input:focus, select:focus { outline: 2px solid rgba(31, 58, 95, .3); border-color: var(--accent); }

.btn {
  font: inherit;
  font-weight: 600;
  padding: 8px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: var(--accent-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #17304f; }
.btn-link { border: none; background: none; color: var(--neg); padding: 2px 4px;
            font-weight: 500; font-size: 12px; text-decoration: underline; }
.btn-link:hover { background: none; }

/* ----------------------------------------------------------------- notices */
.notice {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  border: 1px solid;
}
.notice-ok { background: var(--ok-soft); border-color: #9cd0b4; color: #0b5c3b; }
.notice-warn { background: var(--warn-soft); border-color: var(--warn-border); color: #7a5410; }
.notice-error { background: var(--error-soft); border-color: #eaa8a1; color: #8a231b; }

.empty {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px; text-align: center;
}
.empty h2 { font-size: 18px; }

/* ------------------------------------------------------------------- cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
         gap: 16px; margin-bottom: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.card .muted { max-width: 70ch; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
             gap: 14px; align-items: start; }
.form-grid .wide { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0 0 16px; }
.stats dt { color: var(--text-muted); font-size: 12px; }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }

.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px;
       border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-error { background: var(--error-soft); color: var(--neg); }

/* ------------------------------------------------------------------ tables */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 220px);
}
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--border); }
thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
/* «сентябрь 2026» → «Сентябрь 2026», но «24–30 авг» остаётся как есть:
   capitalize поднял бы и «Авг» в середине диапазона. */
.col-range::first-letter { text-transform: uppercase; }
.col-money { text-align: right; font-variant-numeric: tabular-nums;
             white-space: nowrap; min-width: 108px; }
.col-total { border-left: 1px solid var(--border-strong); font-weight: 600; }
thead .col-total { border-left-color: rgba(255, 255, 255, .25); }
.neg { color: var(--neg); }

/* сводная таблица ДДС */
.dds .col-name {
  position: sticky; left: 0; z-index: 2;
  background: var(--surface);
  font-weight: 400; min-width: 340px; max-width: 420px;
}
.dds thead .col-name { z-index: 4; background: var(--accent); }

.dds .row-block th {
  background: #d6dee9; color: var(--accent);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  position: sticky; left: 0;
  border-top: 1px solid var(--border-strong);
}
.dds .row-asset th, .dds .row-asset td { background: var(--accent-soft); }
.dds .row-liability th, .dds .row-liability td { background: var(--warn-soft); }
.dds .row-subtotal th, .dds .row-subtotal td { background: #f2f4f7; font-weight: 600; }
.dds .row-net th, .dds .row-net td { background: #e6ecf4; font-weight: 700; }
.dds .row-memo th, .dds .row-memo td { font-style: italic; color: #475467; font-size: 12px; }
.dds .row-plan th, .dds .row-plan td { color: #5a6472; background: #fbfbf6; }
.dds .row-plan .col-name::after {
  content: "план"; margin-left: 8px; font-size: 10px; font-weight: 700;
  color: #7a5410; background: var(--warn-soft); border: 1px solid var(--warn-border);
  padding: 1px 6px; border-radius: 999px; vertical-align: middle;
}
.dds .row-item:hover td, .dds .row-item:hover th { background: #f8fafc; }

thead .col-future { background: #16304f; }

/* шапка периода: номер недели и пометка «план» над диапазоном дат */
.col-marks {
  display: flex; gap: 5px; justify-content: flex-end; align-items: center;
  margin-bottom: 2px; min-height: 13px;
}
.badge-week {
  font-size: 9px; font-weight: 700; letter-spacing: .04em;
  color: rgba(255, 255, 255, .95); background: rgba(255, 255, 255, .16);
  border-radius: 3px; padding: 1px 5px; white-space: nowrap;
}
.badge-plan {
  font-size: 9px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: #f0c674; background: rgba(240, 198, 116, .16);
  border-radius: 3px; padding: 1px 5px; white-space: nowrap;
}
/* Текущий период планом не помечаем: в нём уже есть факт, план только
   на оставшиеся дни. */
.badge-now {
  font-size: 9px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: #9fd3b4; background: rgba(159, 211, 180, .18);
  border-radius: 3px; padding: 1px 5px; white-space: nowrap;
}
.col-range { display: block; white-space: nowrap; }
.block-note {
  display: block; font-weight: 400; text-transform: none; letter-spacing: 0;
  font-size: 11px; color: #46586f; margin-top: 3px; max-width: 110ch;
}

/* переключатель «по неделям / по месяцам» */
.segmented { display: inline-flex; border: 1px solid var(--border-strong);
             border-radius: 6px; overflow: hidden; }
.segmented a {
  padding: 8px 14px; font-weight: 600; font-size: 13px; text-decoration: none;
  color: var(--text-muted); background: #fff;
}
.segmented a + a { border-left: 1px solid var(--border-strong); }
.segmented a:hover { background: var(--accent-soft); }
.segmented a.active { background: var(--accent); color: #fff; }

.block-toggle {
  margin-left: 14px; font-size: 11px; font-weight: 600; text-transform: none;
  letter-spacing: 0; color: var(--accent); text-decoration: underline;
}

/* строки быстрого ввода сумм по статьям */
.dds .row-entry-head th, .dds .row-entry-head td {
  background: #eef3f8; font-size: 11px; color: var(--text-muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.dds .row-entry-head td { text-transform: none; letter-spacing: 0; font-weight: 400; }
.dds .row-entry th, .dds .row-entry td { background: #fbfcfe; padding: 3px 8px; }
.dds .row-entry .col-name { font-size: 12px; }
.dds .row-entry-actions th, .dds .row-entry-actions td {
  background: #eef3f8; padding: 10px 12px;
}
.dds .row-entry-actions td { display: table-cell; }
.dds .row-entry-actions .btn { margin-right: 12px; }

/* Текущий период — сквозная подсветка столбца.
   Фон кладём внутренней тенью, а не background: так подсветка не затирает
   собственный фон строк (остатки, итоги, ввод) и работает поверх любого. */
.dds .cell-current {
  box-shadow: inset 0 0 0 9999px rgba(21, 128, 96, .10);
  border-left: 2px solid var(--now);
  border-right: 2px solid var(--now);
}
.dds thead .cell-current {
  box-shadow: none;
  background: var(--now);
  border-left-color: var(--now);
  border-right-color: var(--now);
}
.dds thead .cell-current .badge-week,
.dds thead .cell-current .badge-now {
  background: rgba(255, 255, 255, .22); color: #fff;
}
.dds .row-block th { position: relative; }

.row-overdue td { background: #fdf4e3; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input[type=date] { min-width: 132px; padding: 4px 7px; font-size: 12px; }
.btn-small { padding: 4px 10px; font-size: 12px; }
.cell-input { min-width: 0; width: 110px; text-align: right; padding: 4px 7px; }

.dds .row-detail th, .dds .row-detail td {
  background: #fbfcfe; color: var(--text-muted); font-size: 12px;
}
.dds .row-detail .col-name { padding-left: 34px; font-style: italic; }

.dds .has-details { cursor: pointer; }
.caret {
  display: inline-block; width: 0; height: 0; margin-right: 7px;
  border-left: 5px solid var(--text-muted);
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform .12s ease;
}
.has-details.open .caret { transform: rotate(90deg) translateX(1px); }

.ops tbody tr:hover td { background: #f8fafc; }
.ops td form { margin: 0; }

.legend { color: var(--text-muted); font-size: 12px; margin-top: 14px; max-width: 90ch; }

/* ------------------------------------------------------------------- login */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: 320px; display: flex; flex-direction: column; gap: 14px; margin: 0; }
.login-card h1 { margin: 0; }
.login-card p { margin: 0; }
.login-card input { min-width: 0; }

@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .nav { flex-wrap: wrap; }
  .page { padding: 16px 14px 48px; }
  .dds .col-name { position: static; min-width: 220px; }
  .form-grid .wide { grid-column: span 1; }
}


/* =========================================================================
   Оформление «Арарат»
   Светлая шапка с логотипом ARCHI, полоса цветов флага Армении, знак вечности
   (аревахач, контур из шрифта Noto Sans Armenian, SIL OFL) у заголовков блоков и
   силуэт Арарата. Плетёная лента убрана по решению заказчика, рисунок лежит
   в design/archive/. Источники и лицензии — img/NOTICE.txt.
   ========================================================================= */
a { color: var(--link); }
input:focus, select:focus { outline: 2px solid rgba(0, 51, 160, .3); border-color: var(--link); }
.btn-primary:hover { background: #2a2d36; }
/* кнопка-иконка «развернуть / свернуть ввод» в заголовке блока */
.block-toggle {
  display: inline-grid; place-items: center; vertical-align: middle;
  width: 24px; height: 24px; margin-left: 12px; padding: 0;
  border-radius: 8px; text-decoration: none;
  background: #D90012; color: #fff;
  box-shadow: 0 1px 3px rgba(217, 0, 18, .35);
  transition: transform .12s ease, filter .12s ease;
}
.block-toggle:hover { transform: scale(1.1); filter: brightness(1.08); color: #fff; }
.block-toggle.is-open { background: #1b1c20; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }

/* шапка */
.topbar {
  background: #fff;
  color: var(--text);
  height: 68px;
  box-shadow: 0 1px 0 var(--border);
}
.topbar::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: linear-gradient(90deg, #D90012 0 33.34%, #0033A0 33.34% 66.67%, #F2A800 66.67% 100%);
}
.brand { display: flex; align-items: center; min-width: 150px; }
.brand img { display: block; height: 25px; width: auto; }
.nav a { color: #3b3f4a; font-weight: 600; }
.nav a:hover { background: #f0f2f6; color: var(--text); }
.nav a.active { background: #0a0a0c; color: #fff; }
.topbar-right .muted { color: var(--text-muted); }
.logout { color: var(--text-muted); }
.logout:hover { color: var(--text); }

/* заголовки блоков таблицы */
.dds .row-block th {
  background: #eceff5;
  color: var(--text);
  padding-top: 9px;
  padding-bottom: 9px;
}
thead .col-future { background: #262932; }

/* подвал: силуэт Арарата */
.page { padding-bottom: 24px; }
.foot {
  height: 96px;
  background: url(img/ararat.svg) no-repeat right 32px bottom 0 / 340px auto;
}

/* экран входа */
.login-page {
  background: #f4f6fa url(img/ararat.svg) no-repeat center bottom / 560px auto;
  position: relative;
}
.login-page::before {
  content: "";
  position: fixed; left: 0; right: 0; top: 0; height: 5px;
  background: linear-gradient(90deg, #D90012 0 33.34%, #0033A0 33.34% 66.67%, #F2A800 66.67% 100%);
}
.login-card img.login-logo { display: block; height: 34px; width: auto; align-self: flex-start; margin-bottom: 4px; }

/* навигация не переносится по словам; на узких окнах уступает место подпись справа */
.nav { flex-wrap: nowrap; gap: 2px; min-width: 0; }
.nav a { white-space: nowrap; padding: 7px 10px; font-size: 13px; }
.topbar-right { white-space: nowrap; }
@media (max-width: 1280px) { .topbar-right .muted { display: none; } }
@media (max-width: 960px) {
  .brand { min-width: 0; }
  .brand img { height: 21px; }
  .nav a { padding: 6px 7px; font-size: 12px; }
  .topbar { gap: 12px; padding: 0 12px; }
}
@media (max-width: 720px) {
  .nav { flex-wrap: wrap; }
  .topbar { height: auto; padding: 10px 14px; }
}

/* =========================================================================
   Плитки главных разделов в шапке (вариант «А») и меню «Ещё».
   Плитки и логотип выровнены по одной линии; высота плиток — --tile-h.
   ========================================================================= */
:root { --logo-h: 25px; --tile-h: 40px; }
.brand img { height: var(--logo-h); }
.topbar { height: 68px; }
.nav { align-items: center; gap: 8px; }
.nav a.tile {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--tile-h); padding: 0 20px;
  border-radius: 10px;
  color: #fff; font-size: 15px; font-weight: 800; letter-spacing: .1px; line-height: 1;
  box-shadow: 0 1px 3px rgba(20, 24, 40, .25);
  transition: transform .12s ease, filter .12s ease;
}
.nav a.tile-blue { background: #0033A0; }
.nav a.tile-red { background: #D90012; }
.nav a.tile-gold { background: #F2A800; color: #1b1c20; }
.nav a.tile:hover { transform: translateY(-1px); filter: brightness(1.07); }
.nav a.tile.active { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #1b1c20; }
.tile-count {
  min-width: 20px; height: 18px; padding: 0 6px;
  display: inline-grid; place-items: center;
  border-radius: 999px; background: #fff; color: #111;
  font-size: 11.5px; font-weight: 800;
}
.more { position: relative; margin-left: 2px; }
.more summary {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center;
  height: var(--tile-h); padding: 0 16px; border-radius: 10px;
  font-weight: 700; font-size: 14px; color: #3b3f4a;
  background: #f0f2f6; border: 1px solid var(--border);
}
.more summary::-webkit-details-marker { display: none; }
.more summary:hover, .more[open] summary, .more summary.active { background: #0a0a0c; color: #fff; border-color: #0a0a0c; }
.more-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  width: 210px; padding: 6px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 14px 34px rgba(20, 24, 40, .22);
}
.more-menu a {
  display: block; padding: 9px 12px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 13px;
}
.more-menu a:hover { background: #f0f2f6; }
.more-menu a.active { background: #0a0a0c; color: #fff; }
@media (max-width: 960px) {
  :root { --logo-h: 21px; --tile-h: 34px; }
  .nav a.tile { padding: 0 12px; font-size: 13px; }
}
@media (max-width: 720px) {
  .topbar { height: auto; }
  .nav { flex-wrap: wrap; }
}

/* крестик закрытия уведомлений (добавляется скриптом ко всем .notice) */
.notice { position: relative; }
.notice.has-close { padding-right: 40px; }
.notice-close {
  position: absolute; top: 6px; right: 8px;
  width: 24px; height: 24px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: inherit; opacity: .6;
  font: inherit; font-size: 18px; line-height: 1; cursor: pointer;
}
.notice-close:hover { opacity: 1; background: rgba(0, 0, 0, .08); }
.notice-close:focus-visible { outline: 2px solid currentColor; opacity: 1; }
