/* Komus design tokens — mirror of @komus/shared-components theme */
:root {
  /* Colors — exact values from theme.ts via CLAUDE.md */
  --c-dark-1: #2A2D38;
  --c-dark-2: #6D778B;
  --c-dark-3: #363A47;
  --c-dark-4: #1D2028;

  --c-light-0: #FFFFFF;
  --c-light-1: #FCFCFC;
  --c-light-2: #FAFAFA;
  --c-light-3: #F2F2F2;
  --c-light-4: #E0E0E0;

  --c-grey-1: #EBEBEB;
  --c-grey-2: #D9D9D9;

  --c-blue-5: #2989FF;
  --c-blue-6: #0075FF;
  --c-blue-7: #005FCC;
  --c-blue-soft: #E5F1FF;

  --c-green-3: #27AE60;
  --c-green-soft: #E6F6EC;
  --c-red-2: #DA1F2A;
  --c-red-3: #BE1822;
  --c-red-soft: #FCEBED;
  --c-orange-3: #F95721;
  --c-orange-soft: #FDE9E0;

  --c-text: var(--c-dark-3);
  --c-text-muted: var(--c-dark-2);
  --c-border: var(--c-grey-1);
  --c-border-strong: var(--c-light-4);

  /* Focus tint (brand red) */
  --focus-ring: 0 0 0 3px rgba(218, 31, 42, 0.12);

  /* Font families */
  --ff-base: 'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ff-heading: 'Montserrat', 'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;

  /* Shadows */
  --shadow-1: 0px 0px 24px 0px rgba(0, 0, 0, 0.08);
  --shadow-2: 0px 12px 24px 0px rgba(0, 0, 0, 0.20);
  --shadow-3: 0px 3px 16px -3px rgba(0, 0, 0, 0.10);

  /* Spacing */
  --header-h: 54px;
  --content-max: 1392px;
  --content-pad: 40px;

  /* Type */
  --fs-s: 12px;
  --lh-s: 16px;
  --fs-m: 14px;
  --lh-m: 16px;
  --fs-m2: 14px;
  --lh-m2: 22px;
  --fs-l: 16px;
  --lh-l: 20px;
  --fs-xl: 20px;
  --lh-xl: 24px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--ff-base);
  font-size: var(--fs-m);
  line-height: var(--lh-m);
  color: var(--c-text);
  background: var(--c-light-0);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 {
  font-family: var(--ff-heading);
  font-weight: 700;
}
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ===== App shell ===== */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.content {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0 var(--content-pad);
}

/* ===== Header ===== */
.header {
  height: var(--header-h);
  background: var(--c-light-2);
  border-bottom: 1px solid var(--c-light-4);
  display: flex;
  align-items: center;
  padding: 0 var(--content-pad);
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header__logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}
.header__logo-img {
  height: 36px;
  width: auto;
  display: block;
}
.header__section-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  color: var(--c-dark-3);
  font-weight: 500;
  font-size: var(--fs-l);
  cursor: pointer;
  transition: background 120ms;
  white-space: nowrap;
}
.header__section-trigger:hover { background: var(--c-light-3); }
.header__section-static {
  padding: 6px 10px;
  font-weight: 500;
  font-size: var(--fs-l);
  white-space: nowrap;
}
.header__sub {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}
.header__sub-link {
  text-decoration: none;
  color: var(--c-dark-2);
  font-size: var(--fs-m);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  position: relative;
  transition: color 120ms, background 120ms;
  white-space: nowrap;
}
.header__sub-link:hover { color: var(--c-dark-3); background: var(--c-light-3); }
.header__sub-link--active {
  color: var(--c-dark-3);
  font-weight: 500;
}
.header__admin-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  padding: 6px 10px;
  text-decoration: none;
  color: var(--c-blue-5);
  font-size: var(--fs-m);
  font-weight: 400;
  border-radius: var(--r-sm);
  white-space: nowrap;
}
.header__admin-link:hover { background: var(--c-light-3); }

