:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --border: #d2d2d7;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --danger: #d70015;
  --success: #1a7d36;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 30px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --text: #f5f5f7;
    --text-secondary: #98989d;
    --border: #38383a;
    --accent: #0a84ff;
    --accent-hover: #3aa0ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 30px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Login ---------- */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 40px 32px;
  text-align: center;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px;
}

.login-card p.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 28px;
}

.field {
  text-align: left;
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="text"], input[type="tel"], textarea, select {
  width: 100%;
  font-size: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 18px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.hint {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; }
.success-text { color: var(--success); font-size: 13px; margin-top: 8px; }

/* ---------- App shell ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  font-size: 17px;
  font-weight: 600;
}

.topbar .user-info {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  width: 100%;
}

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 28px;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 24px;
}

.lang-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.lang-row select { flex: 1; }

.swap-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text);
  flex-shrink: 0;
}
.swap-btn:hover { background: var(--border); }

.mode-toggle { display: flex; gap: 8px; margin-bottom: 18px; }

textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.5;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone.dragover { border-color: var(--accent); background: var(--surface-2); }
.dropzone .filename { color: var(--text); font-weight: 500; margin-top: 8px; }

.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.actions .btn { width: auto; padding: 12px 28px; }

.result-box {
  margin-top: 8px;
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 15px;
}

.stats-row {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 14px;
  flex-wrap: wrap;
}

.warning-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(215, 0, 21, 0.08);
  border-radius: 10px;
  font-size: 13px;
  color: var(--danger);
}

#pdf-format-row { margin-top: 18px; }

/* Пункт 1: во время перевода кнопка растягивается на всю ширину блока файла */
.actions.actions-stretch { justify-content: stretch; }
.actions.actions-stretch .btn { width: 100%; }

/* Пункт 2: во время перевода все элементы управления блокируются */
.dropzone.locked { pointer-events: none; opacity: 0.6; }
select:disabled, button:disabled { opacity: 0.5; cursor: default; }

/* Пункты 3 и 10: кнопки "Отменить" и "Отправить в ТГ" под кнопкой перевода */
.progress-actions { display: flex; gap: 10px; margin-top: 12px; }
.progress-actions .btn { width: auto; flex: 1; padding: 10px 20px; font-size: 14px; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b8000f; }

#btn-send-telegram.active { background: var(--success); color: #fff; border-color: var(--success); }

.btn-progress {
  position: relative;
  overflow: hidden;
}

.btn-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: rgba(255, 255, 255, 0.22);
  transition: width 0.3s ease;
  z-index: 0;
}

.btn-label {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

table.glossary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.glossary-table th, table.glossary-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
table.glossary-table th { color: var(--text-secondary); font-weight: 500; font-size: 12px; }

.term-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin-bottom: 20px; }
.term-form input { margin: 0; }

.section-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; margin: 0 0 14px; }

@media (max-width: 640px) {
  .term-form { grid-template-columns: 1fr; }
  .container { padding: 20px 16px 60px; }
}
