/* Дизайн-система ИИ Витрины: шрифт, токены, базовые компоненты.
   Имена компонентов — по мотивам shadcn/ui (button, badge, card, field, input-group, toggle-group,
   table, empty, alert, separator, skeleton, dialog). Цвета — только через семантические токены.
   Старые имена (--brand, --text, --muted как цвет текста, --line, --card, --bg) оставлены: на них
   держатся разделы, которые ещё не переписаны. Сначала телефон, затем широкие экраны. */

@font-face {
  font-family: "Manrope Variable";
  font-style: normal; font-display: swap; font-weight: 200 800;
  src: url("/static/common/fonts/manrope-cyrillic-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Manrope Variable";
  font-style: normal; font-display: swap; font-weight: 200 800;
  src: url("/static/common/fonts/manrope-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

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

:root {
  /* семантика */
  --background: #eef0f3;
  --foreground: #161a22;
  --card: #ffffff;
  --card-foreground: var(--foreground);
  --popover: #ffffff;
  --primary: #1f1a17;
  --primary-foreground: #fffaf5;
  --secondary: #f1f2f5;
  --secondary-foreground: var(--foreground);
  --surface-muted: #f3f4f7;
  --muted-foreground: #626a78;
  --accent: #e9ebf0;
  --border: #dadfe6;
  --input: #d3d9e1;
  --ring: #1f5fad;
  --destructive: #b42318;
  --success: #0f7a55;
  --warning: #9a6200;
  --info: #1f5fad;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgb(20 30 50 / 5%);
  --shadow: 0 1px 2px rgb(20 30 50 / 4%), 0 12px 28px -18px rgb(20 30 50 / 22%);
  --shadow-lg: 0 24px 64px -24px rgb(20 30 50 / 35%);
  --font: "Manrope Variable", Manrope, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  --tap: 44px;
  /* старые имена */
  --brand: #1f5fad;
  --text: var(--foreground);
  --muted: var(--muted-foreground);
  --bg: var(--background);
  --line: var(--border);
  --error: var(--destructive);
  color-scheme: light;
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 500 15px/1.55 var(--font);
  font-variant-numeric: tabular-nums;
  color: var(--foreground);
  background: var(--background);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--brand); text-underline-offset: 3px; }
h1, h2, h3 { letter-spacing: -.02em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); line-height: 1.1; font-weight: 760; letter-spacing: -.045em; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; font-weight: 760; }
h3 { font-size: 1rem; font-weight: 740; }
:where(button, a, input, select, textarea, summary):focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--ring) 22%, transparent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

.page { padding: 16px; }
.muted { color: var(--muted-foreground); }
.inline { display: inline; }
.narrow { max-width: 440px; margin: 24px auto; }
.icon { width: 1em; height: 1em; flex: none; vertical-align: -.125em; }

/* --- Карточка ------------------------------------------------------------------------------ */
.card {
  background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow);
}
.card-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 6px 12px; margin-bottom: 14px; }
.card-title { margin: 0; font-size: 1rem; font-weight: 790; letter-spacing: -.02em; }
.card-description { margin: 3px 0 0; color: var(--muted-foreground); font-size: .85rem; font-weight: 550; }
.card-footer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

