/* ============================================================
   АЯ-Менеджер — дизайн-система веб-кабинета.
   Токены и стиль взяты из AYA-MP (src/panel-ui.html):
   светлая тема в :root, тёмная — html[data-theme='dark'].
   ============================================================ */

:root {
  color-scheme: light;
  --aya-bg: #f6f7fb;
  --aya-surface: #ffffff;
  --aya-surface-2: #f1f3f9;
  --aya-surface-3: #e9edf5;
  --aya-text: #111827;
  --aya-text-soft: #4f596b;
  --aya-text-muted: #677184;
  --aya-line: rgba(17,24,39,0.08);
  --aya-line-strong: rgba(17,24,39,0.14);
  --aya-brand: #005f6d;
  --aya-brand-strong: #004b57;
  --aya-brand-soft: rgba(15,118,110,0.10);
  --aya-danger: #b42318;
  --aya-danger-strong: #912018;
  --aya-shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
  --aya-shadow-md: 0 8px 24px rgba(15,23,42,0.08);
  --aya-shadow-lg: 0 18px 40px rgba(15,23,42,0.12);
  --aya-radius-sm: 12px;
  --aya-radius-md: 18px;
  --aya-radius-lg: 24px;
  --aya-header-bg: rgba(255,255,255,0.82);
  --aya-backdrop: blur(18px);
  --aya-font-ui: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --aya-font-heading: "Geist", "Instrument Sans", -apple-system, sans-serif;
}
html[data-theme='dark'] {
  color-scheme: dark;
  --aya-bg: #121416;
  --aya-surface: #1b1f23;
  --aya-surface-2: #23282e;
  --aya-surface-3: #2b3138;
  --aya-text: #eef2f6;
  --aya-text-soft: #c2c9d2;
  --aya-text-muted: #8f98a3;
  --aya-line: rgba(255,255,255,0.07);
  --aya-line-strong: rgba(255,255,255,0.12);
  --aya-brand: #1f5a64;
  --aya-brand-strong: #2f6f78;
  --aya-brand-soft: rgba(31,90,100,0.16);
  --aya-shadow-sm: 0 1px 2px rgba(0,0,0,0.24);
  --aya-shadow-md: 0 10px 30px rgba(0,0,0,0.34);
  --aya-shadow-lg: 0 20px 48px rgba(0,0,0,0.44);
  --aya-header-bg: rgba(18,20,22,0.78);
}

/* === База === */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: var(--aya-font-ui);
  font-size: 15px;
  line-height: 1.55;
  background: var(--aya-bg);
  color: var(--aya-text);
  -webkit-font-smoothing: antialiased;
}
.page-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1000px 600px at 15% 10%, var(--aya-brand-soft), transparent 60%),
    radial-gradient(900px 500px at 95% 90%, rgba(31,90,100,0.06), transparent 60%);
}
a { color: var(--aya-brand); text-decoration: none; }
a:hover { text-decoration: underline; }
html[data-theme='dark'] a { color: #6fb6bf; }
h1 {
  font-family: var(--aya-font-heading);
  font-size: 1.45rem; font-weight: 700; letter-spacing: -0.01em;
  margin: 0 0 14px;
}
h2 { font-family: var(--aya-font-heading); font-size: 1.1rem; font-weight: 600; margin: 0 0 10px; }
p { margin: 10px 0; }

/* === Шапка (.brandbar) === */
.brandbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px;
  background: var(--aya-header-bg);
  backdrop-filter: var(--aya-backdrop);
  -webkit-backdrop-filter: var(--aya-backdrop);
  border-bottom: 1px solid var(--aya-line);
}
.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--aya-brand); object-fit: cover; display: block;
  box-shadow: 0 0 12px rgba(15,118,110,0.25);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--aya-font-heading);
  font-size: 19px; font-weight: 700; letter-spacing: -0.01em;
  background-image: linear-gradient(135deg, #003841 0%, #1f5a64 34%, #ff9f0a 72%, #ff6b6b 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
html[data-theme='dark'] .brand-name {
  background-image: linear-gradient(135deg, #7fd0da 0%, #48a4b0 38%, #ffb757 74%, #ff8a8a 100%);
}
.brand-sub {
  font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--aya-text-muted);
}
.theme-toggle {
  width: 40px !important; height: 40px; flex: 0 0 auto;
  padding: 0 !important;
  border-radius: 12px !important;
  background: linear-gradient(180deg, var(--aya-surface) 0%, var(--aya-surface-2) 100%) !important;
  border: 1px solid var(--aya-line-strong) !important;
  color: var(--aya-text) !important;
  font-size: 18px !important; line-height: 1 !important;
  box-shadow: var(--aya-shadow-sm) !important;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--aya-brand) !important; transform: translateY(-1px); }

