/* Kristal — təhvil-təslim paneli
   Palette follows the logo (#377EF6 + #4D4D4D) and kristal.az (ink #2C2929, sky #F6FAFF). */

:root {
  --ink: #2C2929;
  --ink-2: #575353;
  --muted: #8C8787;
  --line: #EAEAEA;
  --line-soft: #F1F1F1;

  --bg: #F6FAFF;
  --surface: #FFFFFF;
  --sky: #EEF5FF;
  --sky-2: #DDECFF;

  --brand: #377EF6;
  --brand-strong: #1F63D6;
  --brand-ink: #174EA6;
  --logo-gray: #4D4D4D;

  /* Handover statuses — validated as a set (CVD-safe adjacent pairs); always shown with a label. */
  --st-notready: #A3A9B6;
  --st-ready: #2E9E5B;
  --st-scheduled: #E0A030;
  --st-handedover: #377EF6;
  --st-issue: #D6453D;

  --danger: #C4372F;
  --danger-soft: #FDEEEC;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(44, 41, 41, .04), 0 2px 8px rgba(55, 126, 246, .04);
  --shadow-md: 0 12px 32px -12px rgba(31, 60, 120, .18);
  --shadow-lg: 0 30px 80px -20px rgba(20, 40, 90, .28);

  --font: 'Onest', 'SF Pro Display', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 0;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
[hidden] { display: none !important; }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px;
  border: 1px solid transparent; border-radius: var(--r-pill);
  font-weight: 500; font-size: 15px; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); color: #fff; }

.btn-soft { background: var(--sky); color: var(--brand-ink); }
.btn-soft:hover { background: var(--sky-2); color: var(--brand-ink); }

.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { border-color: #D6D6D6; color: var(--ink); background: #fff; }

.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); color: var(--danger); }

.btn-sm { height: 36px; padding: 0 14px; font-size: 14px; }
.btn-block { width: 100%; }

/* The kristal.az "label + round arrow" call to action */
.btn-arrow { padding-right: 6px; }
.btn-arrow .arrow {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  transition: transform .25s var(--ease);
}
.btn-arrow:hover .arrow { transform: translateX(3px); }
.btn-soft.btn-arrow .arrow { background: #fff; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.icon-btn:hover { background: var(--sky); color: var(--brand-ink); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ */
/* Forms                                                               */
/* ------------------------------------------------------------------ */

.field { display: grid; gap: 6px; }
.field + .field { margin-top: 14px; }
.field label, .field-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }

.input, .select, .textarea {
  width: 100%; height: 46px; padding: 0 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  outline: none;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s;
}
.textarea { height: auto; min-height: 92px; padding: 12px 14px; resize: vertical; line-height: 1.45; }
.select {
  appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238C8787' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.input:hover, .select:hover, .textarea:hover { border-color: #DADADA; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(55, 126, 246, .12); }
.input:disabled, .select:disabled, .textarea:disabled { background: #FAFAFA; color: var(--ink-2); cursor: not-allowed; }
.input::placeholder, .textarea::placeholder { color: #B5B1B1; }

.input-wrap { position: relative; }
.input-wrap .input { padding-left: 44px; }
.input-wrap > svg {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--muted); pointer-events: none;
}
.input-wrap .trail {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-2 .field + .field { margin-top: 0; }

.form-error {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; margin-bottom: 16px;
  background: var(--danger-soft); color: var(--danger);
  border-radius: 14px; font-size: 14px;
}
.form-error svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

/* ------------------------------------------------------------------ */
/* App shell                                                           */
/* ------------------------------------------------------------------ */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner {
  display: flex; align-items: center; gap: 28px;
  max-width: 1400px; margin: 0 auto; padding: 0 28px; height: 72px;
}
.topbar .brand img { height: 24px; width: auto; }

/* Never wraps and never pushes the user chip off screen - a narrow window scrolls the menu instead. */
.nav { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-pill);
  flex: none; white-space: nowrap; color: var(--ink-2); font-weight: 500;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.nav a svg { width: 18px; height: 18px; }
.nav a:hover { color: var(--ink); background: var(--line-soft); }
.nav a[aria-current="page"] { background: var(--sky); color: var(--brand-ink); }

/* A group of pages under one menu item - the list opens below it (placed on <body>, see shell.js). */
.nav-group {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px 0 16px; border-radius: var(--r-pill);
  flex: none; white-space: nowrap; color: var(--ink-2); font: inherit; font-weight: 500;
  background: none; border: 0; cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.nav-group svg { width: 18px; height: 18px; }
.nav-group .caret { display: inline-flex; margin-left: -2px; transition: transform .2s var(--ease); }
.nav-group .caret svg { width: 16px; height: 16px; display: block; }
.nav-group:hover { color: var(--ink); background: var(--line-soft); }
.nav-group.is-active { background: var(--sky); color: var(--brand-ink); }
.nav-group[aria-expanded="true"] .caret { transform: rotate(180deg); }
.nav-group:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.nav-menu {
  position: fixed; z-index: 60; min-width: 270px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 18px;
  box-shadow: 0 18px 48px rgba(17, 24, 39, .14), 0 2px 6px rgba(17, 24, 39, .06);
  animation: nav-menu-in .16s var(--ease);
}
@keyframes nav-menu-in { from { opacity: 0; transform: translateY(-4px); } }
.nav-menu a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px 9px 9px; border-radius: 12px;
  color: var(--ink); line-height: 1.25;
}
.nav-menu a:hover, .nav-menu a:focus-visible { background: var(--line-soft); outline: none; }
.nav-menu a[aria-current="page"] { background: var(--sky); color: var(--brand-ink); }
.nav-menu .ic {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 11px;
  background: var(--line-soft); color: var(--ink-2);
}
.nav-menu a[aria-current="page"] .ic { background: #fff; color: var(--brand-ink); }
.nav-menu .ic svg { width: 18px; height: 18px; }
.nav-menu strong { display: block; font-size: 14.5px; font-weight: 600; }
.nav-menu small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }

.topbar .spacer { flex: 1; }

.user-chip {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 4px 4px 4px; border-radius: var(--r-pill);
}
.avatar {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--sky-2); color: var(--brand-ink);
  font-weight: 600; font-size: 14px; letter-spacing: .02em;
}
.user-chip { flex: none; }
.user-chip .who { line-height: 1.25; max-width: 170px; }
.user-chip .who strong, .user-chip .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who strong { display: block; font-size: 14px; font-weight: 600; }
.user-chip .who span { font-size: 12.5px; color: var(--muted); }

.page {
  max-width: 1400px; margin: 0 auto; padding: 32px 28px 64px;
}

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  margin-bottom: 28px; flex-wrap: wrap;
}
.page-head h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; }
.page-head .lede { margin-top: 6px; color: var(--muted); }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 22px 24px 0;
}
.card-head h2 { font-size: 17px; }
.card-head .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 18px 24px 24px; }

/* ------------------------------------------------------------------ */
/* Status pills / dots                                                 */
/* ------------------------------------------------------------------ */

.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--c, var(--muted)); }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 11px 0 9px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  color: var(--ink); background: #F4F6FA; background: color-mix(in srgb, var(--c) 12%, #fff);
}
.pill .dot { width: 8px; height: 8px; }

[data-status="NotReady"]   { --c: var(--st-notready); }
[data-status="Ready"]      { --c: var(--st-ready); }
[data-status="Scheduled"]  { --c: var(--st-scheduled); }
[data-status="HandedOver"] { --c: var(--st-handedover); }
[data-status="Issue"]      { --c: var(--st-issue); }

/* ------------------------------------------------------------------ */
/* Toast, modal, drawer                                                */
/* ------------------------------------------------------------------ */

.toasts {
  position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: grid; gap: 8px; justify-items: center; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: var(--r-pill);
  background: var(--ink); color: #fff; font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: toast-in .35s var(--ease);
}
.toast svg { width: 18px; height: 18px; }
.toast.ok svg { color: #7FD3A1; }
.toast.err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(30, 36, 52, .32);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade .25s var(--ease);
}
@keyframes fade { from { opacity: 0; } }

.modal {
  position: fixed; z-index: 61; left: 50%; top: 50%;
  width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
  transform: translate(-50%, -50%);
  background: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: pop .3s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(.98); } }
