/* Общая база: сброс, типографика, формы, кнопки, сообщения, видимый фокус, RTL. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-body); font-size: 17px; line-height: 1.5; color: var(--ink);
  background: var(--bg); overflow-wrap: break-word; }
[dir="rtl"] body { font-family: Tahoma, "Noto Sans Arabic", var(--font-body); }
img { max-width: 100%; height: auto; }
a { color: var(--gold-text); text-underline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.2; margin: 0 0 .5em;
  letter-spacing: .01em; }
h1 { font-size: 30px; }
h2 { font-size: 23px; }
h3 { font-size: 19px; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); margin: -1px; padding: 0; border: 0;
  white-space: nowrap; }
.skip-link { position: absolute; inset-inline-start: 8px; top: -200px; z-index: 100; background: var(--paper);
  color: var(--ink); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-weight: 700; }
.skip-link:focus { top: 8px; }

/* Видимый фокус для клавиатуры (A18) */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* Кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap);
  padding: 10px 20px; border-radius: 999px; border: 1px solid transparent; font: inherit; font-weight: 700;
  font-size: 16px; text-decoration: none; cursor: pointer; background: var(--brown); color: #fff;
  transition: background .15s, box-shadow .15s; overflow-wrap: normal; word-break: normal; text-align: center;
  line-height: 1.25; }
.btn:hover { background: var(--brown-deep); }
.btn[disabled], .btn.is-busy { opacity: .6; cursor: progress; }
.btn-gold { background: var(--gold); color: var(--brown-ink); }
.btn-gold:hover { background: var(--gold-light); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--paper); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #7f1b15; }
.btn-block { width: 100%; }
.btn-sm { min-height: 44px; padding: 6px 14px; font-size: 15px; }
.btn-link { background: none; border: 0; color: var(--gold-text); text-decoration: underline; font: inherit;
  cursor: pointer; padding: 8px 0; min-height: var(--tap); }

/* Формы */
.field { margin-bottom: 18px; }
.field > label, .label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 15px; }
.req { color: var(--danger); }
.hint { display: block; color: var(--muted); font-size: 14px; margin-top: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=search], input[type=date], input[type=number],
input[type=time], input[type=datetime-local], input[type=url], input[type=password], input:not([type]), select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px; font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
textarea { min-height: 96px; }
input[type=file] { max-width: 100%; font: inherit; font-size: 15px; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
[x-cloak] { display: none !important; }
/* iOS Safari: без внутренней тени и «своих» размеров; поля ≥ 16px — без автозума */
input[type=text], input[type=email], input[type=tel], input[type=search], input[type=number], input[type=url],
input[type=password], input:not([type]), textarea, select { -webkit-appearance: none; appearance: none; font-size: 17px; }
input[type=date], input[type=time], input[type=datetime-local] { -webkit-appearance: none; appearance: none;
  display: block; min-width: 0; font-size: 17px; text-align: start; line-height: 1.4; }
input::-webkit-date-and-time-value { text-align: start; min-height: 1.4em; }
input[type=search]::-webkit-search-decoration { -webkit-appearance: none; }
select { padding-inline-end: 40px; background-repeat: no-repeat; background-position: right 14px center; background-size: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b5f56' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
[dir="rtl"] select { background-position: left 14px center; }
select.lang-pick-select { background-image: none; padding: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); }
input[type=checkbox], input[type=radio] { accent-color: var(--brown); }
html { -webkit-tap-highlight-color: rgba(184, 150, 62, .18); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 14px; margin-top: 4px; font-weight: 700; }
.check { display: flex; gap: 12px; align-items: flex-start; min-height: var(--tap); padding: 6px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--brown); }
.field > label.check { display: flex; font-weight: 400; font-size: inherit; margin-bottom: 0; }
.code-input { font-size: 28px; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums;
  max-width: 280px; }