/* Header v2 — pill-style nav (distinct from underline tabs in content) */
.header__nav2 {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}
.header__nav2-link {
  text-decoration: none;
  color: var(--c-dark-3);
  font-size: var(--fs-m);
  font-weight: 400;
  padding: 7px 14px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 120ms, color 120ms;
}
.header__nav2-link:hover { color: var(--c-red-2); background: var(--c-red-soft); }
.header__nav2-link--active {
  color: var(--c-red-2);
  background: var(--c-red-soft);
  font-weight: 700;
}
.header__sub-link--active::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px;
  bottom: -10px;
  height: 2px;
  background: var(--c-red-2);
  border-radius: 2px;
}
.header__divider {
  width: 1px; height: 20px;
  background: var(--c-light-4);
  margin: 0 4px;
}
.header__spacer { flex: 1; }
.header__detail-info {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
  min-width: 0;
}
.header__detail-info .info-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.info-cell__label { color: var(--c-dark-2); white-space: nowrap; font-size: var(--fs-m); }
.info-cell__value {
  color: var(--c-dark-3);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  font-size: var(--fs-m);
}
.header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--c-blue-5);
  font-size: var(--fs-m);
  padding: 6px 8px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: background 120ms;
}
.back-link:hover { background: var(--c-blue-soft); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: var(--fs-m);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms, border-color 120ms, color 120ms, opacity 120ms;
  font-family: inherit;
  line-height: 1;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--primary {
  background: var(--c-red-2);
  color: #fff;
}
.btn--primary:hover:not(:disabled) { background: var(--c-red-3); }
.btn--secondary {
  background: var(--c-light-0);
  color: var(--c-dark-3);
  border-color: var(--c-light-4);
}
.btn--secondary:hover:not(:disabled) { background: var(--c-light-3); }
.btn--blue {
  background: var(--c-red-2); color: #fff;
}
.btn--blue:hover:not(:disabled) { background: var(--c-red-3); }
.btn--ghost {
  background: transparent;
  color: var(--c-dark-3);
}
.btn--ghost:hover:not(:disabled) { background: var(--c-light-3); }
.btn--ghost-blue {
  background: transparent;
  color: var(--c-blue-6);
}
.btn--ghost-blue:hover:not(:disabled) { background: var(--c-blue-soft); }
.btn--danger {
  background: transparent;
  color: var(--c-red-2);
}
.btn--danger:hover:not(:disabled) { background: var(--c-red-soft); }
.btn--sm { height: 30px; padding: 0 12px; font-size: var(--fs-m); }
.btn--xs { height: 26px; padding: 0 8px; font-size: var(--fs-s); }

.icon-btn {
  width: 32px; height: 32px;
  display: inline-grid; place-items: center;
  border-radius: var(--r-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--c-dark-2);
  transition: background 120ms, color 120ms;
}
.icon-btn:hover { background: var(--c-light-3); color: var(--c-dark-3); }
.icon-btn--danger:hover { color: var(--c-red-2); background: var(--c-red-soft); }
.icon-btn--blue { color: var(--c-blue-6); }
.icon-btn--blue:hover { background: var(--c-blue-soft); }

/* ===== Inputs ===== */
.input-shell {
  display: flex;
  align-items: center;
  height: 36px;
  background: var(--c-light-0);
  border: 1px solid var(--c-light-4);
  border-radius: var(--r-sm);
  padding: 0 10px;
  gap: 6px;
  transition: border-color 120ms, box-shadow 120ms;
}
.input-shell:focus-within {
  border-color: var(--c-red-2);
  box-shadow: var(--focus-ring);
}
.input-shell--error {
  border-color: var(--c-red-2);
}
.input-shell--disabled {
  background: var(--c-light-3);
  border-color: var(--c-light-4);
  cursor: not-allowed;
}
.input-shell--disabled input,
.input-shell--disabled input::placeholder { color: var(--c-dark-2); }
.input-shell--disabled .leading { opacity: 0.5; }
.input-shell input,
.input-shell select {
  border: none; outline: none; background: transparent;
  flex: 1; min-width: 0;
  font-size: var(--fs-m);
  color: var(--c-dark-3);
}
.input-shell input::placeholder { color: var(--c-dark-2); }
.input-shell input:disabled { cursor: not-allowed; }
.input-shell .leading { color: var(--c-dark-2); display: inline-flex; }

/* ===== Combobox (searchable select) ===== */
.combobox { cursor: text; padding-right: 8px; gap: 4px; }
.combobox input { cursor: text; }
.combobox.combobox--open {
  border-color: var(--c-red-2);
  box-shadow: var(--focus-ring);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: var(--fs-m);
  color: var(--c-dark-3);
  font-weight: 500;
}
.field__label .req { color: var(--c-red-2); margin-left: 2px; }
.field--disabled .field__label { color: var(--c-dark-2); }
.field__hint { font-size: var(--fs-s); color: var(--c-dark-2); }
.field__error { font-size: var(--fs-s); color: var(--c-red-2); }

/* ===== Select ===== */
.select-shell {
  position: relative;
}
.select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  background: var(--c-light-0);
  border: 1px solid var(--c-light-4);
  border-radius: var(--r-sm);
  padding: 0 10px;
  gap: 6px;
  font-size: var(--fs-m);
  color: var(--c-dark-3);
  cursor: pointer;
  text-align: left;
}
.select-trigger:hover { border-color: var(--c-dark-2); }
.select-trigger[data-placeholder] { color: var(--c-dark-2); }
.select-trigger[data-open] {
  border-color: var(--c-red-2);
  box-shadow: var(--focus-ring);
}
.select-trigger > span:first-child {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: left;
}
.select-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: white;
  border: 1px solid var(--c-light-4);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-3);
  z-index: 60;
  max-height: 260px;
  overflow: auto;
  padding: 4px;
}
.select-opt {
  padding: 8px 10px;
  border-radius: var(--r-xs);
  cursor: pointer;
  color: var(--c-dark-3);
  font-size: var(--fs-m);
  display: flex; align-items: center; justify-content: space-between;
}
.select-opt:hover, .select-opt[data-active] { background: var(--c-light-3); }
.select-opt[data-selected] { color: var(--c-red-2); font-weight: 500; }

/* ===== Multi-select ===== */
.ms-trigger {
  padding-right: 8px;
}
.ms-trigger__value {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.ms-trigger__first {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--c-dark-3);
  flex: 1 1 auto;
  min-width: 0;
}
.ms-trigger__plus {
  color: var(--c-dark-2);
  font-weight: 500;
  font-size: var(--fs-m);
  flex-shrink: 0;
  white-space: nowrap;
}
.ms-trigger__placeholder {
  flex: 1; min-width: 0; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--c-dark-2);
}
.ms-trigger__clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: var(--r-xs);
  color: var(--c-dark-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 120ms, color 120ms;
}
.ms-trigger__clear:hover { background: var(--c-light-3); color: var(--c-dark-3); }

