/* === ОТО Ассистент — стили === */
:root {
  --bg: var(--tg-theme-bg-color, #0f1115);
  --text: var(--tg-theme-text-color, #e8eaed);
  --hint: var(--tg-theme-hint-color, #9aa0a6);
  --button: var(--tg-theme-button-color, #2b6cb0);
  --button-text: var(--tg-theme-button-text-color, #fff);
  --secondary: var(--tg-theme-secondary-bg-color, #1a1d24);
  --accent: #4c8bf5;
  --danger: #e85d75;
  --ok: #2ecc71;
  --warn: #f1c40f;
  --radius: 12px;
  --pad: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 15px; }
body { min-height: 100vh; padding-bottom: 70px; }

#app { max-width: 600px; margin: 0 auto; }

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px var(--pad); background: var(--secondary);
  position: sticky; top: 0; z-index: 10; border-bottom: 1px solid rgba(255,255,255,.05);
}
.logo { font-weight: 700; font-size: 17px; }
.user { font-size: 12px; color: var(--hint); }

nav#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 600px; margin: 0 auto;
  display: flex; background: var(--secondary);
  border-top: 1px solid rgba(255,255,255,.08); z-index: 10;
}
nav#bottom-nav button {
  flex: 1; background: transparent; color: var(--hint);
  border: none; padding: 12px 4px; font-size: 11px; cursor: pointer;
}
nav#bottom-nav button.active { color: var(--accent); }

main { padding: var(--pad); }

.tab { display: none; }
.tab.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h1 { font-size: 22px; margin: 0 0 12px; }
.lead { color: var(--hint); margin: 0 0 20px; line-height: 1.5; }

.back { background: transparent; color: var(--accent); border: none; font-size: 14px; padding: 0; margin-bottom: 12px; cursor: pointer; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.card {
  background: var(--secondary); color: var(--text);
  border: 1px solid rgba(255,255,255,.05); border-radius: var(--radius);
  padding: 16px; text-align: left; cursor: pointer; transition: transform .15s;
}
.card:active { transform: scale(.98); }
.card-icon { font-size: 28px; margin-bottom: 8px; }
.card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.card-desc { font-size: 12px; color: var(--hint); line-height: 1.4; }

button.primary {
  background: var(--button); color: var(--button-text);
  border: none; border-radius: var(--radius);
  padding: 14px; width: 100%; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 12px;
}
button.primary:disabled { opacity: .5; cursor: not-allowed; }

.status-card {
  background: var(--secondary); border: 1px solid rgba(255,255,255,.05);
  border-radius: var(--radius); padding: 14px; margin-top: 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.status-label { font-size: 13px; color: var(--hint); }
.status-value { font-weight: 600; }
.status-value.ok { color: var(--ok); }
.status-value.warn { color: var(--warn); }
.status-value.danger { color: var(--danger); }

.upload-area {
  background: var(--secondary); border: 2px dashed rgba(255,255,255,.12);
  border-radius: var(--radius); padding: 32px 16px; text-align: center;
  margin: 16px 0; cursor: pointer;
}
.upload-icon { font-size: 36px; margin-bottom: 8px; }
.upload-text { font-weight: 600; }
.upload-hint { font-size: 12px; color: var(--hint); margin-top: 4px; }

.file-info {
  background: var(--secondary); border-radius: var(--radius);
  padding: 12px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center;
}
.file-info .name { font-size: 13px; word-break: break-all; }
.file-info .size { font-size: 12px; color: var(--hint); margin-top: 2px; }
.file-info .remove { background: transparent; color: var(--danger); border: none; font-size: 18px; cursor: pointer; }

.result {
  background: var(--secondary); border-radius: var(--radius);
  padding: 16px; margin-top: 16px; white-space: pre-wrap; line-height: 1.5;
  max-height: 60vh; overflow-y: auto; font-size: 14px;
}
.result h3 { margin: 0 0 8px; font-size: 16px; }
.result .ok { color: var(--ok); }
.result .err { color: var(--danger); }
.result .warn { color: var(--warn); }

.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--hint); }
.form input, .form textarea, .form select {
  background: var(--secondary); color: var(--text);
  border: 1px solid rgba(255,255,255,.08); border-radius: 8px;
  padding: 10px 12px; font-size: 15px; font-family: inherit;
}
.form input:focus, .form textarea:focus, .form select:focus { outline: 2px solid var(--accent); border-color: transparent; }

.templates { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.template { cursor: pointer; }
.template input { display: none; }
.tpl-card {
  background: var(--secondary); border: 2px solid transparent;
  border-radius: var(--radius); padding: 12px; display: flex; align-items: center; gap: 12px;
}
.template input:checked + .tpl-card { border-color: var(--accent); }
.tpl-icon { font-size: 22px; }
.tpl-name { font-weight: 500; }

.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px;
  border-radius: 8px; font-size: 14px; opacity: 0; transition: opacity .25s;
  z-index: 100; pointer-events: none; max-width: 80%;
}
.toast.show { opacity: .95; }

.loader {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.spinner {
  width: 36px; height: 36px; border: 3px solid rgba(255,255,255,.2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* === ИИ-консультант: чат === */
.suggestions {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px;
}
.chip {
  background: var(--secondary); color: var(--text);
  border: 1px solid var(--border); border-radius: 18px;
  padding: 8px 14px; font-size: 13px; cursor: pointer;
  transition: all .2s; font-family: inherit;
}
.chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.chat-history {
  display: flex; flex-direction: column; gap: 10px;
  min-height: 200px; max-height: 50vh; overflow-y: auto;
  padding: 8px 4px; margin-bottom: 12px;
}
.chat-empty {
  color: var(--muted); text-align: center; padding: 30px 10px;
  font-size: 14px;
}
.msg { display: flex; width: 100%; }
.msg-user { justify-content: flex-end; }
.msg-bot { justify-content: flex-start; }
.msg-bubble {
  max-width: 88%; padding: 10px 14px; border-radius: 14px;
  font-size: 14px; line-height: 1.45;
  word-wrap: break-word; overflow-wrap: break-word;
}
.msg-bubble-user {
  background: var(--accent); color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-bubble-bot {
  background: var(--secondary); color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg-conf {
  display: inline-block; font-size: 10px; text-transform: uppercase;
  letter-spacing: .5px; padding: 2px 7px; border-radius: 8px;
  margin-bottom: 6px; font-weight: 700;
}
.conf-high { background: #2ecc71; color: #fff; }
.conf-medium { background: #f39c12; color: #fff; }
.conf-low { background: #e67e22; color: #fff; }
.conf-very_low { background: #95a5a6; color: #fff; }
.msg-text { white-space: pre-wrap; }
.msg-cites { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.cites-title { font-size: 11px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; letter-spacing: .5px; }
.cite {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; margin-bottom: 4px;
  font-size: 12px; cursor: pointer;
}
.cite summary { font-weight: 500; outline: none; }
.cite[open] summary { margin-bottom: 6px; }
.cite-snippet {
  color: var(--muted); font-size: 12px;
  white-space: pre-wrap; max-height: 200px; overflow-y: auto;
}

.chat-input-row {
  display: flex; gap: 8px; align-items: flex-end;
  position: sticky; bottom: 0; background: var(--bg);
  padding: 8px 0; border-top: 1px solid var(--border);
}
#consult-input {
  flex: 1; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--secondary);
  color: var(--text); font-size: 14px; font-family: inherit;
  resize: none; min-height: 42px; max-height: 120px;
}
#consult-input:focus { outline: none; border-color: var(--accent); }
#consult-send {
  width: 44px; height: 42px; padding: 0;
  font-size: 20px; line-height: 1; border-radius: 12px;
}

/* === ИИ-консультант: уточняющие вопросы === */
.opt-list {
  display: flex; flex-direction: column; gap: 6px; margin-top: 8px;
}
.opt-btn {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 10px 14px; border-radius: 10px;
  text-align: left; font-size: 14px; cursor: pointer;
  transition: all .15s; font-family: inherit;
}
.opt-btn:hover { border-color: var(--accent); background: var(--secondary); }
.opt-btn:active { transform: scale(.98); }
.msg-intent {
  display: inline-block; font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; padding: 3px 8px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 600;
  margin-bottom: 8px;
}
.text-input {
  flex: 1; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--secondary);
  color: var(--text); font-size: 14px; font-family: inherit;
  resize: none; min-height: 36px; max-height: 100px;
}
.text-input:focus { outline: none; border-color: var(--accent); }
.text-send { width: 38px; height: 36px; padding: 0; font-size: 18px; }

/* === ИИ-консультант: чек-лист === */
.msg-checklist {
  max-width: 95% !important;
  background: linear-gradient(135deg, var(--secondary) 0%, var(--bg) 100%);
  border: 1px solid var(--accent);
}
.checklist-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px; margin-bottom: 10px;
}
.checklist-title-main {
  font-size: 16px; font-weight: 700; margin-bottom: 4px;
}
.checklist-summary {
  font-size: 13px; color: var(--muted);
  background: var(--bg); padding: 6px 10px; border-radius: 8px;
  font-family: monospace;
}
.checklist-list { margin: 8px 0; }
.checklist-item {
  display: flex; gap: 10px; margin-bottom: 10px;
  align-items: flex-start;
}
.checklist-num {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff; display: flex;
  align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; margin-top: 2px;
}
.checklist-body { flex: 1; }
.checklist-title { font-size: 14px; font-weight: 500; line-height: 1.35; }
.checklist-note {
  font-size: 12px; color: var(--muted); margin-top: 3px;
  line-height: 1.4;
}
.checklist-meta {
  font-size: 13px; padding: 6px 10px; margin-top: 6px;
  background: var(--bg); border-radius: 8px;
  border-left: 3px solid var(--accent);
}
.checklist-restart { width: 100%; }