/* Сообщения */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin: 0 0 16px; border: 1px solid; }
.alert-error { background: var(--danger-bg); border-color: #efc4c0; color: var(--danger); }
.alert-ok { background: var(--ok-bg); border-color: #c4dfc6; color: var(--ok); }
.alert-info { background: var(--warn-bg); border-color: #f0dfaf; color: #5b4510; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 16px; }
.card h2 { margin-top: 0; }
@media (min-width: 720px) { .card { padding: 20px; } }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; gap: 0 16px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Индикатор связи и тосты (static/js/app.js) */
.net-banner { position: fixed; inset-inline: 0; top: 0; z-index: 90; background: var(--danger); color: #fff;
  padding: 10px 16px; text-align: center; font-weight: 700; display: none; }
.net-banner.show { display: block; }
.toast { position: fixed; inset-inline: 16px; bottom: 96px; z-index: 95; max-width: 520px; margin: 0 auto;
  background: var(--ink); color: #fff; padding: 14px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
  display: none; }
.toast.show { display: block; }
.toast.error { background: var(--danger); }

/* Диалог */
dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: min(520px, calc(100vw - 24px)); width: 100%;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .3); color: var(--ink); }
dialog::backdrop { background: rgba(26, 18, 12, .55); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px;
  background: var(--brown); color: var(--gold-light); }
.dialog-head h2 { margin: 0; color: var(--gold-light); font-weight: 300; font-size: 26px; }
.dialog-body { padding: 16px 20px 20px; max-height: 70vh; overflow: auto; }
.icon-btn { background: none; border: 0; color: inherit; min-width: var(--tap); min-height: var(--tap); font-size: 26px;
  cursor: pointer; border-radius: 50%; }
.contact { padding: 12px 0; border-bottom: 1px solid var(--line); }
.contact:last-child { border-bottom: 0; padding-bottom: 0; }
.card-title + .contact { padding-top: 0; }
/* Последний элемент карточки не добавляет «воздуха» снизу — отступы карточек одинаковые */
.card > :last-child, .card > form > :last-child, .card > form:last-child > .row:last-child { margin-bottom: 0; }
.contact-name { font-weight: 700; }
.tel { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 700; font-size: 18px;
  direction: ltr; unicode-bidi: embed; white-space: nowrap; }
.tel svg { width: 18px; height: 18px; flex: none; }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 14px; color: var(--muted); font-weight: 700; }
.ltr { direction: ltr; unicode-bidi: embed; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.cap::first-letter { text-transform: uppercase; }
.empty { color: var(--muted); padding: 12px 0; }

/* Стрелки «назад/далее» отражаются в RTL */
.arr { display: inline-block; }
[dir="rtl"] .arr { transform: scaleX(-1); }

/* ===== Единые бейджи (статусы во всех зонах) ===== */
.badge, .pill, .p-badge, .nt-tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px;
  font-weight: 700; font-family: var(--font-body); letter-spacing: 0; line-height: 1.5; background: var(--bg);
  color: var(--ink); border: 1px solid var(--line); white-space: nowrap; vertical-align: middle; text-transform: none; }