.ms-pop { max-height: 320px; padding: 0; }
.ms-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--c-dark-3);
  font-size: var(--fs-m);
  transition: background 80ms;
}
.ms-opt:hover { background: var(--c-light-2); }
.ms-opt[data-selected] { background: transparent; }
.ms-opt[data-selected]:hover { background: var(--c-light-2); }
.ms-opt__label {
  flex: 1; min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Segmented control ===== */
.seg {
  display: inline-flex;
  align-self: flex-start;
  background: var(--c-light-3);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
}
.seg__btn {
  border: none;
  background: transparent;
  color: var(--c-dark-2);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: var(--fs-m);
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.seg__btn:hover { color: var(--c-dark-3); }
.seg__btn:disabled { cursor: not-allowed; opacity: 0.55; }
.seg__btn--active {
  background: var(--c-light-0);
  color: var(--c-dark-3);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* Plain variant — no gray tray, just two pills */
.seg--plain {
  background: transparent;
  border-radius: 0;
  padding: 0;
  gap: 8px;
}
.seg--plain .seg__btn {
  border: 1px solid var(--c-light-4);
  border-radius: var(--r-sm);
  background: var(--c-light-0);
  color: var(--c-dark-3);
  padding: 9px 18px;
  box-shadow: none;
  font-weight: 500;
}
.seg--plain .seg__btn:not(.seg__btn--active):hover:not(:disabled) {
  border-color: var(--c-red-2);
  color: var(--c-red-2);
  background: var(--c-light-0);
}
.seg--plain .seg__btn--active,
.seg--plain .seg__btn--active:hover {
  background: var(--c-light-3);
  border-color: transparent;
  color: var(--c-dark-3);
  box-shadow: none;
  font-weight: 600;
}

/* ===== Tabs (inline) ===== */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--c-light-4);
  gap: 24px;
}
.tab {
  background: transparent; border: none;
  padding: 10px 2px;
  font-size: var(--fs-m);
  color: var(--c-dark-3);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  font-weight: 400;
  transition: color 120ms;
}
.tab:hover { color: var(--c-red-2); }
.tab--active {
  color: var(--c-dark-3);
  font-weight: 700;
  border-bottom-color: var(--c-red-2);
}
.tabs--disabled { opacity: 0.55; }
.tabs--disabled .tab { cursor: not-allowed; }
.page__tabs { gap: 24px; }
.page__tabs .tab { white-space: nowrap; }
.tab__count {
  margin-left: 8px;
  font-size: var(--fs-s);
  font-weight: 500;
  color: var(--c-dark-2);
}

/* ===== Dropzone ===== */
.dropzone {
  border: 1px dashed var(--c-light-4);
  border-radius: var(--r-md);
  padding: 24px;
  background: var(--c-light-2);
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.dropzone:hover, .dropzone[data-active] {
  border-color: var(--c-red-2);
  background: var(--c-red-soft);
}
.dropzone--disabled,
.dropzone--disabled:hover {
  cursor: not-allowed;
  background: var(--c-light-3);
  border-color: var(--c-light-4);
  opacity: 0.7;
}
.dropzone--disabled .dropzone__main,
.dropzone--disabled .dropzone__main * { color: var(--c-dark-2) !important; }
.file-pill--disabled { opacity: 0.6; }
.dropzone__main {
  font-size: var(--fs-m);
  color: var(--c-dark-3);
}
.dropzone__sub {
  font-size: var(--fs-s);
  color: var(--c-dark-2);
  margin-top: 4px;
}
.file-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--c-light-4);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  background: var(--c-light-0);
}
.file-pill__icon {
  width: 32px; height: 32px;
  background: var(--c-red-soft);
  color: var(--c-red-2);
  border-radius: 6px;
  display: grid; place-items: center;
}
.file-pill__name { color: var(--c-dark-3); font-weight: 500; font-size: var(--fs-m); flex: 1; min-width: 0;
  white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.file-pill__size { color: var(--c-dark-2); font-size: var(--fs-s); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(45, 50, 65, 0.45);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  z-index: 100;
  padding: 24px;
  animation: fade 160ms ease;
}
.modal {
  background: white;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  width: 520px; max-width: 100%;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  animation: pop 180ms ease;
}
.modal--lg { width: 640px; }
.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 12px;
}
.modal__title { font-family: var(--ff-heading); font-size: var(--fs-xl); line-height: 24px; font-weight: 700; color: var(--c-dark-3); margin: 0; }
.modal__body { padding: 8px 24px 16px; overflow: auto; }
.modal__footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px;
  padding: 12px 24px 20px;
}
@keyframes fade { from { opacity: 0;} to { opacity: 1;} }
@keyframes pop { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ===== Menu ===== */
.menu-pop {
  position: absolute;
  background: white;
  border: 1px solid var(--c-light-4);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-3);
  z-index: 80;
  padding: 4px;
  min-width: 200px;
}
.menu-item {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: transparent; border: none;
  border-radius: var(--r-xs);
  font-size: var(--fs-m);
  color: var(--c-dark-3);
  cursor: pointer;
  text-align: left;
}
.menu-item:hover { background: var(--c-light-3); }
.menu-item--danger { color: var(--c-red-2); }
.menu-item--danger:hover { background: var(--c-red-soft); }

/* ===== Page chrome ===== */
.page {
  padding-top: 20px;
  padding-bottom: 60px;
}
.page__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
}
.page__title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; white-space: nowrap; }
.page__title {
  font-family: var(--ff-heading);
  font-size: var(--fs-xl);
  line-height: 24px;
  font-weight: 700;
  color: var(--c-dark-3);
  margin: 0;
  white-space: nowrap;
}
.page__count {
  font-size: var(--fs-xl);
  font-weight: 500;
  color: var(--c-dark-2);
}
.reset-link {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; border: none;
  color: var(--c-blue-5);
  font-size: var(--fs-m);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  margin-left: 6px;
}
.reset-link:hover { background: var(--c-blue-soft); }
.reset-link:disabled { color: var(--c-dark-2); cursor: not-allowed; background: transparent; }

.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 0 12px;
}
.filters .input-shell { width: 320px; }
.filters .select-shell, .filters .date-input { width: 200px; }

.filters--labeled {
  align-items: flex-end;
  gap: 12px;
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 200px;
  min-width: 180px;
  max-width: 260px;
}
.filter-field .input-shell,
.filter-field .select-shell,
.filter-field .date-input {
  width: 100%;
}
.filter-field__label {
  font-size: var(--fs-s);
  color: var(--c-dark-3);
  font-weight: 500;
}