.modal-head { padding: 24px 24px 4px; }
.modal-head h3 { font-size: 19px; }
.modal-head p { margin-top: 6px; color: var(--muted); font-size: 14px; }
.modal-body { padding: 18px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 4px 24px 24px; }
.modal-foot .spacer { flex: 1; }
.modal-tabs {
  display: flex; gap: 4px; margin: 14px 24px 0; padding: 4px;
  border-radius: var(--r-pill); background: var(--line-soft);
}
.modal-tabs [role="tab"] {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 12px; border: 0; border-radius: var(--r-pill);
  background: none; color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.modal-tabs [role="tab"] svg { width: 16px; height: 16px; }
.modal-tabs [role="tab"]:hover { color: var(--ink); }
.modal-tabs [role="tab"][aria-selected="true"] { background: #fff; color: var(--brand-ink); font-weight: 600; box-shadow: 0 1px 3px rgba(30, 36, 52, .08); }
.modal-note { margin-bottom: 14px; font-size: 14px; color: var(--muted); }

.drawer {
  position: fixed; z-index: 61; top: 12px; right: 12px; bottom: 12px;
  width: min(520px, calc(100vw - 24px));
  display: flex; flex-direction: column;
  background: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  animation: slide .35s var(--ease);
}
@keyframes slide { from { opacity: 0; transform: translateX(24px); } }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 24px 24px 18px; border-bottom: 1px solid var(--line-soft);
}
.drawer-head .eyebrow { font-size: 13px; color: var(--muted); }
.drawer-head h3 { font-size: 22px; margin-top: 2px; }
.drawer-body { flex: 1; overflow: auto; padding: 8px 24px 24px; }
.drawer-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--line-soft);
}
.drawer-foot .spacer { flex: 1; }

.section-title {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 0 12px; font-size: 12px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }

.readonly-note {
  display: flex; gap: 10px; align-items: center;
  margin-top: 18px; padding: 12px 14px; border-radius: 14px;
  background: var(--sky); color: var(--brand-ink); font-size: 13.5px;
}
.readonly-note svg { width: 18px; height: 18px; flex: none; }

/* Status picker: radio group shaped like pills */
.status-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.status-picker label {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px 0 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--ink-2);
  transition: all .2s var(--ease);
}
.status-picker input { position: absolute; opacity: 0; pointer-events: none; }
.status-picker label:hover { border-color: #D6D6D6; }
.status-picker input:checked + label {
  border-color: var(--c); color: var(--ink);
  background: #F4F6FA; background: color-mix(in srgb, var(--c) 12%, #fff);
  box-shadow: inset 0 0 0 1px var(--c);
}
.status-picker input:focus-visible + label { outline: 2px solid var(--brand); outline-offset: 2px; }
.status-picker input:disabled + label { cursor: not-allowed; opacity: .7; }

/* Tooltip used by the charts */
.tip {
  position: fixed; z-index: 90; pointer-events: none;
  padding: 10px 12px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 13px; line-height: 1.4;
  box-shadow: var(--shadow-md);
  transform: translate(-50%, calc(-100% - 12px));
  white-space: nowrap;
}
.tip strong { font-weight: 600; }
.tip .row { display: flex; align-items: center; gap: 8px; }
.tip .dot { box-shadow: 0 0 0 2px rgba(255,255,255,.15); }

/* Loading shimmer */
.skeleton {
  border-radius: 10px;
  background: linear-gradient(90deg, #F2F5F9 0%, #E9EEF5 50%, #F2F5F9 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.empty {
  display: grid; justify-items: center; text-align: center; gap: 10px;
  padding: 56px 24px;
}
.empty .mark { width: 54px; height: 54px; opacity: .9; }
/* Error/empty icons are bare inline SVGs - without a size they fill the whole card. */
.empty > svg { width: 44px; height: 44px; color: var(--danger); }
.empty h3 { font-size: 18px; margin-top: 6px; }
.empty p { color: var(--muted); max-width: 380px; }
.empty .btn { margin-top: 10px; }

@media (max-width: 1500px) {
  .topbar-inner { gap: 14px; }
  .nav { gap: 0; }
  .nav a { padding: 0 9px; gap: 6px; }
  .nav-group { padding: 0 7px 0 9px; gap: 6px; }
}
@media (max-width: 1360px) { .nav a svg, .nav-group > svg { display: none; } }
@media (max-width: 1180px) { .user-chip .who { display: none; } }

/* ------------------------------------------------------------------ */
/* Responsive shell                                                    */
/* ------------------------------------------------------------------ */

@media (max-width: 900px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 12px 16px 0; gap: 12px; }
  .topbar .brand { order: 1; }
  .topbar .spacer { order: 2; }
  .user-chip { order: 3; }
  .user-chip .who { display: none; }
  .nav {
    order: 4; width: calc(100% + 32px); margin: 0 -16px; padding: 0 12px 10px;
    overflow-x: auto; scrollbar-width: none;
  }
  .page { padding: 22px 16px 48px; }
  .page-head h1 { font-size: 24px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 .field + .field { margin-top: 0; }
  .drawer { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 92vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------------------------ */
/* Shared form bits                                                    */
/* ------------------------------------------------------------------ */

/* --- Checkbox --- */
.check { display: flex; align-items: flex-start; gap: 12px; margin-top: 16px; cursor: pointer; font-size: 14.5px; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  flex: none; width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid #CFCFCF; background: #fff;
  display: grid; place-items: center; transition: all .2s var(--ease);
}
.check input:checked + .box { background: var(--brand); border-color: var(--brand); }
.check input:checked + .box::after {
  content: ''; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px);
}
.check input:focus-visible + .box { outline: 2px solid var(--brand); outline-offset: 2px; }
.check input:disabled ~ * { opacity: .7; cursor: not-allowed; }
.check small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }

/* --- Drop zone (plans, product photos) --- */
.dropzone {
  display: grid; justify-items: center; gap: 6px; text-align: center;
  padding: 28px 16px; border: 1.5px dashed #CBD9EE; border-radius: 18px; background: var(--bg);
  color: var(--ink-2); cursor: pointer; transition: all .2s var(--ease);
}
.dropzone svg { width: 28px; height: 28px; color: var(--brand); }
.dropzone strong { font-weight: 600; color: var(--ink); }
.dropzone span { font-size: 12.5px; color: var(--muted); }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--sky); }

