/* ============================================================
   ARENDA DESIGN SYSTEM · COMPONENTS  v1.0
   Требует tokens.css. Классы с префиксом .ar-
   ============================================================ */

/* ---------- SCREEN SHELL ---------- */
.ar-screen {
  min-height: 100dvh;
  background: var(--ar-screen-bg);
  background-attachment: fixed;
  color: var(--ar-on-blue);
  font-family: var(--ar-font);
  -webkit-font-smoothing: antialiased;
  padding: 8px var(--ar-screen-pad) calc(var(--ar-nav-clearance) + var(--ar-safe-bottom, 0px));
  position: relative;
}
.ar-screen::before { content: none; }  /* glow отключён в clean-light */
.ar-screen > * { position: relative; z-index: 1; }

/* ---------- TYPO ---------- */
.ar-hero      { font-size: var(--ar-fs-hero); font-weight: 700; letter-spacing: var(--ar-ls-hero); line-height: var(--ar-lh-tight); }
.ar-hero--sm  { font-size: var(--ar-fs-hero2); }
.ar-hero-label{ font-size: var(--ar-fs-body); font-weight: 500; color: var(--ar-on-blue-2); margin-bottom: 6px; }
.ar-title     { font-size: var(--ar-fs-title); font-weight: 600; }
.ar-muted     { color: var(--ar-on-blue-2); }

/* ---------- CARDS ---------- */
.ar-card-glass {           /* кремовая панель (статы, hero-блоки) */
  background: var(--ar-glass-bg);
  border: 1px solid var(--ar-glass-border);
  border-radius: var(--ar-r-card);
  padding: 13px;
  color: var(--ar-ink);
}
.ar-card-frost {           /* основная белая карточка */
  background: var(--ar-frost-bg);
  border-radius: var(--ar-r-card);
  padding: 14px;
  color: var(--ar-ink);
  box-shadow: var(--ar-shadow-card);
}
.ar-card-frost--muted { background: var(--ar-frost-bg-muted); box-shadow: var(--ar-shadow-card2); }

/* ---------- BUTTONS (min 44px tap: используйте padding-обёртку при h=40) ---------- */
.ar-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--ar-btn-h); padding: 0 16px;
  border: none; border-radius: var(--ar-r-btn);
  font: 600 13px var(--ar-font); cursor: pointer;
}
.ar-btn--lg { height: var(--ar-btn-h-lg); border-radius: var(--ar-r-tile); font-size: 14px; }
.ar-btn--primary {
  background: var(--ar-black);        /* чёрная пилюля, как в референсе */
  color: #fff; box-shadow: var(--ar-shadow-btn);
}
.ar-btn--frosted { background: var(--ar-frost-bg); color: var(--ar-ink); border: 1px solid var(--ar-line); box-shadow: var(--ar-shadow-card2); }
.ar-btn--ghost {   /* спокойная вторичная на кремовом */
  background: var(--ar-frost-bg); color: var(--ar-ink);
  border: 1px solid var(--ar-line);
}
.ar-btn--danger { background: rgba(217,83,74,.1); color: var(--ar-danger-text); }
.ar-btn--icon { width: var(--ar-btn-h); padding: 0; }  /* квадратная */
.ar-btn:active { transform: translateY(1px); }

/* Круглая иконко-кнопка шапки (36-38px, тап-зона добивается margin'ами) */
.ar-iconbtn {
  width: 38px; height: 38px; border-radius: var(--ar-r-pill);
  background: var(--ar-frost-bg); color: var(--ar-ink);
  border: 1px solid var(--ar-line);
  display: inline-flex; align-items: center; justify-content: center;
  position: relative; cursor: pointer;
}
.ar-iconbtn__dot {
  position: absolute; top: 7px; right: 8px; width: 6px; height: 6px;
  border-radius: 999px; background: var(--ar-warning);
}

