/* Дизайн BoevLab в стиле Apple (скилл boevlab-apple-design): один синий акцент,
   карточки с тонкой рамкой без теней, тень только у меню-острова, радиусы по ролям. */

:root {
  --font: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --ground: #f5f5f7; --surface: #ffffff; --surface-2: #f5f5f7;
  --fill: rgba(0, 0, 0, .05); --fill-hover: rgba(0, 0, 0, .09); --seg-on: #ffffff;
  --ink: #1d1d1f; --ink-soft: #515154; --ink-faint: #6e6e73;
  --rule: #f0f0f0; --hairline: #e0e0e0;
  --island: rgba(255, 255, 255, .72);
  --brand: #0066cc; --brand-strong: #0071e3; --link: #0066cc;
  --good: #1d7f3a; --warn: #9a5b00; --bad: #c9231b;
  --good-bg: rgba(52, 199, 89, .14); --warn-bg: rgba(255, 159, 10, .16); --bad-bg: rgba(255, 59, 48, .11);
  --shadow-float: 0 14px 44px rgba(0, 0, 0, .10), 0 1px 3px rgba(0, 0, 0, .06);
  --r-md: 11px; --r-lg: 18px; --r-xl: 24px; --r-sheet: 28px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #000; --surface: #1d1d1f; --surface-2: #272729;
    --fill: rgba(255, 255, 255, .08); --fill-hover: rgba(255, 255, 255, .14); --seg-on: #48484a;
    --ink: #f5f5f7; --ink-soft: #c7c7cc; --ink-faint: #98989d;
    --rule: rgba(255, 255, 255, .08); --hairline: rgba(255, 255, 255, .14);
    --island: rgba(29, 29, 31, .72);
    --brand: #0071e3; --brand-strong: #2997ff; --link: #2997ff;
    --good: #30d158; --warn: #ff9f0a; --bad: #ff6961;
    --good-bg: rgba(48, 209, 88, .16); --warn-bg: rgba(255, 159, 10, .18); --bad-bg: rgba(255, 105, 97, .16);
    --shadow-float: 0 14px 44px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #000; --surface: #1d1d1f; --surface-2: #272729;
  --fill: rgba(255, 255, 255, .08); --fill-hover: rgba(255, 255, 255, .14); --seg-on: #48484a;
  --ink: #f5f5f7; --ink-soft: #c7c7cc; --ink-faint: #98989d;
  --rule: rgba(255, 255, 255, .08); --hairline: rgba(255, 255, 255, .14);
  --island: rgba(29, 29, 31, .72);
  --brand: #0071e3; --brand-strong: #2997ff; --link: #2997ff;
  --good: #30d158; --warn: #ff9f0a; --bad: #ff6961;
  --good-bg: rgba(48, 209, 88, .16); --warn-bg: rgba(255, 159, 10, .18); --bad-bg: rgba(255, 105, 97, .16);
  --shadow-float: 0 14px 44px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 15px/1.47 var(--font); letter-spacing: -.01em;
  background: var(--ground); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 34px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; margin: 0; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -.022em; margin: 0; }
a { color: var(--link); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand-strong); outline-offset: 2px; }

/* Логотип: чёрные буквы в светлой теме, белые — в тёмной */
.logo { display: inline-flex; }
.logo img { height: 30px; width: auto; }
.logo__dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo__light { display: none; }
  :root:not([data-theme="light"]) .logo__dark { display: block; }
}
:root[data-theme="dark"] .logo__light { display: none; }
:root[data-theme="dark"] .logo__dark { display: block; }

/* ---------- Вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login__card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-sheet); padding: 36px 32px 32px; display: grid; gap: 14px;
}
.logo--login { justify-content: center; margin-bottom: 4px; }
.logo--login img { height: 44px; }
.login__title { font-size: 24px; text-align: center; margin-bottom: 8px; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.field input { height: 46px; }
.form-error { color: var(--bad); font-size: 13px; margin: 0; min-height: 18px; }

/* ---------- Каркас ---------- */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 12px; padding: 12px; min-height: 100vh; }
.island {
  position: sticky; top: 12px; height: calc(100vh - 24px);
  background: var(--island); backdrop-filter: saturate(180%) blur(30px); -webkit-backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid var(--hairline); border-radius: var(--r-xl); box-shadow: var(--shadow-float);
  padding: 18px 12px 12px; display: flex; flex-direction: column;
}
.island__head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 18px; }
.island .island__toggle { display: none; }
.island__body { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav__item {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px;
  border-radius: var(--r-md); color: var(--ink); font-weight: 500;
}
.nav__item svg { color: var(--brand); }
.nav__item:hover { background: var(--fill); }
.nav__item.is-active { background: var(--brand); color: #fff; }
.nav__item.is-active svg { color: #fff; }
.island__foot { margin-top: auto; display: grid; gap: 12px; padding: 0 4px; }
.island__user { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--ink-faint); padding: 0 4px; }

.content { padding: 20px 20px 40px; min-width: 0; }
.page-head { margin-bottom: 18px; }
.page-head--row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-sub { color: var(--ink-faint); margin: 6px 0 0; }

/* ---------- Компоненты ---------- */
.card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 22px 24px; min-width: 0; }
.empty { color: var(--ink-faint); margin: 0; }

.input {
  height: 36px; width: 100%; padding: 0 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md);
}
.input:focus, .field input:focus { outline: 2px solid var(--brand-strong); outline-offset: 0; border-color: transparent; }
.field input { width: 100%; padding: 0 14px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); }
.input--search { width: min(360px, 100%); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--link);
  transition: transform .12s ease;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-strong); }
