:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --bg-grad-a: #eef2f6;
  --bg-grad-b: #f7f7f8;
  --bg-decor-a: rgba(59, 130, 246, 0.08);
  --bg-decor-b: rgba(139, 92, 246, 0.06);
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-hover: #f4f4f5;
  --surface-translucent: rgba(255, 255, 255, 0.96);
  --header-bg: rgba(255, 255, 255, 0.85);
  --border: #e5e7eb;
  --border-strong: #d4d4d8;
  --text: #0a0a0a;
  --text-muted: #6b7280;
  --text-subtle: #9ca3af;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: #ecfdf5;
  --accent-soft-strong: #d1fae5;
  --primary: #111827;
  --primary-hover: #000000;
  --on-primary: #ffffff;
  --on-accent: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #059669;
  --success-soft: #ecfdf5;
  --scrollbar-thumb: rgba(15, 23, 42, 0.22);
  --scrollbar-thumb-hover: rgba(15, 23, 42, 0.34);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1020;
  --bg-grad-a: #0d1426;
  --bg-grad-b: #0b1020;
  --bg-decor-a: rgba(96, 165, 250, 0.12);
  --bg-decor-b: rgba(167, 139, 250, 0.10);
  --surface: #131a2c;
  --surface-2: #0f1626;
  --surface-hover: #1b2235;
  --surface-translucent: rgba(19, 26, 44, 0.94);
  --header-bg: rgba(11, 16, 32, 0.82);
  --border: #232c44;
  --border-strong: #2f3a57;
  --text: #e5e7eb;
  --text-muted: #a1a7b4;
  --text-subtle: #6f7687;
  --accent: #2dd4bf;
  --accent-hover: #14b8a6;
  --accent-soft: rgba(45, 212, 191, 0.14);
  --accent-soft-strong: rgba(45, 212, 191, 0.22);
  --primary: #e5e7eb;
  --primary-hover: #ffffff;
  --on-primary: #0b1020;
  --on-accent: #04161a;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --scrollbar-thumb: rgba(226, 232, 240, 0.22);
  --scrollbar-thumb-hover: rgba(226, 232, 240, 0.36);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.35);
}

html { transition: background-color 0.18s ease, color 0.18s ease; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  position: relative;
  z-index: 0;
}

body::before {
  content: "";
  position: fixed;
  top: -10%; left: -10%; right: -10%; bottom: -10%;
  z-index: -1;
  pointer-events: none;
  background: 
    radial-gradient(circle at 20% 30%, var(--bg-decor-a), transparent 50%),
    radial-gradient(circle at 80% 70%, var(--bg-decor-b), transparent 50%),
    radial-gradient(circle at 60% 10%, rgba(56, 189, 248, 0.05), transparent 40%);
  background-size: 100% 100%;
  animation: ambient-drift 25s ease-in-out infinite alternate;
}

@keyframes ambient-drift {
  0% { transform: scale(1) translate(0, 0); }
  50% { transform: scale(1.03) translate(2%, 3%); }
  100% { transform: scale(1) translate(-2%, -1%); }
}

a { color: inherit; text-decoration: none; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
p { margin: 0; color: var(--text-muted); }

/* === HEADER === */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  position: relative;
}

.header__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  flex-shrink: 0;
}

.header__brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
}

.header__brand-mark svg { width: 16px; height: 16px; }

.header-search {
  flex: 1;
  min-width: 0;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-search__input-group {
  position: relative;
  flex: 1;
  min-width: 0;
}

.header-search__icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.header-search__icon svg { width: 14px; height: 14px; }

.header-search__input {
  width: 100%;
  height: 36px;
  padding: 0 54px 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  transition: all 0.12s ease;
}

.header-search__input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.search-shortcut {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  pointer-events: none;
  user-select: none;
  opacity: 0.85;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.header-search__input:focus ~ .search-shortcut,
.pricelist-search__input:focus ~ .search-shortcut {
  opacity: 0;
}

.header-search__category {
  flex-shrink: 0;
  width: 160px;
}

.header-search__select {
  width: 100%;
  height: 36px;
  padding: 0 28px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: all 0.12s ease;
}
.header-search__select:focus {
  outline: none;
  border-color: var(--accent);
}

.header-site-select {
  flex: 1;
  min-width: 0;
  max-width: 360px;
  margin: 0 auto;
  z-index: 12;
}

.header-site-select__trigger {
  width: 100%;
  height: 36px;
  font-size: 13px;
  padding: 7px 12px;
}

.header-search-wrapper {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 auto;
  max-width: 600px;
}

.header-search-wrapper .header-search {
  flex: 1;
  max-width: none;
  margin: 0;
}

.header-search-wrapper .unified-sync {
  flex-shrink: 0;
  margin: 0;
}

.header__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

body.is-page-loading .main {
  opacity: 0.62;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.header__user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
}

.header__user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.header__logout-form { margin: 0; }

/* === MAIN === */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px;
}

/* === CARDS / PANELS === */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

.panel + .panel { margin-top: 20px; }

.panel__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.panel__head--chat h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.panel__head--chat h2 svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.panel__section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
}

.panel__section-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.panel__section-head h2 svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* === FORMS / INPUTS === */
.form { display: grid; gap: 14px; }

.form__field {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.input,
input[type="text"],
input[type="password"],
input[type="number"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.input:hover,
input[type="text"]:hover,
input[type="password"]:hover,
input[type="number"]:hover {
  border-color: var(--border-strong);
}

.input:focus,
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.input-with-suffix {
  position: relative;
  display: block;
}

.input-with-suffix .input,
.input-with-suffix input[type="number"],
.input-with-suffix input[type="text"] {
  padding-right: 48px;
}

.input-with-suffix__label {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-subtle);
  pointer-events: none;
}

/* === BUTTONS === */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease, transform 0.04s ease;
  font-family: inherit;
  white-space: nowrap;
}

