/* Рентабельность — Apple-style design system */

:root {
  --bg: #fbfbfd;
  --bg-grad-1: #f5f5f7;
  --bg-grad-2: #ffffff;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --accent: #0066cc;
  --accent-hover: #0077ed;
  --accent-press: #0058b0;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --green: #1a7f37;
  --green-bg: rgba(52, 199, 89, 0.12);
  --red: #d70015;
  --red-bg: rgba(255, 59, 48, 0.10);
  --nav-bg: rgba(251, 251, 253, 0.72);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 980px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-grad-1: #1c1c1e;
    --bg-grad-2: #0a0a0a;
    --surface: rgba(28, 28, 30, 0.66);
    --surface-solid: #1c1c1e;
    --text: #f5f5f7;
    --text-2: #aeaeb2;
    --text-3: #8e8e93;
    --accent: #2997ff;
    --accent-hover: #47a8ff;
    --accent-press: #1f7fe0;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --green: #30d158;
    --green-bg: rgba(48, 209, 88, 0.14);
    --red: #ff453a;
    --red-bg: rgba(255, 69, 58, 0.14);
    --nav-bg: rgba(0, 0, 0, 0.66);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, var(--bg-grad-1), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---------- Navigation (frosted glass) ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 22px;
  height: 52px;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.nav__brand {
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-right: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.nav__brand .brandico { color: var(--text-2); flex: none; display: block; }
.nav__links { display: flex; gap: 2px; }
.nav__link {
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.nav__link:hover { color: var(--text); background: color-mix(in srgb, var(--text) 7%, transparent); }
.nav__link.is-active { color: var(--text); background: color-mix(in srgb, var(--text) 9%, transparent); }
.nav__spacer { flex: 1; }
.nav__user { font-size: 13px; color: var(--text-3); margin-right: 6px; }

/* ---------- Layout ---------- */
.page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 56px 22px 96px;
  animation: rise 0.6s var(--ease) both;
}
.page--narrow { max-width: 720px; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.hero { margin-bottom: 40px; }
.eyebrow {
  font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--accent); text-transform: uppercase; margin-bottom: 10px;
}
h1.title {
  font-size: 44px; font-weight: 700; letter-spacing: -0.03em;
  margin: 0 0 8px; line-height: 1.08;
}
.subtitle { font-size: 19px; color: var(--text-2); margin: 0; max-width: 60ch; }
h2.section { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; margin: 0 0 18px; }

/* staggered children */
.stagger > * { animation: rise 0.55s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: 0.04s; }
.stagger > *:nth-child(2) { animation-delay: 0.10s; }
.stagger > *:nth-child(3) { animation-delay: 0.16s; }
.stagger > *:nth-child(4) { animation-delay: 0.22s; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 28px;
}
.card + .card { margin-top: 20px; }
.card__title { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.card__hint { font-size: 14px; color: var(--text-3); margin: 0 0 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-size: 15px; font-weight: 500;
  padding: 11px 22px; border-radius: var(--radius-pill);
  border: 1px solid transparent; cursor: pointer;
  background: var(--accent); color: #fff;
  transition: transform 0.15s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 34%, transparent); }
.btn:active { background: var(--accent-press); transform: translateY(0); }
.btn--secondary {
  background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--text);
  box-shadow: none;
}
.btn--secondary:hover { background: color-mix(in srgb, var(--text) 12%, transparent); box-shadow: none; }
.btn--ghost { background: transparent; color: var(--accent); padding: 6px 12px; font-size: 13px; box-shadow: none; }
.btn--ghost:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); transform: none; }
.btn--danger { background: transparent; color: var(--red); padding: 6px 12px; font-size: 13px; box-shadow: none; }
.btn--danger:hover { background: var(--red-bg); transform: none; }
.btn--lg { font-size: 17px; padding: 14px 30px; }