.date-input {
  display: inline-flex;
  align-items: center;
  height: 36px;
  border: 1px solid var(--c-light-4);
  border-radius: var(--r-sm);
  padding: 0 10px;
  gap: 6px;
  background: var(--c-light-0);
  font-size: var(--fs-m);
  color: var(--c-dark-3);
  cursor: pointer;
}
.date-input[data-placeholder] { color: var(--c-dark-2); }
.date-input[data-open] {
  border-color: var(--c-red-2);
  box-shadow: var(--focus-ring);
}
.date-input:hover:not([data-open]) { border-color: var(--c-dark-2); }

/* Calendar */
.calendar-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: white;
  border: 1px solid var(--c-light-4);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  z-index: 80;
  padding: 16px;
  width: 320px;
}
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.calendar-title {
  font-size: var(--fs-m);
  font-weight: 500;
  color: var(--c-dark-3);
  text-transform: capitalize;
  white-space: nowrap;
  flex: 1;
  text-align: center;
}
.calendar-nav {
  width: 28px; height: 28px;
  background: transparent;
  border: none;
  border-radius: var(--r-xs);
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--c-dark-2);
}
.calendar-nav:hover { background: var(--c-light-3); color: var(--c-dark-3); }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.calendar-wd {
  height: 28px;
  display: grid; place-items: center;
  font-size: var(--fs-s);
  color: var(--c-dark-2);
  font-weight: 500;
}
.calendar-wd--weekend { color: var(--c-red-2); }
.calendar-cell {
  height: 36px;
  background: transparent;
  border: none;
  border-radius: var(--r-xs);
  font-size: var(--fs-m);
  color: var(--c-dark-3);
  cursor: pointer;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.calendar-cell[data-weekend] { color: var(--c-red-2); }
.calendar-cell[data-dim] { color: var(--c-light-4); }
.calendar-cell:hover:not([data-start]):not([data-end]) {
  background: var(--c-light-3);
}
.calendar-cell[data-range] {
  background: var(--c-red-soft);
  color: var(--c-red-3);
  border-radius: 0;
}
.calendar-cell[data-start], .calendar-cell[data-end] {
  background: var(--c-red-2);
  color: white;
  font-weight: 500;
}
.calendar-cell[data-start] { border-radius: var(--r-xs) 0 0 var(--r-xs); }
.calendar-cell[data-end] { border-radius: 0 var(--r-xs) var(--r-xs) 0; }
.calendar-cell[data-start][data-end] { border-radius: var(--r-xs); }

/* ===== Table ===== */
.table-wrap {
  border: 1px solid var(--c-grey-1);
  border-radius: var(--r-sm);
  overflow-x: auto;
  background: white;
}
.table {
  width: 100%;
  min-width: 1100px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-m);
}
.table thead th {
  background: var(--c-light-2);
  color: var(--c-dark-2);
  font-weight: 500;
  font-size: var(--fs-s);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--c-grey-1);
  white-space: nowrap;
  user-select: none;
}
.table thead th.sortable { cursor: pointer; }
.table thead th .th-content {
  display: inline-flex; align-items: center; gap: 4px;
}
.table tbody tr {
  background: white;
  transition: background 100ms;
}
.table tbody tr:hover { background: var(--c-light-2); }
.table tbody tr[data-clickable] { cursor: pointer; }
.table tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--c-grey-1);
  color: var(--c-dark-3);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table .row-actions {
  opacity: 0;
  display: flex; align-items: center; gap: 0;
  justify-content: flex-start;
  transition: opacity 120ms;
}
.table tbody tr:hover .row-actions { opacity: 1; }
/* Compact actions column — shrink to its content, icons flush left */
.table td.actions-col {
  width: 1%;
  white-space: nowrap;
  padding-left: 0;
  padding-right: 10px;
  text-align: left;
}
.table-sentinel {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 16px;
  color: var(--c-dark-2);
  font-size: var(--fs-s);
  border-top: 1px solid var(--c-grey-1);
}
.table-sentinel .spin { animation: table-spin 0.8s linear infinite; }
@keyframes table-spin { to { transform: rotate(360deg); } }
.table td.num-col { color: var(--c-dark-3); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.muted { color: var(--c-dark-2); white-space: nowrap; }
.table td.user-col {
  max-width: 220px;
  overflow: hidden;
}
.table td.user-col > span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--c-dark-2);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-state__title { font-family: var(--ff-heading); font-size: var(--fs-l); line-height: 18px; color: var(--c-dark-3); font-weight: 700; }

/* ===== Spec detail ===== */
.spec-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.spec-actions .left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.processing-card {
  border: 1px solid var(--c-light-4);
  border-radius: var(--r-md);
  background: var(--c-light-2);
  padding: 48px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center;
}
.processing-spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--c-light-4);
  border-top-color: var(--c-red-2);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-card__title { font-family: var(--ff-heading); font-size: var(--fs-l); line-height: 18px; color: var(--c-dark-3); font-weight: 700; }
.processing-card__stage { font-size: var(--fs-m); color: var(--c-dark-2); }
.processing-steps {
  display: flex; gap: 6px; margin-top: 8px;
}
.processing-steps .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-light-4);
}
.processing-steps .dot[data-done] { background: var(--c-green-3); }
.processing-steps .dot[data-active] { background: var(--c-red-2); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.5); } }

