/* ==========================================================================
   Aplosoft case pages — shared core (corporate style of aplosoft.ru)
   Inlined into every template by build.py in place of the aplo:core marker.
   Edit here, not in built pages. Template-specific CSS lives in the template.
   ========================================================================== */

:root {
  color-scheme: light;

  /* neutrals — taken from aplosoft.ru */
  --bg: #F3F4F7;
  --surface: #FFFFFF;
  --surface-2: #F4F4F5;
  --line: #E4E5E9;
  --line-2: #D3D5DA;
  --ink: #2F2F2F;
  --ink-2: #55626F;
  --ink-3: #646E79;
  --dark: #2F2F2F;
  --on-dark: #FFFFFF;
  --on-dark-2: #C8CBD1;

  /* brand hues — fill / tint / soft / text-safe ink */
  --blue: #4199F6;    --blue-tint: #D9EBFD;   --blue-soft: #EEF6FE;   --blue-ink: #1A5DAB;
  --orange: #FF8400;  --orange-tint: #FFE6CC; --orange-soft: #FFF4E8; --orange-ink: #9A4B00;
  --purple: #7978DC;  --purple-tint: #E4E4F8; --purple-soft: #F3F3FC; --purple-ink: #4544A3;
  --green: #82C114;   --green-tint: #E6F5CB;  --green-soft: #F4FBE6;  --green-ink: #416605;

  /* status tones — never used as decoration, always with a text label */
  --ok-bg: #E4F3E9;   --ok-fg: #1C7A44;   --ok-dot: #2E9E5B;
  --wait-bg: #FFF1D9; --wait-fg: #8A5108; --wait-dot: #E0890B;
  --info-bg: #E0F0F2; --info-fg: #0E6B76; --info-dot: #1593A0;
  --risk-bg: #FBE8E5; --risk-fg: #B22A1B; --risk-dot: #DC4633;
  --mute-bg: #ECEDF0; --mute-fg: #55626F; --mute-dot: #9AA1AB;

  /* page accent — overridden by html[data-accent] or any .t-* wrapper */
  --accent: var(--blue); --accent-tint: var(--blue-tint); --accent-soft: var(--blue-soft); --accent-ink: var(--blue-ink);

  --r-card: 24px;
  --r-box: 16px;
  --r-ctl: 12px;
  --gap: 20px;
  --pad: clamp(20px, 3vw, 34px);
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Consolas, 'Liberation Mono', monospace;
}

html[data-accent="blue"],   .t-blue   { --accent: var(--blue);   --accent-tint: var(--blue-tint);   --accent-soft: var(--blue-soft);   --accent-ink: var(--blue-ink); }
html[data-accent="orange"], .t-orange { --accent: var(--orange); --accent-tint: var(--orange-tint); --accent-soft: var(--orange-soft); --accent-ink: var(--orange-ink); }
html[data-accent="purple"], .t-purple { --accent: var(--purple); --accent-tint: var(--purple-tint); --accent-soft: var(--purple-soft); --accent-ink: var(--purple-ink); }
html[data-accent="green"],  .t-green  { --accent: var(--green);  --accent-tint: var(--green-tint);  --accent-soft: var(--green-soft);  --accent-ink: var(--green-ink); }
html[data-accent="graphite"], .t-graphite { --accent: #2F2F2F; --accent-tint: #E4E5E9; --accent-soft: #F4F4F5; --accent-ink: #2F2F2F; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
a { color: var(--accent-ink); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: 4px; }
p, ul, ol, dl, figure, h1, h2, h3, h4 { margin: 0; }
p, li { max-width: 72ch; }
b, strong { font-weight: 600; }
code, .mono {
  font-family: var(--mono); font-size: .88em;
  background: var(--surface-2); border-radius: 6px; padding: 1px 6px;
  overflow-wrap: anywhere;
}

h1, h2 { text-transform: uppercase; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: clamp(28px, 4.4vw, 46px); line-height: 1.06; }
h2 { font-size: clamp(20px, 2.5vw, 27px); line-height: 1.15; }
h3 { font-size: 17px; line-height: 1.3; font-weight: 600; text-wrap: balance; }
h4 { font-size: 15px; line-height: 1.3; font-weight: 600; }
.h-plain { text-transform: none; letter-spacing: -.02em; }   /* sentence-case heading for long titles */
.lead { font-size: clamp(17px, 1.6vw, 19px); line-height: 1.5; color: var(--ink-2); }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.eyebrow {
  font-size: 12px; line-height: 1.3; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3);
}
.accent { color: var(--accent-ink); }

