/* ============================================================
   Учётная панель — светлая и тёмная тема
   ============================================================ */

:root {
  --paper:        #F3F1EA;
  --paper-2:      #EAE6DC;
  --surface:      #FFFFFF;
  --surface-2:    #FBFAF7;
  --ink:          #17191C;
  --ink-2:        #565C64;
  --ink-3:        #8B9199;
  --line:         #E3DFD4;
  --line-2:       #D3CDBF;
  --accent:       #1C5A45;
  --accent-ink:   #FFFFFF;
  --accent-soft:  #E6EFE9;
  --pos:          #1C5A45;
  --neg:          #9B3A2B;
  --warn:         #8A5C1E;
  --warn-soft:    #F6EEDF;
  --shadow:       0 1px 2px rgba(23, 25, 28, .05), 0 8px 24px -18px rgba(23, 25, 28, .35);
  --radius:       4px;
  --rail:         256px;
}

[data-theme="dark"] {
  --paper:        #0E1013;
  --paper-2:      #14171B;
  --surface:      #16191D;
  --surface-2:    #1B1F24;
  --ink:          #E8E5DE;
  --ink-2:        #A3A9B1;
  --ink-3:        #737A83;
  --line:         #262A30;
  --line-2:       #333941;
  --accent:       #63BB94;
  --accent-ink:   #0E1013;
  --accent-soft:  #16241E;
  --pos:          #63BB94;
  --neg:          #DE8676;
  --warn:         #D0A257;
  --warn-soft:    #241E12;
  --shadow:       0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -20px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv05" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, .serif {
  font-family: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

a { color: inherit; text-decoration: none; }
p { margin: 0; }

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}
.num.pos, .pos { color: var(--pos); }
.num.neg, .neg { color: var(--neg); }
.num.zero { color: var(--ink-3); }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }

.ic { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------------- каркас ---------------- */

.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }

.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  padding: 22px 14px 16px;
}

.brand { display: block; padding: 2px 8px 24px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text b {
  font-family: "Source Serif 4", Georgia, serif; font-size: 16.5px; font-weight: 600;
  letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text i {
  font-style: normal; font-size: 11px; color: var(--ink-3);
  letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.rail nav { flex: 1; overflow-y: auto; }
.nav-group + .nav-group { margin-top: 20px; }
.nav-group-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--ink-3); padding: 0 10px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 1px;
  border-radius: 3px; color: var(--ink-2); font-size: 13.5px;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: rgba(0, 0, 0, .04); color: var(--ink); }
[data-theme="dark"] .nav-item:hover { background: rgba(255, 255, 255, .05); }
.nav-item.on { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: var(--shadow); }
.nav-item.on .ic { color: var(--accent); }
.nav-item.as-button {
  width: 100%; background: none; border: 0; cursor: pointer;
  font: inherit; font-size: 13.5px; text-align: left;
}
.rail-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }

.main { padding: 34px 40px 72px; max-width: 1360px; width: 100%; }

.rail-toggle { display: none; }