/* Spec generated table */
.spec-table-wrap {
  border: 1px solid var(--c-grey-1);
  border-radius: var(--r-sm);
  overflow: auto;
  background: white;
}
.spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-m);
}
.spec-table th {
  background: var(--c-light-2);
  font-weight: 500;
  color: var(--c-dark-3);
  font-size: var(--fs-s);
  padding: 10px 12px;
  border: 1px solid var(--c-grey-1);
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
.spec-table td {
  padding: 0;
  border: 1px solid var(--c-grey-1);
  color: var(--c-dark-3);
  vertical-align: middle;
  position: relative;
}
.spec-table .cell {
  padding: 8px 12px;
  min-height: 36px;
  width: 100%;
  cursor: text;
  display: flex; align-items: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.spec-table .cell--edited {
  background: #FFF7E6;
  box-shadow: inset 2px 0 0 #F2A93A;
}
.spec-table .cell--editing {
  padding: 0;
}
.spec-table .cell input {
  width: 100%;
  height: 100%;
  border: 1px solid var(--c-red-2);
  padding: 6px 10px;
  background: white;
  font: inherit;
  color: var(--c-dark-3);
  outline: none;
  border-radius: 2px;
}
.spec-table tr.total-row td {
  background: var(--c-light-3);
  font-weight: 600;
  color: var(--c-dark-3);
}
.spec-table tr.total-row .cell--label {
  text-align: right;
  justify-content: flex-end;
  text-transform: uppercase;
  font-size: var(--fs-s);
  letter-spacing: 0.04em;
}

/* ===== Constructor ===== */
.constructor {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  padding-bottom: 80px;
}
.constructor[data-layout="two-pane"] {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  align-items: start;
}
.constructor[data-layout="table"] {
  grid-template-columns: minmax(0, 1fr);
}
.constructor-section {
  min-width: 0;
  background: white;
  border: 1px solid var(--c-light-4);
  border-radius: var(--r-md);
  overflow: hidden;
}
.constructor-section__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-light-4);
  background: var(--c-light-2);
}
.constructor-section__title {
  font-family: var(--ff-heading);
  font-size: var(--fs-l);
  line-height: 18px;
  font-weight: 700;
  color: var(--c-dark-3);
  margin: 0;
}
.constructor-section__hint {
  font-size: var(--fs-s);
  color: var(--c-dark-2);
}
.constructor-section__body {
  padding: 16px 20px;
}