/* === Контейнер === */
.wrap {
  position: relative; z-index: 1;
  max-width: 720px; margin: 0 auto;
  padding: 28px 20px 64px;
}
.wrap.narrow { max-width: 460px; }
.wrap.wide { max-width: 960px; }
.wrap.xwide { max-width: 1160px; }

/* === Карточка === */
.card {
  background: var(--aya-surface);
  border: 1px solid var(--aya-line);
  border-radius: var(--aya-radius-md);
  box-shadow: var(--aya-shadow-md);
  padding: 20px 22px;
  margin: 0 0 16px;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* === Кнопки === */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 0.92rem;
  padding: 10px 16px;
  border: 1px solid var(--aya-brand);
  border-radius: var(--aya-radius-sm);
  background: linear-gradient(180deg, var(--aya-brand) 0%, var(--aya-brand-strong) 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--aya-shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
button:hover, .btn:hover { transform: translateY(-1px); box-shadow: var(--aya-shadow-md); text-decoration: none; }
button:active, .btn:active { transform: translateY(0); box-shadow: var(--aya-shadow-sm); }
.btn.secondary, button.sec, button.sec2 {
  background: var(--aya-surface-2);
  color: var(--aya-text);
  border-color: var(--aya-line-strong);
}
.btn.secondary:hover, button.sec:hover, button.sec2:hover { border-color: var(--aya-brand); }
.btn.danger {
  background: linear-gradient(180deg, var(--aya-danger) 0%, var(--aya-danger-strong) 100%);
  border-color: var(--aya-danger);
}
.btn.block, button.block { width: 100%; margin-top: 12px; }

/* === Поля форм === */
.field { margin: 10px 0; }
.label, label {
  display: block;
  font-size: 0.82rem; font-weight: 500;
  color: var(--aya-text-soft);
  margin: 10px 0 4px;
}
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 8px 4px; font-size: 0.88rem; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit; color: var(--aya-text);
  background: var(--aya-surface);
  border: 1px solid var(--aya-line-strong);
  border-radius: var(--aya-radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--aya-brand);
  box-shadow: 0 0 0 3px var(--aya-brand-soft);
}
input::placeholder, textarea::placeholder { color: var(--aya-text-muted); }
input[type="checkbox"], input[type="radio"] { width: auto; padding: 0; accent-color: var(--aya-brand); }
input[type="file"] { padding: 9px; background: var(--aya-surface-2); font-size: 0.88rem; margin: 8px 0; }
textarea { resize: vertical; }
/* iOS Safari/WebView увеличивает страницу при фокусе на поле со шрифтом < 16px и не возвращает масштаб
   (на iPhone это выглядело как «вылезшая» за край форма). На тач-устройствах — не меньше 16px. */
@media (hover: none) and (pointer: coarse) { input, select, textarea { font-size: 16px; } }
.row { display: flex; gap: 10px; }
.row > div { flex: 1; min-width: 0; }

/* === Текстовые утилиты === */
.muted { color: var(--aya-text-muted); }
.warn { color: #b45309; font-size: 0.85rem; }
html[data-theme='dark'] .warn { color: #fbbf24; }

/* === Бейджи === */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
  background: var(--aya-surface-3); color: var(--aya-text-soft);
}
.badge.ok { background: #dcfce7; color: #14532d; }
.badge.warn { background: #fef3c7; color: #78350f; }
.badge.danger { background: #fee2e2; color: #7f1d1d; }
.badge.info { background: #e0f2fe; color: #0c4a6e; }

/* === Баннеры === */
.banner {
  padding: 10px 14px;
  border-radius: var(--aya-radius-sm);
  border: 1px solid var(--aya-line);
  margin: 0 0 12px;
  font-size: 0.9rem;
  background: var(--aya-surface-2);
}
.banner.info { background: #e0f2fe; border-color: #bae6fd; color: #0c4a6e; }
.banner.warn { background: #fef3c7; border-color: #fde68a; color: #78350f; }
.banner.danger { background: #fee2e2; border-color: #fecaca; color: #7f1d1d; }
html[data-theme='dark'] .banner.info { background: rgba(56,189,248,0.12); border-color: rgba(56,189,248,0.28); color: #bae6fd; }
html[data-theme='dark'] .banner.warn { background: rgba(251,191,36,0.12); border-color: rgba(251,191,36,0.28); color: #fde68a; }
html[data-theme='dark'] .banner.danger { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.28); color: #fecaca; }

/* === Сообщение-блок === */
.msg {
  background: var(--aya-surface-2);
  border: 1px solid var(--aya-line);
  border-radius: var(--aya-radius-sm);
  padding: 12px 14px;
  margin: 10px 0;
  font-size: 0.92rem;
}

/* === Таблицы === */
.table-scroll { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th {
  text-align: left; font-weight: 600; font-size: 0.78rem;
  color: var(--aya-text-muted);
  padding: 8px; border-bottom: 1px solid var(--aya-line-strong);
  white-space: nowrap;
}
td { padding: 7px 8px; border-bottom: 1px solid var(--aya-line); vertical-align: top; }
tbody tr:hover { background: var(--aya-surface-2); }
td input {
  border: 0; background: transparent; border-radius: 8px; padding: 5px 6px;
}
td input:focus { background: var(--aya-surface); box-shadow: 0 0 0 2px var(--aya-brand-soft); }
td.price input { text-align: right; }
td button { padding: 5px 10px; font-size: 0.8rem; border-radius: 9px; margin: 1px; }

/* === Навигация кабинета (/app) === */
.navgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.navlink {
  display: block; padding: 13px 14px;
  background: var(--aya-surface-2);
  border: 1px solid var(--aya-line);
  border-radius: var(--aya-radius-sm);
  color: var(--aya-text); font-weight: 600; font-size: 0.92rem;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.navlink:hover { text-decoration: none; border-color: var(--aya-brand); transform: translateY(-1px); box-shadow: var(--aya-shadow-sm); }
.navlink.primary {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, var(--aya-brand) 0%, var(--aya-brand-strong) 100%);
  border-color: var(--aya-brand);
  color: #fff;
  padding: 15px 14px; font-size: 1rem;
}
html[data-theme='dark'] .navlink { color: var(--aya-text); }
html[data-theme='dark'] .navlink.primary { color: #fff; }

/* === Переписка (пузыри) === */
.thread { max-height: 280px; overflow: auto; margin: 8px 0; display: flex; flex-direction: column; }
.b { padding: 8px 12px; border-radius: 14px; margin: 4px 0; max-width: 80%; font-size: 0.92rem; }
.b.client { background: var(--aya-brand); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.b.admin { background: var(--aya-surface-3); color: var(--aya-text); margin-right: auto; border-bottom-left-radius: 4px; }
.b .muted { font-size: 0.72rem; }
.b.client .muted { color: rgba(255,255,255,0.75); }
/* В админке платформы (#out) зеркально: справа — админ (свои), слева — клиент. */
#out .b.admin { background: var(--aya-brand); color: #fff; margin-left: auto; margin-right: 0; border-radius: 14px 14px 4px 14px; }
#out .b.admin .muted { color: rgba(255,255,255,0.75); }
#out .b.client { background: var(--aya-surface-3); color: var(--aya-text); margin-right: auto; margin-left: 0; border-radius: 14px 14px 14px 4px; }

/* === Совместимость со старыми инлайн-стилями из JS-строк ===
   (баннеры и статусы, которые собираются в innerHTML со светлым фоном) */
[style*="background:#fee2e2"], [style*="background:#fef3c7"],
[style*="background:#e0f2fe"], [style*="background:#dcfce7"],
[style*="background:#f1f5f9"] { color: #111827; border-radius: 10px; }
[style*="background:#fee2e2"] a, [style*="background:#fef3c7"] a,
[style*="background:#e0f2fe"] a { color: #005f6d; text-decoration: underline; }
.st {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; color: #111827; background: #f1f5f9;
}

/* === Адаптивность === */
@media (max-width: 600px) {
  .wrap { padding: 18px 14px 48px; }
  .card { padding: 16px; border-radius: var(--aya-radius-sm); }
  .row { flex-direction: column; gap: 0; }
  .brandbar { padding: 8px 14px; }
  .brand-name { font-size: 17px; }
  h1 { font-size: 1.25rem; }
}