/* --- Lightbox --- */
.lightbox {
  position: fixed; inset: 24px; z-index: 61; display: grid; place-items: center;
  pointer-events: none; animation: fade .25s var(--ease);
}
.lightbox img {
  max-width: 100%; max-height: 100%; border-radius: 18px; background: #fff; padding: 18px;
  box-shadow: var(--shadow-lg); pointer-events: auto;
}
.lightbox .icon-btn { position: fixed; right: 28px; top: 28px; background: #fff; pointer-events: auto; }


/* --- Filter chips (apartments: statuses, products: categories) --- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px 0 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all .2s var(--ease);
}
.chip:hover { border-color: #D6D6D6; color: var(--ink); }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip[aria-pressed="true"] .n { color: rgba(255, 255, 255, .7); }
.chip[aria-pressed="true"] .dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, .9); }
.chip[data-all] { padding-left: 14px; }
.chip svg { width: 16px; height: 16px; }
.chip.add { border-style: dashed; color: var(--brand-ink); }
.chip.add:hover { border-color: var(--brand); background: var(--sky); }
.chip-tools { display: inline-flex; gap: 2px; align-items: center; margin-left: 2px; }
.chip-tools .icon-btn { width: 36px; height: 36px; }

@media (max-width: 760px) {
  .chips { flex-wrap: nowrap; overflow-x: auto; margin-left: -16px; margin-right: -16px; padding: 0 16px; scrollbar-width: none; }
  .chip { flex: none; }
}

/* Safety net: an inline icon that no rule sizes stays icon-sized instead of filling its box. */
svg[aria-hidden="true"]:not([width]) { max-width: 48px; max-height: 48px; }

/* --- Customer picker --- */
.party-box { position: relative; }
.party-box .input { padding-right: 40px; }
.party-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); cursor: pointer;
}
.party-clear:hover { background: var(--sky); color: var(--ink); }
.party-clear svg { width: 15px; height: 15px; }
.party-list {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 6px);
  max-height: 280px; overflow: auto; padding: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.party-opt { display: grid; gap: 1px; padding: 9px 12px; border-radius: 10px; cursor: pointer; }
.party-opt .nm { font-size: 14.5px; font-weight: 500; color: var(--ink); }
.party-opt .sub { font-size: 12.5px; color: var(--muted); }
.party-opt[aria-selected="true"], .party-opt:hover { background: var(--sky); }
.party-opt.add { display: flex; align-items: center; gap: 8px; margin-top: 4px; border-top: 1px solid var(--line-soft); border-radius: 0 0 10px 10px; color: var(--brand-ink); font-size: 14px; font-weight: 500; }
.party-opt.add svg { width: 16px; height: 16px; }
.party-none { padding: 10px 12px; font-size: 13.5px; color: var(--muted); }
.party .hint:empty { display: none; }