.col-card {
  border: 1px solid var(--c-light-4);
  border-radius: var(--r-sm);
  background: white;
  transition: box-shadow 120ms, border-color 120ms, transform 120ms;
  display: flex;
  flex-direction: column;
  position: relative;
}
.col-card:hover { border-color: var(--c-dark-2); }
.col-card[data-dragging] {
  opacity: 0.55;
  box-shadow: var(--shadow-2);
  transform: rotate(-1deg);
}
.col-card[data-drop-target]::before {
  content: '';
  position: absolute;
  inset: -1px;
  border: 2px dashed var(--c-red-2);
  border-radius: var(--r-sm);
  pointer-events: none;
}
.col-card__head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-light-3);
}
.col-card__grip {
  color: var(--c-dark-2);
  cursor: grab;
  display: inline-flex;
  padding: 2px;
  border-radius: 4px;
}
.col-card__grip:hover { background: var(--c-light-3); color: var(--c-dark-3); }
.col-card__grip:active { cursor: grabbing; }
.col-card__order {
  background: var(--c-light-3);
  color: var(--c-dark-2);
  border-radius: 4px;
  width: 22px;
  height: 22px;
  display: grid; place-items: center;
  font-size: var(--fs-s);
  font-weight: 500;
}
.col-card__type {
  font-weight: 500;
  color: var(--c-dark-3);
  font-size: var(--fs-m);
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-card__type-pill {
  background: var(--c-blue-soft);
  color: var(--c-blue-6);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--fs-s);
  font-weight: 500;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.col-card__body {
  padding: 12px 14px;
  display: grid; gap: 10px;
  grid-template-columns: 1fr 1fr;
}
.col-card__body .field--span2 { grid-column: span 2; }

.col-list { display: flex; flex-direction: column; gap: 12px; }
.col-list[data-layout="table"] .col-card {
  flex-direction: row;
  align-items: stretch;
}
.col-list[data-layout="table"] .col-card__head {
  border-bottom: none;
  border-right: 1px solid var(--c-light-3);
  flex-direction: column;
  width: 200px;
  align-items: flex-start;
  gap: 6px;
  flex-shrink: 0;
}
.col-list[data-layout="table"] .col-card__body {
  flex: 1;
  border-bottom: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.add-col-btn {
  background: transparent;
  border: 1px dashed var(--c-light-4);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  color: var(--c-dark-3);
  font-size: var(--fs-m);
  font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background 120ms, border-color 120ms;
}
.add-col-btn:hover { background: var(--c-light-3); border-color: var(--c-dark-2); color: var(--c-dark-3); }

/* Redesign: block section titles — smaller, closer to the list-table scale */
.constructor--redesign .constructor-section__title {
  font-size: var(--fs-m);
  line-height: 16px;
}

/* Redesign: "Добавить колонку" reuses the header sub-link look
   (same size, non-bold, subtle hover that keeps clear of the block edges) */
.constructor--redesign .add-col-btn {
  border: none;
  margin: 8px 8px 8px 8px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  color: var(--c-dark-2);
  font-size: var(--fs-m);
  font-weight: 400;
  justify-content: flex-start;
  align-self: flex-start;
  white-space: nowrap;
  transition: color 120ms, background 120ms;
}
.constructor--redesign .add-col-btn:hover {
  background: var(--c-light-3);
  border: none;
  color: var(--c-dark-3);
}

.type-picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
.type-picker__item {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: none;
  padding: 10px 12px;
  border-radius: var(--r-xs);
  color: var(--c-dark-3);
  font-size: var(--fs-m);
  text-align: left;
  cursor: pointer;
}
.type-picker__item:hover { background: var(--c-light-3); }
.type-picker__item-desc {
  display: block;
  font-size: var(--fs-s);
  color: var(--c-dark-2);
  margin-top: 2px;
}
/* type-picker as a scrollable popover (used by Add column) */
.type-picker.menu-pop { max-height: 300px; overflow-y: auto; }

/* ===== Inline-editable description (template detail) ===== */
.inline-desc {
  display: block;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  font-family: var(--ff-body);
  font-size: var(--fs-m);
  font-weight: 400;
  color: var(--c-dark-3);
  padding: 7px 10px;
  margin: 0 0 16px;
  transition: border-color 120ms, background 120ms;
}
.inline-desc::placeholder { color: var(--c-dark-2); }
.inline-desc:hover:not(:focus) { border-color: var(--c-light-4); background: white; }
.inline-desc:focus { border-color: var(--c-red-2); background: white; box-shadow: var(--focus-ring); outline: none; }

/* ===== Compact mini-field (inside column rows + section head) ===== */
.mini-field { display: flex; flex-direction: column; gap: 3px; }
.mini-field__label {
  font-size: 11px;
  font-weight: 500;
  color: var(--c-dark-2);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.size-input {
  height: 34px;
  border: 1px solid var(--c-grey-2);
  border-radius: var(--r-sm);
  background: white;
  padding: 0 8px;
  font-size: var(--fs-m);
  color: var(--c-dark-3);
  width: 100%;
  font-variant-numeric: tabular-nums;
}
.size-input:focus { border-color: var(--c-red-2); box-shadow: var(--focus-ring); outline: none; }
.size-input:disabled { background: var(--c-light-3); color: var(--c-dark-2); cursor: not-allowed; }

.table-size-field { display: flex; align-items: center; gap: 10px; flex-shrink: 0; padding-left: 16px; }
.table-size-field .mini-field__label { font-size: var(--fs-s); flex-shrink: 0; }

/* ===== Column rows (compact) — REDESIGN only ===== */
.constructor--redesign .constructor-section__body--rows { padding: 0; }
.constructor--redesign .col-list { display: flex; flex-direction: column; gap: 0; }

.col-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--c-light-3);
  position: relative;
  background: white;
}
.col-row:hover { background: var(--c-light-2); }
.col-row[data-dragging] { opacity: 0.5; }
.col-row[data-drop-target]::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: -1px;
  height: 2px;
  background: var(--c-red-2);
}
.col-row__grip {
  color: var(--c-dark-2);
  cursor: grab;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  margin-bottom: 5px;
  flex-shrink: 0;
}
.col-row__grip:active { cursor: grabbing; }
.col-row__order {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--c-light-3);
  color: var(--c-dark-2);
  font-size: var(--fs-s);
  font-weight: 600;
  display: inline-grid; place-items: center;
  margin-bottom: 5px;
}
/* Element name — larger / heavier than field labels */
.col-row__name {
  flex-shrink: 0;
  width: 168px;
  font-size: var(--fs-m);
  font-weight: 500;
  color: var(--c-dark-3);
  display: flex;
  align-items: center;
  min-height: 22px;
  line-height: 1.3;
  margin-bottom: 5px;
  white-space: normal;
  overflow-wrap: break-word;
  hyphens: none;
}
.col-row__fields {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  min-width: 0;
}
.col-row__sizes {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.col-row__del {
  flex-shrink: 0;
  opacity: 0;
  padding-bottom: 1px;
  transition: opacity 120ms;
}
.col-row:hover .col-row__del { opacity: 1; }

/* Preview */
.preview-card {
  position: sticky;
  top: calc(var(--header-h) + 16px);
}
/* Borderless preview block: just a heading + the table flush to the left,
   with horizontal scroll when the (static-width) table grows past the area. */
.constructor--redesign .preview-card {
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}
.constructor--redesign .preview-card .constructor-section__head {
  background: transparent;
  border-bottom: none;
  padding: 16px 0 12px;
}
.constructor--redesign .preview-card .constructor-section__body {
  padding: 0;
}
.preview-table-wrap {
  border: 1px solid var(--c-grey-1);
  border-radius: var(--r-xs);
  overflow: auto;
  max-height: 400px;
}
/* Preview table styled like the list tables: rounded outer border, header
   fill, horizontal row separators, no heavy gridlines. */
.constructor--redesign .preview-card .preview-table-wrap {
  border: 1px solid var(--c-grey-1);
  border-radius: var(--r-sm);
  overflow-x: auto;
  overflow-y: hidden;
  max-height: none;
  width: max-content;
  max-width: 100%;
}
.constructor--redesign .preview-card .preview-table {
  border-collapse: separate;
  border-spacing: 0;
}
.constructor--redesign .preview-card .preview-table th,
.constructor--redesign .preview-card .preview-table td {
  border: none;
  border-bottom: 1px solid var(--c-grey-1);
}
.constructor--redesign .preview-card .preview-table th {
  background: var(--c-light-2);
  color: var(--c-dark-2);
  padding: 12px 14px;
}
.constructor--redesign .preview-card .preview-table td {
  padding: 12px 14px;
}
.constructor--redesign .preview-card .preview-table tbody tr:last-child td {
  border-bottom: none;
}
.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-s);
}
.preview-table th, .preview-table td {
  border: 1px solid var(--c-grey-1);
  padding: 6px 8px;
  text-align: left;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  vertical-align: top;
}
.preview-table th {
  background: var(--c-light-3);
  color: var(--c-dark-3);
  font-weight: 500;
  font-size: 11px;
  position: relative;
}
/* Column-resize handle on header borders (excel/sheets-style) */
.col-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  width: 9px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
}
.col-resizer::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 4px;
  width: 2px;
  background: transparent;
  transition: background 120ms;
}
.col-resizer:hover::after { background: var(--c-red-2); }
body.col-resizing { cursor: col-resize; user-select: none; }
body.col-resizing .col-resizer::after { background: var(--c-red-2); }

/* «Итого» flag checkbox in the column settings row */
.size-check {
  width: 18px;
  height: 18px;
  margin: 8px 0 0;
  accent-color: var(--c-red-2);
  cursor: pointer;
}
.size-check--empty { visibility: hidden; display: inline-block; }
.preview-table tr.total td {
  background: var(--c-light-3);
  font-weight: 600;
}