/* ---------- Forms / inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-2); }
input[type="text"], input[type="password"], input[type="date"], input.inp, select {
  font-family: var(--font); font-size: 15px; color: var(--text);
  padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-solid);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  width: 100%;
}
input::placeholder { color: var(--text-3); }
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* file drop / picker */
.filepick {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface-solid);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
  cursor: pointer;
}
.filepick:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 4%, var(--surface-solid)); }
.filepick input[type="file"] { display: none; }
.filepick__icon {
  width: 38px; height: 38px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent);
}
.filepick__meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.filepick__label { font-size: 14px; font-weight: 600; }
.filepick__name { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filepick.has-file { border-style: solid; border-color: color-mix(in srgb, var(--green) 50%, var(--border-strong)); }
.filepick.has-file .filepick__icon { background: var(--green-bg); color: var(--green); }

.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- Status banners ---------- */
.banner { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.banner__icon { width: 22px; height: 22px; flex: none; }
.banner--ok { background: var(--green-bg); color: var(--green); }
.banner--err { background: var(--red-bg); color: var(--red); }
.banner strong { font-weight: 600; }
.errlist { margin: 6px 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.errlist li { font-size: 14px; color: var(--text); background: var(--surface-solid); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px 8px 12px; display: flex; align-items: center; gap: 12px; }
.errlist li::before { content: "⚠"; color: var(--red); flex: none; }
.errlist li > span { flex: 1; }
.errlist li > a { flex: none; }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; max-height: 70vh; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-solid); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl thead th {
  position: sticky; top: 0; z-index: 2; text-align: left; font-weight: 600; font-size: 12px;
  letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-3);
  padding: 14px 16px; background: var(--surface-solid);
  box-shadow: inset 0 -1px 0 var(--border);
}
table.tbl tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background 0.15s var(--ease); }
table.tbl tbody tr:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; white-space: nowrap; }

.tag {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px;
  border-radius: var(--radius-pill); background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent); margin: 0 4px 4px 0;
}
.tag--muted { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text-2); }
.count-pill {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  background: color-mix(in srgb, var(--text) 7%, transparent);
  padding: 4px 12px; border-radius: var(--radius-pill); margin-left: 10px;
}

.empty { text-align: center; padding: 60px 20px; color: var(--text-3); }

/* ---------- Progress ---------- */
.progress { display: flex; flex-direction: column; gap: 10px; }
.progress__head { display: flex; justify-content: space-between; align-items: baseline; }
.progress__stage { font-size: 15px; font-weight: 600; }
.progress__pct { font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.progress__track { height: 8px; border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--text) 9%, transparent); overflow: hidden; }
.progress__bar { height: 100%; width: 0%; border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent), #34c759);
  transition: width 0.3s var(--ease); }
.progress__bar.indet { width: 40% !important; animation: indet 1.1s var(--ease) infinite; }
@keyframes indet { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.progress__sub { font-size: 13px; color: var(--text-3); }

/* ---------- Result summary ---------- */
.sumhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.sumhead > div { display: flex; gap: 10px; align-items: center; }
.roundpanel { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin: 0 0 16px; padding: 14px 16px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 6%, transparent); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tbl td.num, table.tbl th.num { text-align: right; }
.finresult { display: flex; flex-direction: column; gap: 8px; margin-top: 20px;
  padding: 18px 20px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--text) 4%, transparent); }
.finrow { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; }
.finrow.total { font-size: 20px; font-weight: 700; padding-top: 10px;
  border-top: 1px solid var(--border); margin-top: 4px; }
.finrow .pos { color: var(--green); }
.finrow .neg { color: var(--red); }

/* ---------- Segmented sub-nav ---------- */
.subnav {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin-bottom: 28px;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border-radius: var(--radius);
}
.subnav a {
  font-size: 14px; font-weight: 500; color: var(--text-2);
  padding: 7px 18px; border-radius: var(--radius-pill);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.subnav a:hover:not(.is-active) { color: var(--text); }
.subnav a.is-active { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Search + toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.searchbar { display: flex; gap: 8px; flex: 1; min-width: 240px; max-width: 460px; }
.searchbar input { flex: 1; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: nowrap; white-space: nowrap; }
.row-actions form { display: inline-flex; margin: 0; }
table.tbl td:first-child, table.tbl th:first-child { white-space: nowrap; }

@media (max-width: 720px) {
  h1.title { font-size: 34px; }
  .upload-grid { grid-template-columns: 1fr; }
  .page { padding: 36px 16px 72px; }
  .nav__user { display: none; }
}