/* Customer kind tag */
.kind-tag { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 500; background: var(--sky); color: var(--brand-ink); white-space: nowrap; }
.kind-tag[data-kind="Entrepreneur"] { background: #FFF3E3; color: #8A4B00; }

/* A field right after a two-column row gets the same gap as after a single field. */
.grid-2 + .field, .field + .grid-2, .grid-2 + .grid-2 { margin-top: 14px; }
.grid-2 > .party { align-self: start; }
.party-caret { position: absolute; right: 14px; top: 50%; transform: translateY(-50%) rotate(90deg); display: grid; color: var(--muted); pointer-events: none; }
.party-caret[hidden] { display: none; }
.party-caret svg { width: 15px; height: 15px; }
.party-box .input { cursor: pointer; }

/* ------------------------------------------------------------------ */
/* Phones & touch                                                      */
/* ------------------------------------------------------------------ */

/* Height of the sticky top bar - sticky page parts can sit under it with top: var(--topbar-h). */
:root { --topbar-h: 72px; }
.nav-burger { display: none; }

/* Side sheet with the whole menu (phones; opened by the burger in shell.js) */
.mnav {
  position: fixed; z-index: 61; top: 0; right: 0; bottom: 0; width: min(340px, 88vw);
  display: flex; flex-direction: column; background: var(--surface);
  border-radius: var(--r-lg) 0 0 var(--r-lg); box-shadow: var(--shadow-lg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) 0;
  animation: mnav-in .28s var(--ease);
}
@keyframes mnav-in { from { transform: translateX(40px); opacity: 0; } }
.mnav-head { display: flex; align-items: center; gap: 12px; padding: 16px 12px 14px 18px; border-bottom: 1px solid var(--line-soft); }
.mnav-head .who { flex: 1; min-width: 0; line-height: 1.25; }
.mnav-head .who strong, .mnav-head .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mnav-head .who strong { font-size: 15px; }
.mnav-head .who span { font-size: 12.5px; color: var(--muted); }
.mnav-head .icon-btn { width: 40px; height: 40px; }
.mnav-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 10px 12px; }
.mnav-body a {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 10px 6px 6px; border-radius: 14px;
  color: var(--ink); line-height: 1.25;
}
.mnav-body a:active { background: var(--line-soft); }
.mnav-body a[aria-current="page"] { background: var(--sky); color: var(--brand-ink); }
.mnav-body .ic { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 11px; background: var(--line-soft); color: var(--ink-2); }
.mnav-body a[aria-current="page"] .ic { background: #fff; color: var(--brand-ink); }
.mnav-body .ic svg { width: 18px; height: 18px; }
.mnav-body strong { display: block; font-size: 15px; font-weight: 600; }
.mnav-body small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.mnav-group { margin: 14px 10px 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mnav-foot { padding: 12px 16px 16px; border-top: 1px solid var(--line-soft); }

/* Bigger hit areas wherever the pointer is a finger. */
@media (pointer: coarse), (max-width: 760px) {
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn.sm { position: relative; width: 36px; height: 36px; }
  .icon-btn.sm svg { width: 17px; height: 17px; }
  .icon-btn.sm::after { content: ''; position: absolute; inset: -2px; }
  .btn-sm { height: 40px; }
  .chip { height: 40px; }
  .status-picker label { height: 42px; }
}

@media (max-width: 760px) {
  :root { --topbar-h: calc(60px + env(safe-area-inset-top)); }
  html, body { overflow-x: clip; }
  body { overflow-wrap: break-word; }

  /* One slim row: logo, avatar, menu button - the menu itself opens as a sheet. */
  .topbar { padding-top: env(safe-area-inset-top); }
  .topbar-inner { flex-wrap: nowrap; height: 60px; padding: 0 max(10px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); gap: 8px; }
  .topbar .brand img { height: 22px; }
  .nav { display: none; }
  .nav-burger { display: inline-grid; width: 42px; height: 42px; }
  .nav-burger svg { width: 22px; height: 22px; }
  .user-chip { gap: 4px; padding: 0; }
  .user-chip .avatar { width: 36px; height: 36px; font-size: 13px; }
  .user-chip [data-logout] { display: none; }

  /* Room under the last card for the assistant button. */
  .page { padding: 18px max(16px, env(safe-area-inset-left)) calc(96px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 20px; gap: 14px; }
  .page-head > * { min-width: 0; }
  .card-head { padding: 18px 18px 0; }
  .card-body { padding: 14px 18px 18px; }

  /* 16px text keeps iOS from zooming into a focused field. */
  .input, .select, .textarea, input[type="text"], input[type="search"], input[type="number"], input[type="tel"],
  input[type="email"], input[type="password"], input[type="date"], input[type="datetime-local"], select, textarea { font-size: 16px; }

  /* Modal: full width minus a small gutter, buttons wrap instead of leaving the box. */
  .modal { width: calc(100vw - 24px); max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); border-radius: 20px; }
  .modal-head { padding: 20px 18px 4px; }
  .modal-head h3 { font-size: 18px; }
  .modal-body { padding: 16px 18px; }
  .modal-foot { flex-wrap: wrap; padding: 4px 18px 18px; }
  .modal-foot .btn { flex: 1 1 auto; white-space: normal; height: auto; min-height: 44px; padding-top: 8px; padding-bottom: 8px; text-align: center; line-height: 1.25; }
  .modal-foot .spacer { display: none; }
  .modal-foot [data-danger], .modal-foot .btn-danger-ghost { order: 9; flex-basis: 100%; }
  .modal-tabs { margin: 12px 18px 0; overflow-x: auto; scrollbar-width: none; }
  .modal-tabs::-webkit-scrollbar { display: none; }
  .modal-tabs [role="tab"] { flex: 1 0 auto; white-space: nowrap; height: 38px; }

  /* Drawer: bottom sheet (from 900px) - tighter padding, footer buttons wrap. */
  .drawer { left: 6px; right: 6px; bottom: calc(6px + env(safe-area-inset-bottom)); max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); border-radius: 20px; }
  .drawer-head { padding: 18px 16px 14px 18px; }
  .drawer-head > :first-child { min-width: 0; }
  .drawer-head h3 { font-size: 19px; }
  .drawer-body { padding: 6px 18px 18px; overscroll-behavior: contain; }
  .drawer-foot { flex-wrap: wrap; padding: 12px 18px; }
  .drawer-foot .btn { white-space: normal; height: auto; min-height: 44px; line-height: 1.25; text-align: center; }
  .drawer-foot > .btn { flex: 1 1 auto; }
  .drawer-foot > .spacer { display: none; }
  .drawer-foot > .btn-danger-ghost { order: 9; flex-basis: 100%; }

  .toasts { left: 12px; right: 12px; transform: none; bottom: calc(16px + env(safe-area-inset-bottom)); }
  .toast { max-width: 100%; border-radius: 18px; }
  .toast span { min-width: 0; }

  .tip { width: max-content; max-width: min(260px, calc(100vw - 24px)); white-space: normal; }
  .lightbox { inset: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); }
  .lightbox img { padding: 8px; }
  .lightbox .icon-btn { right: 16px; top: calc(16px + env(safe-area-inset-top)); }
  .empty { padding: 40px 16px; }
  .party-list { max-height: 240px; }
  .party-opt { padding: 11px 12px; }
  .area-b { min-height: 40px; }
}