.button svg { width: 16px; height: 16px; flex-shrink: 0; }

.button:active { transform: translateY(0.5px); }

.button:disabled { opacity: 0.55; cursor: not-allowed; }

.button--primary {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.button--primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }

.button--accent {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
.button--accent:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.button--ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.button--ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.button--danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.25);
}
.button--danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.button--success {
  background: rgba(5, 150, 105, 0.12);
  color: var(--success);
  border-color: rgba(5, 150, 105, 0.25);
}
.button--success:hover:not(:disabled) {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.button--small { padding: 7px 10px; font-size: 12px; border-radius: 8px; }
.button--small svg { width: 14px; height: 14px; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease, transform 0.04s ease;
  padding: 0;
}

.icon-button:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.icon-button--danger:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

.icon-button--danger-action {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.34);
  background: var(--danger-soft);
}

.icon-button--danger-action:hover {
  color: #fff;
  border-color: var(--danger);
  background: var(--danger);
}

.icon-button--success {
  color: var(--success);
  border-color: rgba(5, 150, 105, 0.34);
  background: rgba(5, 150, 105, 0.1);
}

.icon-button--success:hover {
  color: #fff;
  border-color: var(--success);
  background: var(--success);
}

.icon-button--active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.icon-button--active:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft-strong, var(--accent-soft));
}

.icon-button svg { width: 16px; height: 16px; }

.icon-button:active { transform: translateY(0.5px); }

/* === FLASH === */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}

.flash--success {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(5, 150, 105, 0.2);
}

.flash--error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.2);
}

.flash--hidden { display: none; }

/* === TOASTS === */
.toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 40px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  padding-bottom: 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: toast-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast--leaving { animation: toast-out 0.2s ease-in forwards; }

.toast__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  color: var(--text-muted);
  background: var(--surface-2);
}
.toast__icon svg { width: 16px; height: 16px; }

.toast--success .toast__icon { color: var(--success); background: var(--success-soft); }
.toast--error .toast__icon { color: var(--danger); background: var(--danger-soft); }

.toast__message {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  min-width: 0;
  word-wrap: break-word;
}

.toast__close {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--text-subtle);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.12s ease, background 0.12s ease;
}
.toast__close:hover { color: var(--text); background: var(--surface-hover); }
.toast__close svg { width: 14px; height: 14px; }

.toast__progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: var(--accent);
  transform-origin: left center;
  animation: toast-shrink 5s linear forwards;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}
.toast--success .toast__progress { background: var(--success); }
.toast--error .toast__progress { background: var(--danger); }

