:root {
:root {
  --bg-1: #eef5fb;
  --bg-2: #e6f0f7;
  --ink: #111827;
  --ink-soft: #4b5563;
  --card: #ffffff;
  --line: #d7e3f2;
  --line-strong: #c3d3e8;
  --accent: #5bbeeb;
  --accent-2: #27abe4;
  --ok-bg: #e8f8f0;
  --ok-line: #b9e8ce;
  --ok-ink: #16603c;
  --warn-bg: #fff8e3;
  --warn-line: #f2df9f;
  --warn-ink: #7a5a00;
  --err-bg: #fff0f2;
  --err-line: #f2c5cf;
  --err-ink: #a3203f;
  --shadow: 0 24px 64px rgba(20, 32, 51, 0.14);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

@font-face {
  font-family: "DM Serif Text";
  src: url("fonts/DMSerifText-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

body.app-body {
  min-height: 100vh;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--ink);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 34px 24px 28px;
}

body.app-index {
  background:
    radial-gradient(1100px 520px at -5% -12%, #d8f2ea 0%, transparent 64%),
    radial-gradient(980px 520px at 108% -16%, #d9e7ff 0%, transparent 66%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
}

body.app-manage {
  background:
    radial-gradient(1100px 520px at -5% -12%, #d8f2ea 0%, transparent 64%),
    radial-gradient(980px 520px at 108% -16%, #d9e7ff 0%, transparent 66%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
}

.app-card {
  width: min(1120px, 100%);
  background: #ffffff;
  border: 1px solid #cbd9ea;
  border-radius: 24px;
  padding: 26px;
  box-shadow: 0 28px 70px rgba(20, 32, 51, 0.2);
}

.app-card-index {
  width: min(920px, 100%);
}

.brand-hero {
  display: flex;
  gap: 18px;
  align-items: center;
  margin: 8px 0 18px;
  flex-wrap: nowrap;
}

.brand-hero img {
  width: 108px;
  height: 108px;
  object-fit: contain;
}

.brand-name {
  font-family: "DM Serif Text", "Times New Roman", serif;
  font-size: clamp(30px, 3.2vw, 40px);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.05;
}

.brand-tagline {
  color: var(--ink-soft);
  margin-top: 4px;
  font-size: 16px;
}

.brand-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.brand-inline img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.brand-hero .action-link,
.brand-inline .action-link,
.logout-link {
  margin-left: 10px;
  font-weight: 600;
}

.logout-link {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 10px;
}

.checklist-jump.action-link {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: #2455b8;
  text-align: left;
}

.checklist-jump.action-link:hover {
  color: #123b90;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 2.8vw, 34px);
  line-height: 1.15;
  letter-spacing: 0.01em;
  font-family: "DM Serif Text", "Times New Roman", serif;
}

h2 {
  margin: 0 0 10px;
  font-size: 22px;
  font-family: "DM Serif Text", "Times New Roman", serif;
}

p {
  margin: 0 0 16px;
  line-height: 1.55;
}

a {
  color: #2455b8;
  text-decoration-thickness: 1.4px;
  text-underline-offset: 2px;
}

a:hover {
  color: #123b90;
}

.lang,
.lang-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang {
  justify-content: flex-end;
  margin-bottom: 12px;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

label {
  display: inline-block;
  font-weight: 600;
  margin-bottom: 6px;
}

.required-mark {
  color: #b3273f;
  font-weight: 700;
}

input,
select,
button,
textarea {
  font-family: inherit;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  max-width: 560px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fbfdff;
  color: var(--ink);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent-2) 58%, white);
  outline-offset: 2px;
}

#langSelect {
  width: auto;
  min-width: 150px;
  max-width: 220px;
}

button,
.btn,
.primary,
.secondary,
.ghost {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.1;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

button:hover,
.btn:hover,
.primary:hover,
.secondary:hover,
.ghost:hover {
  transform: translateY(-1px);
}

button:disabled,
.btn:disabled,
.primary:disabled,
.secondary:disabled,
.ghost:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.primary,
.btn-primary {
  background: linear-gradient(135deg, #6ad1f2 0%, #5bbeeb 45%, #27abe4 100%);
  color: #fff;
  box-shadow: 0 10px 22px rgba(39, 171, 228, 0.25);
}

.secondary {
  background: linear-gradient(135deg, #27abe4 0%, #1e8ac0 100%);
  color: #fff;
  box-shadow: 0 10px 22px rgba(39, 171, 228, 0.25);
}

.ghost,
.btn-ghost {
  background: #eaf6fd;
  color: #0f3c6e;
}

.btn-danger {
  background: linear-gradient(135deg, #df2f4f 0%, #bf1e3c 100%);
  color: #fff;
  border: 1px solid #a41833;
  box-shadow: 0 10px 22px rgba(191, 30, 60, 0.3);
}

.link-btn {
  background: transparent;
  color: #6f5021;
  text-decoration: underline;
  text-underline-offset: 2px;
  border-radius: 0;
  padding: 0;
}

.primary.recording {
  background: linear-gradient(135deg, #be243c 0%, #a51f35 100%);
  box-shadow: 0 0 0 3px rgba(190, 36, 60, 0.24);
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1.1fr 0.9fr;
}


.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f3f8ff;
  padding: 16px;
}

.panel-wide {
  grid-column: 1 / -1;
}

section[data-tab-panel="active_checks"] {
  overflow-x: hidden;
}

section[data-tab-panel="active_checks"] .grid > div {
  min-width: 0;
}

section[data-tab-panel="active_checks"] select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.row {
  margin-bottom: 14px;
}

.info,
.error,
.warning {
  border-radius: 12px;
  padding: 12px 13px;
  border: 1px solid transparent;
  font-size: 14px;
}

.info {
  background: var(--ok-bg);
  border-color: var(--ok-line);
  color: var(--ok-ink);
}

.error {
  background: #ffe8ee;
  border: 2px solid #d62a4d;
  color: #781128;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(214, 42, 77, 0.14);
}

.warning {
  background: #fff2d9;
  border: 2px solid #e39a1a;
  color: #7a4a00;
  font-weight: 600;
}

.hint {
  font-size: 14px;
  color: var(--ink-soft);
}

.mail-preview {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
  padding: 8px 10px;
}

.mail-preview summary {
  cursor: pointer;
  font-weight: 700;
  color: #21416f;
}

.mail-preview-content {
  margin-top: 8px;
}

.mail-preview-body {
  margin-top: 8px;
  border: 1px solid #d9e5f4;
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-family: "Source Sans 3", "Segoe UI", "Trebuchet MS", sans-serif;
  font-size: 14px;
  color: var(--ink);
}

.account-meta {
  margin-bottom: 10px;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
  margin-top: 6px;
}

.account-actions .action-link,
.account-actions .tab-btn {
  min-width: 210px;
  justify-content: center;
}

.action-link,
.back-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: #f1f6ff;
  color: #21416f;
  font-weight: 700;
  text-decoration: none;
}

.action-link:hover,
.back-link-btn:hover {
  background: #e6eefc;
}

.status {
  font-weight: 700;
  color: var(--accent);
}

.checklist-panel {
  margin-bottom: 14px;
}

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

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #f8fbff;
}

.checklist-jump {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.checklist-item.open {
  border-color: #f0d79a;
  background: #fff9ea;
}

.checklist-item.done {
  border-color: #b9e8ce;
  background: #eefbf4;
}

.checkmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.checklist-item.done .checkmark {
  background: #1f7a57;
  color: #fff;
}

.checklist-item.open .checkmark {
  background: #d08a17;
  color: #fff;
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.contacts-inline-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin: 6px 0 10px;
}

video,
#preview {
  width: 100%;
  border-radius: 12px;
  background: #111;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 16px;
}

.tab-btn {
  border: 0;
  background: transparent;
  padding: 0;
  font-weight: 700;
}

.tab-btn.active {
  background: transparent;
  border-color: transparent;
  color: inherit;
}

.tab-btn.action-link.active {
  background: #e6eefc;
  border-color: var(--accent-2);
  color: #0f3c6e;
}

.hidden-tab,
.hidden {
  display: none !important;
}


.check-list {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.check-option {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.prefs-card {
  border: 1px dashed #cfdded;
  border-radius: 12px;
  padding: 11px;
  margin-top: 8px;
  background: #f8fbff;
}

.prefs-inline-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  margin-top: 8px;
}

.prefs-inline-field {
  min-width: 240px;
}

.prefs-inline-field label {
  margin-bottom: 4px;
  white-space: normal;
  font-size: 13px;
}

.prefs-inline-field select {
  width: 180px;
  max-width: 180px;
}

.prefs-inline-field-target select {
  width: min(100%, 420px);
  max-width: 420px;
}

.input-wide {
  max-width: 740px;
  width: 100%;
}

.plan-props {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 4px;
}

.plan-props li {
  margin: 0;
}

.plan-option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.plan-option-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 10px 12px;
  background: #f8fbff;
  cursor: pointer;
}

.plan-option-card input[type="radio"] {
  margin: 2px 0 0;
  flex: 0 0 auto;
}

.plan-option-card > div {
  flex: 1 1 auto;
  min-width: 0;
}

.plan-option-card .hint {
  white-space: normal;
  overflow-wrap: anywhere;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 8px;
  border-bottom: 1px solid #e4edf8;
}

.log-panel {
  overflow-x: auto;
}

.log-table {
  width: 100%;
  table-layout: fixed;
  min-width: 0;
}

.log-col-time {
  width: 170px;
}

.log-col-event {
  width: 220px;
}

.log-col-details {
  width: auto;
}

.log-table td,
.log-table th {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-text {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  margin-top: 6px;
}

.badge-pending {
  background: #fff4de;
  border-color: #f2d39b;
  color: #8a5a00;
}

.badge-confirmed {
  background: #e8f6ef;
  border-color: #b8e0cb;
  color: #1f7a57;
}

.badge-confirmed-soft {
  background: #f0faee;
  border-color: #cfe8c9;
  color: #3f7f35;
}

.badge-rejected {
  background: #fde9ec;
  border-color: #f4c4cb;
  color: #a22;
}

.badge-none {
  background: #f0f3f7;
  border-color: #d7e0ec;
  color: #4f5f75;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 16, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal-card {
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 42px rgba(20, 32, 51, 0.22);
}

.modal-title {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 800;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 30, 0.38);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
}

.loading-overlay.active {
  display: flex;
}

.loading-badge {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 14px 16px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 16px 34px rgba(20, 32, 51, 0.2);
  font-weight: 700;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #d9e7fb;
  border-top-color: var(--accent-2);
  border-radius: 999px;
  animation: loading-spin 0.8s linear infinite;
}

@keyframes loading-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .input-wide {
    max-width: 100%;
  }

  section[data-tab-panel="active_checks"] table,
  section[data-tab-panel="emergency"] table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 760px) {
  body.app-body {
    padding: 16px 12px 12px;
  }

  .app-card {
    border-radius: 18px;
    padding: 14px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .lang-wrap,
  .lang {
    justify-content: flex-start;
  }

  .prefs-inline-fields {
    flex-wrap: wrap;
    gap: 10px;
  }

  .prefs-inline-field {
    min-width: 100%;
  }

  .prefs-inline-field select {
    width: 100%;
    max-width: 220px;
  }

  .prefs-inline-field-target select {
    width: 100%;
    max-width: 100%;
  }

  .app-card {
    width: 100%;
    padding: 12px;
  }

  .panel {
    padding: 12px;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    max-width: 100%;
    width: 100%;
    min-width: 0;
    font-size: 16px;
  }

  form {
    min-width: 0;
  }

  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .tab-btn {
    width: 100%;
    font-size: 15px;
    padding: 11px 12px;
  }

  .lang-wrap label,
  .lang label {
    font-size: 15px;
  }

  #langSelect {
    min-width: 128px;
    max-width: 100%;
  }

  .account-actions {
    gap: 10px;
  }

  .action-link,
  .back-link-btn {
    flex: 1 1 calc(50% - 6px);
    min-height: 46px;
    font-size: 15px;
    padding: 11px 12px;
  }

  section[data-tab-panel="active_checks"] select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  section[data-tab-panel="active_checks"] .grid {
    gap: 12px;
    grid-template-columns: 1fr;
  }

  section[data-tab-panel="active_checks"] .grid > div {
    min-width: 0;
  }

  section[data-tab-panel="active_checks"] label {
    white-space: normal;
  }

  section[data-tab-panel="emergency"] .prefs-inline-field {
    min-width: 0;
  }

  section[data-tab-panel="emergency"] .prefs-inline-field select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .plan-option-grid {
    grid-template-columns: 1fr;
  }
}