/* ------------------------------------------------------------------ */
/* Internal chat: the top-bar button with its unread badge, and the pop-up for a new message (chat-live.js) */
.chat-btn { position: relative; }
.chat-btn[aria-current="page"] { background: var(--sky); color: var(--brand-ink); }
.chat-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #E5484D; color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums;
}
.chat-badge[hidden] { display: none; }
.chat-btn .chat-badge { position: absolute; top: -2px; right: -4px; box-shadow: 0 0 0 2px #fff; }
.mnav-body a .chat-badge { margin-left: auto; align-self: center; }

.chat-pop {
  position: fixed; z-index: 70; right: 24px; top: calc(var(--topbar-h, 72px) + 12px); width: min(360px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 12px; padding: 12px 10px 12px 12px; border-radius: 18px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-soft); box-shadow: var(--shadow-lg);
  animation: chat-pop-in .25s var(--ease); transition: opacity .3s, transform .3s;
}
.chat-pop.is-gone { opacity: 0; transform: translateY(-8px); }
.chat-pop:hover { border-color: var(--sky-2); }
.chat-pop-tx { flex: 1; min-width: 0; display: grid; line-height: 1.35; }
.chat-pop-tx b { font-size: 14.5px; }
.chat-pop-tx span { font-size: 13.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-pop-x { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: var(--muted); flex: none; }
.chat-pop-x:hover { background: var(--line-soft); }
.chat-pop-x svg { width: 15px; height: 15px; }
@keyframes chat-pop-in { from { opacity: 0; transform: translateY(-8px); } }
@media (max-width: 760px) {
  .chat-pop { right: 12px; left: 12px; width: auto; top: calc(env(safe-area-inset-top) + 68px); }
  .user-chip .chat-btn { width: 42px; height: 42px; }
  .user-chip .chat-btn svg { width: 22px; height: 22px; }
}

/* The messages bubble above the Kristal AI button, and its small window (chat-live.js) */
.kmsg { position: fixed; right: 28px; bottom: 98px; z-index: 45; }
html.kai-open .kmsg { display: none; }
html.kmsg-open .kai-tease { display: none; }
.kmsg-fab {
  position: relative; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%;
  background: var(--brand); color: #fff; box-shadow: 0 10px 26px rgba(55, 126, 246, .34), 0 2px 6px rgba(20, 30, 60, .1);
  transition: transform .2s var(--ease), background .2s var(--ease);
}
.kmsg-fab:hover { transform: translateY(-2px) scale(1.04); background: var(--brand-strong); }
.kmsg-fab:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.kmsg-fab svg { width: 24px; height: 24px; }
.kmsg.is-open .kmsg-fab { background: var(--brand-strong); transform: scale(.94); }
.kmsg-fab .chat-badge { position: absolute; top: -3px; right: -3px; box-shadow: 0 0 0 2px #fff; }
.kmsg-panel {
  position: fixed; right: 96px; bottom: 24px; width: 400px; height: min(660px, calc(100vh - 110px));
  display: flex; flex-direction: column; overflow: hidden; background: var(--surface);
  border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 24px 60px rgba(20, 30, 60, .2);
  animation: kmsg-in .2s var(--ease);
}
.kmsg-panel[hidden] { display: none; }
@keyframes kmsg-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.kmsg-head { display: flex; align-items: center; gap: 4px; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--line-soft); }
.kmsg-head strong { flex: 1; font-size: 15.5px; }
.kmsg-body { flex: 1; min-height: 0; }
.kmsg-body iframe { display: block; width: 100%; height: 100%; border: 0; }
@media (max-width: 520px) {
  .kmsg { right: calc(max(12px, env(safe-area-inset-right)) + 2px); bottom: calc(76px + env(safe-area-inset-bottom)); }
  .kmsg-fab { width: 48px; height: 48px; }
  .kmsg-fab svg { width: 22px; height: 22px; }
}
@media print { .kmsg { display: none; } }

/* «Sistem yeniləndi» - a deploy happened while the page was open (shell.js watchUpdates) */
.upd-bar {
  position: fixed; z-index: 72; left: 50%; top: calc(var(--topbar-h, 72px) + 12px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; max-width: calc(100vw - 24px);
  background: var(--ink); color: #fff; border-radius: 999px; box-shadow: var(--shadow-lg); animation: chat-pop-in .25s var(--ease);
}
.upd-bar > span { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.upd-bar > span svg { width: 17px; height: 17px; }
.upd-bar .icon-btn { color: #fff; }
.upd-bar .icon-btn:hover { background: rgba(255, 255, 255, .15); color: #fff; }

/* «Kristal 1.3 hazırdır» - the Android app asks to be updated (app-update.js) */
.upd-modal { width: min(400px, calc(100vw - 32px)); }
.upd-card { padding: 28px 24px 22px; text-align: center; display: grid; gap: 10px; }
.upd-ic { justify-self: center; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--sky); margin-bottom: 4px; }
.upd-card h2 { font-size: 21px; letter-spacing: -.01em; }
.upd-sub { color: var(--ink-2); font-size: 14.5px; }
.upd-notes { text-align: left; margin: 4px 0 6px; padding: 12px 14px 12px 32px; background: var(--bg); border-radius: 14px; font-size: 14px; color: var(--ink-2); display: grid; gap: 4px; }
.upd-go { margin-top: 4px; }
.upd-go svg { width: 18px; height: 18px; }
.upd-help { font-size: 13.5px; color: var(--ink-2); background: #EAF7EF; border-radius: 12px; padding: 10px 12px; }
