:root {
  --bg: #041823;
  --panel: #072d3f;
  --ink: #eaf6f8;
  --muted: #9cb7bf;
  --accent: #007c8a;
  --green-dark: #116149;
  --accent-coral: #c93030;
  --line: #0e3a4e;
  --danger: #c93030;
  --card-page-height: 289mm;
  --card-side-label-width: 224px;
  --card-side-label-width-print: 104px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, #0b2c3b, var(--bg) 40%);
}

.topbar {
  padding: 30px 22px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #072d3f, #0b4057);
  color: var(--ink);
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 42px;
  line-height: 1.05;
}

.brand-domain {
  font-size: 0.62em;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tool-brand {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
}

.tool-title-group p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.tool-brand-logo {
  justify-self: start;
  height: 1px;
  width: auto;
  object-fit: contain;
}

.layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  padding: 16px;
}

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

.panel h2 {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.1;
}

.panel-lite {
  background: #0a3448;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.stepper {
  margin: 14px 16px 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.step span {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #0e3e52;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-head h2 {
  margin: 0;
}

.action-toolbar {
  margin-left: auto;
  justify-content: flex-end;
  align-items: flex-start;
  align-self: flex-start;
}

.section-tools,
.diver-toolbar {
  justify-content: flex-end;
  align-items: flex-start;
  align-self: flex-start;
}

.button-like.import-btn,
button.save-btn,
button.save-diver-btn {
  width: 170px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}

.button-like.import-btn {
  background: var(--green-dark);
}

button.save-btn {
  background: var(--accent);
}

.section-tools {
  margin-bottom: 10px;
}

button,
.button-like {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.primary {
  background: var(--accent-coral);
}

fieldset {
  border: 1px solid var(--line);
  margin-top: 12px;
  border-radius: 8px;
}

legend {
  padding: 0 6px;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 700;
}

label {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 14px;
}

input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #0b3a4f;
  color: var(--ink);
}

select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #0b3a4f;
  color: var(--ink);
}

.status {
  font-size: 13px;
  color: var(--muted);
}

.lang-block {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.language-section legend {
  margin-bottom: 8px;
}

.language-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px 12px;
}

.language-field {
  display: grid;
  gap: 6px;
}

.language-field label {
  margin: 0;
  font-size: 14px;
}

.lang-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  display: inline-block;
}

.lang-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lang-chip {
  border: 1px solid #adc2ce;
  background: #f7fbfd;
  color: #174053;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
}

.lang-chip.active {
  background: #d7eef8;
  border-color: #67a6c3;
}

.more-lang-panel {
  margin-top: 8px;
}

.more-lang-panel select {
  border: 1px solid #b7c4cc;
  border-radius: 6px;
  padding: 6px;
  background: #fff;
}

.small-note {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.address-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

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

.hidden {
  display: none;
}

.check-panel {
  margin-top: 10px;
}

.check-panel h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.check-panel ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
}

.export-panel {
  margin-bottom: 10px;
}

.export-grid {
  display: grid;
  grid-template-columns: minmax(170px, 220px) 1fr;
  gap: 12px;
  align-items: start;
}

.export-actions {
  display: grid;
  gap: 8px;
  align-items: start;
  justify-items: stretch;
}

.export-btn {
  background: var(--green-dark);
  width: 100%;
  min-width: 160px;
  min-height: 44px;
  font-weight: 700;
}

.export-info {
  min-width: 0;
}

.export-warning {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 700;
  color: #eaf6f8;
  text-align: center;
}

.step-section {
  background: #0a3448;
}

.section-with-tools {
  position: relative;
  padding-top: 34px;
}

.section-with-tools > .section-tools,
.section-with-tools > .diver-toolbar {
  position: absolute;
  top: 10px;
  right: 12px;
  margin: 0;
}

.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  background: #fff;
  color: #111;
  font-size: 14px;
  line-height: 1.4;
  display: grid;
  gap: 12mm;
}