/* ---------- CHIPS (фильтры) ---------- */
.ar-chip {
  white-space: nowrap; display: inline-flex; align-items: center;
  padding: 7px 12px; border: 1px solid var(--ar-line); border-radius: var(--ar-r-pill);
  font: 500 12px var(--ar-font); cursor: pointer;
  background: var(--ar-frost-bg); color: var(--ar-ink-2);
}
.ar-chip--active { background: var(--ar-green); border-color: var(--ar-green); color: var(--ar-ink); font-weight: 600; }

/* ---------- BADGES (статусы) ---------- */
.ar-badge {
  white-space: nowrap; display: inline-block;
  font: 600 var(--ar-fs-badge)/1 var(--ar-font);
  text-transform: uppercase; letter-spacing: .03em;
  padding: 4px 8px; border-radius: var(--ar-r-pill);
}
.ar-badge--paid    { color: var(--ar-success-text); background: var(--ar-green-soft); }
.ar-badge--partial { color: var(--ar-warning-text); background: rgba(208,152,42,.14); }
.ar-badge--debt    { color: var(--ar-danger-text);  background: rgba(217,83,74,.11); }
.ar-badge--active  { color: var(--ar-success-text); background: var(--ar-green-soft); }
/* Историческое имя: акцентный «долг»-бейдж */
.ar-badge--on-blue-debt {
  color: var(--ar-danger-text); background: rgba(217,83,74,.13);
  border: 1px solid rgba(217,83,74,.25);
}