/* --- Формы ---------------------------------------------------------------------------------- */
.form { display: grid; gap: 16px; }
.form label, .field { display: grid; gap: 7px; font-weight: 650; font-size: .92rem; }
.field-description, .hint { color: var(--muted-foreground); font-size: .85rem; font-weight: 500; margin: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type="checkbox"], [type="radio"], [type="color"], [type="range"], [type="file"]), select, textarea {
  width: 100%; min-height: var(--tap); padding: 9px 13px;
  border: 1px solid var(--input); border-radius: var(--radius-sm);
  background: var(--card); color: var(--foreground);
  font-weight: 550; font-size: .95rem;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
textarea { line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted-foreground) 80%, transparent); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 22%, transparent);
}
select {
  appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23626a78' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--primary); }
input[type="file"] { font-size: .9rem; }
input[type="file"]::file-selector-button {
  margin-right: 10px; border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px;
  background: var(--secondary); color: var(--foreground); font-weight: 700; cursor: pointer;
}
[aria-invalid="true"] { border-color: var(--destructive) !important; }
.form-error, .field-error { color: var(--destructive); margin: 0; font-weight: 600; font-size: .9rem; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 8px; }

/* InputGroup: поле с иконкой или кнопкой внутри */
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .icon { position: absolute; left: 13px; color: var(--muted-foreground); pointer-events: none; width: 16px; height: 16px; }
.input-group > input { padding-left: 38px !important; }

/* --- Кнопки --------------------------------------------------------------------------------- */
.button, button.button, a.button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 999px;
  background: var(--primary); color: var(--primary-foreground);
  font-weight: 760; font-size: .9rem; line-height: 1.2; white-space: nowrap;
  text-decoration: none; cursor: pointer;
  transition: filter .15s, background-color .15s, transform .15s, box-shadow .15s;
}
.button:hover, .btn:hover { filter: brightness(1.15); }
.button:active, .btn:active { transform: translateY(1px); }
.button:disabled, .btn:disabled, .button[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.button .icon, .btn .icon { width: 16px; height: 16px; }
.button-secondary, .btn-secondary {
  background: var(--secondary) !important; color: var(--secondary-foreground) !important;
  border-color: var(--border) !important;
}
.button-secondary:hover, .btn-secondary:hover { filter: none; background: var(--accent) !important; }
.button-outline, .btn-outline { background: transparent !important; color: var(--foreground) !important; border-color: var(--border) !important; }
.button-ghost, a.button-ghost, button.button-ghost, .btn-ghost {
  background: transparent; color: var(--foreground); border-color: transparent;
}
.button-ghost:hover, .btn-ghost:hover { filter: none; background: var(--accent); }
.button-danger, .btn-destructive { background: var(--destructive) !important; color: #fff !important; }
.btn-sm { min-height: 34px; padding: 0 13px; font-size: .82rem; }
.btn-lg { min-height: 50px; padding: 0 24px; font-size: 1rem; }
.btn-icon { width: 42px; padding: 0; }
.link-button { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--brand); cursor: pointer; min-height: var(--tap); padding: 0 8px; font-weight: 700; }

/* --- Значки --------------------------------------------------------------------------------- */
.badge {
  --badge: var(--muted-foreground);
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 780; line-height: 1.3; white-space: nowrap; vertical-align: middle;
  color: var(--badge); background: color-mix(in srgb, var(--badge) 12%, transparent);
}
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-demo, .badge-warning { --badge: var(--warning); }
.badge-success { --badge: var(--success); }
.badge-danger { --badge: var(--destructive); }
.badge-info { --badge: var(--info); }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--foreground); }

/* --- Сегменты (ToggleGroup) ------------------------------------------------------------------ */
.toggle-group {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 3px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-muted);
}
.toggle-group > a, .toggle-group > button, .toggle-group > label {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 0 14px; border: 0; border-radius: 999px;
  background: transparent; color: var(--foreground); font-size: .82rem; font-weight: 740;
  text-decoration: none; white-space: nowrap; cursor: pointer;
}
.toggle-group > :is(a, button, label):hover { background: var(--accent); }
.toggle-group > :is(.active, [aria-current="page"], [aria-pressed="true"]),
.toggle-group > label:has(input:checked) { background: var(--primary); color: var(--primary-foreground); }
.toggle-group > label input { position: absolute; opacity: 0; pointer-events: none; }

/* --- Таблица -------------------------------------------------------------------------------- */
.table-wrap, .work-scroll, .op-scroll { max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
.table, .work-table, .op-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .88rem; }
.table :is(th, td), .work-table :is(th, td), .op-table :is(th, td) { text-align: left; padding: 11px 12px; vertical-align: top; }
.table th, .work-table th, .op-table th {
  background: var(--surface-muted); color: var(--muted-foreground);
  font-size: .74rem; font-weight: 800; letter-spacing: .02em; white-space: nowrap;
}
.table th:first-child, .work-table th:first-child, .op-table th:first-child { border-radius: 10px 0 0 10px; }
.table th:last-child, .work-table th:last-child, .op-table th:last-child { border-radius: 0 10px 10px 0; }
.table tbody tr + tr td, .work-table tbody tr + tr td, .op-table tbody tr + tr td,
.work-table > tr + tr td { border-top: 1px solid var(--border); }
.table tbody tr:hover td, .work-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.table .num, .work-table .num, .op-table .num { text-align: right; white-space: nowrap; }
.row-link { color: inherit; font-weight: 760; text-decoration: none; }
.row-link:hover { text-decoration: underline; }

