/* «Полевой журнал» — оформление в фирменном стиле Activeron.
   Токены взяты с сайта activeron.com (app/globals.css), а не подобраны на глаз:
   тёмный фон #08090d, оранжевый градиент #ff7a4d → #ff5a2e → #e6391a,
   индиго #6c7dff, Inter для текста, Space Grotesk для заголовков. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/static/fonts/space-grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --bg: #08090d;
  --bg-elevated: #131420;
  --panel: #14151f;
  --panel-hover: #181a27;
  --line: rgba(44, 46, 66, .7);
  --line-strong: #2c2e42;
  --text: #f6f5f2;
  --muted: #9a9db3;
  --accent: #ff5a2e;
  --accent-bright: #ff7a4d;
  --accent-deep: #e6391a;
  --accent-soft: rgba(255, 90, 46, .12);
  --indigo: #6c7dff;
  --indigo-soft: rgba(108, 125, 255, .12);
  --grad: linear-gradient(135deg, #ff7a4d 0%, #ff5a2e 55%, #e6391a 100%);
  --danger: #ff6b60;
  --warn: #f0a93b;
  --ok: #3ddc97;
  --radius: 16px;
  --radius-sm: 12px;
  --tap: 48px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Space Grotesk", "Inter", -apple-system, sans-serif;
  --shadow-card: 0 2px 8px rgba(0, 0, 0, .3), 0 16px 40px -20px rgba(0, 0, 0, .6);
}

/* Светлая тема — та же палитра, но фон и панели светлые (как lk-light на сайте). */
[data-theme="light"] {
  color-scheme: light;
  --bg: #eef0f4;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --panel-hover: #f7f8fa;
  --line: #e2e5ea;
  --line-strong: #d5d9e0;
  --text: #14161a;
  --muted: #6b7280;
  --accent-soft: rgba(255, 90, 46, .1);
  --indigo-soft: rgba(108, 125, 255, .1);
  --shadow-card: 0 1px 2px rgba(20, 22, 26, .06), 0 8px 24px -16px rgba(20, 22, 26, .24);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
html { -webkit-text-size-adjust: 100%; }
body {
  font: 16px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  background-image: radial-gradient(900px 420px at 50% -180px, rgba(255, 90, 46, .10), transparent 70%);
  background-repeat: no-repeat;
  min-height: 100vh;
}
a { color: var(--indigo); }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { max-width: 1100px; margin: 0 auto; padding: 14px 16px 96px; }

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}
.topbar .brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--display); font-weight: 600; font-size: 17px; letter-spacing: -.01em;
  color: var(--text); text-decoration: none;
}
.topbar .brand .logo { width: 26px; height: 26px; display: block; flex: none; }
.topbar .brand span { white-space: nowrap; }
.topbar .brand .logo-light { display: none; }
[data-theme="light"] .topbar .brand .logo-dark { display: none; }
[data-theme="light"] .topbar .brand .logo-light { display: block; }
.topbar .brand .tag {
  font-family: var(--font); font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent-bright);
  background: var(--accent-soft); padding: 3px 8px; border-radius: 999px;
}
.topbar .spacer { flex: 1; }
.topbar .who {
  color: var(--muted); font-size: 13px; max-width: 36vw; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .02); border: 1px solid var(--line-strong); color: var(--text);
  border-radius: 999px; min-width: 40px; height: 40px; cursor: pointer;
  transition: border-color .2s ease, background .2s ease, color .2s ease;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-soft); }
[data-theme="light"] .icon-btn { background: #fff; }

/* ---------- заголовки ---------- */
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.02em; }
h1 { font-size: 26px; margin: 20px 0 12px; }
h2 { font-size: 19px; margin: 20px 0 10px; }
h3 { font-size: 16px; margin: 14px 0 8px; }
.muted { color: var(--muted); }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.eyebrow::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--grad);
  box-shadow: 0 0 12px 2px rgba(255, 90, 46, .55);
}