@keyframes toast-in {
  from { transform: translateX(110%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toast-out {
  to { transform: translateX(110%); opacity: 0; }
}
@keyframes toast-shrink {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* === PRICELIST SEARCH === */
.pricelist-search {
  position: relative;
  margin-bottom: 10px;
}

.pricelist-search__icon {
  position: absolute;
  top: 50%;
  left: 11px;
  transform: translateY(-50%);
  display: inline-flex;
  color: var(--text-subtle);
  pointer-events: none;
}
.pricelist-search__icon svg { width: 14px; height: 14px; }

.pricelist-search__input {
  width: 100%;
  padding: 9px 54px 9px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.pricelist-search__input::placeholder { color: var(--text-subtle); }
.pricelist-search__input:hover { border-color: var(--border-strong); }
.pricelist-search__input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}
.pricelist-search__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.pricelist-empty {
  padding: 16px 10px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 12px;
}

/* === PRICELIST LINKS === */
.pricelist-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  transition: background 0.12s ease, color 0.12s ease;
}
.pricelist-link:hover {
  background: var(--surface-hover);
}
.pricelist-link--active {
  background: var(--accent-soft);
  color: var(--accent);
}
.pricelist-link__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.pricelist-link__icon svg {
  width: 14px;
  height: 14px;
}
.pricelist-link__body {
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
}
.pricelist-link__body strong {
  display: block;
  font-weight: 600;
}

/* === PRICELIST SCROLL === */
.pricelist-list.is-searching > .pricelist-link { display: flex; }
.pricelist-list.is-searching > .pricelist-link[data-hidden-by-search] { display: none; }

.pricelist-list-scroll {
  --pricelist-item-h: 58px;
  --pricelist-gap: 6px;
  --pricelist-visible: 8;
  max-height: calc(var(--pricelist-item-h) * var(--pricelist-visible) + var(--pricelist-gap) * (var(--pricelist-visible) - 1));
  overflow-y: auto;
  padding-right: 6px;
  margin-right: -6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.pricelist-list-scroll::-webkit-scrollbar {
  width: 8px;
}
.pricelist-list-scroll::-webkit-scrollbar-track {
  background: transparent;
  margin: 2px 0;
}
.pricelist-list-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.pricelist-list-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-subtle);
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* === LAYOUTS === */
.dashboard-shell { display: grid; gap: 20px; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.workspace-grid--reverse {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
}

.workspace-side, .workspace-main { min-width: 0; }
.workspace-side-stack { display: grid; gap: 20px; }

/* === CHAT === */
.chat-widget {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 30;
  pointer-events: none;
}

.chat-widget__fab {
  pointer-events: auto;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  border-radius: 999px;
  padding: 14px 16px;
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: transform 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
  font: inherit;
  font-weight: 700;
}

.chat-widget__fab:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.chat-widget__fab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.14), var(--shadow-lg);
}

.chat-widget__fab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.chat-widget__fab-icon svg {
  width: 18px;
  height: 18px;
}

.chat-widget__fab-label {
  font-size: 13px;
  letter-spacing: 0.02em;
}

.chat-widget__panel {
  pointer-events: none;
  position: absolute;
  right: 0;
  bottom: 76px;
  width: min(390px, calc(100vw - 24px));
  max-height: min(72vh, 620px);
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background:
    linear-gradient(180deg, var(--accent-soft), transparent 110px),
    var(--surface-translucent);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
}

.chat-widget[data-chat-open="true"] .chat-widget__panel {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.chat-widget__panel,
.chat-thread,
.chat-composer__input {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.chat-widget__panel::-webkit-scrollbar,
.chat-thread::-webkit-scrollbar,
.chat-composer__input::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.chat-widget__panel::-webkit-scrollbar-track,
.chat-thread::-webkit-scrollbar-track,
.chat-composer__input::-webkit-scrollbar-track {
  background: transparent;
}

.chat-widget__panel::-webkit-scrollbar-thumb,
.chat-thread::-webkit-scrollbar-thumb,
.chat-composer__input::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}

.chat-widget__panel::-webkit-scrollbar-thumb:hover,
.chat-thread::-webkit-scrollbar-thumb:hover,
.chat-composer__input::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.chat-widget__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.chat-widget__title h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-widget__title h2 svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.chat-widget__title p {
  font-size: 12px;
  color: var(--text-subtle);
}

.chat-widget__tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.04s ease, box-shadow 0.12s ease;
}

.chat-action-button svg {
  width: 18px;
  height: 18px;
}

.chat-action-button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.chat-action-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chat-action-button--ghost {
  background: var(--surface);
}

.chat-action-button--send {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.chat-action-button--send:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.chat-panel__meta {
  font-size: 12px;
  color: var(--text-subtle);
}

.chat-panel__notice {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(220, 38, 38, 0.18);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.chat-thread {
  display: grid;
  gap: 12px;
  min-height: 240px;
  max-height: 320px;
  overflow: auto;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(13, 148, 136, 0.04), transparent 120px),
    var(--surface-2);
}

.chat-empty {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.chat-empty code {
  display: inline-block;
  margin-top: 8px;
}

.chat-message {
  display: grid;
  gap: 6px;
  max-width: min(720px, 100%);
}

.chat-message--user {
  justify-self: end;
}

.chat-message__meta {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-subtle);
}

.chat-message--user .chat-message__meta {
  text-align: right;
}

.chat-message__bubble {
  padding: 11px 13px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-message--assistant .chat-message__bubble {
  border-top-left-radius: 6px;
}

.chat-message--user .chat-message__bubble {
  background: var(--accent-soft);
  border-color: rgba(13, 148, 136, 0.16);
  border-top-right-radius: 6px;
}

.chat-message--pending .chat-message__bubble {
  opacity: 0.7;
}

.chat-schedule {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.chat-schedule__site {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(13, 148, 136, 0.14);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(13, 148, 136, 0.06), transparent 70%),
    var(--surface-2);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.chat-schedule__site.is-pending {
  opacity: 0.65;
}

.chat-schedule__site-head {
  display: grid;
  gap: 3px;
}

.chat-schedule__site-head strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.chat-schedule__site-head span {
  font-size: 12px;
  color: var(--text-subtle);
}

.chat-schedule__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-schedule__button {
  display: grid;
  gap: 2px;
  min-width: 88px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background:
    linear-gradient(180deg, var(--accent-soft-strong), transparent 140%),
    var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.chat-schedule__button:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.chat-schedule__button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chat-schedule__button:disabled {
  cursor: wait;
  opacity: 0.7;
  box-shadow: none;
}

.chat-schedule__button.is-active,
.chat-schedule__button[aria-expanded="true"] {
  border-color: var(--accent);
  background:
    linear-gradient(180deg, var(--accent-soft-strong), transparent 120%),
    var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chat-schedule__button--custom {
  border-style: dashed;
}

.chat-schedule__button--custom .chat-schedule__button-bottom {
  color: var(--text-muted);
}

.chat-schedule__button-top {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.chat-schedule__button-bottom {
  font-size: 12px;
  color: var(--text);
  line-height: 1.3;
}

.chat-schedule__custom {
  display: flex;
  flex: 1 1 100%;
  align-items: center;
  gap: 8px;
}

.chat-schedule__custom[hidden] {
  display: none;
}

.chat-schedule__date-input {
  flex: 1 1 180px;
  min-width: 0;
}

.chat-schedule__custom-apply {
  flex: 0 0 auto;
}

.chat-schedule__selected {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(13, 148, 136, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.chat-schedule--complete .chat-schedule__site.is-selected {
  border-color: rgba(13, 148, 136, 0.2);
}

@media (max-width: 640px) {
  .chat-schedule__custom {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-schedule__custom-apply {
    width: 100%;
  }
}

.chat-form {
  display: grid;
  gap: 12px;
}

.chat-form--widget {
  gap: 8px;
}

.chat-composer {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 10px 10px 8px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(13, 148, 136, 0.05), transparent 80%),
    var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.chat-autocomplete {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow-md);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-autocomplete strong {
  color: var(--primary);
}
.chat-autocomplete kbd {
  font-size: 11px;
  font-family: inherit;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 5px;
}

.chat-composer:hover {
  border-color: var(--border-strong);
}

.chat-composer:focus-within {
  border-color: var(--accent);
  box-shadow:
    0 0 0 4px rgba(13, 148, 136, 0.14),
    var(--shadow-sm);
  background:
    linear-gradient(180deg, rgba(13, 148, 136, 0.07), transparent 80%),
    var(--surface);
}

.chat-composer__input {
  width: 100%;
  min-height: 44px;
  max-height: 200px;
  resize: none;
  border: none;
  background: transparent;
  padding: 8px 4px 0;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  overflow-y: auto;
}

.chat-composer__input:focus {
  outline: none;
}

.chat-composer__input::placeholder {
  color: var(--text-subtle);
}

.chat-composer__input:disabled {
  color: var(--text-subtle);
  cursor: not-allowed;
}

.chat-composer__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
  min-height: 32px;
}

.chat-composer__hint {
  font-size: 11px;
  color: var(--text-subtle);
  line-height: 1.4;
  user-select: none;
}

.chat-composer__hint kbd {
  display: inline-block;
  padding: 1px 5px;
  margin: 0 1px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
}

.chat-composer__controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.chat-composer__counter {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-subtle);
  transition: color 0.12s ease;
}

.chat-composer__counter[data-state="warn"] {
  color: var(--accent);
}

.chat-composer__counter[data-state="limit"] {
  color: var(--danger, #dc2626);
  font-weight: 600;
}

.chat-composer__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(13, 148, 136, 0.35);
  transition: background 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.chat-composer__send svg {
  width: 16px;
  height: 16px;
}

.chat-composer__send:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.4);
}

.chat-composer__send:active:not(:disabled) {
  transform: translateY(1px) scale(0.97);
}

.chat-composer__send:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.25);
}

.chat-composer__send:disabled {
  background: var(--border-strong);
  color: var(--surface);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.75;
}

.chat-form__hint {
  font-size: 12px;
  color: var(--text-subtle);
  text-align: center;
  max-width: 250px;
}

/* === SITE + PRICELIST LISTS === */
.site-list {
  display: block;
}

/* === CUSTOM SELECT === */
.custom-select {
  position: relative;
  width: 100%;
}

.custom-select__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  text-align: left;
}

.custom-select__trigger:hover {
  border-color: var(--border-strong);
}

.custom-select__trigger:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.custom-select__trigger[aria-expanded="true"] {
  border-color: var(--accent);
}

.custom-select__trigger-text {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}

.custom-select__trigger-arrow {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.custom-select__trigger[aria-expanded="true"] .custom-select__trigger-arrow {
  transform: rotate(180deg);
}

.custom-select__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 100;
  display: none;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.custom-select__dropdown:not([hidden]) {
  display: grid;
  animation: dropdown-in 0.16s ease;
}

@keyframes dropdown-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.custom-select__search {
  position: relative;
  display: flex;
  align-items: center;
}

.custom-select__search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  pointer-events: none;
}

.custom-select__search-icon svg {
  width: 16px;
  height: 16px;
}

.custom-select__search-input {
  width: 100%;
  padding: 8px 12px 8px 12px !important;
  text-indent: 40px !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.custom-select__search-input::placeholder {
  color: var(--text-subtle);
}

.custom-select__search-input:hover {
  border-color: var(--border-strong);
}

.custom-select__search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.custom-select__options {
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}

.custom-select__scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.custom-select__scroll::-webkit-scrollbar {
  width: 6px;
}

.custom-select__scroll::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}

.custom-select__scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.custom-select__scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-subtle);
  background-clip: padding-box;
}

.custom-select__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  color: var(--text);
}

.custom-select__option:hover {
  background: var(--surface-hover);
}

.custom-select__option.selected {
  background: var(--accent-soft);
  color: var(--accent);
}

.custom-select__option.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.custom-select__option-text {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}

.custom-select__option-check {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.custom-select__option-check svg {
  width: 14px;
  height: 14px;
}

.custom-select__option.hidden {
  display: none;
}

.pricelist-list { display: grid; gap: 6px; }

.site-card,
.pricelist-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
  min-width: 0;
}

.site-card__icon,
.pricelist-link__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-muted);
  flex-shrink: 0;
}