/* ---------------- шапка страницы ---------------- */

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap; margin-bottom: 26px;
}
.eyebrow {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .16em;
  color: var(--ink-3); margin-bottom: 8px;
}
.page-head h1 { font-size: 29px; line-height: 1.15; }
.page-sub { color: var(--ink-2); font-size: 13.5px; margin-top: 7px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------------- кнопки ---------------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 3px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink);
  font: 500 13px/1 "Inter", sans-serif; cursor: pointer; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { border-color: var(--ink-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost:hover { color: var(--ink); }
.btn-danger { color: var(--neg); border-color: var(--line-2); background: transparent; }
.btn-danger:hover { border-color: var(--neg); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-link { border: 0; background: none; padding: 4px 2px; color: var(--ink-2); }
.btn-link:hover { color: var(--accent); }

/* ---------------- карточки ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 22px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 20px; border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.card-head h2 { font-size: 15.5px; letter-spacing: 0; }
.card-note { font-size: 12px; color: var(--ink-3); }
.card-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; align-items: start; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.split-7-5 { display: grid; grid-template-columns: 7fr 5fr; gap: 22px; align-items: start; }
.split-7-5 > .card { margin-bottom: 0; }

/* ---------------- показатели ---------------- */

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 22px; overflow: hidden;
}
.stat { padding: 16px 20px 17px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .13em;
  color: var(--ink-3); margin-bottom: 9px;
}
.stat-value {
  font-family: "Source Serif 4", Georgia, serif; font-size: 25px; font-weight: 600;
  letter-spacing: -0.015em; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.stat-value .cur { font-size: 15px; color: var(--ink-3); margin-left: 3px; font-weight: 400; }
.stat-hint { font-size: 12px; color: var(--ink-2); margin-top: 7px; }
.stat.accent-pos .stat-value { color: var(--pos); }
.stat.accent-neg .stat-value { color: var(--neg); }

/* ---------------- таблицы ---------------- */

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; font-weight: 500; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .11em; color: var(--ink-3); padding: 11px 14px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2);
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover td { background: var(--surface-2); }
table.tbl .r { text-align: right; }
table.tbl .c { text-align: center; }
table.tbl td.r, table.tbl th.r { font-variant-numeric: tabular-nums; }
table.tbl .w-1 { width: 1%; white-space: nowrap; }
table.tbl .strong { font-weight: 500; }
table.tbl tfoot td {
  border-top: 1px solid var(--line-2); border-bottom: 0; font-weight: 500;
  background: var(--surface-2); padding: 12px 14px;
}
.row-link { color: var(--ink); }
.row-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.cell-sub { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

.tag {
  display: inline-block; padding: 2px 7px; border-radius: 2px; font-size: 11px;
  background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--line);
  white-space: nowrap;
}
.tag.pos { background: var(--accent-soft); color: var(--pos); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.neg { background: transparent; color: var(--neg); border-color: var(--neg); }

/* ---------------- формы ---------------- */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label, .lbl {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3);
}
input[type="text"], input[type="password"], input[type="date"], input[type="number"],
input[type="search"], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line-2); border-radius: 3px;
  background: var(--surface); color: var(--ink);
  font: 400 13.5px/1.4 "Inter", sans-serif;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
textarea { resize: vertical; min-height: 74px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238B9199' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px;
}
input.money, input.qty, td input { font-variant-numeric: tabular-nums; }
input[type="date"] { min-height: 37px; }
.hint { font-size: 11.5px; color: var(--ink-3); }
.checkline { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-2); }
.checkline input { width: 15px; height: 15px; accent-color: var(--accent); }
.form-foot {
  display: flex; gap: 10px; align-items: center; margin-top: 22px;
  padding-top: 18px; border-top: 1px solid var(--line);
}
.form-foot .spacer { margin-left: auto; }

/* строки позиций документа */
#items { overflow-x: auto; }
.items-tbl { width: 100%; border-collapse: collapse; min-width: 520px; }
.items-tbl th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .11em; color: var(--ink-3);
  font-weight: 500; text-align: left; padding: 0 8px 8px;
}
.items-tbl th.r { text-align: right; }
.items-tbl td { padding: 4px 8px 4px 0; vertical-align: middle; }
.items-tbl td:last-child { padding-right: 0; }
.items-tbl .line-total { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13.5px; }
.row-del {
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-3);
  width: 30px; height: 34px; border-radius: 3px; cursor: pointer; display: grid; place-items: center;
}
.row-del:hover { color: var(--neg); border-color: var(--neg); }
.items-total {
  display: flex; justify-content: flex-end; gap: 28px; padding-top: 14px; margin-top: 6px;
  border-top: 1px solid var(--line); font-size: 13.5px;
}
.items-total b { font-family: "Source Serif 4", Georgia, serif; font-size: 19px; font-variant-numeric: tabular-nums; }

/* ---------------- фильтры ---------------- */

.period-bar {
  display: flex; gap: 14px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: 20px;
}
.period-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 12.5px; color: var(--ink-2);
  transition: all .12s ease;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.period-custom { display: flex; gap: 8px; align-items: center; }
.period-custom input[type="date"] { width: 148px; padding: 6px 9px; font-size: 12.5px; }
.period-custom .dash { color: var(--ink-3); }

.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px;
}
.toolbar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .search { position: relative; }
.toolbar .search input { padding-left: 32px; width: 260px; }
.toolbar .search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.toolbar select { width: auto; min-width: 150px; }
.toolbar .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------------- графики ---------------- */

.chart { padding: 4px 0 0; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-area { fill: color-mix(in srgb, var(--accent) 11%, transparent); stroke: none; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; }
.chart-line-2 { fill: none; stroke: var(--ink-3); stroke-width: 1.3; stroke-dasharray: 4 3; }
.chart-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; }
.chart-ylabel { fill: var(--ink-3); font-size: 10px; font-family: "Inter", sans-serif; }
.chart-xlabel { fill: var(--ink-3); font-size: 10px; text-anchor: middle; font-family: "Inter", sans-serif; }
.chart-legend {
  display: flex; gap: 18px; align-items: center; padding: 12px 2px 2px;
  font-size: 12px; color: var(--ink-2); flex-wrap: wrap;
}
.lg { display: inline-flex; align-items: center; gap: 7px; }
.lg::before { content: ""; width: 14px; height: 2px; background: var(--accent); border-radius: 2px; }
.lg-2::before { background: var(--ink-3); height: 0; border-top: 2px dashed var(--ink-3); }
.lg-max { margin-left: auto; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart-empty { padding: 40px 0; text-align: center; color: var(--ink-3); font-size: 13px; }

.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 1.5fr) 3fr minmax(74px, auto); gap: 12px; align-items: center; font-size: 13px; }
.bar-label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 7px; background: var(--paper-2); border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.bar-fill.neg { background: var(--neg); }
.bar-value { text-align: right; color: var(--ink); }