.switch-row {
  display: flex; align-items: center; gap: 10px;
}
.switch {
  width: 36px; height: 20px;
  background: var(--c-light-4);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 120ms;
  border: none;
  padding: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform 160ms;
}
.switch[data-on] { background: var(--c-red-2); }
.switch[data-on]::after { transform: translateX(16px); }

.checkbox {
  width: 20px; height: 20px;
  border: 1.5px solid var(--c-light-4);
  border-radius: 4px;
  display: inline-grid; place-items: center;
  cursor: pointer;
  background: white;
  flex-shrink: 0;
  padding: 0;
  line-height: 0;
  transition: background 100ms, border-color 100ms;
}
.checkbox > * { grid-area: 1 / 1; justify-self: center; align-self: center; }
.checkbox[data-on] { background: var(--c-red-2); border-color: var(--c-red-2); color: white; }
.checkbox--red[data-on] { background: var(--c-red-2); border-color: var(--c-red-2); color: white; }
.checkbox--blue[data-on] { background: var(--c-blue-6); border-color: var(--c-blue-6); color: white; }
.checkbox:disabled { cursor: not-allowed; opacity: 0.5; }

/* Checkbox + label row */
.checkbox-row {
  display: inline-flex; align-items: center; gap: 10px;
  align-self: flex-start;
  cursor: pointer;
  user-select: none;
}
.checkbox-row__label { font-size: var(--fs-m); color: var(--c-dark-3); }
.checkbox-row--disabled { cursor: not-allowed; }
.checkbox-row--disabled .checkbox-row__label { color: var(--c-dark-2); }

/* Inline-edit name in header */
.inline-name {
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 4px 8px;
  font-size: var(--fs-m);
  font-weight: 500;
  color: var(--c-dark-3);
  font-family: inherit;
  background: transparent;
  outline: none;
  min-width: 240px;
  transition: border-color 120ms, background 120ms;
}
.inline-name:hover:not(:focus) { border-color: var(--c-light-4); background: white; }
.inline-name:focus { border-color: var(--c-red-2); background: white; box-shadow: var(--focus-ring); }

/* Click-to-edit name/description: text + pencil icon */
.editable-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.editable-inline--name .editable-inline__text {
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--c-dark-3);
  white-space: nowrap;
}
.editable-inline--desc {
  margin-bottom: 4px;
}
.editable-inline--desc .editable-inline__text {
  font-size: var(--fs-m);
  color: var(--c-dark-3);
}
.editable-inline--total {
  margin-bottom: 4px;
}
.editable-inline--total .editable-inline__text {
  font-size: var(--fs-m);
  color: var(--c-dark-3);
  font-weight: 500;
  white-space: nowrap;
}
.editable-inline__text--empty { color: var(--c-dark-2); font-weight: 400; }
.inline-desc-row { margin-bottom: 20px; }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--fs-s);
  font-weight: 500;
}
.badge--blue { background: var(--c-blue-soft); color: var(--c-blue-6); }
.badge--green { background: var(--c-green-soft); color: var(--c-green-3); }
.badge--orange { background: var(--c-orange-soft); color: var(--c-orange-3); }
.badge--grey { background: var(--c-light-3); color: var(--c-dark-2); }

/* misc text helpers */
.muted { color: var(--c-dark-2); }
.text-s { font-size: var(--fs-s); line-height: var(--lh-s); }
.text-l { font-size: var(--fs-l); line-height: var(--lh-l); }
.text-xl { font-size: var(--fs-xl); line-height: var(--lh-xl); }
.row { display: flex; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; }

/* Source doc preview modal */
.doc-preview {
  background: white;
  border: 1px solid var(--c-light-4);
  border-radius: var(--r-sm);
  padding: 32px;
  font-size: var(--fs-m);
  color: var(--c-dark-3);
  min-height: 400px;
}
.doc-preview h3 {
  font-size: 18px;
  margin: 0 0 16px;
}
.doc-preview table {
  width: 100%; border-collapse: collapse; margin-top: 12px;
  font-size: var(--fs-s);
}
.doc-preview table th, .doc-preview table td {
  border: 1px solid var(--c-grey-1);
  padding: 6px 8px;
}

/* Sortable indicator */
.sort-ind { display: inline-flex; flex-direction: column; gap: 1px; }

/* Toast */
.toast-wrap {
  position: fixed;
  top: 70px;
  right: 24px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: white;
  border-left: 4px solid var(--c-green-3);
  border-radius: var(--r-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-3);
  font-size: var(--fs-m);
  color: var(--c-dark-3);
  min-width: 280px;
  animation: slide 220ms ease;
}
.toast--info { border-left-color: var(--c-blue-6); }
.toast--error { border-left-color: var(--c-red-2); }

/* ===== Global instant tooltip ===== */
.app-tooltip {
  position: fixed;
  z-index: 9999;
  max-width: 360px;
  padding: 14px 18px;
  background: #fff;
  color: var(--c-dark-3);
  font-size: var(--fs-m);
  line-height: 1.5;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16), 0 1px 3px rgba(0, 0, 0, 0.08);
  pointer-events: none;
  white-space: normal;
  overflow-wrap: break-word;
  opacity: 0;
  visibility: hidden;
}
.app-tooltip[data-show] {
  opacity: 1;
  visibility: visible;
}