.card-page {
  --page-scale: 1;
  width: 100%;
  min-height: var(--card-page-height);
  height: var(--card-page-height);
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-page-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.card-page-primary .card-page-body {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.card-header {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  background: var(--danger);
  color: #fff;
  padding: calc(14px * var(--page-scale)) calc(12px * var(--page-scale));
  border-bottom: 0;
  flex: 0 0 auto;
}

.card-header h3 {
  margin: 0;
  font-size: calc(28px * var(--page-scale));
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.card-header p {
  margin: calc(4px * var(--page-scale)) 0 0;
  font-size: calc(13px * var(--page-scale));
}

.card h4 {
  margin: 12px 0 6px;
  font-size: 14px;
  color: #111;
}

.i18n-line {
  display: block;
  line-height: 1.12;
}

.i18n-alt {
  font-style: italic;
  font-weight: 500;
}

.i18n-ar {
  direction: rtl;
  text-align: right;
  unicode-bidi: plaintext;
}

.card-section {
  margin-bottom: 10px;
}

.card-section-row {
  display: grid;
  grid-template-columns: var(--card-side-label-width) 1fr;
  border-bottom: 0;
  break-inside: avoid;
  page-break-inside: avoid;
  min-height: 0;
}

.side-label {
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  font-size: calc(28px * var(--page-scale));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: 0;
  gap: calc(2px * var(--page-scale));
}

.section-body {
  padding: 0;
  min-width: 0;
  min-height: 0;
  display: flex;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.weighted-table {
  height: 100%;
  table-layout: fixed;
}

.weighted-table tbody {
  height: 100%;
}

.weighted-table .weighted-row {
  height: calc((100% * var(--row-weight)) / var(--row-weight-total));
}

.data-table th,
.data-table td {
  border: 1px solid #111;
  padding: calc(5px * var(--page-scale)) calc(6px * var(--page-scale));
  vertical-align: top;
  font-size: calc(14px * var(--page-scale));
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.data-table th {
  text-align: left;
}

.where-table th {
  width: 38%;
}

.where-table td,
.what-table td {
  vertical-align: middle;
  text-align: center;
}

.row-emergency-number-top td strong {
  font-weight: 800;
}

.what-table th {
  width: 42%;
}

.data-table thead th {
  background: #e9eef2;
}

.qr-inline-block {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: calc(6px * var(--page-scale));
  align-items: center;
  text-align: left;
  width: fit-content;
  max-width: 100%;
}

.qr-inline-block.qr-pos-left {
  grid-template-columns: auto minmax(0, 1fr);
}

.qr-inline-block.qr-pos-left .qr-inline-code {
  order: 1;
}

.qr-inline-block.qr-pos-left .qr-inline-text {
  order: 2;
}

.qr-inline-text {
  min-width: 0;
  display: grid;
  gap: calc(2px * var(--page-scale));
}

.qr-inline-text span {
  display: block;
}

.qr-inline-block.qr-align-left {
  margin-right: auto;
}

.qr-inline-block.qr-align-right {
  margin-left: auto;
}

.qr-inline-block.qr-gap-tight {
  gap: calc(2px * var(--page-scale));
}

.qr-stack {
  display: grid;
  gap: calc(6px * var(--page-scale));
}

.qr-inline-code {
  width: calc(52px * var(--page-scale));
  height: calc(52px * var(--page-scale));
  object-fit: contain;
  image-rendering: crisp-edges;
}

.data-table.compact th {
  width: 34%;
  text-align: left;
}

.map-wrap {
  margin-top: 8px;
  border: 1px solid #111;
  padding: 4px;
}

.map-frame {
  width: 100%;
  height: 220px;
  border: 0;
}

.map-note {
  margin: 6px 0 2px;
  font-size: 12px;
}

.map-preview-panel {
  margin-bottom: 10px;
}

.export-panel {
  margin-bottom: 10px;
}

.who-table th {
  width: 28%;
  background: #efefef;
}

.card-page-primary .section-who,
.card-page-cont .section-who {
  flex: 1 1 auto;
}

.card-page-primary .section-who .data-table,
.card-page-cont .section-who .data-table {
  height: 100%;
}

.card-page-primary .section-where,
.card-page-primary .section-what {
  align-self: start;
}

.card-page-cont .card-page-body {
  flex: 1;
}

.who-table td {
  text-align: center;
  vertical-align: middle;
}

.who-table td .qr-inline-block {
  text-align: left;
}

.where-table td .qr-inline-block,
.what-table td .qr-inline-block {
  margin-inline: auto;
}

.who-table th {
  width: 31%;
}

.card-page-cont .side-label,
.card-page-primary .section-who .side-label {
  align-items: center;
  justify-content: center;
}

.card-page.lang-count-3 .data-table th,
.card-page.lang-count-3 .data-table td {
  font-size: calc(13px * var(--page-scale));
  padding: calc(4px * var(--page-scale)) calc(5px * var(--page-scale));
}

.card-page.lang-count-3 .i18n-line {
  line-height: 1.04;
}

.diver-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-top: 10px;
}

.diver-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.diver-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.diver-header h3 {
  margin: 0;
  font-size: 16px;
}

.remove-diver-btn {
  background: #9b2d30;
}

.diver-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 8px 10px;
}

.preview-wrap {
  position: sticky;
  top: 10px;
  align-self: start;
  display: grid;
  gap: 10px;
}

.preview-wrap h2 {
  margin: 0 0 10px;
}

.a4-frame {
  background: #0e3a4e;
  border-radius: 10px;
  padding: 12px;
  overflow: auto;
}

.a4-frame .card {
  width: 210mm;
  margin: 0 auto;
  background: #fff;
}

.site-status {
  margin: 0 16px 16px;
}

.site-info {
  margin: 0 16px 12px;
  background: linear-gradient(135deg, rgba(11, 64, 87, 0.96), rgba(7, 45, 63, 0.96));
}

.site-info h2 {
  margin-bottom: 10px;
}

.site-info p {
  margin: 0;
  max-width: 1100px;
  color: var(--ink);
  line-height: 1.5;
}

.site-info p + p {
  margin-top: 8px;
}

.site-info a {
  color: #8adcf2;
}

.site-info a:hover {
  color: #c7f4ff;
}

.site-status h2 {
  margin-bottom: 8px;
}

.site-status .status {
  margin-top: 8px;
}

.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2000;
  display: grid;
  gap: 8px;
  max-width: min(460px, calc(100vw - 32px));
}

.toast {
  background: #173a44;
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-error {
  border-left-color: var(--accent-coral);
}

.toast-hide {
  opacity: 0;
  transform: translateY(6px);
}

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

  .preview-wrap {
    position: static;
  }

  .tool-brand {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .topbar h1 {
    font-size: 34px;
  }

  .tool-title-group p {
    font-size: 15px;
  }

  .tool-brand-logo {
    max-width: 62%;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .action-toolbar {
    margin-left: 0;
    justify-content: flex-start;
  }

  .export-grid {
    grid-template-columns: 1fr;
  }

  .a4-frame .card {
    width: 100%;
    gap: 14px;
  }

  .card-page-primary .card-page-body {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .language-grid {
    grid-template-columns: 1fr;
  }

  .diver-grid {
    grid-template-columns: 1fr;
  }

  .section-with-tools {
    padding-top: 12px;
  }

  .section-with-tools > .section-tools,
  .section-with-tools > .diver-toolbar {
    position: static;
    margin-bottom: 10px;
    justify-content: flex-start;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  .topbar,
  .panel:first-child {
    display: none;
  }

  .layout {
    display: block;
    padding: 0;
    margin: 0;
  }

  .panel {
    border: none;
    padding: 0;
    margin: 0;
    border-radius: 0;
  }

  .card {
    border: none;
    border-radius: 0;
    padding: 0;
    width: auto;
    margin: 0;
    gap: 0;
  }

  .card-page {
    min-height: var(--card-page-height);
    height: var(--card-page-height);
    break-after: page;
    page-break-after: always;
  }

  .card-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .card-header {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .card-section-row {
    grid-template-columns: var(--card-side-label-width-print) 1fr;
  }

  .side-label {
    padding-top: 6px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .section-body {
    padding: 0;
  }

  .preview-wrap h2 {
    display: none;
  }

  .map-wrap {
    display: none;
  }

  .map-preview-panel {
    display: none;
  }

  .export-panel {
    display: none;
  }

  .stepper,
  .check-panel,
  .lang-block,
  .action-toolbar,
  .site-info,
  .site-status,
  .toast-container {
    display: none;
  }
}