.badge-ok, .p-badge.ok, .nt-tag.ok, .pill-boarded, .pill-resolved, .pill-create, .pill-arrived {
  background: var(--ok-bg); color: var(--ok); border-color: #c4dfc6; }
.badge-off, .p-badge.off, .pill-no_show, .pill-archived, .pill-error {
  background: var(--danger-bg); color: var(--danger); border-color: #efc4c0; }
.badge-gold, .p-badge.gold, .nt-tag.new { background: #f6eedb; color: var(--gold-text); border-color: #e8d7ac; }
.badge-warn, .pill-at_pickup, .pill-open { background: var(--warn-bg); color: #5b4510; border-color: #f0dfaf; }
.pill-expected, .pill-skip { background: #f2f0ec; color: var(--muted); }
.badge-info, .pill-update { background: #eef3fb; color: #1b4a8f; border-color: #c9d8f0; }
.badge-brand, .nt-tag.imp { background: var(--brown); color: #fff; border-color: var(--brown); }

/* Вкладки-«таблетки» (языки, статусы) */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.tabs a { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 4px 14px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--paper); color: var(--ink);
  text-decoration: none; font-size: 15px; }
.tabs a:hover { border-color: var(--gold); }
.tabs a[aria-current]:not([aria-current="false"]) { background: var(--brown); color: #fff; border-color: var(--brown); }

/* Список с флажками в прокручиваемой рамке */
.pick-list { max-height: 300px; overflow: auto; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 4px 12px; background: var(--paper); }
.pick-list label { display: flex; gap: 10px; align-items: center; min-height: 44px; border-bottom: 1px solid var(--line); }
.pick-list label:last-child { border-bottom: 0; }
.pick-list input[type=checkbox] { width: 20px; height: 20px; flex: none; accent-color: var(--brown); }

/* Пары «название — значение» */
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
/* Телефон: подпись капителью над значением (как .info-row) — строки не расходятся по линии */
@media (max-width: 719px) {
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv dt { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; padding-top: 10px; border-top: 1px solid var(--line); }
  .kv dt:first-of-type { border-top: 0; padding-top: 0; }
  .kv dd { margin: 2px 0 10px; overflow-wrap: break-word; }
  .kv dd:last-child { margin-bottom: 0; }
  [dir="rtl"] .kv dt { letter-spacing: 0; text-transform: none; }
}
@media (min-width: 720px) { .kv { align-items: baseline; } .kv dd .tel { min-height: 0; } }

/* ===== Выбор языка: компактный выпадающий список (нативный select поверх «таблетки») =====
   Без JS — кнопка OK в <noscript>; с JS — отправка при выборе (static/js/app.js, data-autosubmit). */
.lang-pick { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.lang-pick-field { position: relative; display: inline-flex; margin: 0; cursor: pointer; }
.lang-pick-face { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: var(--paper); color: var(--ink);
  font-size: 15px; font-weight: 700; line-height: 1; white-space: nowrap; }
.lang-pick-face svg { width: 18px; height: 18px; flex: none; }
.lang-pick-face svg:last-child { width: 14px; height: 14px; opacity: .8; }
.lang-pick-select { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0;
  opacity: 0; cursor: pointer; font-size: 16px; border: 0; -webkit-appearance: none; appearance: none; }
.lang-pick-field:focus-within .lang-pick-face { outline: 3px solid var(--focus); outline-offset: 2px; }
.lang-pick-field:hover .lang-pick-face { border-color: var(--gold); }
.lang-pick-go { min-height: 44px; padding: 6px 14px; }
/* на тёмном фоне (приветствие, шапки) */
.on-dark .lang-pick-face, .auth-body .lang-pick-face, .g-header .lang-pick-face, .a-side .lang-pick-face {
  background: rgba(255, 255, 255, .04); color: var(--gold-light); border-color: rgba(217, 189, 115, .5); }
.auth-body .lang-pick-field:focus-within .lang-pick-face, .g-header .lang-pick-field:focus-within .lang-pick-face,
.a-side .lang-pick-field:focus-within .lang-pick-face { outline-color: #8fb4ff; }

/* RTL (ar, fa, ur): разрядка ломает связность арабского письма; данные на латинице/кириллице
   (адреса, инструкции сотрудников) — направление по содержимому абзаца */
[dir="rtl"] body * { letter-spacing: 0 !important; }
[dir="rtl"] dd, [dir="rtl"] .trip-note, [dir="rtl"] .p-place { unicode-bidi: plaintext; }
.btn-icon { min-width: 44px; min-height: 44px; padding: 4px 12px; font-size: 18px; }
input[type=file]::file-selector-button { min-height: 44px; margin-inline-end: 12px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); font: inherit; font-weight: 700;
  font-size: 15px; cursor: pointer; }
input[type=file]::file-selector-button:hover { border-color: var(--gold); }
/* поля в flex-строках не распираются длинными вариантами select (WebKit) */
input, select, textarea { min-width: 0; max-width: 100%; }
select { text-overflow: ellipsis; overflow: hidden; }  /* WebKit: длинный вариант иначе даёт прокрутку страницы */
[tabindex="-1"]:focus { outline: none; }
[dir="rtl"] .card-title { font-size: 15px; font-weight: 700; }
.nowrap { white-space: nowrap; }

/* Выбор файла: одинаковая кнопка на всех языках (вместо «Choose File / no file selected») */
.file-pick { position: relative; overflow: hidden; border-style: dashed; width: 100%; }
.file-pick:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.file-pick input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-name { display: block; margin-top: 8px; overflow-wrap: anywhere; font-weight: 600; }
.file-name:empty { display: none; }
@media (min-width: 720px) { .file-pick { width: auto; } }