/* ---------- PROGRESS ---------- */
.ar-progress { height: 6px; border-radius: 999px; background: var(--ar-track); overflow: hidden; }
.ar-progress--on-blue { height: 8px; background: rgba(26,25,23,.10); }
.ar-progress__fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #a9cf7d, #7cb45a); }
.ar-progress__fill--warn   { background: linear-gradient(90deg, var(--ar-warning), #f2b94a); }
.ar-progress__fill--danger { background: linear-gradient(90deg, var(--ar-warning), var(--ar-danger)); }
.ar-progress__fill--white  { background: linear-gradient(90deg, #a9cf7d, #7cb45a); } /* историческое имя */

/* ---------- ICON SQUARE (плитки «Ещё», алерты) ---------- */
.ar-iconsq {
  width: 40px; height: 40px; flex: none;
  border-radius: var(--ar-r-btn);
  display: flex; align-items: center; justify-content: center;
}
.ar-iconsq--blue    { background: var(--ar-green-soft);  color: var(--ar-green-ink); }
.ar-iconsq--warning { background: rgba(208,152,42,.14); color: var(--ar-warning-text); }
.ar-iconsq--danger  { background: rgba(217,83,74,.12);  color: var(--ar-danger-text); }
.ar-iconsq--success { background: var(--ar-green-soft); color: var(--ar-success-text); }

/* ---------- LIST ROW (история платежей и т.п.) ---------- */
.ar-row { display: flex; align-items: center; gap: 10px; }
.ar-row__body { flex: 1; min-width: 0; }
.ar-row__title { font-size: 12px; font-weight: 600; }
.ar-row__sub   { font-size: 10.5px; color: var(--ar-ink-3); }
.ar-row__num   { font-size: 12.5px; font-weight: 700; }

/* ---------- BOTTOM NAV (5 вкладок, без FAB) ---------- */
.ar-nav {
  position: fixed; left: 14px; right: 14px;
  bottom: calc(14px + var(--ar-safe-bottom, 0px));
  height: 62px; z-index: 50;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(var(--ar-blur-nav)); -webkit-backdrop-filter: blur(var(--ar-blur-nav));
  border: 1px solid var(--ar-line);
  border-radius: var(--ar-r-pill);
  box-shadow: var(--ar-shadow-nav);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px;
}
.ar-nav__item {
  flex: 1; min-height: var(--ar-tap-min);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ar-ink-3); text-decoration: none;
  font: 500 9px var(--ar-font);
  background: none; border: 0; cursor: pointer;   /* сброс для <button> («Ещё») */
}
.ar-nav__item--active { color: var(--ar-accent); font-weight: 700; }

/* ---------- BOTTOM SHEET ---------- */
.ar-scrim { position: fixed; inset: 0; background: var(--ar-scrim); z-index: 60; }
.ar-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  background: var(--ar-frost-bg);
  backdrop-filter: blur(var(--ar-blur-sheet)); -webkit-backdrop-filter: blur(var(--ar-blur-sheet));
  border-radius: var(--ar-r-sheet) var(--ar-r-sheet) 0 0;
  padding: 12px 18px calc(26px + var(--ar-safe-bottom, 0px));
  color: var(--ar-ink);
  box-shadow: var(--ar-shadow-sheet);
}
.ar-sheet__handle { width: 38px; height: 5px; border-radius: 999px; background: #d9d2c3; margin: 0 auto 16px; }
.ar-sheet__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ar-sheet__tile {
  display: flex; align-items: center; gap: 11px;
  background: #fff; border-radius: var(--ar-r-tile); padding: 11px;
  border: 1px solid var(--ar-line);
  box-shadow: 0 4px 14px rgba(70,58,34,.06);
  font: 600 13px var(--ar-font); color: var(--ar-ink);
  min-height: var(--ar-tap-min); cursor: pointer;
}

/* ---------- SEARCH ---------- */
.ar-search {
  display: flex; align-items: center; gap: 9px;
  background: #fff; border: 1px solid var(--ar-line);
  border-radius: var(--ar-r-pill); padding: 0 12px; height: 40px;
}
.ar-search input {
  flex: 1; border: none; background: none; outline: none;
  font: 400 13px var(--ar-font); color: var(--ar-ink);
}
.ar-search input::placeholder { color: var(--ar-ink-3); }

/* ---------- ICONS ---------- */
.ar-icon { width: 20px; height: 20px; stroke-width: 1.8; }
.ar-icon--sm { width: 16px; height: 16px; }

/* ============================================================
   RESPONSIVE VISIBILITY (integration with legacy app.css)
   Desktop: hide new bottom nav & sheet, keep legacy top nav.
   Mobile:  hide legacy top nav, show new bottom nav & sheet.
   ============================================================ */

/* Default (desktop ≥ 701px): hide the mobile-only pieces */
.ar-nav, .ar-scrim, .ar-sheet { display: none; }

/* Bottom sheet default state (closed); overrides positional rules in base */
.ar-sheet {
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.32,.72,0,1);
  pointer-events: none;
}
.ar-scrim {
  background: transparent;
  transition: background .22s ease;
  pointer-events: none;
}
.ar-sheet.open { transform: translateY(0); pointer-events: auto; }
.ar-scrim.open { background: var(--ar-scrim); pointer-events: auto; }

/* Clean-light screen shell only applies on pages that opt in. */
html:has(body.ar-screen),
body.ar-screen { background-color: var(--ar-screen-solid); }

body.ar-screen {
  min-height: 100dvh;
  background-image: var(--ar-screen-bg);
  background-repeat: no-repeat;
  background-size: 100% 100vh;
  background-attachment: fixed;
  color: var(--ar-on-blue);
  font-family: var(--ar-font);
  -webkit-font-smoothing: antialiased;
}
body.ar-screen .container {
  padding: 8px var(--ar-screen-pad) calc(var(--ar-nav-clearance) + var(--ar-safe-bottom, 0px));
  max-width: 640px;
  position: relative;
  z-index: 1;
  margin: 0 auto;
}
/* Glow отключён в clean-light */
body.ar-screen::before { content: none; }

/* ─── Desktop / tablet — wider layout, no bottom nav clearance ─── */
@media (min-width: 900px) {
  body.ar-screen .container {
    max-width: 1180px;
    padding: 20px 32px 40px;   /* remove bottom-nav clearance on desktop */
  }
  body.ar-screen::before {
    max-width: 1400px;
    height: 300px;
  }
  /* Hero can breathe a bit on wide screens */
  body.ar-screen .ar-hero      { font-size: 44px; }
  body.ar-screen .ar-hero--sm  { font-size: 34px; }
}

/* ─── Reusable desktop grids for cards ─── */
.ar-dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.ar-dash-grid > * { min-width: 0; }
@media (min-width: 900px) {
  .ar-dash-grid--2 { grid-template-columns: 1fr 1fr; }
  .ar-dash-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
  .ar-dash-grid--2-1 { grid-template-columns: 2fr 1fr; }
  /* Auto-fit for alert cards — collapses cleanly if some are absent */
  .ar-dash-grid--auto {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  }
  /* Cards inside the grid should stretch to equal height */
  .ar-dash-grid > .ar-card-frost,
  .ar-dash-grid > .ar-card-glass { align-self: stretch; }
}
/* Legacy top-nav on the cream screen: dark ink, quiet */
body.ar-screen nav.top {
  background: transparent;
  border-bottom: 0.5px solid rgba(26,25,23,0.08);
  color: var(--ar-ink);
  padding: 12px 20px;
}
body.ar-screen nav.top .brand {
  color: var(--ar-ink);
  font-weight: 700;
  letter-spacing: -.01em;
}
body.ar-screen nav.top .links a {
  color: var(--ar-ink-2);
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 13.5px;
  transition: background .15s, color .15s;
}
body.ar-screen nav.top .links a:hover {
  color: var(--ar-ink);
  background: rgba(26,25,23,0.05);
}
body.ar-screen nav.top .links a.active {
  color: var(--ar-ink);
  background: var(--ar-green);
  border: 1px solid var(--ar-green);
}
body.ar-screen nav.top .icon-btn {
  color: var(--ar-ink);
  border-color: var(--ar-line);
  background: #fff;
}
body.ar-screen nav.top .icon-btn:hover { background: var(--ar-frost-bg-muted); }
body.ar-screen nav.top .user-name { color: var(--ar-ink-2); }

/* Constrain top nav content to same width as page container on desktop */
@media (min-width: 900px) {
  body.ar-screen nav.top {
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 32px;
  }
}
body.ar-screen .flash { border-radius: 12px; padding: 10px 14px; }

@media (max-width: 700px) {
  /* Show the new bottom nav + sheet on mobile */
  .ar-nav   { display: flex; }
  .ar-scrim { display: block; }
  .ar-sheet { display: block; }

  /* Hide the legacy top-nav horizontal links on mobile — replaced by ar-nav */
  nav.top .links               { display: none; }
  nav.top .top-right .user-name { display: none; }
  nav.top                       { margin-bottom: 16px; padding: 10px 0 6px; }

  /* Ensure content doesn't sit under the floating nav */
  .container { padding-bottom: calc(var(--ar-nav-clearance) + var(--ar-safe-bottom, 0px)) !important; }
}

/* ============================================================
   FORMS — scoped to .ar-form (used inside frosted card)
   ============================================================ */
.ar-form .field { margin-bottom: 14px; }
.ar-form .field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 520px) {
  .ar-form .field-row { grid-template-columns: 1fr; gap: 0; }
  .ar-form .field-row > div { margin-bottom: 14px; }
}
.ar-form label {
  display: block;
  font: 600 11.5px var(--ar-font);
  color: var(--ar-ink-2);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.ar-form input[type="text"],
.ar-form input[type="email"],
.ar-form input[type="password"],
.ar-form input[type="number"],
.ar-form input[type="date"],
.ar-form input[type="tel"],
.ar-form input[type="url"],
.ar-form textarea,
.ar-form select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  font: 500 14px var(--ar-font);
  color: var(--ar-ink);
  background: #fff;
  border: 1px solid var(--ar-line);
  border-radius: 11px;
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
  font-variant-numeric: tabular-nums;
}
.ar-form textarea { min-height: 72px; resize: vertical; line-height: 1.4; }
.ar-form input:focus,
.ar-form textarea:focus,
.ar-form select:focus {
  border-color: var(--ar-accent);
  box-shadow: 0 0 0 3px rgba(26,25,23,.10);
}
.ar-form input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--ar-accent);
  vertical-align: middle;
  margin-right: 6px;
}
.ar-form .field small,
.ar-form .field .hint,
.ar-form .field .help-text {
  display: block;
  font: 400 11.5px var(--ar-font);
  color: var(--ar-ink-3);
  margin-top: 4px;
  line-height: 1.4;
}