/* ---------- карточки и списки ---------- */
.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 12px 0; box-shadow: var(--shadow-card);
}
[data-theme="light"] .card { background: var(--panel); box-shadow: var(--shadow-card); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.list { display: grid; gap: 10px; }
.item {
  position: relative; display: block;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; text-decoration: none; color: var(--text);
  transition: border-color .2s ease, background .2s ease, transform .2s cubic-bezier(.2, .8, .2, 1);
}
[data-theme="light"] .item { background: var(--panel); }
.item:hover {
  border-color: rgba(255, 90, 46, .55); background: var(--panel-hover);
  transform: translateY(-1px);
}
.item::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--grad); opacity: 0; transition: opacity .2s ease;
}
.item:hover::before { opacity: 1; }
.item .t { font-family: var(--display); font-weight: 600; font-size: 17px; letter-spacing: -.01em; }
.item .s { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---------- кнопки: пилюли, как на сайте ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 11px 22px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .02);
  color: var(--text); cursor: pointer; text-decoration: none;
  font-weight: 600; font-size: 15px; line-height: 1.1;
  transition: transform .2s cubic-bezier(.2, .8, .2, 1), border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
[data-theme="light"] .btn { background: #fff; }
.btn:hover { transform: translateY(-1px); border-color: rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .05); }
[data-theme="light"] .btn:hover { background: #f7f8fa; border-color: #c6cad3; }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--grad); border-color: transparent; color: #0a0b10;
  box-shadow: 0 8px 30px -8px rgba(255, 90, 46, .45);
}
.btn.primary:hover { box-shadow: 0 12px 36px -6px rgba(255, 90, 46, .6); background: var(--grad); }
.btn.danger { color: var(--danger); border-color: rgba(255, 107, 96, .45); }
.btn.danger:hover { background: rgba(255, 107, 96, .1); border-color: var(--danger); }
.btn.small { min-height: 38px; padding: 7px 16px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }

.pill {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-bright);
}
.pill.warn { background: rgba(240, 169, 59, .14); color: var(--warn); }
.pill.ok { background: rgba(61, 220, 151, .12); color: var(--ok); }