/* ---------- layout ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: clamp(14px, 2.4vw, 28px); display: flex; flex-direction: column; gap: var(--gap); }
.page--narrow { max-width: 820px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack--lg { gap: 24px; }
.row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.row--between { justify-content: space-between; }
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.grid--tight { gap: 12px; }

/* ---------- brand bar and footer ---------- */
.logo { display: block; height: 34px; width: auto; flex: none; align-self: flex-start; }
.brandbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; padding: 4px 6px; }
.brandbar__meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px 32px;
  padding: 10px 6px 4px; color: var(--ink-3); font-size: 13px; line-height: 1.5;
}
.foot a { color: inherit; }
.foot .logo { height: 28px; margin-bottom: 10px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border-radius: var(--r-card); padding: var(--pad); display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card--tint { background: var(--accent-tint); }
.card--soft { background: var(--accent-soft); }
.card--flat { background: var(--surface-2); }
.card--dark { background: var(--dark); color: var(--on-dark); --logo-bg: #fff; --logo-fg: #2F2F2F; }
.card--dark .lead, .card--dark .muted { color: var(--on-dark-2); }
.card--dark .eyebrow { color: #A9AEB7; }
.card--dark a { color: #fff; }
.card--line { background: transparent; border: 1px solid var(--line-2); }
.box { background: var(--surface-2); border-radius: var(--r-box); padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.box--tint { background: var(--accent-tint); }
.box--soft { background: var(--accent-soft); }
.box--white { background: var(--surface); }
.box--line { background: transparent; border: 1px solid var(--line-2); }

/* isometric grid — the signature backdrop of aplosoft.ru illustrations */
.deco { position: relative; overflow: hidden; isolation: isolate; }
.deco::after {
  content: ""; position: absolute; z-index: -1; inset: -20% -10% -20% 35%;
  background:
    repeating-linear-gradient(30deg, transparent 0 39px, var(--deco-line, #DADCE3) 39px 40px),
    repeating-linear-gradient(150deg, transparent 0 39px, var(--deco-line, #DADCE3) 39px 40px);
  -webkit-mask-image: radial-gradient(ellipse at 75% 50%, #000 0%, transparent 70%);
  mask-image: radial-gradient(ellipse at 75% 50%, #000 0%, transparent 70%);
  pointer-events: none;
}
.card--dark.deco { --deco-line: rgba(255, 255, 255, .13); }
.card--tint.deco { --deco-line: rgba(47, 47, 47, .09); }

/* ---------- small components ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  font-size: 12px; line-height: 1.2; font-weight: 600; letter-spacing: .02em;
  padding: 5px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--mute-bg); color: var(--mute-fg);
}
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--mute-dot); flex: none; }
.tag--ok   { background: var(--ok-bg);   color: var(--ok-fg); }   .tag--ok::before   { background: var(--ok-dot); }
.tag--wait { background: var(--wait-bg); color: var(--wait-fg); } .tag--wait::before { background: var(--wait-dot); }
.tag--info { background: var(--info-bg); color: var(--info-fg); } .tag--info::before { background: var(--info-dot); }
.tag--risk { background: var(--risk-bg); color: var(--risk-fg); } .tag--risk::before { background: var(--risk-dot); }
.tag--accent { background: var(--accent-tint); color: var(--accent-ink); } .tag--accent::before { background: var(--accent); }
.tag--plain { background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-2); padding: 4px 10px; }
.tag--plain::before { display: none; }
.tag--dark { background: var(--dark); color: #fff; } .tag--dark::before { display: none; }

.btn {
  display: inline-flex; align-items: center; gap: 12px; align-self: flex-start;
  background: var(--dark); color: #fff; text-decoration: none; font: 500 15px/1 var(--font);
  padding: 6px 6px 6px 20px; border-radius: 999px; border: 0; cursor: pointer;
}
.btn::after {
  content: ""; width: 34px; height: 34px; border-radius: 50%; background: #fff no-repeat center / 16px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232F2F2F' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 7l10 10'/%3E%3Cpath d='M17 8v9H8'/%3E%3C/svg%3E");
}
.btn:hover { background: #1c1c1c; }
.btn--light { background: #fff; color: var(--ink); }
.btn--light::after { background-color: var(--dark); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 7l10 10'/%3E%3Cpath d='M17 8v9H8'/%3E%3C/svg%3E"); }
.btn--light:hover { background: #f1f1f1; }
.card--dark a.btn--light { color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink); border: 1px solid var(--line-2); padding: 12px 20px; }
.btn--ghost::after { display: none; }
.btn--ghost:hover { background: var(--surface-2); }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icbox {
  width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-tint); color: var(--accent-ink);
}
.icbox .ic { width: 22px; height: 22px; }

.note {
  border-radius: var(--r-box); padding: 16px 20px; background: var(--wait-bg); color: #5B3A0A;
  display: flex; flex-direction: column; gap: 6px;
}
.note--info { background: var(--accent-soft); color: var(--ink); }
.note--risk { background: var(--risk-bg); color: #6E1D13; }
.note--ok { background: var(--ok-bg); color: #124F2C; }
.note > b:first-child, .note__title { font-weight: 600; }

.kv { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); font-size: 15px; }
.kv dt, .kv dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); }
.kv dt { color: var(--ink-2); padding-right: 18px; }
.kv dd { text-align: right; font-weight: 500; }
.kv > :nth-last-child(-n+2) { border-bottom: 0; }
.card--dark .kv dt, .card--dark .kv dd { border-color: rgba(255, 255, 255, .14); }
.card--dark .kv dt { color: var(--on-dark-2); }

.steps { list-style: none; padding: 0; counter-reset: step; display: flex; flex-direction: column; gap: 14px; }
.steps > li { counter-increment: step; position: relative; padding-left: 46px; min-height: 32px; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: -3px; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px; font-weight: 600;
  background: var(--accent-tint); color: var(--accent-ink);
}
.checks { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.checks > li { position: relative; padding-left: 30px; }
.checks > li::before {
  content: ""; position: absolute; left: 0; top: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent-tint) no-repeat center / 12px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232F2F2F' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}
.checks--todo > li::before { background: transparent; border: 2px solid var(--line-2); }
.card--tint .steps > li::before, .box--tint .steps > li::before,
.card--tint .checks:not(.checks--todo) > li::before, .box--tint .checks:not(.checks--todo) > li::before { background-color: var(--surface); }
.plain { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

.stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat__label { font-size: 13px; color: var(--ink-2); }
.stat__value { font-size: clamp(26px, 3vw, 36px); line-height: 1.1; font-weight: 700; letter-spacing: -.02em; }
.stat__value small { font-size: .5em; font-weight: 500; letter-spacing: 0; color: var(--ink-2); margin-left: 4px; }
.stat__delta { font-size: 13px; color: var(--ink-2); }
.stat__delta b { font-weight: 600; }
.up { color: var(--ok-fg); } .down { color: var(--risk-fg); }
.card--dark .stat__label, .card--dark .stat__delta, .card--dark .stat__value small { color: var(--on-dark-2); }
.card--dark .up { color: #7FD6A0; } .card--dark .down { color: #FF9C8C; }

.meter { height: 8px; border-radius: 999px; background: var(--accent-tint); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

/* ---------- tables ---------- */
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-box); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-2); background: var(--surface-2); white-space: nowrap;
}
tbody tr:last-child > * { border-bottom: 0; }
tfoot td, tfoot th { font-weight: 600; background: var(--surface-2); border-bottom: 0; border-top: 1px solid var(--line-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.is-key > * { background: var(--accent-soft); }
.tbl--wide table { min-width: 620px; }   /* 4+ columns: scroll sideways on phones instead of squeezing */

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  :root { --r-card: 20px; --gap: 14px; }
  body { font-size: 15.5px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-4.grid--keep2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .deco::after { inset: -10% -30% -10% 20%; opacity: .7; }
  th, td { padding: 10px 12px; }
  .kv dd { text-align: left; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv dt { border-bottom: 0; padding-bottom: 0; font-size: 13px; }
  .kv > :nth-last-child(2) { border-bottom: 0; }
}

/* ---------- print (clients save these pages to PDF) ---------- */
@media print {
  @page { margin: 14mm 12mm; }
  body { background: #fff; font-size: 11.5pt; }
  .page { padding: 0; max-width: none; gap: 12px; }
  /* on paper a card is a section under a rule: a framed card that breaks across pages leaves empty boxes */
  .card { background: transparent; border-top: 1px solid var(--line-2); border-radius: 0; padding: 14px 0 0; }
  .card--tint { background: var(--accent-tint); }
  .card--soft { background: var(--accent-soft); }
  .card--flat { background: var(--surface-2); }
  .card--tint, .card--soft, .card--flat, .card--line { border: 0; border-radius: 12px; padding: 16px 18px; break-inside: avoid; }
  .card--line { border: 1px solid var(--line-2); }
  tfoot { display: table-row-group; }
  /* A4 is narrower than the tablet breakpoint: keep the desktop column counts on paper */
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
  .card--dark { background: transparent; color: var(--ink); --logo-bg: #2F2F2F; --logo-fg: #fff; }
  .card--dark .lead, .card--dark .muted, .card--dark .stat__label, .card--dark .stat__delta, .card--dark .kv dt, .card--dark .eyebrow { color: var(--ink-2); }
  .card--dark .kv dt, .card--dark .kv dd { border-color: var(--line); }
  .card--dark .up { color: var(--ok-fg); } .card--dark .down { color: var(--risk-fg); }
  .card--dark a { color: inherit; }
  .deco::after, .no-print { display: none !important; }
  .tbl { overflow: visible; }
  tr, .box, .note, li { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
  a { color: inherit; text-decoration: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
