:root {
  --bg: #f5f6fa; --panel: #ffffff; --panel-2: #f9fafc; --ink: #101828; --muted: #667085; --line: #e6e8ef;
  --field: #ffffff; --field-line: #d5d9e3; --hover: #f2f4f8;
  --accent: #4f46e5; --accent-2: #7c3aed; --accent-soft: #eef0ff; --accent-ink: #ffffff;
  --plus: #0e9f6e; --minus: #e02d3c; --warn: #b54708; --warn-bg: #fff6e5; --bad-bg: #ffeceb; --ok-bg: #e7f8f0; --off-bg: #eef0f4;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 24px 64px rgba(16, 24, 40, .22);
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1017; --panel: #161a23; --panel-2: #1a1f2a; --ink: #e8eaf0; --muted: #8b93a7; --line: #262c3a;
    --field: #11151d; --field-line: #2f3646; --hover: #1e2430;
    --accent: #7c83ff; --accent-2: #a78bfa; --accent-soft: #23264a; --accent-ink: #0d1017;
    --plus: #3ecf8e; --minus: #ff6b6b; --warn: #f5b759; --warn-bg: #33270f; --bad-bg: #3a1c1f; --ok-bg: #133126; --off-bg: #232836;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.2; letter-spacing: -.02em; font-weight: 700; margin: 0 0 18px; }
h2 { font-size: 15px; font-weight: 650; margin: 28px 0 10px; letter-spacing: -.01em; }
svg { width: 18px; height: 18px; flex: none; }

/* каркас */
.layout { display: flex; min-height: 100vh; }
.side { width: 240px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 14px 12px; }
.side .org { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; }
.side .org span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; flex: none; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 4px 12px rgba(79, 70, 229, .35); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; color: var(--muted); font-weight: 500; transition: background .12s, color .12s; }
.side nav a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.side nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .who { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--line); }
.side .who div { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.side .who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .who span { color: var(--muted); font-size: 12px; }
.side .who a { color: var(--muted); display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; }
.side .who a:hover { background: var(--hover); color: var(--minus); }
.ava { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex: none; background: var(--accent-soft); color: var(--accent); font-style: normal; font-weight: 700; }
.main { flex: 1; min-width: 0; padding: 30px 36px 70px; max-width: 1500px; }

.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.bar .sp { flex: 1; }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; margin-bottom: 18px; padding: 4px; background: var(--off-bg); border-radius: 12px; }
.tabs a { padding: 6px 13px; color: var(--muted); border-radius: 9px; font-weight: 500; font-size: 13.5px; }
.tabs a.on { color: var(--ink); background: var(--panel); box-shadow: var(--shadow); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* поля и кнопки */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { border: 1px solid var(--field-line); border-radius: 10px; padding: 8px 11px; background: var(--field); max-width: 100%; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
button { border: 1px solid var(--field-line); background: var(--panel); border-radius: 10px; padding: 8px 14px; cursor: pointer; white-space: nowrap; font-weight: 550; transition: background .12s, transform .05s, box-shadow .12s; }
button:hover { background: var(--hover); }
button:active { transform: translateY(1px); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.pri { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; font-weight: 600; box-shadow: 0 2px 8px rgba(79, 70, 229, .3); }
button.pri:hover { filter: brightness(1.07); }
button.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }
button.danger { color: var(--minus); }
button.danger:hover { background: var(--bad-bg); border-color: transparent; }
button:disabled { opacity: .5; cursor: default; }

/* карточки и плитки */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); }
.tile .l { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.tile .v { font-size: 23px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile.hero { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; box-shadow: 0 8px 24px rgba(79, 70, 229, .28); }
.tile.hero .l { color: rgba(255, 255, 255, .8); }

/* таблицы */
.tw { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; background: var(--panel-2); white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
tfoot td { border-top: 1px solid var(--line); font-weight: 650; background: var(--panel-2); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.act { white-space: nowrap; text-align: right; }
.plus { color: var(--plus); font-weight: 600; } .minus { color: var(--minus); font-weight: 600; }
.muted { color: var(--muted); } .empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.tag, .chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag { background: var(--ok-bg); color: var(--plus); }
.tag.warn { background: var(--warn-bg); color: var(--warn); } .tag.bad { background: var(--bad-bg); color: var(--minus); } .tag.off { background: var(--off-bg); color: var(--muted); }
.chip { background: var(--off-bg); color: var(--muted); }
.chip.lombard { background: var(--accent-soft); color: var(--accent); }
.chip.shop { background: var(--warn-bg); color: var(--warn); }
.chip.new { background: var(--ok-bg); color: var(--plus); }

/* окна */
.ov { position: fixed; inset: 0; background: rgba(10, 14, 25, .5); backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 14px; overflow-y: auto; z-index: 10; animation: fade .15s; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; width: 540px; max-width: 100%; box-shadow: var(--shadow-lg); animation: pop .18s cubic-bezier(.2, .9, .3, 1.2); }
.modal.wide { width: 1020px; }
.modal header { padding: 22px 24px 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.modal .mb { padding: 16px 24px 6px; }
.modal footer { padding: 14px 24px 20px; display: flex; gap: 8px; justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.err { color: var(--minus); margin-right: auto; align-self: center; font-size: 13px; }
.f { margin-bottom: 13px; }
.f label { display: block; font-size: 12.5px; font-weight: 550; color: var(--muted); margin-bottom: 5px; }
.f input:not([type=checkbox]), .f select, .f textarea { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.info { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px; margin-bottom: 14px; display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; }
.info span { color: var(--muted); }
.info b { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.note { background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 11px 14px; margin-bottom: 14px; font-size: 13.5px; font-weight: 550; }
.rowsed th { background: none; padding: 4px; text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.rowsed input, .rowsed select { width: 100%; min-width: 84px; padding: 7px 9px; }
.rowsed td { padding: 4px; border: 0; }
.rowsed tbody tr:hover { background: none; }
.cp { position: relative; display: flex; gap: 6px; }
.cp input.cp-q { flex: 1; }
.cp-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; z-index: 5; max-height: 230px; overflow: auto; box-shadow: var(--shadow-lg); padding: 4px; }
.cp-list div { padding: 8px 10px; cursor: pointer; border-radius: 8px; }
.cp-list div:hover { background: var(--accent-soft); }
.opmenu { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.opmenu button { padding: 16px; text-align: left; border-radius: 12px; font-weight: 600; }
.opmenu button:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* вход */
.login { max-width: 400px; margin: 10vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: 0 12px 40px rgba(16, 24, 40, .08); }
.login .logo { width: 46px; height: 46px; border-radius: 14px; margin-bottom: 18px; }
.login .logo svg { width: 24px; height: 24px; }
.login h1 { margin-bottom: 6px; }
.login p { color: var(--muted); margin: 0 0 20px; }
.login button { width: 100%; padding: 11px; margin-top: 6px; }

#print { display: none; }
@media print {
  body { background: #fff; }
  #app, #modals { display: none !important; }
  #print { display: block; padding: 10mm; font-size: 12pt; color: #000; }
  #print h1 { text-align: center; font-size: 15pt; }
  #print table th, #print table td { border: 1px solid #000; background: none; color: #000; text-transform: none; letter-spacing: 0; font-size: 11pt; }
  #print .sign { display: flex; justify-content: space-between; margin-top: 18mm; }
}
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .side { width: auto; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .side .org { padding-bottom: 10px; }
  .side nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; scrollbar-width: none; }
  .side nav a { white-space: nowrap; padding: 8px 12px; }
  .side .who { position: absolute; top: 8px; right: 12px; border: 0; padding: 0; }
  .side .who div { display: none; }
  .main { padding: 20px 14px 50px; }
  h1 { font-size: 21px; }
  .grid2, .opmenu { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .tile .v { font-size: 19px; }
  th, td { padding: 9px 10px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* графики */
:root { --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; }
@media (prefers-color-scheme: dark) { :root { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; } }
.chart { padding: 14px 16px 8px; margin-bottom: 12px; }
svg.plot { width: 100%; height: auto; display: block; }
.plot .grid { stroke: var(--line); stroke-width: 1; }
.plot .ax { fill: var(--muted); font-size: 11px; }
.plot .lb { fill: var(--ink); font-size: 12px; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 6px; font-size: 13px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
#tip { position: fixed; z-index: 30; pointer-events: none; white-space: pre-line; background: var(--ink); color: var(--panel); padding: 7px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow-lg); }
.hbar { display: grid; grid-template-columns: minmax(120px, 260px) 1fr 44px; align-items: center; gap: 12px; padding: 5px 0; }
.hbar div { height: 12px; }
.hbar i { display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--s1); }
.hbar b { text-align: right; font-variant-numeric: tabular-nums; }

/* инструменты таблиц */
.tbox { margin-bottom: 4px; }
.ttools { display: flex; justify-content: flex-end; gap: 2px; margin: -4px 0 4px; }
button.ghost { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; color: var(--muted); padding: 3px 8px; font-size: 12.5px; font-weight: 500; border-radius: 7px; }
button.ghost svg { width: 15px; height: 15px; }
button.ghost:hover { background: var(--hover); color: var(--ink); }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-bottom: 8px; }
.checks label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checks input { width: 16px; height: 16px; accent-color: var(--accent); }
@media (max-width: 860px) { .checks { grid-template-columns: 1fr; } }

/* вход, регистрация, профиль */
.login.wide { max-width: 460px; }
.login .tabs { display: flex; margin: 4px 0 18px; }
.login .tabs a { flex: 1; text-align: center; cursor: pointer; }
.login .err:empty { display: none; }
.login .btn.big { display: block; text-align: center; padding: 12px; margin: 8px 0 10px; text-decoration: none; }
a.btn.pri, label.btn { display: inline-block; text-decoration: none; }
a.btn.pri { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-radius: 10px; font-weight: 600; }
label.btn { border: 1px solid var(--field-line); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 550; background: var(--panel); }
.seg { display: flex; gap: 8px; }
.seg label { flex: 1; display: flex; align-items: center; gap: 8px; border: 1px solid var(--field-line); border-radius: 10px; padding: 9px 12px; cursor: pointer; color: var(--ink) !important; font-size: 14px !important; }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.seg label.off { opacity: .45; cursor: default; }
.chk { display: flex; align-items: center; gap: 9px; margin: 8px 0; cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.logo.img { background: none; box-shadow: none; overflow: hidden; }
.logo.img img { width: 100%; height: 100%; object-fit: contain; }
.logobox { min-height: 72px; display: flex; align-items: center; margin-bottom: 8px; }
.logobox img { max-height: 96px; max-width: 260px; }
.side .fb { display: flex; align-items: center; gap: 11px; padding: 9px 10px; margin-top: 10px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.side .fb:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.side .who div[data-act] { cursor: pointer; }
.side .who div[data-act]:hover b { color: var(--accent); }
.banner { margin-bottom: 18px; }
@media (max-width: 860px) { .side .fb { display: none; } .side .who div[data-act] { display: flex; } }