.site-card__icon svg,
.pricelist-link__icon svg { width: 16px; height: 16px; }

.site-card__body,
.pricelist-link__body {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.site-card strong,
.pricelist-link strong {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-card span,
.pricelist-link span {
  font-size: 12px;
  color: var(--text-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-card:hover,
.pricelist-link:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.site-card--active,
.pricelist-link--active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent-soft-strong) inset;
}

.site-card--active .site-card__icon,
.pricelist-link--active .pricelist-link__icon {
  background: var(--accent);
  color: #fff;
}

/* === BACKUP LIST === */
.backup-list { display: grid; gap: 6px; }

.backup-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 13px;
}

.backup-item__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text-muted);
  flex-shrink: 0;
}

.backup-item__icon svg { width: 14px; height: 14px; }

.backup-item__body { display: grid; gap: 1px; min-width: 0; }
.backup-item strong { font-weight: 600; font-size: 13px; color: var(--text); }
.backup-item span { font-size: 12px; color: var(--text-subtle); }

/* === META FORM === */
.form--meta {
  grid-template-columns: minmax(240px, 1.3fr) minmax(200px, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 18px;
}

/* === TABLE === */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
  font-size: 14px;
}

.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.table tbody tr:last-child td { border-bottom: none; }

.table th {
  color: var(--text-subtle);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
}

.table__muted { color: var(--text-muted); min-width: 220px; font-size: 13px; }
.table__actions { min-width: 140px; width: 140px; }
.table__actions--sites { min-width: 220px; width: 220px; }

.table--products {
  table-layout: fixed;
  min-width: 760px;
}
.table--products__col-name   { width: auto; }
.table--products__col-price  { width: 170px; }
.table--products__col-markup { width: 150px; }
.table--products__col-action { width: 170px; }
.table--products th,
.table--products td { vertical-align: middle; }
.table--products .input { width: 100%; }
.table--products .price-effective {
  margin-top: 6px;
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
}
.table--products .row-actions { flex-wrap: nowrap; }
.table--products .row-actions .button { flex-shrink: 0; }
.table--products .row-status {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: 100%;
}
.table__subtle {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-subtle);
}