.btn--wide { width: 100%; height: 44px; margin-top: 4px; }
.btn[disabled] { opacity: .5; cursor: default; transform: none; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--fill); display: grid; place-items: center; }
.link-btn { border: 0; background: none; color: var(--link); padding: 0; font-size: 13px; }

.segmented { display: flex; background: var(--fill); border-radius: 999px; padding: 3px; }
.segmented button { flex: 1; border: 0; background: none; border-radius: 999px; height: 28px; font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.segmented button[aria-checked="true"] { background: var(--seg-on); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.segmented--small button { height: 26px; font-size: 12px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.badge--ok { background: var(--good-bg); color: var(--good); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--bad { background: var(--bad-bg); color: var(--bad); }
.badge--muted { background: var(--fill); color: var(--ink-faint); }

/* ---------- Новый акт ---------- */
.grid-new { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 12px; align-items: start; }
.card--list { padding: 14px; display: grid; gap: 10px; position: sticky; top: 12px; }
.order-list { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 220px); overflow: auto; }
.order-list button {
  width: 100%; text-align: left; border: 0; background: none; border-radius: var(--r-md);
  padding: 9px 12px; display: grid; gap: 1px;
}
.order-list button:hover { background: var(--fill); }
.order-list button.is-active { background: var(--brand); color: #fff; }
.order-list button.is-active .order-meta { color: rgba(255, 255, 255, .8); }
.order-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-meta { font-size: 13px; color: var(--ink-faint); }

.preview-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.preview-head a { font-size: 13px; }
.warnings { list-style: none; margin: 16px 0 0; padding: 12px 14px; border-radius: var(--r-md); background: var(--warn-bg); color: var(--warn); font-size: 14px; display: grid; gap: 4px; }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.result { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--rule); display: grid; gap: 12px; }
.result__files { display: flex; gap: 10px; flex-wrap: wrap; }
.history { margin-top: 22px; }
.history h2 { margin-bottom: 8px; }

/* Форма акта */
.act-form { display: grid; gap: 18px; margin-top: 16px; }
.group { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 0; }
.group legend { font-size: 15px; font-weight: 600; padding: 0; margin-bottom: 8px; }
.row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; align-items: start; }
.row > span { color: var(--ink-faint); font-size: 14px; padding-top: 8px; }
.input--area { height: auto; min-height: 36px; padding: 8px 12px; line-height: 1.45; resize: vertical; }
.warnings { margin-top: 0; }

/* ---------- Таблица ---------- */
.card--table { padding: 6px 0; overflow-x: auto; }
.card--table .empty { padding: 16px 24px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 500; color: var(--ink-faint); padding: 10px 14px; }
.table td { padding: 11px 14px; border-top: 1px solid var(--rule); vertical-align: top; }
.table th:first-child, .table td:first-child { padding-left: 24px; }
.table th:last-child, .table td:last-child { padding-right: 24px; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .sub { display: block; color: var(--ink-faint); font-size: 13px; }
.files { display: flex; gap: 10px; white-space: nowrap; }

.spinner { width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } .btn { transition: none; } }

/* ---------- Телефон ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); padding: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  .island { position: sticky; top: 8px; height: auto; z-index: 5; padding: 10px 10px 10px 14px; }
  .island__head { padding: 0; }
  .island .island__toggle { display: grid; }
  .island__body { display: none; padding-top: 10px; }
  .island.is-open .island__body { display: flex; }
  .nav__item { height: 44px; }
  .island__foot { margin-top: 10px; }
  .content { padding: 18px 6px 32px; }
  h1 { font-size: 28px; }
  .grid-new { grid-template-columns: minmax(0, 1fr); }
  .card--list { position: static; }
  .order-list { max-height: 260px; }
  .row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .row > span { padding-top: 0; font-size: 13px; }
      .input, .field input { font-size: 16px; }
  .btn { height: 44px; }
  .card { padding: 18px; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: 12px 18px; border-top: 1px solid var(--rule); }
  .table td, .table td:first-child, .table td:last-child { border: 0; padding: 2px 0; }
  .table td.files { display: flex; }
}
