/* =====================================================================
   Alpline Finance · 2026 — back-office accounting
   Дизайн повторяет alpline.digital: Onest + JetBrains Mono,
   steel-blue монохром, glassy navbar, hairline borders.
   ===================================================================== */

:root {
  /* palette · cool steel monochrome (из alpline.digital) */
  --bg:           #F6F8FB;
  --bg-2:         #FFFFFF;
  --bg-3:         #ECF0F5;
  --bg-deep:      #0A1626;
  --ink:          #0E1825;
  --ink-2:        #1F2C42;
  --ink-3:        #4A5670;
  --muted:        #6B7B95;
  --hairline:     #E1E6EE;
  --hairline-2:  #C9D1DD;
  --steel-1:      #2B4566;
  --steel-2:      #4F6A8C;
  --steel-3:      #8AA0BD;
  --tint:         #E6EDF7;

  --danger:       #7A1F1F;
  --danger-tint:  #FBE7E7;
  --ok:           #1F5A3A;
  --ok-tint:      #E1F1E9;
  --warn:         #7A5400;
  --warn-tint:    #FFF3D6;

  --ui:   'Onest', -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --fs-mono: 11px;
  --fs-body: 15px;
  --fs-h1:   clamp(28px, 3.4vw, 44px);
  --fs-h2:   clamp(20px, 2vw, 26px);

  --pad-x:   clamp(20px, 4vw, 56px);
  --r-1: 6px; --r-2: 12px; --r-3: 20px; --r-pill: 999px;
  --wrap: 1480px;

  --ease: cubic-bezier(.16,.84,.24,1);
  --shadow-1: 0 1px 2px rgba(14,24,37,.04);
  --shadow-2: 0 14px 30px -10px rgba(14,24,37,.10);
  --shadow-3: 0 28px 60px -16px rgba(14,24,37,.14);
  --blur-nav: blur(16px) saturate(140%);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  font-family: var(--ui);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "ss01" 1;
}
h1,h2,h3,h4,p,ul,ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
img,svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
::selection { background: var(--ink); color: var(--bg-2); }

/* === text helpers === */
.mono, .eyebrow, .pill, .table th, .stat-k {
  font-family: var(--mono);
  font-weight: 500;
  font-size: var(--fs-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--muted); }

/* === layout shell === */
.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 24px var(--pad-x) 64px;
}
.page-head {
  display: flex; align-items: end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  margin: 12px 0 28px;
}
.page-head h1 {
  font-size: var(--fs-h1);
  letter-spacing: -0.04em;
  color: var(--ink);
  font-weight: 600;
  line-height: 1.04;
}
.page-head .eyebrow { margin-bottom: 8px; display: block; color: var(--steel-2); }

/* === topbar (glassy, alpline-style) === */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  padding: 14px var(--pad-x);
  background: rgba(246,248,251,0.85);
  backdrop-filter: var(--blur-nav);
  -webkit-backdrop-filter: var(--blur-nav);
  border-bottom: 1px solid var(--hairline);
}
.topbar-logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.topbar-logo img { height: 22px; width: auto; opacity: .92; }
.topbar-logo b { font-weight: 600; letter-spacing: -0.02em; }
.topbar-logo .badge {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--steel-2);
  padding: 3px 8px;
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-pill);
  margin-left: 6px;
}
.topbar-nav {
  flex: 1;
  display: flex; gap: 4px; flex-wrap: wrap;
  margin-left: 16px;
}
.topbar-nav a {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  padding: 8px 12px;
  border-radius: var(--r-1);
  color: var(--ink-3);
  transition: background .2s var(--ease), color .2s var(--ease);
}
.topbar-nav a:hover { color: var(--ink); background: var(--bg-3); }
.topbar-nav a.is-active { color: var(--bg-2); background: var(--ink); }

.topbar-user {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  background: var(--bg-2);
}
.topbar-user .who { font-weight: 500; color: var(--ink); font-size: 13px; }
.topbar-user .role {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--steel-1);
  padding: 2px 6px;
  border-radius: var(--r-1);
  background: var(--tint);
}
.topbar-user .logout {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted);
}
.topbar-user .logout:hover { color: var(--ink); }

/* === buttons === */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px;
  border-radius: var(--r-2);
  font-weight: 500;
  font-size: 14px;
  transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .15s var(--ease);
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--ink);
  color: var(--bg-2);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--steel-1); border-color: var(--steel-1); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--hairline);
}
.btn-ghost:hover { background: var(--bg-2); border-color: var(--ink); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger-tint);
}
.btn-danger:hover { background: var(--danger-tint); }
.btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: var(--r-1); }