.table__empty {
  text-align: center;
  color: var(--text-subtle);
  padding: 40px 14px;
  font-size: 13px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row-actions--compact {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.row-status {
  font-size: 11px;
  color: var(--text-subtle);
  min-height: 14px;
}
.row-status--saving { color: var(--accent); }
.row-status--success { color: var(--success); }
.row-status--error { color: var(--danger); }

.product-row--dirty td { background: rgba(13, 148, 136, 0.03); }
.product-row--saving td { background: rgba(99, 102, 241, 0.03); }

@keyframes ai-row-flash {
  0%   { background: var(--accent-soft-strong); box-shadow: inset 3px 0 0 var(--accent); }
  60%  { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
  100% { background: transparent; box-shadow: inset 0 0 0 transparent; }
}

.product-row--ai-updated td {
  animation: ai-row-flash 2.2s ease-out;
}

.product-row--ai-updated td:first-child {
  position: relative;
}

.product-row--ai-updated td:first-child::before {
  content: "AI";
  position: absolute;
  top: 4px;
  left: 4px;
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 4px;
  color: var(--on-accent, #fff);
  background: var(--accent);
  animation: ai-row-flash-badge 2.2s ease-out forwards;
  pointer-events: none;
}

@keyframes ai-row-flash-badge {
  0%   { opacity: 1; transform: translateY(0); }
  80%  { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-4px); }
}

.input--dirty {
  border-color: var(--accent);
  background: var(--accent-soft);
}

code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
}

/* === ADMIN === */
.admin-shell { gap: 20px; }

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.stat-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.stat-card__icon svg { width: 20px; height: 20px; }

.stat-card__body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.stat-card__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-subtle);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-card__value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.stat-card__sub {
  font-size: 12px;
  color: var(--text-muted);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.admin-section { display: grid; gap: 16px; }

.admin-section__head h2 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--text);
}

.admin-section__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-muted);
}
.admin-section__icon svg { width: 16px; height: 16px; }