/* ===== Tweaks launcher (bottom-right corner) ===== */
.tweaks-fab {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 2147483645;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--c-grey-1);
  border-radius: 8px;
  background: #fff;
  color: var(--c-dark-2);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: background 120ms, color 120ms;
}
.tweaks-fab:hover { background: var(--c-light-2); color: var(--c-dark-4); }
@keyframes slide { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Confirm */
.confirm-text { font-size: var(--fs-m); color: var(--c-dark-3); line-height: 1.5; }

/* =================================================================
   Admin — Prompt management (Settings Navigation)
   ================================================================= */
.ap-tabs { margin-bottom: 28px; flex-wrap: wrap; }
.ap-tabs .tab { white-space: nowrap; }
.ap-list { display: flex; flex-direction: column; }
.ap-card {
  display: flex; flex-direction: column; gap: 14px;
  padding: 24px 0 28px;
  border-bottom: 1px solid var(--c-grey-1);
}
.ap-card:first-child { padding-top: 4px; }
.ap-card__row { display: flex; align-items: center; gap: 10px; }
.ap-card__textarea {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  border: 1px solid var(--c-grey-1);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  font-family: var(--ff-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: var(--fs-m);
  line-height: 1.55;
  color: var(--c-dark-3);
  background: var(--c-light-0);
  outline: none;
}
.ap-card__textarea:focus { border-color: var(--c-blue-6); }
.ap-foot { padding-top: 22px; }

/* =================================================================
   Spec detail — alternative version (preview panel + template select)
   ================================================================= */

/* Превью toggle in the actions row */
.specx-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-m); font-weight: 500; color: var(--c-dark-3);
  cursor: pointer; user-select: none;
}

/* Template select on the right of the actions row */
.specx-tpl { display: inline-flex; align-items: center; gap: 10px; }
.specx-tpl__label { font-size: var(--fs-m); color: var(--c-dark-2); white-space: nowrap; }

/* When the preview is open, use the full viewport width so the document
   and the table can sit side by side (and scroll horizontally if needed). */
.content.page--preview { max-width: none; padding-bottom: 12px; }

/* The two-column row. Closed: table fills width and scrolls inside its own
   wrap (original behavior). Open: a single horizontal scroller holds the
   document panel + the table at natural width. */
.specx-layout { display: flex; gap: 20px; align-items: stretch; }
.specx-layout--open {
  overflow-x: auto;
  padding-bottom: 10px;
  align-items: flex-start;
}
.specx-table-col { flex: 1 1 auto; min-width: 0; }
.specx-layout--open .specx-table-col {
  flex: 0 0 auto;
  width: max-content;
}
.specx-layout--open .spec-table-wrap { overflow: visible; }

/* Open: the document panel stays pinned to the left while the table scrolls
   horizontally underneath it. */
.specx-layout--open .specx-doc {
  position: sticky;
  left: 0;
  z-index: 5;
}
.specx-layout--open .specx-doc__inner {
  box-shadow: 8px 0 18px -8px rgba(0, 0, 0, 0.18);
}

/* ---- Sliding document viewer panel (width driven inline by React) ---- */
.specx-doc {
  flex: 0 0 auto;
  overflow: hidden;
}
@media (prefers-reduced-motion: no-preference) {
  .specx-doc { transition: width 380ms cubic-bezier(0.4, 0, 0.2, 1); }
}
.specx-doc__inner {
  width: 744px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 150px);
  min-height: 460px;
  border: 1px solid var(--c-grey-1);
  border-radius: var(--r-sm);
  background: var(--c-light-3);
  overflow: hidden;
}

.specx-doc__toolbar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px;
  background: var(--c-light-0);
  border-bottom: 1px solid var(--c-grey-1);
}
.specx-doc__zoom { display: flex; align-items: center; gap: 2px; }
.specx-doc__pct {
  font-size: var(--fs-m); color: var(--c-dark-3);
  font-variant-numeric: tabular-nums; margin-right: 6px; min-width: 42px; text-align: right;
}

.specx-doc__scroll { flex: 1 1 auto; overflow: auto; }
.specx-doc__stage {
  display: flex; justify-content: center;
  padding: 24px 20px 32px;
  min-width: max-content;
}

/* The "paper" document — scaled/rotated by the toolbar */
.docpaper {
  width: 640px;
  flex: 0 0 auto;
  background: #fff;
  box-shadow: 0 6px 24px rgba(0,0,0,0.12);
  padding: 40px 44px;
  transform-origin: top center;
  transition: transform 160ms ease;
  color: var(--c-dark-4);
}
.docpaper__head { text-align: center; margin-bottom: 22px; }
.docpaper__title { font-family: var(--ff-heading); font-size: 18px; font-weight: 700; letter-spacing: 0.02em; }
.docpaper__sub { font-size: 12px; color: var(--c-dark-2); margin-top: 6px; }
.docpaper__meta { font-size: 12px; line-height: 1.7; margin-bottom: 16px; }
.docpaper__meta span { color: var(--c-dark-2); display: inline-block; min-width: 130px; }
.docpaper__table { width: 100%; border-collapse: collapse; font-size: 11px; }
.docpaper__table th, .docpaper__table td {
  border: 1px solid var(--c-grey-2); padding: 5px 7px; text-align: left; vertical-align: top;
}
.docpaper__table th { background: var(--c-light-3); font-weight: 600; font-size: 10px; }
.docpaper__table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.docpaper__total td { font-weight: 700; background: var(--c-light-2); }
.docpaper__words { font-size: 11px; font-style: italic; color: var(--c-dark-3); margin-top: 14px; line-height: 1.6; }
.docpaper__signs { display: flex; gap: 40px; margin-top: 36px; }
.docpaper__signs div { flex: 1; }
.docpaper__signs span { font-size: 11px; color: var(--c-dark-2); }
.docpaper__signs i { display: block; border-bottom: 1px solid var(--c-dark-2); margin-top: 28px; }

.specx-doc__footer {
  flex: 0 0 auto;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 10px 12px;
  background: var(--c-light-0);
  border-top: 1px solid var(--c-grey-1);
}
.specx-doc__filefield { display: flex; flex-direction: column; gap: 4px; }
.specx-doc__filelabel { font-size: var(--fs-s); color: var(--c-dark-2); }
.specx-doc__filebtns { display: flex; align-items: center; gap: 2px; }