/* === cards / tiles === */
.card {
  background: var(--bg-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  padding: 22px 24px;
  box-shadow: var(--shadow-1);
  transition: box-shadow .25s var(--ease), border-color .25s var(--ease);
}
.card:hover { box-shadow: var(--shadow-2); }
.card h3 { font-size: 16px; font-weight: 600; color: var(--ink); margin-bottom: 4px; letter-spacing: -0.01em; }
.card .eyebrow { display: block; margin-bottom: 12px; }
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }

/* === KPI === */
.kpi { padding: 22px; }
.kpi .label { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 12px; }
.kpi .val { font-family: var(--ui); font-size: 32px; font-weight: 500; letter-spacing: -0.03em; color: var(--ink); line-height: 1; }
.kpi .val .ccy { font-size: 14px; color: var(--muted); margin-left: 6px; font-family: var(--mono); letter-spacing: .12em; }
.kpi .sub { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* === tables === */
.table-wrap {
  background: var(--bg-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table th {
  background: var(--bg);
  color: var(--ink-3);
  font-weight: 500;
}
.table tbody tr:hover td { background: var(--bg); }
.table td.num, .table th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* === forms === */
.form { display: grid; gap: 14px; }
.form-row { display: grid; gap: 8px; }
.form-row label {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-3);
}
.form-row input,
.form-row select,
.form-row textarea {
  padding: 11px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  background: var(--bg-2);
  color: var(--ink);
  font-size: 14px;
  width: 100%;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: 2px solid var(--steel-2);
  outline-offset: -1px;
  border-color: var(--steel-2);
}
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 8px; }

/* === pills === */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--tint);
  color: var(--steel-1);
  border: 1px solid var(--hairline-2);
  letter-spacing: .14em;
}
.pill.ok { background: var(--ok-tint); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-tint); color: var(--warn); border-color: transparent; }
.pill.danger { background: var(--danger-tint); color: var(--danger); border-color: transparent; }
.pill.neutral { background: var(--bg-3); color: var(--ink-3); border-color: var(--hairline); }

/* === modal === */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(10,22,38,0.45);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 24px;
}
.modal {
  background: var(--bg-2);
  border-radius: var(--r-3);
  border: 1px solid var(--hairline);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-3);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 28px;
  border-bottom: 1px solid var(--hairline);
}
.modal-head h2 { font-size: 18px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.modal-head .x {
  font-family: var(--mono); color: var(--muted);
  font-size: 12px; letter-spacing: .16em; text-transform: uppercase;
}
.modal-head .x:hover { color: var(--ink); }
.modal-body { padding: 24px 28px 28px; }

/* === toasts === */
.toasts { position: fixed; right: 24px; bottom: 24px; z-index: 300; display: grid; gap: 10px; max-width: 360px; }
.toast {
  padding: 12px 16px;
  border-radius: var(--r-2);
  background: var(--ink);
  color: var(--bg-2);
  font-size: 13px;
  box-shadow: var(--shadow-3);
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* === login === */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(60% 80% at 80% 20%, var(--tint), transparent 60%),
    radial-gradient(60% 80% at 10% 90%, #eef2f7, transparent 60%),
    var(--bg);
  padding: 24px;
}
.login-card {
  background: var(--bg-2);
  border-radius: var(--r-3);
  border: 1px solid var(--hairline);
  padding: 36px 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-3);
}
.login-card .brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
  color: var(--ink);
}
.login-card .brand img { height: 22px; }
.login-card .brand b { font-weight: 600; letter-spacing: -0.01em; }
.login-card h1 {
  font-size: 26px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.04em;
  margin: 18px 0 4px;
}
.login-card p.muted { font-size: 13px; margin-bottom: 22px; }

/* === empty states === */
.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
  border: 1px dashed var(--hairline-2);
  border-radius: var(--r-3);
}
.empty .eyebrow { display: block; margin-bottom: 10px; }

/* === tree (categories) === */
.tree { display: grid; gap: 4px; }
.tree-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  background: var(--bg-2);
}
.tree-row.child { margin-left: 24px; border-color: var(--bg-3); }
.tree-row .name { flex: 1; color: var(--ink); }
.tree-row .pill { margin-left: auto; }

/* === fade-in === */
.fade-in { animation: fade-in 240ms var(--ease); }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
