/* app-base.css — базовые стили приложения, вынесены из <style> в public/index.html
   (задача «последний шаг до ≤300 строк», 10.11.2026).

   ВАЖНО про порядок каскада: файл подключён в index.html РОВНО там, где стоял <style> —
   после критичного инлайна (токены темы, шрифт, плотность, motion) и ДО brand.css/design-1…5.
   Если переставить его после дизайн-слоёв, правила с равной специфичностью начнут их
   перебивать и вид изменится. Блоки перенесены дословно, порядок правил сохранён.

   Что осталось инлайном в index.html и почему:
   • :root / html[data-theme=dark] / html[data-font] — тема и шрифт должны примениться
     до загрузки внешних CSS, иначе при старте мигнёт светлая тема/другой кегль (FOUC);
   • html[data-density] .bar и html[data-motion=off] — применяются до первой отрисовки
     (theme.js/ближайший инлайн-скрипт), это часть «критичного» минимума. */

    input, select, textarea { background: var(--card); color: var(--fg); border-color: var(--line); }
    a { color: var(--accent-text); }
    .navbadge { display: inline-block; font-size: 11px; background: var(--line); color: var(--fg); border-radius: 12px; padding: 0 6px; margin-left: 6px; }
    .navnews { display: inline-block; font-size: 11px; font-weight: bold; background: var(--accent); color: var(--accent-on); border-radius: 12px; padding: 0 6px; margin-left: 4px; }
    .prev { border: 1px dashed var(--line); border-radius: 10px; padding: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
    .prev table { width: auto; min-width: 210px; }
    .prev .tile { margin: 0; }
    html[data-theme="dark"] [style*="color:#666"] { color: var(--dim) !important; }
    html[data-theme="dark"] .miss { color: #ff8a8a; }
    html[data-theme="dark"] #warn.bad { background: #3a1b1b; border-color: #a33; color: #ffd9d9; }
    * { box-sizing: border-box; }
    body { font-family: system-ui, sans-serif; margin: 0; padding: 12px 16px; font-size: var(--fs); }
    header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
    header h1 { font-size: 20px; margin: 0 12px 0 0; }
    nav button { padding: 8px 14px; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 8px; cursor: pointer; }
    nav button.on { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
    #stats { color: var(--dim); font-size: 13px; margin: 8px 0; }
    #warn { display: none; background: var(--warnbg); border: 1px solid var(--warnline); border-radius: 8px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
    #warn.bad { display: block; background: #fee; border-color: #a00; }
    #warn.info { display: block; }
    .bar { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
    .bar input, .bar select { padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: var(--fs); }
    .bar input[type="search"] { flex: 1; min-width: 200px; }
    button.act { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-on); cursor: pointer; white-space: nowrap; }
    button.ghost { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; font-size: 13px; }
    #tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tilemin), 1fr)); gap: 10px; }
    .tilesgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 10px 0; }
    .tilesgrid .tile { text-align: center; font-size: 14px; }
    .orggrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
    .orggrid .card { margin-top: 0; }
    @media (max-width: 760px) { .orggrid { grid-template-columns: 1fr; } }
    .tile { border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; background: var(--card); color: var(--fg); }
    .tile:hover { border-color: var(--accent); }
    .tile b { display: block; font-size: 15px; margin-bottom: 4px; }
    .tile span { color: var(--dim); font-size: 13px; }
    .card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-top: 12px; }
    .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 12px; }
    .cards .card { margin-top: 0; text-align: center; }
    .cards b { font-size: 26px; display: block; }
    .tabs { display: flex; gap: 6px; margin: 12px 0; flex-wrap: wrap; }
    .tabs button { padding: 8px 12px; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 8px; cursor: pointer; }
    .tabs button.on { background: var(--tabon); border-color: var(--accent); }
    table { width: 100%; border-collapse: collapse; font-size: 14px; }
    td, th { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
    .badge { display: inline-block; font-size: 12px; border: 1px solid var(--line); border-radius: 20px; padding: 1px 8px; color: var(--fg); background: var(--line); }
    .miss { color: #a00; font-size: 12px; }
    .rowmiss { opacity: 0.75; }
    .yr { margin: 14px 0 4px; color: var(--dim); font-size: 13px; font-weight: bold; }
    .frm { display: none; }
    .frm.open { display: block; }
    .frm input, .frm select { width: 100%; padding: 9px; margin: 4px 0; border: 1px solid var(--line); border-radius: 8px; }
    .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    @media (max-width: 640px) { .two { grid-template-columns: 1fr; } }
    .path { font-size: 12px; color: var(--dim); word-break: break-all; }
    select.mini, input.mini { padding: 4px 6px; font-size: 13px; border: 1px solid var(--line); border-radius: 6px; }
    tr.compact td { padding: 3px 8px !important; font-size: 13px; }
    .fcards { display: grid; gap: 10px; margin: 10px 0; }
    .fcards.cards-big { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
    .fcards.cards-small { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .fcard { border: 1px solid var(--line); border-radius: 10px; padding: 8px; cursor: pointer; background: var(--card); color: var(--fg); }
    .fcard:hover { border-color: var(--accent); }
    .fthumb { width: 100%; object-fit: cover; border-radius: 6px; background: var(--thumb); display: flex; align-items: center; justify-content: center; font-size: 40px; }
    .cards-big .fthumb { height: 130px; }
    .cards-small .fthumb { height: 80px; font-size: 28px; }
    .fthumb.pdf { color: #a00; font-weight: bold; }
    .fthumb.xls { color: #0a0; font-weight: bold; }
    .fthumb.doc { color: #00a; font-weight: bold; }
    .fnm { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 6px 0; }
    .facts { margin-top: 6px; }
    .facts .ghost { padding: 3px 7px; font-size: 12px; }
    h3 { margin: 18px 0 6px; }
    .app { display: flex; gap: 16px; align-items: flex-start; }
    #side { width: var(--sidew); flex: none; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
    #side nav { display: flex; flex-direction: column; gap: 6px; }
    #side nav button { text-align: left; }
    #navMoreWrap { position: relative; }
    #navMoreWrap #navMore { width: 100%; }
    #navMoreList { position: absolute; z-index: 45; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: none; min-width: 180px; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
    #navMoreList button { width: 100%; text-align: left; margin-bottom: 4px; }
    html[data-nav="side"] #navMoreList { left: 100%; top: 0; margin-left: 6px; }
    html[data-nav="top"] #navMoreList { left: 0; top: 100%; margin-top: 6px; }
    html[data-nav="bottom"] #navMoreList { left: 0; bottom: 100%; margin-bottom: 6px; }
    main { flex: 1; min-width: 0; }
    #burger { display: none; }
    #scrim { display: none; }
    .scrollx { overflow-x: auto; }
    .scrollx table { min-width: 760px; }
    .scrollx input, .scrollx select { width: 100%; padding: 6px; font-size: 13px; border: 1px solid var(--line); border-radius: 6px; }
    .sheet { max-width: 1050px; }
    .docbox { border: 1px solid #000; text-align: center; padding: 8px; margin: 8px 0; }
    .stamp { border: 1px dashed #999; border-radius: 8px; color: #999; text-align: center; padding: 18px 8px; font-size: 13px; }
    .docfoot { text-align: right; color: #333; margin-top: 10px; }
    .docorg { text-align: center; color: #444; font-size: 13px; }
    .doctitle { text-align: center; margin: 10px 0 16px; }
    .drow { display: grid; grid-template-columns: 160px 1fr; gap: 8px; margin: 6px 0; align-items: center; }
    .dlabel { color: #444; font-size: 14px; }
    .sheet input, .sheet textarea, .sheet select { width: 100%; padding: 8px; font-size: 15px; border: none; border-bottom: 1px solid #999; border-radius: 0; background: transparent; }
    .sheet table.doc { border-collapse: collapse; width: 100%; font-size: 14px; }
    .sheet table.doc td, .sheet table.doc th { border: 1px solid #999; padding: 6px; }
    .sheet table.doc input { border: none; padding: 4px; font-size: 13px; }
    @media (max-width: 640px) { .drow { grid-template-columns: 1fr; } }
    @media print {
      header, #side, #scrim, #burger, .bar, .tabs, #svState, button, .noprint, #stats, #warn, .frm, .docfoot { display: none !important; }
      body { max-width: none; padding: 0; }
      .app { display: block; }
      .sheet { max-width: none; }
      .card { border: none; box-shadow: none; }
      .sheet table.doc { font-size: 12pt; }
      .sheet input, .sheet textarea, .sheet select { border-bottom-color: #fff; }
      .sheet select { appearance: none; -webkit-appearance: none; }
    }
    html[data-nav="top"] .app { flex-direction: column; }
    html[data-nav="top"] #side { position: sticky; top: 0; z-index: 35; width: auto; max-height: none; overflow: visible; background: var(--bg); padding: 8px 0 2px; border-bottom: 1px solid var(--line); }
    html[data-nav="top"] #side nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; width: max-content; max-width: 100%; margin: 0 auto; padding-bottom: 6px; }
    html[data-nav="top"] #side nav button { white-space: nowrap; }
    html[data-nav="top"] #navMoreWrap { flex: none; }
    html[data-nav="top"] #burger { display: none; }
    html[data-nav="bottom"] body { padding-bottom: 76px; }
    html[data-nav="bottom"] #side { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: none; overflow: visible; background: var(--card); border-top: 1px solid var(--line); z-index: 50; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
    html[data-nav="bottom"] #side nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; width: max-content; max-width: 100%; margin: 0 auto; }
    html[data-nav="bottom"] #side nav button { white-space: nowrap; }
    html[data-nav="bottom"] #navMoreWrap { flex: none; }
    html[data-nav="bottom"] #burger, html[data-nav="top"] #burger { display: none; }
    html[data-nav="bottom"] #scrim { display: none !important; }
    @media (max-width: 760px) {
      .tabs { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
      .tabs button { white-space: nowrap; }
    }
    @media (max-width: 760px) {
      html[data-nav="side"] #burger { display: inline-block; }
      html[data-nav="side"] #side { position: fixed; left: 0; top: 0; bottom: 0; width: min(88vw, max(var(--sidew), 230px)); max-height: none; background: var(--card); z-index: 50; padding: 16px; border-right: 1px solid var(--line); transform: translateX(-110%); transition: transform .2s; overflow-y: auto; }
      html[data-nav="side"] #navMoreList { position: static; margin: 6px 0 0; box-shadow: none; min-width: 0; }
      body.side-open #side { transform: none; }
      body.side-open #scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 40; }
    }
    label.f { display: block; font-size: 12px; color: var(--dim); margin-top: 6px; }
    label.f input, label.f select { display: block; width: 100%; }
    /* Модальные окна управления файлами */
    .modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow: auto; }
    .modal-card { background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; padding: 14px; width: min(760px, 100%); box-shadow: 0 12px 40px rgba(0,0,0,.3); }
    .mhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
    .mbar { border-color: var(--accent); }
    [data-dropto].dropok { outline: 2px dashed var(--accent); outline-offset: 2px; background: var(--accent-soft); }
    .fsel { cursor: pointer; }
    .frow:hover { background: var(--accent-soft); }
    .hsec { border-bottom: 1px solid var(--line); padding: 6px 0; }
    /* Скрытие числовых метрик: галочка в Настройках → Вид (сколько файлов, заключений и т.п.) */
    html[data-counts="off"] .metric { display: none !important; }
    html[data-counts="off"] #dCards b { display: none; }
    .hsec summary { cursor: pointer; font-size: var(--fs); }
    .hsec > ul { margin: 8px 0 10px; padding-left: 22px; }
    .hsec > ul li { margin: 4px 0; }
    .hhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
    .hintro { color: var(--fg); margin-bottom: 10px; }
    .hqa { margin: 8px 0 10px; }
    .hq { margin: 8px 0; }
    .hq b { display: block; }
    .hfoot { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px; font-size: 13px; }
    @media print {
      #vHelp .bar { display: none !important; }
      #vHelp details > ul, #vHelp details > div { display: block !important; }
      #vHelp .hsec, #vHelp .card { border: none; }
    }
