/* =========================================================
   IvStOr Project v2.5 — theme.css
   + v3: голосовой экран, тикер подсказок, черновик ТЗ
   ========================================================= */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { overscroll-behavior-y: contain; height: 100%; overflow: hidden; }
body { margin: 0; font-family: -apple-system, system-ui, sans-serif; background: #f2f2f2; color: #2a2a2a; font-size: 16px; display: flex; flex-direction: column; }

/* ================= ИКОНКА IO + ТОЧКА ================= */
.io-icon {
  display: inline-flex; align-items: center; gap: 5px;
  height: 38px; padding: 0 12px; border-radius: 10px;
  background: #ffffff; border: 1px solid #e5e0d5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800; font-size: 18px; letter-spacing: -1px;
  color: #2a2a2a; cursor: pointer; user-select: none; flex-shrink: 0;
  transition: border-color .25s, background .25s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.io-icon:active { background: #f7f5f0; }
.io-icon .io-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #21a038; box-shadow: 0 0 6px rgba(33,160,56,0.55);
  transition: background .25s, box-shadow .25s;
}
.io-icon.status-idle  .io-dot { background: #21a038; box-shadow: 0 0 6px rgba(33,160,56,0.7); }
.io-icon.status-busy  .io-dot { background: #e8b84b; box-shadow: 0 0 8px rgba(232,184,75,0.9); animation: pulse 0.9s infinite; }
.io-icon.status-error .io-dot { background: #ff3b3b; box-shadow: 0 0 8px rgba(255,59,59,0.9); }
.io-icon.status-nav   .io-dot { background: #4a9eff; box-shadow: 0 0 8px rgba(74,158,255,0.9); }
.io-icon.status-off   .io-dot { background: #a8a194; box-shadow: none; }
.io-icon.status-save  .io-dot { background: #b788e8; box-shadow: 0 0 8px rgba(183,136,232,0.9); }
.io-icon-large { height: 72px; padding: 0 18px; border-radius: 18px; font-size: 36px; letter-spacing: -2px; gap: 8px; }
.io-icon-large .io-dot { width: 12px; height: 12px; }

/* ================= ПРИВЕТСТВИЕ ================= */
#welcomeScreen {
  position: fixed; inset: 0; z-index: 5000;
  background: linear-gradient(160deg, #f7f5f0 0%, #eef2e6 50%, #f7f5f0 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  transition: opacity .45s ease, visibility .45s ease;
  overflow: hidden;
}
#welcomeScreen.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.bg-scene { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.bg-scene > span { position: absolute; opacity: 0.13; filter: grayscale(0.2); animation: drift linear infinite; will-change: transform; }
@keyframes drift { from { transform: translateX(-20vw); } to { transform: translateX(120vw); } }
.welcome-content { position: relative; z-index: 2; max-width: 420px; width: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; animation: welcomeIn .8s ease both; }
@keyframes welcomeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.welcome-logo { margin-bottom: 22px; }
.welcome-title { font-size: 28px; font-weight: 800; margin: 0 0 14px;
  background: linear-gradient(135deg, #4a6b1e 0%, #8fc44a 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent; letter-spacing: -0.5px; }
.welcome-sub { font-size: 15px; color: #555; line-height: 1.5; margin: 0 0 8px; }
.welcome-sub2 { font-size: 13.5px; color: #777; line-height: 1.5; margin: 0 0 22px; }
.welcome-btn { width: 100%; padding: 16px 20px; font-size: 16px; font-weight: 700; border-radius: 12px; border: none;
  background: linear-gradient(135deg, #4a6b1e 0%, #8fc44a 100%);
  color: #fff; cursor: pointer; font-family: inherit;
  box-shadow: 0 8px 20px rgba(143,196,74,0.35); margin-bottom: 10px; touch-action: manipulation; }
.welcome-btn:active { transform: translateY(1px); }
.welcome-btn-2 { background: #e8f0fb; color: #2b6bd8; border: 1px solid #b8d0f0; box-shadow: none; }
.welcome-btn-3 { background: #eef5e3; color: #4a6b1e; border: 1px solid #c8e0a8; box-shadow: none; }
.welcome-auth { display: flex; gap: 10px; width: 100%; margin-top: 12px; }
.welcome-auth button { flex: 1; padding: 12px 14px; font-size: 14px; font-weight: 600; border-radius: 10px; border: 1px solid #e5e0d5; background: #ffffff; color: #555; cursor: pointer; font-family: inherit; }
.welcome-auth button:active { background: #f7f5f0; }

/* ================= ОСНОВНОЙ КАРКАС ================= */
.wrap { max-width: 620px; width: 100%; margin: 0 auto; padding: 12px 16px 0; display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
header.app { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; flex-shrink: 0; background: #f2f2f2; }
.header-mini { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 700; letter-spacing: -0.2px; color: #4a6b1e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-mini small { display: block; font-size: 10.5px; color: #777; font-weight: 500; letter-spacing: 0.2px; margin-top: 1px; }
.home-btn { width: 38px; height: 38px; min-width: 0; flex-shrink: 0; border-radius: 10px; background: #ffffff; border: 1px solid #e5e0d5; color: #4a6b1e; font-size: 17px; padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; font-family: inherit; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.home-btn:active { background: #eef5e3; border-color: #c8e0a8; }

/* ================= ТАБЫ ================= */
.screen-tabs { display: flex; gap: 4px; margin-bottom: 10px; flex-shrink: 0; background: #ffffff; border: 1px solid #e5e0d5; border-radius: 10px; padding: 4px; }
.screen-tabs .tab { flex: 1; padding: 8px 6px; border-radius: 7px; text-align: center; font-size: 11px; font-weight: 700; color: #777; cursor: pointer; user-select: none; letter-spacing: 0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .2s, color .2s; }
.screen-tabs .tab.active { background: linear-gradient(135deg, #4a6b1e 0%, #8fc44a 100%); color: #fff; }
.screen-tabs .tab:active { opacity: 0.85; }

/* ================= ВЬЮПОРТ ЭКРАНОВ ================= */
.screens-viewport { position: relative; overflow: hidden; flex: 1; min-height: 0; touch-action: pan-y; }
.screens-track { display: flex; height: 100%; transition: transform .3s cubic-bezier(0.22, 1, 0.36, 1); will-change: transform; }
.screen { flex: 0 0 100%; width: 100%; height: 100%; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 0 0 90px; overscroll-behavior: contain; }

/* ================= БАЗОВЫЕ ЭЛЕМЕНТЫ ================= */
.sub { font-size: 13px; color: #777; margin-top: 6px; }
.bar { height: 4px; background: #e5e0d5; border-radius: 4px; margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #4a6b1e, #8fc44a); transition: width .3s; }
.card { background: #ffffff; border: 1px solid #e5e0d5; border-radius: 14px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03); }
.q { font-size: 17px; font-weight: 600; margin-bottom: 8px; line-height: 1.35; color: #2a2a2a; }
.hint { font-size: 13px; color: #777; margin-bottom: 14px; line-height: 1.4; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.choice { padding: 10px 14px; border-radius: 10px; background: #ffffff; border: 1px solid #e5e0d5; color: #2a2a2a; font-size: 14px; cursor: pointer; user-select: none; }
.choice.active { background: #4a9eff; border-color: #4a9eff; color: #fff; }
textarea { width: 100%; background: #ffffff; color: #2a2a2a; border: 1px solid #e5e0d5; border-radius: 12px; padding: 14px; font-size: 16px; font-family: inherit; line-height: 1.45; resize: vertical; min-height: 200px; -webkit-appearance: none; }
textarea:focus { outline: none; border-color: #4a9eff; }
textarea.extra { min-height: 90px; margin-top: 8px; font-size: 16px; }
input[type=text], input[type=number] { width: 100%; background: #ffffff; color: #2a2a2a; border: 1px solid #e5e0d5; border-radius: 10px; padding: 12px 40px 12px 12px; font-size: 16px; font-family: inherit; -webkit-appearance: none; min-width: 0; }
input:focus { outline: none; border-color: #4a9eff; }
.rec-live { display: none; align-items: center; gap: 8px; background: #fdecea; border: 1px solid #f5c6c0; color: #a03030; padding: 8px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 10px; }
.rec-live.on { display: flex; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ff3b3b; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
button { padding: 14px 16px; border-radius: 10px; border: none; font-size: 15px; font-weight: 600; cursor: pointer; font-family: inherit; transition: background .2s, color .2s; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
.row button { flex: 1; min-width: 110px; }
.btn-primary { background: linear-gradient(135deg, #4a6b1e 0%, #8fc44a 100%); color: #fff; box-shadow: 0 2px 6px rgba(143,196,74,0.3); }
.btn-primary:disabled { opacity: 0.55; }
.btn-ghost { background: #ffffff; color: #2a2a2a; border: 1px solid #e5e0d5; }
.btn-voice { background: #b94a4a; color: #fff; }
.btn-voice.rec { background: #ff3b3b; animation: pulse 1.2s infinite; }
.btn-green { background: #2d6b4a; color: #fff; }
.btn-red { background: #7a2a2a; color: #fff; }
.btn-save { background: #e8f0fb; color: #2b6bd8; border: 1px solid #b8d0f0; }
.btn-extra { background: #fff8e0; color: #8a6300; border: 1px solid #e8c84b; }
.btn-send { background: linear-gradient(135deg, #4a6b1e 0%, #8fc44a 100%); color: #fff; box-shadow: 0 2px 6px rgba(143,196,74,0.3); }
.btn-send.working { background: #e8b84b; color: #1a1f2b; animation: sendPulse 1.1s ease-in-out infinite; font-weight: 800; }
.btn-send.done { background: #21a038; color: #fff; }
.btn-send.fail { background: #b94a4a; color: #fff; }
@keyframes sendPulse { 0%,100% { background: #e8b84b; box-shadow: 0 0 0 0 rgba(232,184,75,0.7); } 50% { background: #f5c95e; box-shadow: 0 0 0 10px rgba(232,184,75,0); } }
.btn-stop-red { background: #b93a3a; color: #fff; font-weight: 800; width: 100%; padding: 12px; }
.btn-stop-red:active { background: #d04040; }
.hold-hint { font-size: 11.5px; color: #777; text-align: center; margin-top: 8px; line-height: 1.4; }
.hold-hint b { color: #4a6b1e; }
.hold-hint.stop-mode b { color: #b93a3a; }
.status { font-size: 12px; color: #777; margin-top: 8px; min-height: 16px; }
.preview { background: #f7f5f0; border: 1px solid #e5e0d5; border-radius: 10px; padding: 12px; font-family: ui-monospace, monospace; font-size: 12px; color: #555; white-space: pre-wrap; word-break: break-word; max-height: 340px; overflow-y: auto; }
.answer { background: #eef7f0; border: 1px solid #c8e0d0; border-radius: 10px; padding: 12px; margin-top: 12px; font-size: 13px; white-space: pre-wrap; color: #2d6b4a; max-height: 400px; overflow-y: auto; }
.err { background: #fdecea; border-color: #f5c6c0; color: #a03030; }
.chk { display: flex; flex-wrap: wrap; gap: 8px; }
.chk .choice { font-size: 13px; padding: 8px 12px; }
.chk .choice.on { background: #2d6b4a; border-color: #2d6b4a; color: #fff; }
.grad { background: linear-gradient(135deg, #4a6b1e 0%, #8fc44a 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; font-weight: 700; display: inline-block; }

/* ================= ШАБЛОНЫ ================= */
.tpl-card { background: #ffffff; border: 1px solid #c8e0a8; box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 16px rgba(143,196,74,0.12); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.tpl-head { display: flex; align-items: center; justify-content: space-between; font-size: 14px; font-weight: 700; color: #4a6b1e; margin-bottom: 4px; }
.tpl-count { background: #4a6b1e; color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.tpl-hint { font-size: 12px; color: #6a8a3a; margin-bottom: 10px; line-height: 1.4; }
.tpl-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.tpl-chip { position: relative; background: #ffffff; border: 1px solid #e5e0d5; border-radius: 10px; padding: 10px 42px 10px 12px; cursor: pointer; user-select: none; }
.tpl-chip:active { background: #eef5e3; border-color: #c8e0a8; }
.tpl-name { font-size: 14px; font-weight: 600; color: #2a2a2a; word-break: break-word; }
.tpl-date { font-size: 11px; color: #999; margin-top: 2px; }
.tpl-del { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; min-width: 0; flex: none; border-radius: 50%; background: #f2f2f2; color: #777; font-size: 14px; font-weight: 700; padding: 0; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; line-height: 1; }
.tpl-del:active { background: #b93a3a; color: #fff; }

.tpl-chip-bar {
  display: flex; align-items: center; gap: 8px;
  background: #ffffff; border: 1px solid #c8e0a8;
  border-radius: 10px; padding: 10px 12px;
  cursor: pointer; user-select: none;
  font-size: 13.5px; font-weight: 700; color: #4a6b1e;
  transition: background .2s, border-color .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.tpl-chip-bar:active { background: #eef5e3; }
.tpl-chip-bar .tpl-chip-count { background: #4a6b1e; color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.tpl-chip-bar .tpl-chip-arrow { margin-left: auto; color: #999; transition: transform .25s; font-size: 14px; line-height: 1; }
.tpl-chip-bar.open .tpl-chip-arrow { transform: rotate(180deg); }
.tpl-accordion { max-height: 0; overflow: hidden; transition: max-height .32s ease; }
.tpl-accordion.open { max-height: 500px; }
.tpl-accordion .tpl-list { margin-top: 8px; max-height: 380px; overflow-y: auto; }

/* ================= Шаг 5f-UI-fix: ЭКРАН КАТЕГОРИЙ ================= */
.work-screen {
  position: fixed; inset: 0; z-index: 6000;
  background: linear-gradient(160deg, #f7f5f0 0%, #eef2e6 50%, #f7f5f0 100%);
  display: none; align-items: flex-start; justify-content: center;
  padding: 24px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.work-screen.show { display: flex; }
.work-content {
  width: 100%; max-width: 420px;
  animation: welcomeIn .5s ease both;
  padding-bottom: 40px;
}
.work-check {
  display: flex; align-items: flex-start; gap: 12px;
  background: #fff; border: 1px solid #e5e0d5; border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  transition: background .2s, border-color .2s, box-shadow .2s;
  user-select: none; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.work-check:active { background: #f7f5f0; }
.work-check.checked {
  background: #eef5e3; border-color: #4a6b1e;
  box-shadow: 0 0 0 1px #4a6b1e inset;
}
.work-check .box {
  width: 22px; height: 22px; min-width: 22px; flex: none;
  border-radius: 6px; border: 2px solid #ccc; background: #fff;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px; transition: all .15s;
}
.work-check.checked .box { background: #4a6b1e; border-color: #4a6b1e; }
.work-check.checked .box::after { content: "✓"; color: #fff; font-size: 14px; font-weight: 800; line-height: 1; }
.work-check .txt { flex: 1; min-width: 0; }
.work-check .txt b { display: block; font-size: 15px; font-weight: 700; color: #2a2a2a; }
.work-check .txt small { display: block; font-size: 12px; color: #777; margin-top: 2px; line-height: 1.35; }
.work-check.checked .txt b { color: #4a6b1e; }
.work-extra { margin-top: 16px; margin-bottom: 4px; }
.work-extra label {
  display: block; font-size: 11.5px; color: #777;
  text-transform: uppercase; letter-spacing: 0.3px;
  font-weight: 600; margin-bottom: 6px;
}
.work-extra textarea { min-height: 80px; font-size: 16px; }
.work-actions { margin-top: 18px; }
.work-actions .btn-primary { width: 100%; padding: 16px; font-size: 15.5px; }
.work-actions .btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.card.suggested-step {
  border-color: #f0d88a;
  background: linear-gradient(180deg, #fffce8 0%, #ffffff 100%);
}
.ai-sugg-badge {
  display: inline-block; background: #fff3d6; color: #a06a00;
  padding: 2px 8px; border-radius: 6px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.3px; margin-bottom: 8px;
}
.start-menu-overlay, .role-screen, .object-screen, .q-loader {
  position: fixed; inset: 0; z-index: 6000;
  background: linear-gradient(160deg, #f7f5f0 0%, #eef2e6 50%, #f7f5f0 100%);
  display: none; align-items: center; justify-content: center;
  padding: 24px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.start-menu-overlay.show, .role-screen.show, .object-screen.show, .q-loader.show { display: flex; }

.start-menu-content, .role-content, .object-content {
  width: 100%; max-width: 420px;
  animation: welcomeIn .5s ease both;
}
.start-menu-title { font-size: 22px; font-weight: 800; margin: 0 0 6px; color: #2a2a2a; text-align: center; letter-spacing: -0.3px; }
.start-menu-sub { font-size: 13.5px; color: #777; margin: 0 0 22px; text-align: center; line-height: 1.45; }

.start-menu-btn {
  width: 100%; padding: 16px 18px; font-size: 15.5px; font-weight: 700;
  border-radius: 12px; border: 1px solid #e5e0d5; background: #fff;
  color: #2a2a2a; cursor: pointer; font-family: inherit;
  text-align: left; margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: background .2s, border-color .2s, transform .12s;
  touch-action: manipulation;
}
.start-menu-btn:active { background: #f7f5f0; }
.start-menu-btn.primary {
  background: linear-gradient(135deg, #4a6b1e 0%, #8fc44a 100%);
  border: none; color: #fff;
  box-shadow: 0 6px 16px rgba(143,196,74,0.3);
}
.start-menu-btn.primary:active { transform: translateY(1px); }
.start-menu-btn .ico { font-size: 22px; flex-shrink: 0; line-height: 1; }
.start-menu-btn .txt { flex: 1; min-width: 0; }
.start-menu-btn .txt small { display: block; font-size: 12px; opacity: 0.7; font-weight: 500; margin-top: 2px; line-height: 1.35; }

.back-link { display: inline-block; font-size: 13px; color: #777; margin-bottom: 16px; cursor: pointer; padding: 6px 0; user-select: none; }
.back-link:active { color: #4a6b1e; }

.role-card, .object-card {
  width: 100%; padding: 18px 16px; font-size: 16px; font-weight: 700;
  border-radius: 14px; border: 1px solid #e5e0d5; background: #fff;
  color: #2a2a2a; cursor: pointer; font-family: inherit;
  text-align: left; margin-bottom: 12px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: background .2s, border-color .2s, transform .12s;
  touch-action: manipulation;
}
.role-card:active, .object-card:active {
  background: #eef5e3; border-color: #c8e0a8;
  transform: scale(0.99);
}
.role-card .emoji, .object-card .emoji { font-size: 30px; flex-shrink: 0; line-height: 1; }
.role-card .txt, .object-card .txt { flex: 1; min-width: 0; }
.role-card .txt small, .object-card .txt small {
  display: block; font-size: 12.5px; color: #777; font-weight: 500;
  margin-top: 3px; line-height: 1.35;
}

.q-loader .loader-card {
  width: 100%; max-width: 420px;
  background: #fff; border: 1px solid #e5e0d5;
  border-radius: 16px; padding: 26px 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
  text-align: center;
  animation: welcomeIn .4s ease both;
}
.q-loader .loader-spin {
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid #e5e0d5; border-top-color: #4a6b1e;
  animation: spin 0.9s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.q-loader .loader-title { font-size: 17px; font-weight: 700; color: #2a2a2a; margin: 0 0 8px; }
.q-loader .loader-sub { font-size: 13px; color: #777; line-height: 1.5; margin: 0 0 14px; }
.q-loader .loader-status { font-size: 12.5px; color: #999; font-family: ui-monospace, monospace; min-height: 16px; }
.q-loader .loader-err { background: #fdecea; border: 1px solid #f5c6c0; color: #a03030; padding: 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; text-align: left; line-height: 1.45; }

/* ================= КАРТОЧКИ ================= */
.cat-block { background: #ffffff; border: 1px solid #e5e0d5; border-radius: 14px; margin-bottom: 12px; overflow: hidden; position: relative; max-width: 100%; box-shadow: 0 1px 3px rgba(0,0,0,0.05); transition: background .2s, border-color .2s, box-shadow .2s; }
.cat-block.c1 { --cat-bg: #eef5e3; --cat-accent: #4a6b1e; --cat-border: #c8e0a8; }
.cat-block.c2 { --cat-bg: #e8f0fb; --cat-accent: #2b6bd8; --cat-border: #b8d0f0; }
.cat-block.c3 { --cat-bg: #fdf0e8; --cat-accent: #b85a20; --cat-border: #f0c8a8; }
.cat-block.c4 { --cat-bg: #f0e8f8; --cat-accent: #7a3fb8; --cat-border: #d0b8f0; }
.cat-block.c5 { --cat-bg: #e8f5f5; --cat-accent: #2a8a8a; --cat-border: #a8dcdc; }
.cat-block.c6 { --cat-bg: #f8e8f0; --cat-accent: #b84070; --cat-border: #f0b8d0; }
.cat-block.edited { background: #fffce8; border-color: #e8b84b; box-shadow: 0 0 0 2px rgba(232,184,75,0.35); }
.cat-block.edited .cat-head { background: #fff5cc; }
.cat-block.edited .cat-title { color: #8a6300; }
.cat-head { display: flex; align-items: center; gap: 10px; padding: 13px 14px; background: var(--cat-bg, #f7f5f0); cursor: pointer; user-select: none; transition: background .2s; }
.cat-title { font-size: 15px; font-weight: 700; flex: 1; min-width: 0; letter-spacing: 0.2px; color: var(--cat-accent, #2a2a2a); word-break: break-word; }
.cat-count { font-size: 11px; padding: 3px 8px; background: #ffffff; color: var(--cat-accent, #555); border-radius: 10px; font-weight: 700; flex-shrink: 0; border: 1px solid #e5e0d5; }
.cat-total { font-size: 13px; color: var(--cat-accent, #4a9eff); font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.cat-arrow { color: #999; transition: transform .2s; font-size: 14px; flex-shrink: 0; }
.cat-block.open .cat-arrow { transform: rotate(180deg); }
.cat-body { display: none; padding: 10px 10px 12px; min-width: 0; overflow-x: hidden; }
.cat-block.open .cat-body { display: block; }
.sub-block { background: #faf8f3; border: 1px solid #e5e0d5; border-radius: 10px; margin-bottom: 10px; overflow: hidden; position: relative; max-width: 100%; border-left: 3px solid var(--cat-accent, #e5e0d5); transition: background .2s, border-color .2s, box-shadow .2s; }
.sub-block.edited { background: #fffce8; border-color: #e8b84b; box-shadow: 0 0 0 2px rgba(232,184,75,0.3); }
.sub-block.edited .sub-head { background: #fff5cc; }
.sub-block.edited .sub-title { color: #8a6300; }
.sub-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #f7f5f0; cursor: pointer; user-select: none; transition: background .2s; }
.sub-title { font-size: 13.5px; font-weight: 700; flex: 1; min-width: 0; color: #2a2a2a; word-break: break-word; }
.sub-count { font-size: 10.5px; padding: 2px 7px; background: #ffffff; color: var(--cat-accent, #555); border-radius: 8px; font-weight: 700; flex-shrink: 0; border: 1px solid #e5e0d5; }
.sub-total { font-size: 12px; color: var(--cat-accent, #4a9eff); font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.sub-arrow { color: #999; transition: transform .2s; font-size: 13px; flex-shrink: 0; }
.sub-block.open .sub-arrow { transform: rotate(180deg); }
.sub-body { display: none; padding: 8px; min-width: 0; overflow-x: hidden; }
.sub-block.open .sub-body { display: block; }
.level-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.level-actions button { flex: none; min-width: 0; font-size: 12px; padding: 7px 10px; border-radius: 8px; }
.btn-mini { background: #ffffff; color: #2a2a2a; border: 1px solid #e5e0d5; }
.btn-mini-add { background: #e8f0fb; color: #2b6bd8; border: 1px solid #b8d0f0; }
.swipe-wrap { position: relative; overflow: hidden; border-radius: 12px; margin-bottom: 8px; max-width: 100%; }
.swipe-actions { position: absolute; top: 0; right: 0; bottom: 0; display: flex; align-items: stretch; }
.swipe-del { width: 90px; background: #b93a3a; color: #fff; font-size: 13px; font-weight: 700; border: none; border-radius: 0; min-width: 0; padding: 0; flex: none; }
.swipe-del:active { background: #d04040; }
.swipe-content { position: relative; z-index: 1; transition: transform 0.2s ease; touch-action: pan-y; min-width: 0; background: #ffffff; }
.swipe-content.open { transform: translateX(-90px); }
.swipe-wrap.cat-swipe .swipe-content { border-radius: 14px 14px 0 0; }
.works-list { min-width: 0; }
.work { background: #ffffff; border: 1px solid #e5e0d5; border-radius: 12px; padding: 10px; margin-bottom: 0; position: relative; min-width: 0; max-width: 100%; transition: background .2s, border-color .2s, box-shadow .2s; }
.work.open { border-color: #b8d0f0; }
.work.edited { background: #fffce8; border-color: #e8b84b; box-shadow: 0 0 0 2px rgba(232,184,75,0.3); }
.work.edited .work-title { color: #8a6300; }
.work-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; min-width: 0; }
.cat { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase; background: #e2ecff; color: #2b6bd8; flex-shrink: 0; }
.cat.final { background: #d6f0ff; color: #006b8a; }
.cat.install { background: #e2ecff; color: #2b6bd8; }
.cat.rough { background: #e8e0ff; color: #5a3a8a; }
.cat.remove { background: #ffe0e0; color: #a03030; }
.cat.prep { background: #e8f0e8; color: #3a5a3a; }
.work-title { font-size: 14.5px; font-weight: 600; line-height: 1.35; flex: 1; min-width: 0; cursor: pointer; transition: color .2s; word-break: break-word; color: #2a2a2a; }
.work-sub { font-size: 12.5px; color: #777; margin-top: 4px; }
.work-arrow { font-size: 15px; color: #999; transition: transform .2s; user-select: none; padding: 4px 6px; cursor: pointer; flex-shrink: 0; }
.work.open .work-arrow { transform: rotate(180deg); }
.clar-badge { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: #e8b84b; color: #2a2a2a; font-size: 11px; font-weight: 800; flex-shrink: 0; }
.new-tag { background: #ff8c1a; color: #fff; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 800; letter-spacing: 0.3px; flex-shrink: 0; }
.clar-inline { background: #fffce8; border-left: 3px solid #e8b84b; padding: 8px 10px; border-radius: 6px; font-size: 12.5px; color: #6b5000; margin-top: 8px; line-height: 1.45; }
.clar-inline b { color: #8a6300; }
.work-body { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px solid #eee8d8; min-width: 0; overflow-x: hidden; }
.work.open .work-body { display: block; }
.ai-tag { background: #fff3d6; color: #a06a00; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.field { margin-bottom: 10px; min-width: 0; }
.field label { display: block; font-size: 11px; color: #777; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.3px; font-weight: 600; }
.inp-wrap { position: relative; min-width: 0; }
.inp-wrap.no-clear input[type=number], .inp-wrap.no-clear input[type=text] { padding-right: 12px; }
.clear-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%; border: none; background: #f2f2f2; color: #777; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; min-width: 0; flex: none; }
.clear-btn:active { background: #e5e0d5; color: #2a2a2a; }
.row-total { display: flex; justify-content: space-between; align-items: center; background: #f7f5f0; border: 1px solid #e5e0d5; border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-top: 4px; gap: 10px; flex-wrap: wrap; color: #2a2a2a; }
.row-total b { color: #4a6b1e; font-size: 16px; }
.notes-line { font-size: 11.5px; color: #999; margin-top: 8px; line-height: 1.5; }
.warn-line { font-size: 12px; color: #b87a20; margin-top: 6px; }
.total-bar { display: flex; justify-content: space-between; align-items: center; background: linear-gradient(135deg, #eef5e3 0%, #e8f0fb 100%); border: 1px solid #c8e0a8; border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.total-bar span:first-child { font-size: 15px; font-weight: 600; color: #2a2a2a; }
.total-bar b { color: #4a6b1e; font-size: 20px; }
.qty-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.qty-row .inp-wrap { flex: 1; min-width: 0; }
.qty-btn { width: 38px; height: 38px; min-width: 0; flex: none; border-radius: 10px; background: #ffffff; border: 1px solid #e5e0d5; color: #4a6b1e; font-size: 20px; font-weight: 800; padding: 0; display: flex; align-items: center; justify-content: center; line-height: 1; }
.qty-btn:active { background: #eef5e3; border-color: #c8e0a8; }
.materials-block { margin-top: 10px; padding-top: 10px; border-top: 1px dashed #e5e0d5; min-width: 0; overflow-x: hidden; }
.materials-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.materials-head .mtitle { font-size: 13px; font-weight: 700; }
.mat-count { font-size: 10.5px; padding: 2px 7px; background: #ffffff; color: #555; border-radius: 8px; font-weight: 700; flex-shrink: 0; border: 1px solid #e5e0d5; }
.mat-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.mat-actions button { flex: none; min-width: 0; font-size: 12px; padding: 7px 10px; border-radius: 8px; }
.mat-btn-search { background: #e8f0fb; color: #2b6bd8; border: 1px solid #b8d0f0; }
.mat-btn-add { background: #ffffff; color: #2a2a2a; border: 1px solid #e5e0d5; }
.material-row { background: #faf8f3; border: 1px solid #e5e0d5; border-radius: 10px; padding: 8px; margin-bottom: 6px; position: relative; min-width: 0; max-width: 100%; overflow-x: hidden; transition: background .2s, border-color .2s, box-shadow .2s; }
.material-row.edited { background: #fffce8; border-color: #e8b84b; box-shadow: 0 0 0 1px rgba(232,184,75,0.5); }
.mat-head-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; min-width: 0; }
.mat-head-row input.mat-name { flex: 1 1 0; min-width: 0; padding: 9px 10px; font-size: 16px; background: #ffffff; border: 1px solid #e5e0d5; border-radius: 8px; color: #2a2a2a; }
.mat-del { width: 34px; height: 34px; padding: 0; min-width: 0; flex: 0 0 34px; border-radius: 8px; background: #b93a3a; color: #fff; font-size: 16px; font-weight: 700; border: none; display: flex; align-items: center; justify-content: center; }
.mat-del:active { background: #d04040; }
.mat-row2 { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; min-width: 0; }
.mat-row2 input { padding: 9px 10px; font-size: 16px; background: #ffffff; border: 1px solid #e5e0d5; border-radius: 8px; color: #2a2a2a; min-width: 0; }
.mat-row2 input.mat-qty { flex: 1 1 0; min-width: 0; text-align: center; }
.mat-row2 input.mat-unit { flex: 0 0 72px; text-align: center; }
.mat-row3 { display: flex; gap: 6px; align-items: center; min-width: 0; }
.mat-row3 input.mat-price { flex: 1 1 0; min-width: 0; padding: 9px 10px; font-size: 16px; background: #ffffff; border: 1px solid #e5e0d5; border-radius: 8px; color: #2a2a2a; }
.mat-row3 .mat-sum { flex: 0 0 auto; font-size: 14px; color: #4a6b1e; font-weight: 700; font-variant-numeric: tabular-nums; padding: 0 4px; white-space: nowrap; }
.qty-btn-sm { width: 34px; height: 34px; min-width: 0; flex: 0 0 34px; border-radius: 8px; background: #ffffff; border: 1px solid #e5e0d5; color: #4a6b1e; font-size: 18px; font-weight: 800; padding: 0; display: flex; align-items: center; justify-content: center; line-height: 1; }
.qty-btn-sm:active { background: #eef5e3; border-color: #c8e0a8; }
.mat-src { font-size: 10.5px; color: #999; text-transform: uppercase; letter-spacing: 0.4px; margin-top: 6px; }
.mat-empty { font-size: 12px; color: #999; font-style: italic; padding: 4px 0; }

/* ================= УТОЧНЕНИЯ ================= */
.clar-list-block { background: #fffce8; border: 1px solid #f0d88a; border-left: 3px solid #e8b84b; border-radius: 8px; padding: 10px 12px; margin-top: 10px; }
.clar-list-title { font-size: 12.5px; font-weight: 700; color: #8a6300; margin-bottom: 8px; letter-spacing: 0.3px; }
.clar-list { list-style: none; padding: 0; margin: 0; }
.clar-list li { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-top: 1px solid #f0e0a0; cursor: pointer; }
.clar-list li:first-child { border-top: none; }
.clar-list li:active { background: #fff5cc; border-radius: 6px; }
.clar-num { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: #e8b84b; color: #2a2a2a; font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.clar-list li.answered .clar-num { background: #21a038; color: #fff; }
.clar-list li.answered .clar-text { color: #6a8050; text-decoration: line-through; text-decoration-color: rgba(106,128,80,0.5); }
.clar-text { font-size: 12.5px; color: #6b5000; line-height: 1.45; flex: 1; min-width: 0; }
.clar-answer-badge { font-size: 10.5px; color: #2d6b4a; margin-top: 4px; display: block; }

/* ================= ЛОГ AI ================= */
.log-card { background: #ffffff; border: 1px solid #e5e0d5; border-radius: 14px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.log-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.log-title { font-size: 15px; font-weight: 700; letter-spacing: 0.2px; display: flex; align-items: center; gap: 8px; color: #2a2a2a; }
.log-title .spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #4a6b1e; border-top-color: transparent; animation: spin 0.8s linear infinite; display: inline-block; }
.log-title.stopped .spin { display: none; }
.log-timer { font-family: ui-monospace, monospace; font-size: 14px; color: #4a6b1e; font-weight: 700; background: #eef5e3; border: 1px solid #c8e0a8; padding: 4px 10px; border-radius: 8px; }
.live-line { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; background: linear-gradient(90deg, #eef5e3 0%, #e8f0fb 50%, #eef5e3 100%); background-size: 200% 100%; animation: shimmer 2.5s ease-in-out infinite; color: #2b6bd8; font-size: 14px; font-weight: 600; margin-bottom: 12px; min-height: 44px; }
.live-line .icon { font-size: 18px; flex-shrink: 0; animation: bob 1.4s ease-in-out infinite; }
@keyframes shimmer { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.live-line.done { background: #eef7f0; color: #2d6b4a; animation: none; border: 1px solid #c8e0d0; }
.live-line.fail { background: #fdecea; color: #a03030; animation: none; border: 1px solid #f5c6c0; }
.log-progress { height: 3px; background: #e5e0d5; border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.log-progress > i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #4a6b1e, #8fc44a, #fc3f1d); background-size: 200% 100%; animation: shimmer 2s linear infinite; transition: width 0.4s linear; }
.log-body { max-height: 340px; overflow-y: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: #f7f5f0; border: 1px solid #e5e0d5; border-radius: 10px; padding: 12px 14px; }
.log-line { padding: 3px 0; color: #555; line-height: 1.5; }
.log-line.ok { color: #2d6b4a; }
.log-line.err { color: #a03030; }
.log-line.warn { color: #b87a20; }
.log-line.step { color: #4a6b1e; font-weight: 700; }
.log-time { color: #999; margin-right: 6px; }
.provider-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #eef5e3; border: 1px solid #c8e0a8; color: #4a6b1e; font-size: 11px; font-weight: 700; letter-spacing: 0.3px; }
.screen3-send-block { margin-top: 12px; }

/* ================= МЕНЮ / SHEET ================= */
.menu-overlay, .header-sheet { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; display: flex; align-items: flex-end; animation: fadeIn 0.15s ease; }
.header-sheet { align-items: flex-start; justify-content: center; padding: 60px 16px 16px; background: rgba(0,0,0,0.5); z-index: 1200; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.menu-sheet { width: 100%; max-width: 620px; margin: 0 auto; background: #ffffff; border-radius: 20px 20px 0 0; padding: 20px 16px 24px; display: flex; flex-direction: column; gap: 8px; animation: slideUp 0.2s ease; padding-bottom: calc(24px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 20px rgba(0,0,0,0.1); }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.menu-title { font-size: 12px; color: #777; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700; padding: 4px 8px 10px; }
.menu-item { display: flex; flex-direction: row; align-items: center; gap: 12px; background: #ffffff; border: 1px solid #e5e0d5; border-radius: 12px; padding: 12px 14px; text-align: left; color: #2a2a2a; font-size: 15px; cursor: pointer; font-family: inherit; width: 100%; }
.menu-item b { font-weight: 700; margin-bottom: 3px; display: block; }
.menu-item:active { background: #f7f5f0; }
.menu-item .menu-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.menu-item .menu-text span { font-size: 12px; color: #777; line-height: 1.35; }
.menu-cancel { background: #ffffff; border: 1px solid #e5e0d5; border-radius: 12px; padding: 14px; color: #555; font-size: 15px; margin-top: 4px; width: 100%; }
.ai-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: #fff; flex-shrink: 0; letter-spacing: -0.5px; }
.ai-icon.auto { background: linear-gradient(135deg, #4a6b1e 0%, #8fc44a 100%); }
.ai-icon.deepseek { background: linear-gradient(135deg, #4d6bfe 0%, #2b3fd8 100%); }
.ai-icon.yandex { background: linear-gradient(135deg, #fc3f1d 0%, #c72d10 100%); }
.header-card { background: #ffffff; border: 1px solid #e5e0d5; border-radius: 16px; padding: 16px; width: 100%; max-width: 420px; animation: fadeIn 0.15s ease; box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
.header-sheet-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.header-sheet-info { flex: 1; min-width: 0; }
.header-sheet-info b { display: block; font-size: 16px; color: #2a2a2a; letter-spacing: -0.2px; }
.header-sheet-info span { display: block; font-size: 11.5px; color: #777; margin-top: 2px; }
.ver-tag { font-size: 10px; font-weight: 700; color: #4a6b1e; background: #eef5e3; border: 1px solid #c8e0a8; padding: 4px 8px; border-radius: 8px; letter-spacing: 0.3px; white-space: nowrap; }
.header-conn { font-size: 12px; color: #777; margin-bottom: 12px; padding: 10px 12px; background: #f7f5f0; border-radius: 10px; border: 1px solid #e5e0d5; }
.header-conn.ok { color: #2d6b4a; border-color: #c8e0d0; background: #eef7f0; }
.header-conn.err { color: #a03030; border-color: #f5c6c0; background: #fdecea; }
.raw-card summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; color: #2b6bd8; }
.raw-card summary::-webkit-details-marker { display: none; }
.raw-card summary::after { content: "▾"; margin-left: auto; color: #999; transition: transform .2s; }
.raw-card[open] summary::after { transform: rotate(180deg); }
.raw-diag { font-size: 11.5px; color: #777; margin: 10px 0 8px; line-height: 1.55; font-family: ui-monospace, monospace; word-break: break-word; }
.raw-diag b { color: #4a6b1e; }
.raw-diag .warn { color: #b87a20; }
.raw-diag .bad  { color: #a03030; }
.raw-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.raw-actions button { flex: none; min-width: 0; font-size: 12.5px; padding: 8px 12px; }
.undo-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120%); background: #2a2a2a; border: 1px solid #444; border-radius: 12px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: #f2f2f2; z-index: 2000; box-shadow: 0 6px 24px rgba(0,0,0,0.25); transition: transform 0.3s ease; max-width: calc(100% - 32px); }
.undo-toast.show { transform: translateX(-50%) translateY(0); }
.undo-toast button { flex: none; min-width: 0; padding: 8px 14px; font-size: 13px; font-weight: 700; background: #8fc44a; color: #1a1f2b; border-radius: 8px; }
.price-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1500; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadeIn 0.15s ease; }
.price-card { background: #ffffff; border: 1px solid #e5e0d5; border-radius: 16px; padding: 18px; width: 100%; max-width: 520px; max-height: 85vh; overflow-y: auto; box-shadow: 0 8px 30px rgba(0,0,0,0.15); }
.price-card h3 { margin: 0 0 12px; font-size: 17px; color: #2a2a2a; }
.price-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: #f7f5f0; border: 1px solid #e5e0d5; border-radius: 10px; margin-bottom: 8px; font-size: 13px; }
.price-item .pn { color: #2a2a2a; flex: 1; min-width: 0; }
.price-item .pv { color: #4a6b1e; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.price-actions { display: flex; gap: 8px; margin-top: 14px; }
.clar-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1600; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fadeIn 0.15s ease; }
.clar-card { background: #ffffff; border: 1px solid #e5e0d5; border-radius: 16px; padding: 18px; width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; box-shadow: 0 8px 30px rgba(0,0,0,0.15); }
.clar-card h3 { margin: 0 0 10px; font-size: 16px; color: #8a6300; }
.clar-card .clar-question { font-size: 14px; color: #6b5000; background: #fffce8; border-left: 3px solid #e8b84b; padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; line-height: 1.45; }
.clar-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.clar-actions button { flex: 1; min-width: 120px; }
.clar-works { margin-top: 12px; }
.clar-works h4 { margin: 0 0 8px; font-size: 13px; color: #555; font-weight: 700; }
.clar-work-row { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.clar-work-row input { padding: 9px 10px; font-size: 16px; background: #ffffff; border: 1px solid #e5e0d5; border-radius: 8px; color: #2a2a2a; }
.clar-work-row input.cw-name { flex: 1 1 100%; }
.clar-work-row input.cw-qty { flex: 0 0 80px; }
.clar-work-row input.cw-unit { flex: 0 0 80px; }
#docRender { position: absolute; left: -9999px; top: 0; width: 794px; }

/* ================= v3: ГОЛОСОВОЙ ЭКРАН ================= */
.voice-screen, .voice-draft-screen {
  position: fixed; inset: 0; z-index: 6000;
  background: linear-gradient(160deg, #f7f5f0 0%, #eef2e6 50%, #f7f5f0 100%);
  display: none; align-items: flex-start; justify-content: center;
  padding: 20px 16px 40px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.voice-screen.show, .voice-draft-screen.show { display: flex; }
.voice-content, .voice-draft-content {
  width: 100%; max-width: 620px;
  animation: welcomeIn .4s ease both;
  padding-bottom: 40px;
}

/* Тикер подсказок (сверху, 3 карточки, авто-сдвиг) */
.hints-ticker {
  position: relative; overflow: hidden;
  height: 204px;
  margin-bottom: 14px;
  background: #ffffff;
  border: 1px solid #e5e0d5;
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.hints-track { display: flex; flex-direction: column; gap: 4px; will-change: transform; }
.hint-card {
  background: linear-gradient(135deg, #f7f5f0 0%, #eef5e3 100%);
  border-left: 3px solid #8fc44a;
  border-radius: 10px;
  padding: 8px 12px;
  height: 60px;
  box-sizing: border-box;
  display: flex; flex-direction: column; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.hint-t { font-size: 12.5px; font-weight: 700; color: #4a6b1e; letter-spacing: 0.2px; line-height: 1.2; }
.hint-s { font-size: 11.5px; color: #6a7a55; margin-top: 3px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Поле ввода + статус */
.voice-field-wrap { position: relative; margin-bottom: 14px; }
.voice-field {
  width: 100%;
  min-height: 180px;
  background: #ffffff;
  color: #2a2a2a;
  border: 1px solid #e5e0d5;
  border-radius: 14px;
  padding: 14px;
  font-size: 17px;
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  resize: vertical;
  -webkit-appearance: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.voice-field:focus { outline: none; border-color: #4a9eff; box-shadow: 0 0 0 3px rgba(74,158,255,0.15); }
.voice-field[readonly] { background: #fafaf5; color: #4a6b1e; }
.voice-status { font-size: 12px; color: #777; margin-top: 6px; min-height: 16px; padding-left: 4px; }
.voice-banner {
  background: #fdecea; border: 1px solid #f5c6c0; color: #a03030;
  padding: 10px 14px; border-radius: 10px;
  font-size: 13px; margin-bottom: 12px; line-height: 1.4;
}

/* Кнопки */
.voice-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.voice-record-btn {
  width: 100%; padding: 16px; font-size: 16px; font-weight: 700;
  border-radius: 12px;
}
.voice-record-btn.rec {
  background: #ff3b3b;
  animation: voicePulse 1.2s infinite;
}
@keyframes voicePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,59,59,0.55); }
  50% { box-shadow: 0 0 0 14px rgba(255,59,59,0); }
}
.voice-finish-btn {
  width: 100%; padding: 16px; font-size: 16px; font-weight: 700;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.ai-pulse {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: #ffffff;
  color: #2b6bd8;
  font-size: 11px; font-weight: 800; letter-spacing: -0.3px;
  animation: aiPulse 1.8s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes aiPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(74,158,255,0.55); transform: scale(1); }
  50% { box-shadow: 0 0 0 8px rgba(74,158,255,0); transform: scale(1.05); }
}

/* Черновик ТЗ — блоки */
.draft-block {
  background: #ffffff;
  border: 1px solid #e5e0d5;
  border-radius: 14px;
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.draft-block-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #eef5e3 0%, #e8f0fb 100%);
  border-bottom: 1px solid #e5e0d5;
}
.draft-block-title { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 800; color: #4a6b1e; letter-spacing: 0.2px; }
.draft-block-del {
  width: 30px; height: 30px; min-width: 0; padding: 0;
  border-radius: 50%; background: #f2f2f2; color: #777;
  font-size: 16px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; flex: none;
}
.draft-block-del:active { background: #b93a3a; color: #fff; }
.draft-block-body { padding: 10px 12px 14px; }

.draft-item {
  display: flex; align-items: flex-start; gap: 8px;
  background: #faf8f3;
  border: 1px solid #e5e0d5;
  border-radius: 10px;
  padding: 10px 10px 10px 12px;
  margin-bottom: 6px;
}
.draft-item-main { flex: 1; min-width: 0; }
.draft-item-text {
  font-size: 14.5px; font-weight: 600; color: #2a2a2a;
  line-height: 1.35; cursor: pointer; word-break: break-word;
}
.draft-item-text:active { color: #4a9eff; }
.draft-item-qty {
  font-size: 12.5px; color: #4a9eff; margin-top: 3px;
  font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums;
}
.draft-item-qty:active { color: #2b6bd8; }
.draft-item-del {
  width: 30px; height: 30px; min-width: 0; padding: 0;
  border-radius: 50%; background: #f2f2f2; color: #777;
  font-size: 15px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; flex: none;
}
.draft-item-del:active { background: #b93a3a; color: #fff; }

.draft-add-item {
  width: 100%; padding: 10px; margin-top: 4px;
  background: #e8f0fb; color: #2b6bd8;
  border: 1px solid #b8d0f0; border-radius: 10px;
  font-size: 13px; font-weight: 700; cursor: pointer;
}
.draft-add-item:active { background: #d6e4fa; }
.draft-empty { font-size: 12.5px; color: #999; font-style: italic; padding: 4px 0; }

.draft-clar {
  background: #fffce8;
  border: 1px solid #f0d88a;
  border-left: 3px solid #e8b84b;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 10px;
}
.draft-clar.answered {
  background: #eef7f0;
  border-color: #c8e0d0;
  border-left-color: #21a038;
}
.draft-clar.skipped {
  background: #f2f2f2;
  border-color: #e5e0d5;
  border-left-color: #bbb;
  opacity: 0.65;
}
.draft-clar-q { font-size: 13px; color: #6b5000; line-height: 1.4; font-weight: 600; }
.draft-clar.answered .draft-clar-q { color: #2d6b4a; }
.draft-clar.skipped .draft-clar-q { color: #777; }
.draft-clar-a {
  font-size: 12.5px; color: #2d6b4a; margin-top: 6px;
  padding: 6px 8px; background: #ffffff; border-radius: 6px;
  border: 1px solid #c8e0d0;
}
.draft-clar-a.skipped { color: #888; border-color: #e5e0d5; background: #fafafa; font-style: italic; }
.draft-clar-actions { display: flex; gap: 6px; margin-top: 10px; }
.draft-clar-actions button {
  flex: 1; min-width: 0; padding: 9px 10px; font-size: 13px; font-weight: 700;
  border-radius: 8px;
}
.draft-clar-yes { background: #2d6b4a; color: #fff; border: none; }
.draft-clar-yes:active { background: #245a3d; }
.draft-clar-skip { background: #ffffff; color: #555; border: 1px solid #e5e0d5; }
.draft-clar-skip:active { background: #f2f2f2; }

.draft-unknown {
  background: #f2f2f2;
  border: 1px dashed #c8c0b0;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.draft-unknown-title { font-size: 12px; color: #777; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.draft-unknown-line { font-size: 12.5px; color: #555; line-height: 1.5; }

/* ================= v3.2: СВАЙП УТОЧНЕНИЙ ================= */
.draft-clar-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  margin-top: 10px;
  max-width: 100%;
}
.draft-clar-actions-bg {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  display: flex;
  align-items: stretch;
  pointer-events: none;
  border-radius: 10px;
  overflow: hidden;
}
.draft-clar-bg-left {
  flex: 1;
  background: linear-gradient(90deg, #d9efd0 0%, #c3e5b5 100%);
  display: flex;
  align-items: center;
  padding-left: 22px;
  color: #2d6b4a;
  font-weight: 800;
  font-size: 14px;
}
.draft-clar-bg-right {
  flex: 1;
  background: linear-gradient(270deg, #e5e0d5 0%, #d8d2c4 100%);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 22px;
  color: #555;
  font-weight: 800;
  font-size: 14px;
}
.draft-clar-content {
  position: relative;
  z-index: 1;
  background: #fffce8;
  border: 1px solid #f0d88a;
  border-left: 3px solid #e8b84b;
  border-radius: 10px;
  padding: 12px 14px;
  transition: transform 0.22s ease;
  touch-action: pan-y;
}
.draft-clar-wrap.answered .draft-clar-content {
  background: #eef7f0;
  border-color: #c8e0d0;
  border-left-color: #21a038;
}
.draft-clar-wrap.skipped .draft-clar-content {
  background: #f2f2f2;
  border-color: #e5e0d5;
  border-left-color: #bbb;
  opacity: 0.65;
}

/* Полоса-подсказка свайпа — вне карточки, подпись снизу */
.clar-swipe-hint {
  margin-top: 4px;
  padding: 6px 4px 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  font-weight: 800;
  color: #8a8272;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  background: transparent;
}
.clar-swipe-hint .hint-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.clar-swipe-hint .hint-item .arr {
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  display: inline-block;
}
.clar-swipe-hint .hint-item.left { color: #8a8272; }
.clar-swipe-hint .hint-item.right { color: #2d6b4a; }
.clar-swipe-hint .hint-item.left .arr { animation: clarSwayLeft 2.4s ease-in-out infinite; }
.clar-swipe-hint .hint-item.right .arr { animation: clarSwayRight 2.4s ease-in-out infinite; }
@keyframes clarSwayLeft {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-4px); }
}
@keyframes clarSwayRight {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px); }
}
.draft-clar-wrap.answered .clar-swipe-hint,
.draft-clar-wrap.skipped .clar-swipe-hint,
.draft-clar-wrap.dismissed .clar-swipe-hint { display: none; }
/* Кнопки для десктопа */
.draft-clar-buttons {
  display: none;
  gap: 8px;
  margin-top: 10px;
}
.draft-clar-buttons button {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
}
.draft-clar-yes { background: #2d6b4a; color: #fff; border: none; }
.draft-clar-yes:active { background: #245a3d; }
.draft-clar-skip { background: #ffffff; color: #555; border: 1px solid #e5e0d5; }
.draft-clar-skip:active { background: #f2f2f2; }

/* Туториал при первом заходе */
.clar-tutorial {
  position: fixed;
  inset: 0;
  z-index: 7000;
  background: rgba(26, 22, 12, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  animation: tutFadeIn 0.25s ease;
}
.clar-tutorial.show { display: flex; }
@keyframes tutFadeIn { from { opacity: 0; } to { opacity: 1; } }
.clar-tutorial-card {
  background: #ffffff;
  border: 2px solid #8fc44a;
  border-radius: 18px;
  padding: 22px 20px;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.25);
  animation: tutPop 0.35s cubic-bezier(0.22, 1.4, 0.44, 1);
}
@keyframes tutPop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.clar-tutorial-title {
  font-size: 17px;
  font-weight: 800;
  color: #2a2a2a;
  margin: 0 0 6px;
  letter-spacing: -0.2px;
}
.clar-tutorial-sub {
  font-size: 13px;
  color: #777;
  line-height: 1.45;
  margin: 0 0 16px;
}
.clar-tutorial-row {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}
.clar-tutorial-item {
  flex: 1;
  background: #f7f5f0;
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
}
.clar-tutorial-item .arr {
  display: inline-block;
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 4px;
  line-height: 1;
}
.clar-tutorial-item.yes .arr { color: #2d6b4a; animation: tutArrRight 1.2s ease-in-out infinite; }
.clar-tutorial-item.no .arr { color: #8a8272; animation: tutArrLeft 1.2s ease-in-out infinite; }
.clar-tutorial-item .lbl {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #555;
}
.clar-tutorial-item.yes .lbl { color: #2d6b4a; }
@keyframes tutArrRight {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(6px); }
}
@keyframes tutArrLeft {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-6px); }
}
.clar-tutorial-hint {
  font-size: 11.5px;
  color: #999;
  margin-top: 8px;
  font-style: italic;
}
@media (hover: hover) and (pointer: fine) {
  .draft-clar-buttons { display: flex; }
  .clar-arrow-hint { display: none !important; }
  .draft-clar-content { transform: none !important; }
  .draft-clar-wrap { overflow: visible; }
  .draft-clar-actions-bg { display: none; }
}

@media print {  @page { size: A4; margin: 12mm; }
  html, body { background: #fff !important; color: #000 !important; padding: 0 !important; margin: 0 !important; min-height: 0 !important; height: auto !important; overflow: visible !important; display: block !important; }
  .wrap, #welcomeScreen, .start-menu-overlay, .role-screen, .object-screen, .q-loader, .work-screen,
  .voice-screen, .voice-draft-screen { display: none !important; }
  .menu-overlay, .header-sheet, .undo-toast, .price-modal, .clar-modal { display: none !important; }
  #docRender { position: static !important; left: auto !important; top: auto !important; width: 100% !important; display: block !important; }
  #docRender .doc { width: 100% !important; }
  .doc-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc table th, .doc .cat-row td, .doc .sub-row td, .doc .sub-total td, .doc .cat-total td, .doc .clar, .doc .mat-row td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-foot { page-break-inside: avoid; }
}
/* FIX: принудительно показываем активные экраны, побеждаем inline display:none */
.start-menu-overlay.show, .role-screen.show, .object-screen.show, .q-loader.show,
.work-screen.show, .voice-screen.show, .voice-draft-screen.show {
  display: flex !important;
}

/* ================= v3.3: свайп уточнений — override ================= */
/* Прячем старые круглые стрелки полностью */
.clar-arrow-hint { display: none !important; }

/* Переопределяем полосу-подсказку: вне карточки, крупные стрелки, спокойная анимация */
.draft-clar-wrap .clar-swipe-hint,
.clar-swipe-hint {
  margin-top: 4px !important;
  padding: 6px 4px 2px !important;
  border-top: none !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  font-size: 11.5px !important;
  font-weight: 800 !important;
  color: #8a8272 !important;
  letter-spacing: 0.4px !important;
  text-transform: uppercase !important;
  background: transparent !important;
}
.clar-swipe-hint .hint-item {
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
}
.clar-swipe-hint .hint-item .arr {
  font-size: 17px !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  display: inline-block !important;
}
.clar-swipe-hint .hint-item.left { color: #8a8272 !important; }
.clar-swipe-hint .hint-item.right { color: #2d6b4a !important; }
.clar-swipe-hint .hint-item.left .arr { animation: clarSwayLeft 2.4s ease-in-out infinite !important; }
.clar-swipe-hint .hint-item.right .arr { animation: clarSwayRight 2.4s ease-in-out infinite !important; }
@keyframes clarSwayLeft {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-4px); }
}
@keyframes clarSwayRight {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px); }
}
.draft-clar-wrap.answered .clar-swipe-hint,
.draft-clar-wrap.skipped .clar-swipe-hint,
.draft-clar-wrap.dismissed .clar-swipe-hint { display: none !important; }