/* ---------------- уведомления, пустые состояния ---------------- */

.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin-bottom: 20px; border-radius: 3px;
  font-size: 13.5px; border: 1px solid var(--line);
  background: var(--accent-soft); color: var(--pos);
}
.flash.err { background: var(--warn-soft); color: var(--neg); }
.flash-x {
  margin-left: auto; border: 0; background: none; color: inherit;
  font-size: 19px; line-height: 1; cursor: pointer; opacity: .55; padding: 0 2px;
}
.flash-x:hover { opacity: 1; }

.empty { padding: 46px 20px; text-align: center; color: var(--ink-3); }
.empty .ic { color: var(--line-2); margin-bottom: 12px; }
.empty p { margin-bottom: 14px; font-size: 13.5px; }

/* ---------------- пояснения и шаги ---------------- */

.explain {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: 3px;
  padding: 12px 15px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
}
.explain b { color: var(--ink); font-weight: 500; }

.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; }
.steps li { font-size: 13.5px; line-height: 1.6; color: var(--ink-2); padding-left: 4px; }
.steps li b { color: var(--ink); font-weight: 600; }
.steps li::marker { color: var(--accent); font-variant-numeric: tabular-nums; }
.steps-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.card.onboarding { border-color: var(--line-2); }

/* ---------------- узкий режим менеджера ---------------- */

body.simple { background: var(--paper); }
.simple-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--paper-2);
}
.simple-brand {
  font-family: "Source Serif 4", Georgia, serif; font-size: 16.5px; font-weight: 600;
  letter-spacing: -0.01em;
}
.simple-right { display: flex; align-items: center; gap: 12px; }
.simple-main { max-width: 820px; margin: 0 auto; padding: 32px 24px 72px; }
.simple-main .page-head { margin-bottom: 22px; }
.simple-main .page-head h1 { font-size: 26px; }

@media (max-width: 640px) {
  .simple-bar { padding: 12px 16px; }
  .simple-main { padding: 22px 16px 60px; }

  /* позиции документа складываются в карточки */
  #items { overflow-x: visible; }
  .items-tbl { min-width: 0; display: block; }
  .items-tbl thead { display: none; }
  .items-tbl tbody { display: block; }
  .items-tbl .item-row {
    display: block; position: relative;
    border: 1px solid var(--line); border-radius: 3px;
    padding: 14px 14px 10px; margin-bottom: 10px; background: var(--surface-2);
  }
  .items-tbl td { display: block; width: 100%; padding: 0 0 10px; }
  .items-tbl td[data-label]::before {
    content: attr(data-label);
    display: block; margin-bottom: 5px;
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3);
  }
  .items-tbl td input, .items-tbl td select { width: 100% !important; text-align: left !important; }
  .items-tbl td.line-total { text-align: left; font-size: 15px; color: var(--ink); }
  .items-tbl td:last-child { padding: 0; }
  .item-row .row-del { position: absolute; top: 10px; right: 10px; width: 32px; height: 30px; }
  .items-total { flex-direction: column; align-items: flex-end; gap: 8px; }
}

/* ---------------- обязательные поля и метки ---------------- */

.items-tbl th .req {
  display: inline-block; margin-left: 4px;
  font-size: 9.5px; letter-spacing: .06em; text-transform: none;
  color: var(--warn);
}
.items-tbl input:required:placeholder-shown { border-color: var(--warn); }
.row-link.warn { color: var(--warn); }
.row-link.warn:hover { color: var(--warn); text-decoration: underline; text-underline-offset: 3px; }
.btn.on { border-color: var(--accent); color: var(--accent); }

/* ---------------- переключатель кабинетов ---------------- */

.who-menu { position: relative; }
.who-menu > summary {
  display: inline-flex; align-items: center; gap: 5px;
  cursor: pointer; list-style: none; user-select: none;
}
.who-menu > summary::-webkit-details-marker { display: none; }
.who-menu > summary:hover { border-color: var(--ink-3); color: var(--ink); }
.who-menu[open] > summary .ic { transform: rotate(180deg); }
.who-menu > summary .ic { transition: transform .15s ease; opacity: .7; }

.who-list {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  min-width: 210px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .65);
}
.who-head {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-3); padding: 6px 10px 8px;
}
.who-list form { display: block; }
.who-list button {
  display: block; width: 100%; text-align: left;
  padding: 9px 10px; border: 0; border-radius: 3px;
  background: none; color: var(--ink); cursor: pointer;
  font: 500 13.5px/1.2 "Inter", sans-serif;
}
.who-list button:hover { background: var(--surface-2); color: var(--accent); }