/* --- Пустое состояние, оповещение ------------------------------------------------------------ */
.empty {
  display: grid; justify-items: center; gap: 8px; text-align: center;
  padding: 40px 20px; border: 1px dashed var(--border); border-radius: var(--radius-lg);
  color: var(--muted-foreground);
}
.empty-icon {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px;
  background: var(--surface-muted); color: var(--foreground);
}
.empty-icon .icon { width: 20px; height: 20px; }
.empty-title { margin: 4px 0 0; color: var(--foreground); font-weight: 790; font-size: 1rem; }
.empty p { margin: 0; max-width: 42ch; }
.alert {
  --alert: var(--info);
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--alert) 28%, transparent);
  background: color-mix(in srgb, var(--alert) 8%, var(--card));
  color: var(--foreground); font-weight: 560; margin: 0 0 14px;
}
.alert > .icon { color: var(--alert); width: 18px; height: 18px; margin-top: 2px; }
.alert p { margin: 0; }
.alert-success { --alert: var(--success); }
.alert-danger { --alert: var(--destructive); }
.alert-warning { --alert: var(--warning); }
.separator { height: 1px; border: 0; background: var(--border); margin: 16px 0; }
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface-muted), var(--accent), var(--surface-muted)); background-size: 200% 100%; animation: skeleton 1.4s ease infinite; }
@keyframes skeleton { to { background-position: -200% 0; } }

/* --- Список определений ---------------------------------------------------------------------- */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.dl dt { color: var(--muted-foreground); font-weight: 600; }
.dl dd { margin: 0; overflow-wrap: anywhere; font-weight: 650; }

/* --- Диалог (нативный <dialog>) ------------------------------------------------------------- */
.ui-dialog {
  width: min(calc(100% - 24px), 520px); padding: 0; border: 1px solid var(--border);
  border-radius: 22px; background: var(--popover); color: var(--foreground); box-shadow: var(--shadow-lg);
}
.ui-dialog::backdrop { background: rgb(20 16 14 / 42%); backdrop-filter: blur(4px); }

/* --- Вход, ошибки ---------------------------------------------------------------------------- */
.auth {
  min-height: 100svh; display: grid; place-items: center; padding: 24px 16px;
  background:
    linear-gradient(116deg, rgb(73 48 37 / 35%), transparent 43%, rgb(162 101 63 / 24%) 76%, transparent),
    linear-gradient(0deg, rgb(53 33 25 / 34%), transparent 58%),
    url("/static/img/panel-bg.webp") 38% 62% / cover fixed, #ab8e76;
}
.auth > .page { width: 100%; padding: 0; display: flex; justify-content: center; }
.auth .narrow, .auth .card { width: min(440px, 100%); margin: 0; }
.auth .card :is(input:not([type="checkbox"], [type="radio"]), select, textarea) { background: rgb(255 251 245 / 85%); border-color: rgb(74 49 33 / 18%); }
.auth .card .button { background: #261e1b; color: #fffaf5; }
.auth .muted, .auth .hint { color: #5a4c44; }
.auth a { color: #261e1b; font-weight: 700; }
.auth .form-error { color: #a43c27; }
.auth .card {
  padding: 28px; border-radius: 28px;
  border: 1px solid rgb(255 253 246 / 55%);
  background: linear-gradient(150deg, rgb(255 251 242 / 55%), transparent 40%), rgb(250 242 232 / 72%);
  box-shadow: inset 1px 1px 1px rgb(255 254 247 / 84%), 0 22px 72px rgb(35 21 14 / 28%);
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
}
.auth h1 { font-size: 1.8rem; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; letter-spacing: -.03em; font-size: 1.15rem; }
.auth-ai { font-weight: 400; opacity: .55; }
.auth-logo { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; box-shadow: 0 2px 7px rgb(35 21 14 / 14%); }
.auth-logo svg { display: block; border-radius: 10px; }
.auth .button { width: 100%; min-height: 46px; }

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