.admin-section__count {
  margin-left: auto;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.admin-create {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.admin-create__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.admin-create__field {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.admin-create__field em {
  font-style: normal;
  color: var(--text-subtle);
  font-weight: 400;
}

.admin-create__field--narrow { grid-column: span 1; }
.admin-create__field--full { grid-column: 1 / -1; }

.admin-create__submit {
  justify-self: start;
}

.admin-search {
  margin-bottom: 8px;
}

.admin-search__input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
}

.admin-list {
  display: grid;
  gap: 8px;
}

.admin-list__empty {
  padding: 24px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.admin-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.admin-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.admin-card--collapsible {
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: start;
}

.admin-card__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-top: 2px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.admin-card__toggle:hover {
  background: var(--surface-2);
  color: var(--text);
}
.admin-card__toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.admin-card__body {
  display: grid;
  gap: 12px;
  margin-top: 8px;
  transition: opacity 0.2s ease, max-height 0.2s ease;
}
.admin-card__body--collapsed {
  display: none;
}

.admin-card__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.admin-card--collapsible .admin-card__avatar {
  margin-top: 2px;
}

.admin-card__avatar--site {
  background: var(--surface-2);
  color: var(--text-muted);
}
.admin-card__avatar--site svg { width: 18px; height: 18px; }

.admin-card__info {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.admin-card__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.admin-card__title strong {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.admin-card__meta {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-card__actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.admin-card--collapsible .admin-card__actions {
  margin-top: 2px;
}

.admin-card__hint {
  font-size: 11px;
  color: var(--text-subtle);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-2);
}

select.input,
.form select[name] {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>") no-repeat right 10px center / 16px 16px;
  padding: 10px 34px 10px 12px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}

.inline-form { margin: 0; display: inline; }

.role-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-badge svg { width: 11px; height: 11px; }

.role-badge--admin {
  background: rgba(13, 148, 136, 0.1);
  color: var(--accent);
  border-color: rgba(13, 148, 136, 0.25);
}
.role-badge--manager {
  background: rgba(17, 24, 39, 0.06);
  color: var(--text);
  border-color: var(--border);
}

.status-badge--on {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(5, 150, 105, 0.22);
}
.status-badge--off {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.22);
}

.status-badge--info {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(13, 148, 136, 0.22);
}

.status-badge--muted {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--border);
}

/* === SCHEDULED UPDATES === */
.panel__section-hint {
  font-size: 12px;
  color: var(--text-subtle);
  font-weight: 500;
}

.panel--scheduled { position: sticky; top: 76px; }

.scheduled-scroll {
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  padding-right: 6px;
  margin-right: -6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.scheduled-scroll::-webkit-scrollbar { width: 8px; }
.scheduled-scroll::-webkit-scrollbar-track { background: transparent; margin: 2px 0; }
.scheduled-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.scheduled-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-subtle);
  background-clip: padding-box;
  border: 2px solid transparent;
}

.scheduled-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.scheduled-item {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 13px;
}

.scheduled-item__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.scheduled-item__date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 12.5px;
}

.scheduled-item__date svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

.scheduled-item__kind {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.scheduled-item__kind--price {
  background: var(--accent-soft);
  color: var(--accent);
}

.scheduled-item__kind--markup {
  background: var(--success-soft);
  color: var(--success);
}

.scheduled-item__location {
  color: var(--text);
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}

.scheduled-item__change {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

.scheduled-item__prev {
  text-decoration: line-through;
  color: var(--text-subtle);
}

.scheduled-item__arrow {
  color: var(--text-subtle);
}

.scheduled-item__next {
  color: var(--text);
  font-weight: 700;
}

/* === AUDIT LOG === */
.audit-filters {
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.audit-filters__actions {
  display: flex;
  gap: 8px;
  grid-column: 1 / -1;
}

.audit-table {
  table-layout: fixed;
  min-width: 820px;
}

.audit-table__col-when { width: 110px; }
.audit-table__col-who  { width: 130px; }
.audit-table__col-what { width: auto; }
.audit-table__col-ai   { width: 34%; }

.audit-table th,
.audit-table td {
  vertical-align: top;
}

.audit-row--ai td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.audit-row__when {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.audit-row__date { display: block; color: var(--text); font-weight: 500; }
.audit-row__time { display: block; color: var(--text-subtle); }

.audit-row__who {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.audit-row__what {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.audit-row__summary {
  font-weight: 500;
}

.audit-row__location {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-subtle);
  word-break: break-word;
}

.audit-row__change {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.audit-row__change strong {
  color: var(--text);
}

.audit-row__prev {
  color: var(--text-subtle);
  text-decoration: line-through;
  text-decoration-color: var(--text-subtle);
}

.audit-row__error {
  margin-top: 4px;
  font-size: 12px;
  color: var(--danger);
}

.audit-row__ai { min-width: 0; }

.audit-row__ai-empty {
  color: var(--text-subtle);
  font-size: 13px;
}

.audit-row__ai-thread {
  display: grid;
  gap: 6px;
}

.audit-row__ai-line {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.audit-row__ai-tag {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-subtle);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: baseline;
}

.audit-row__ai-tag--ai {
  background: var(--accent-soft);
  color: var(--accent);
}

.audit-row__ai-line--ai { color: var(--text); }

.audit-pagination {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.audit-pagination__label {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* === AUTH / LOGIN === */
.auth-wrap {
  min-height: calc(100dvh - 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 32px;
}

.auth-card__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--primary);
  color: var(--on-primary);
  margin: 0 auto 16px;
}

.auth-card__logo svg { width: 24px; height: 24px; }

.auth-card__intro { text-align: center; margin-bottom: 24px; }
.auth-card__intro h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card__intro p { color: var(--text-muted); font-size: 13px; }

.auth-card .form { gap: 14px; }

.auth-card .button--primary { width: 100%; padding: 11px 14px; margin-top: 4px; }

/* Responsive */
@media (max-width: 1180px) {
  /* Site selector now uses dropdown, no grid needed */
}
@media (max-width: 960px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .workspace-grid--reverse { grid-template-columns: 1fr; }
  .panel--scheduled { position: static; }
  .scheduled-scroll { max-height: 320px; }
  /* Site selector now uses dropdown, no grid needed */
  .form--meta { grid-template-columns: 1fr; }
  .audit-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audit-table__col-ai { width: 38%; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .admin-create__fields { grid-template-columns: 1fr; }
  .admin-card {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .admin-card--collapsible {
    grid-template-columns: auto auto minmax(0, 1fr);
  }
  .admin-card__actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}
@media (max-width: 640px) {
  .main { padding: 20px 16px; }
  .header__inner { padding: 12px 16px; gap: 8px; }
  .header__user strong { display: none; }
  .header__user { padding: 4px; }
  .header-site-select { max-width: 180px; }
  .panel { padding: 18px; border-radius: 14px; }
  /* Site selector now uses dropdown, no grid needed */
  .auth-card { padding: 24px; }
  .chat-widget {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
  .chat-widget__panel {
    width: auto;
    left: 0;
    right: 0;
    bottom: 72px;
    max-height: min(70vh, 560px);
    transform-origin: bottom center;
  }
  .chat-composer__hint {
    display: none;
  }
  .chat-composer__controls {
    margin-left: auto;
  }
  .audit-filters {
    grid-template-columns: 1fr;
  }
  .audit-filters__actions {
    flex-direction: column;
  }
  .audit-filters__actions .button {
    width: 100%;
  }
  .audit-pagination {
    grid-template-columns: 1fr;
  }
}

/* === THEME TOGGLE === */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.08s ease, box-shadow 0.14s ease;
}

.theme-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}

.theme-toggle:active {
  transform: scale(0.96);
}

.theme-toggle:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.theme-toggle__icon {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.22s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle__icon svg {
  width: 18px;
  height: 18px;
}

.theme-toggle__icon--sun {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
  color: #f59e0b;
}

.theme-toggle__icon--moon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

[data-theme="dark"] .theme-toggle__icon--sun {
  opacity: 1;
  transform: rotate(0) scale(1);
}

[data-theme="dark"] .theme-toggle__icon--moon {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

[data-theme="dark"] .theme-toggle {
  background: var(--surface);
  border-color: var(--border);
}

/* ===== Import page ===== */
.import-page { max-width: 860px; margin: 0 auto; }

.import-steps {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; margin-bottom: 20px; flex-wrap: wrap;
}
.import-step {
  padding: 4px 12px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted);
}
.import-step--active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.import-step--done {
  background: var(--success, #16a34a); color: #fff; border-color: transparent;
}
.import-step-sep { color: var(--text-muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; }
.card__title { font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.card__desc  { color: var(--text-muted); font-size: 14px; margin: 0 0 24px; }

/* Dropzone */
.import-dropzone {
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 40px 24px; text-align: center; cursor: pointer;
  transition: border-color 0.15s, background 0.15s; position: relative;
}
.import-dropzone--drag,
.import-dropzone:focus-within { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, transparent); }
.import-dropzone--has-file    { border-color: var(--success, #16a34a); }
.import-dropzone__icon        { color: var(--text-muted); margin-bottom: 12px; }
.import-dropzone__icon svg    { width: 40px; height: 40px; }
.import-dropzone__text        { font-size: 15px; margin-bottom: 6px; }
.import-dropzone__browse      { color: var(--primary); cursor: pointer; text-decoration: underline; }
.import-dropzone__hint        { font-size: 12px; color: var(--text-muted); }
.import-dropzone__filename    { margin-top: 10px; font-size: 13px; font-weight: 500; color: var(--primary); }
.import-dropzone__input       { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* Hints */
.import-hints { margin-top: 16px; border: 1px solid var(--border); border-radius: 10px; }
.import-hints summary { padding: 12px 16px; cursor: pointer; font-size: 13px; color: var(--text-muted); }
.import-hints__body   { padding: 0 16px 16px; font-size: 13px; }
.import-hints__pre    { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 12px; overflow-x: auto; }

/* Preview */
.import-preview-meta  { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.badge                { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; background: var(--surface); border: 1px solid var(--border); }
.badge--type          { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); border-color: transparent; }
.badge--count         { background: color-mix(in srgb, #16a34a 12%, transparent); color: #16a34a; border-color: transparent; }
.badge--warn          { background: color-mix(in srgb, #d97706 12%, transparent); color: #d97706; border-color: transparent; }
.badge--error         { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border-color: transparent; }

.import-price         { font-variant-numeric: tabular-nums; white-space: nowrap; }
.import-price--old    { color: var(--text-muted); text-decoration: line-through; }
.import-price--new    { font-weight: 600; color: #16a34a; }
.import-arrow         { color: var(--text-muted); }

.import-change        { font-size: 12px; margin-bottom: 4px; }
.import-change__field { font-weight: 600; color: var(--text-muted); }
.import-change__old   { color: var(--text-muted); text-decoration: line-through; }
.import-change__new   { color: #16a34a; font-weight: 500; }

.import-unmatched     { margin-top: 20px; border: 1px solid var(--border); border-radius: 10px; }
.import-unmatched summary { padding: 12px 16px; cursor: pointer; font-size: 13px; color: var(--text-muted); }
.import-apply-form    { margin-top: 24px; }
.import-apply-actions { gap: 12px; }

/* Result */
.import-result        { display: flex; gap: 16px; align-items: flex-start; padding: 20px; border-radius: 12px; }
.import-result svg    { width: 28px; height: 28px; flex-shrink: 0; }
.import-result--ok    { background: color-mix(in srgb, #16a34a 10%, transparent); color: #16a34a; border: 1px solid color-mix(in srgb, #16a34a 30%, transparent); }
.import-result--ok strong { font-size: 16px; }
.import-result--error { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.import-result__sub   { font-size: 13px; margin-top: 4px; opacity: 0.85; }

/* ========================================================================
   Unified Catalog & Regional Coefficient (Приоритет №1 ТЗ)
   ======================================================================== */

/* Coefficient badge in dashboard header */
.badge--coefficient {
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  font-weight: 600;
}

.badge--info {
  background: color-mix(in srgb, #0ea5e9 12%, transparent);
  color: #0ea5e9;
  border-color: transparent;
}

.panel__badges {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Unified catalog actions in sidebar */
.unified-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
}

.unified-actions .button {
  width: 100%;
  justify-content: center;
}

/* Unified catalog page */
.unified-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.unified-toolbar__title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.unified-toolbar__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  flex: 0 0 auto;
}

.unified-toolbar__icon svg { width: 20px; height: 20px; }

.unified-toolbar h1 {
  margin: 0;
  font-size: 22px;
}

.unified-toolbar p,
.unified-products-head p {
  margin: 3px 0 0;
  color: var(--text-subtle);
  font-size: 13px;
}


.unified-sync {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.unified-category-list {
  display: grid;
  gap: 6px;
}

.unified-category-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
}

.unified-category-link:hover,
.unified-category-link--active {
  background: var(--surface-hover);
  color: var(--text);
}

.unified-category-link strong {
  font-size: 11px;
  color: var(--text-subtle);
}

.unified-category-form {
  display: grid;
  gap: 10px;
}

.unified-products-head {
  align-items: center;
}

.unified-layout {
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
}

.unified-products-panel {
  padding: 18px;
  overflow: hidden;
}

.unified-table {
  min-width: 780px;
  table-layout: fixed;
  font-size: 13px;
}

.unified-table tbody[data-loading="1"] {
  opacity: 0.55;
}

.unified-table th,
.unified-table td {
  padding: 10px 12px;
}

.unified-table__col-product { width: auto; }
.unified-table__col-category { width: 155px; }
.unified-table__col-price { width: 255px; }
.unified-table__col-links { width: 92px; }
.unified-table__col-date { width: 118px; }

.unified-product {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.unified-product strong {
  color: var(--text);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.unified-product__meta {
  color: var(--text-subtle);
  font-size: 12px;
}

.unified-category-badge {
  display: inline-flex;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unified-price-form {
  display: grid;
  grid-template-columns: minmax(92px, 120px) 36px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.unified-price-input {
  width: 100%;
  text-align: right;
}

.unified-inline-status {
  min-width: 0;
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 1.35;
}

.unified-inline-status[data-state="success"] { color: var(--success); }
.unified-inline-status[data-state="warning"] { color: #d97706; }
.unified-inline-status[data-state="error"] { color: var(--danger); }
.unified-inline-status[data-state="pending"] { color: var(--text-muted); }

.unified-date {
  color: var(--text-subtle);
  font-size: 12px;
  white-space: nowrap;
}

.unified-detail-row td {
  background: var(--surface-2);
}

.unified-detail {
  padding: 10px;
}

.unified-links-table {
  min-width: 760px;
  font-size: 13px;
}

.unified-link-site {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.25;
}

.unified-link-site__host {
  color: var(--text-subtle);
  font-size: 12px;
}

.unified-link-target {
  color: var(--accent);
  text-decoration: none;
}

.unified-link-target:hover {
  text-decoration: underline;
}

.unified-detail__loading,
.unified-detail__error {
  padding: 12px;
  color: var(--text-subtle);
  font-size: 13px;
}

.unified-detail__error {
  color: var(--danger);
}

.unified-pagination,
.unified-pagination-bottom {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.unified-pagination span {
  color: var(--text-subtle);
  font-size: 12px;
}

.unified-pagination .is-disabled {
  pointer-events: none;
  opacity: 0.45;
}

.unified-pagination-bottom {
  margin-top: 14px;
}

/* Coefficient form in admin site cards */
.coefficient-form {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.coefficient-form__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.coefficient-form__label .input--narrow {
  width: 80px;
  text-align: right;
}

.category-coefficients-form {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-coefficients-form__title {
  font-size: 12px;
  color: var(--text-muted);
}

.category-coefficients-form__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.category-coefficients-form__field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.category-coefficients-form__field .input--narrow {
  width: 78px;
  text-align: right;
}

/* Status badges extension */
.status-badge--warn {
  background: color-mix(in srgb, #d97706 12%, transparent);
  color: #d97706;
  border-color: transparent;
}

/* Inline forms for AJAX */
.inline-form {
  display: inline;
}

/* Price with coefficient in table */
.price-with-coeff {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.price-with-coeff__regional {
  font-size: 11px;
  color: var(--text-muted);
}

/* Sync status */
.sync-status {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
}

.unified-sync-progress {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 218px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.unified-sync-progress[hidden] {
  display: none;
}

.unified-sync-progress__ring {
  --progress: 0%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle closest-side, var(--surface) 72%, transparent 73%),
    conic-gradient(var(--accent) var(--progress), var(--border) 0);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  flex: 0 0 auto;
}

.unified-sync-progress[data-status="failed"] .unified-sync-progress__ring {
  background:
    radial-gradient(circle closest-side, var(--surface) 72%, transparent 73%),
    conic-gradient(var(--danger) var(--progress), var(--border) 0);
  color: var(--danger);
}

.unified-sync-progress[data-status="finished"] .unified-sync-progress__ring {
  background:
    radial-gradient(circle closest-side, var(--surface) 72%, transparent 73%),
    conic-gradient(var(--success) var(--progress), var(--border) 0);
  color: var(--success);
}

.unified-sync-progress__body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.unified-sync-progress__body strong {
  font-size: 13px;
  color: var(--text);
}

.unified-sync-progress__body span {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.unified-sync-progress__cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.unified-sync-progress__cancel:hover:not(:disabled) {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

.unified-sync-progress__cancel:disabled {
  cursor: wait;
  opacity: 0.55;
}

.unified-sync-progress[data-status="canceled"] .unified-sync-progress__ring {
  background:
    radial-gradient(circle closest-side, var(--surface) 72%, transparent 73%),
    conic-gradient(var(--text-subtle) var(--progress), var(--border) 0);
  color: var(--text-subtle);
}

.sync-confirm-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sync-confirm-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.sync-confirm-box {
  width: min(480px, 100%);
  max-height: min(86vh, 680px);
  overflow: auto;
  padding: 28px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(0.98);
  transition: transform 0.2s ease;
}

.sync-confirm-overlay.is-active .sync-confirm-box {
  transform: translateY(0) scale(1);
}

.sync-confirm-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.sync-confirm-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  flex: 0 0 auto;
}

.sync-confirm-icon svg {
  width: 22px;
  height: 22px;
}

.sync-confirm-title {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.sync-confirm-body {
  margin-bottom: 24px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
}

.sync-confirm-body p {
  margin: 0 0 12px;
}

.sync-confirm-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.sync-confirm-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text);
  font-size: 13px;
}

.sync-confirm-item-bullet {
  color: var(--danger);
  font-weight: 800;
  line-height: 1.25;
}

.sync-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.sync-confirm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.sync-confirm-btn--cancel {
  background: var(--surface);
  color: var(--text);
}

.sync-confirm-btn--cancel:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.sync-confirm-btn--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.sync-confirm-btn--danger:hover {
  filter: brightness(1.05);
}

.sync-confirm-btn--success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.sync-confirm-btn--success:hover {
  filter: brightness(1.05);
}

.sync-confirm-icon--success {
  background: rgba(5, 150, 105, 0.12);
  color: var(--success);
}

.sync-confirm-item-bullet--success {
  color: var(--success);
  font-weight: 800;
  line-height: 1.25;
}

@media (max-width: 960px) {
  .header-site-select {
    max-width: 260px;
    margin: 0;
  }
  .unified-toolbar { flex-direction: column; align-items: flex-start; gap: 12px; }
  .unified-sync { justify-content: flex-start; }
}

@media (max-width: 640px) {
  .unified-products-head { align-items: flex-start; }
  .unified-products-head,
  .unified-pagination,
  .unified-pagination-bottom {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .unified-price-form { grid-template-columns: minmax(100px, 1fr) 36px; }
  .unified-price-form .unified-inline-status { grid-column: 1 / -1; }
  .unified-sync-progress {
    left: 12px;
    bottom: 12px;
    min-width: 198px;
  }
}

.header-site-select-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 400px;
  margin: 0 auto;
  min-width: 0;
}
.header-site-select-container .header-site-select {
  margin: 0;
  max-width: none;
}
@media (max-width: 960px) {
  .header-site-select-container {
    max-width: 300px;
    margin: 0;
  }
}