/* ---------------- подтверждение ---------------- */

.confirm-back {
  position: fixed; inset: 0; z-index: 90;
  display: none; align-items: center; justify-content: center; padding: 20px;
  background: rgba(0, 0, 0, .55);
}
.confirm-back.on { display: flex; }
.confirm-box {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .7);
  padding: 22px 22px 18px;
}
.confirm-box h3 { font-size: 17px; margin-bottom: 10px; }
.confirm-text { color: var(--ink-2); font-size: 13.5px; line-height: 1.55; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.confirm-actions .btn { padding: 9px 16px; }
body.no-scroll { overflow: hidden; }

.row-del-form { display: inline; }
.btn-link.danger { color: var(--ink-3); }
.btn-link.danger:hover { color: var(--neg); }
table.tbl tbody tr:hover .btn-link.danger { color: var(--ink-2); }
table.tbl tbody tr:hover .btn-link.danger:hover { color: var(--neg); }

/* ---------------- вход ---------------- */

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 460px at 50% -12%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--paper);
}
.login-box {
  width: 100%; max-width: 372px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 34px 32px 30px; box-shadow: var(--shadow);
}
.login-box h1 { font-size: 24px; margin-bottom: 6px; }
.login-box .sub { color: var(--ink-3); font-size: 13px; margin-bottom: 24px; }
.login-box .field { margin-bottom: 14px; }
.login-box .btn { width: 100%; justify-content: center; padding: 11px; margin-top: 8px; }
.login-err {
  background: var(--warn-soft); color: var(--neg); border-radius: 3px;
  padding: 9px 12px; font-size: 12.5px; margin-bottom: 16px;
}
.login-foot { margin-top: 22px; text-align: center; font-size: 11px; color: var(--ink-3); letter-spacing: .05em; }

/* ---------------- служебное ---------------- */

.pwd-box {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 3px;
  padding: 11px 13px; font-size: 14px; letter-spacing: .04em; word-break: break-all;
}
.dl { display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; font-size: 13.5px; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.sep { height: 1px; background: var(--line); margin: 20px 0; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: baseline; }
.list-plain li:last-child { border-bottom: 0; }
.list-plain .lp-main { flex: 1; min-width: 0; }
.list-plain .lp-sub { font-size: 11.5px; color: var(--ink-3); }

/* ---------------- адаптив ---------------- */

@media (max-width: 1180px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-7-5 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; z-index: 40; left: 0; top: 0; width: 264px;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow);
  }
  body.rail-open .rail { transform: none; }
  .main { padding: 20px 18px 60px; }
  .rail-toggle {
    display: flex; flex-direction: column; gap: 4px; justify-content: center;
    width: 38px; height: 34px; padding: 0 8px; margin-bottom: 18px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 3px; cursor: pointer;
  }
  .rail-toggle span { display: block; height: 1.5px; background: var(--ink-2); border-radius: 2px; }
  .grid-2, .grid-3, .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 24px; }
  .stat-value { font-size: 22px; }
  .toolbar .search input { width: 100%; }
  .toolbar form { width: 100%; }
}

@media print {
  .rail, .page-actions, .toolbar, .period-bar, .rail-toggle, .flash { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  body { background: #fff; }
  .card { break-inside: avoid; border-color: #ccc; }
}

/* ================= VPN: фото и заметки ================= */

.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px;
}
.photo { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.photo a { display: block; }
.photo img { display: block; width: 100%; height: 130px; object-fit: cover; background: var(--surface-2); }
.photo figcaption {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 7px 9px; font-size: 11.5px; color: var(--ink-2);
}
.photo-cap { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo figcaption .row-del-form { flex: none; }

.inline-upload { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-upload input[type=file] { max-width: 200px; font-size: 12px; }

.note-item { padding: 16px 0; border-bottom: 1px solid var(--line); }
.note-item:first-child { padding-top: 0; }
.note-item:last-child { border-bottom: 0; padding-bottom: 0; }
.note-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.note-date { font-size: 12px; color: var(--ink-3); }
.note-text { font-size: 14px; line-height: 1.6; color: var(--ink); white-space: pre-wrap; margin-bottom: 10px; }
.note-upload { margin-top: 10px; }

table.tbl tr.dim td { opacity: .6; }
input[type=file] { color: var(--ink-2); }
input[type=file]::file-selector-button {
  margin-right: 10px; padding: 7px 12px; border-radius: 3px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font: 500 12.5px "Inter", sans-serif; cursor: pointer;
}
input[type=file]::file-selector-button:hover { border-color: var(--ink-3); }

@media (max-width: 640px) {
  .photo img { height: 108px; }
  .inline-upload input[type=file] { max-width: 100%; }
}