/* ---------- формы ---------- */
label.f { display: block; margin: 12px 0; }
label.f span { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: color-mix(in srgb, var(--bg) 55%, var(--panel));
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 12px 14px; min-height: var(--tap);
  transition: border-color .2s ease, box-shadow .2s ease;
}
[data-theme="light"] input, [data-theme="light"] select, [data-theme="light"] textarea { background: #fff; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 84px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 640px) { .grid3 { grid-template-columns: 1fr 1fr; } .grid2 { grid-template-columns: 1fr; } }

/* ---------- вкладки ---------- */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .02); color: var(--text);
  border-radius: 999px; padding: 9px 16px; white-space: nowrap; cursor: pointer;
  font-weight: 600; font-size: 14px; transition: border-color .2s ease, background .2s ease, color .2s ease;
}
[data-theme="light"] .tab { background: #fff; }
.tab:hover { border-color: var(--accent); color: var(--accent-bright); }
.tab.on { background: var(--grad); border-color: transparent; color: #0a0b10; box-shadow: 0 6px 20px -8px rgba(255, 90, 46, .55); }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
table.t th, table.t td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
table.t th {
  color: var(--muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em; background: color-mix(in srgb, var(--bg) 45%, var(--panel));
}
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
table.t input, table.t select, table.t textarea { padding: 8px 10px; min-height: 40px; font-size: 14px; }
table.t textarea { min-height: 40px; }

/* Модальные окна не должны прятаться под закреплённой шапкой */
#modal { scroll-margin-top: 72px; }
#modal > .card { scroll-margin-top: 72px; }

/* ---------- состояние связи ---------- */
.offline-bar {
  position: sticky; top: 61px; z-index: 19;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: flex; gap: 10px 14px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 9px 16px; font-size: 13px; font-weight: 500;
  background: rgba(255, 90, 46, .14); color: var(--accent-bright);
  border-bottom: 1px solid rgba(255, 90, 46, .38);
}
.offline-bar b { font-weight: 600; }
.offline-bar.pending { background: var(--indigo-soft); color: var(--indigo); border-color: rgba(108, 125, 255, .3); }
.offline-bar .link-btn { color: inherit; text-decoration: underline; font-size: 13px; padding: 0; }
[data-theme="light"] .offline-bar { background: rgba(255, 90, 46, .12); color: var(--accent-deep); }

/* ---------- сообщения ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--panel); border: 1px solid var(--line-strong); border-left: 4px solid var(--accent);
  border-radius: 14px; padding: 13px 18px; max-width: min(560px, 92vw);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .7); font-size: 15px;
}
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.notes {
  margin: 12px 0 0; padding: 12px 14px 12px 30px;
  background: rgba(240, 169, 59, .08); border: 1px solid rgba(240, 169, 59, .3);
  border-radius: var(--radius-sm); font-size: 14px;
}
.notes li { margin: 3px 0; }
.empty {
  text-align: center; color: var(--muted); padding: 40px 16px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: color-mix(in srgb, var(--panel) 35%, transparent);
}
.spinner {
  display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line-strong);
  border-top-color: var(--accent); border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -3px;
}
@keyframes sp { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ---------- вход ---------- */
.login { max-width: 430px; margin: 6vh auto; padding: 28px 26px 24px; }
.login h1 { text-align: center; margin: 14px 0 4px; font-size: 27px; }
.login .eyebrow { display: flex; justify-content: center; margin-top: 14px; }
.login .login-logo { display: block; width: 54px; height: 54px; margin: 0 auto; }
.login .login-logo.logo-light { display: none; }
[data-theme="light"] .login .login-logo.logo-dark { display: none; }
[data-theme="light"] .login .login-logo.logo-light { display: block; margin: 0 auto; }
.login .card { background: none; border: 0; box-shadow: none; padding: 0; }
.link-btn {
  background: none; border: 0; color: var(--indigo); cursor: pointer; padding: 6px;
  font-size: 14px; text-decoration: none;
}
.link-btn:hover { color: var(--accent-bright); }

/* ---------- прочее ---------- */
.sticky-actions {
  position: sticky; bottom: 0; display: flex; gap: 10px;
  padding: 16px 0 calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 46%);
}
.sticky-actions .btn { flex: 1; white-space: nowrap; padding-left: 14px; padding-right: 14px; }
.field-mode { --tap: 56px; }
.field-mode input, .field-mode select, .field-mode textarea { font-size: 18px; }
.field-mode .btn { font-size: 17px; }
.crumbs { font-size: 13px; color: var(--muted); margin-top: 14px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent-bright); }

@media (max-width: 640px) {
  .app { padding: 10px 12px 92px; }
  .topbar { padding: 9px 12px; }
  .topbar .brand { font-size: 15px; gap: 8px; }
  .topbar .brand .logo { width: 24px; height: 24px; }
  .topbar .brand .tag, .topbar .who { display: none; }
  h1 { font-size: 22px; }
  .card { padding: 15px; }
}

/* Телефон: таблицы разрезов и образцов превращаются в карточки —
   в поле некогда возиться с горизонтальной прокруткой. */
@media (max-width: 640px) {
  .table-wrap { border: 0; border-radius: 0; overflow: visible; background: none; }
  table.t { min-width: 0; display: block; }
  table.t thead { display: none; }
  table.t tbody { display: block; }
  table.t tr {
    display: block; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px; margin-bottom: 12px; background: var(--panel);
  }
  table.t td {
    display: grid; grid-template-columns: 118px 1fr; gap: 8px; align-items: center;
    border: 0; padding: 5px 0;
  }
  table.t td::before {
    content: attr(data-label); font-size: 11px; color: var(--muted);
    text-transform: uppercase; letter-spacing: .05em;
  }
  table.t td:last-child { display: flex; justify-content: flex-end; }
  table.t td:last-child::before { content: ""; }
  table.t td input, table.t td select, table.t td textarea { width: 100% !important; }
  table.t td[data-label="Описание слоя"] { grid-template-columns: 1fr; }
  table.t td[data-label="Описание слоя"]::before { margin-bottom: 2px; }
}
