:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #64748b;
  --line: #d8e1ec;
  --soft: #eef4f7;
  --accent: #116a63;
  --accent-strong: #0b514b;
  --blue: #0a75b8;
  --danger: #a7342f;
  --success: #1c7f46;
  --shadow: 0 14px 34px rgba(24, 33, 47, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

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

.workspace {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 34px;
}

.app-hero {
  position: relative;
  overflow: hidden;
  min-height: 228px;
  border-radius: 8px;
  background: #12333b;
  box-shadow: var(--shadow);
}

.hero-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(9, 28, 35, 0.78), rgba(9, 28, 35, 0.46), rgba(9, 28, 35, 0.14)),
    linear-gradient(0deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.06));
}

.hero-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 228px;
  padding: 28px;
}

.hero-logo {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 4px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.22);
}

.hero-copy {
  min-width: 0;
  color: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 820px;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  margin: 10px 0 0;
  max-width: 640px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 15px;
  line-height: 1.45;
}

.save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  padding: 11px 18px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 12px 20px rgba(17, 106, 99, 0.28);
  cursor: pointer;
  white-space: nowrap;
}

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

.save-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.document-shell {
  overflow: hidden;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section-heading,
.editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f9fbfd);
}

.editor-heading {
  border-top: 1px solid var(--line);
}

.section-heading h2,
.editor-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.section-heading p,
.editor-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px 16px;
  padding: 18px 22px 22px;
}

.field {
  min-width: 0;
}

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

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fbfdff;
  outline: none;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 106, 99, 0.13);
}

.number-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.number-button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 12px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}

.number-button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.number-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.field textarea[readonly],
.field input[readonly] {
  color: #475569;
  background: #eef4f7;
  cursor: default;
}

.field textarea[readonly]:focus,
.field input[readonly]:focus {
  border-color: var(--line);
  box-shadow: none;
}

.recipient-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdff;
}

.fixed-line {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: var(--soft);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}

.recipient-option {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.recipient-option input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
}

.add-recipient-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  margin-top: 10px;
}

.add-button {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
}

.add-button:hover {
  background: #075d93;
}

.add-recipient-row + textarea {
  margin-top: 10px;
}

.suggestion-list {
  display: grid;
  gap: 6px;
  max-height: 210px;
  overflow: auto;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  box-shadow: 0 12px 24px rgba(24, 33, 47, 0.12);
}

.suggestion-list[hidden] {
  display: none;
}

.suggestion-item {
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: #f1f7fb;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.suggestion-item:hover,
.suggestion-item:focus {
  background: #dfeef7;
  outline: none;
}

.field-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.document-presentation {
  padding: 20px 48px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
  color: #111827;
  font-family: "Times New Roman", Times, serif;
  font-size: 16px;
  line-height: 1.35;
}

.presentation-top {
  display: grid;
  grid-template-columns: minmax(260px, 0.88fr) minmax(390px, 1.12fr);
  gap: 28px;
  align-items: start;
}

.presentation-agency,
.presentation-national {
  display: grid;
  justify-items: center;
  text-align: center;
  min-width: 0;
}

.presentation-agency p,
.presentation-agency strong,
.presentation-national strong {
  margin: 0;
  max-width: 100%;
  letter-spacing: 0;
  overflow-wrap: normal;
}

.presentation-national strong:first-child,
.presentation-agency strong {
  font-weight: 700;
}

.presentation-national strong:first-child {
  white-space: nowrap;
  font-size: 15.5px;
}

.presentation-agency strong {
  text-transform: uppercase;
}

.presentation-rule {
  display: block;
  width: 42%;
  min-width: 116px;
  border-bottom: 1px solid #111827;
  margin-top: 6px;
}

.presentation-meta {
  display: grid;
  grid-template-columns: minmax(260px, 0.95fr) minmax(320px, 1.05fr);
  gap: 28px;
  margin-top: 20px;
}

.presentation-meta > div {
  min-width: 0;
  text-align: center;
  overflow-wrap: anywhere;
}

#presentationDate {
  font-style: italic;
}

.presentation-subject-wrap {
  display: grid;
  justify-items: center;
  gap: 5px;
  max-width: 780px;
  margin: 22px auto 0;
  text-align: center;
}

.presentation-type-title {
  font-size: 21px;
  font-weight: 700;
  text-transform: uppercase;
}

.presentation-subject {
  max-width: 720px;
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.presentation-title-rule {
  display: block;
  width: 220px;
  border-bottom: 1px solid #111827;
  margin-top: 4px;
}

.presentation-recipient {
  max-width: 760px;
  margin: 20px auto 0;
  text-align: center;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.presentation-authority {
  max-width: 760px;
  margin: 18px auto 0;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.doc-type-cong-van .presentation-type-title {
  display: none;
}

.doc-type-cong-van .presentation-subject-wrap {
  justify-items: start;
  max-width: none;
  margin: 14px 0 0;
  text-align: center;
}

.doc-type-cong-van .presentation-subject {
  width: min(360px, 44%);
  max-width: 360px;
  font-size: 16px;
  font-weight: 400;
}

.doc-type-cong-van .presentation-title-rule {
  display: none;
}

.doc-type-cong-van .presentation-recipient {
  margin: -34px 0 0 auto;
  width: min(520px, 52%);
  text-align: left;
  font-size: 16px;
}

.doc-type-quyet-dinh .presentation-recipient,
.doc-type-thong-bao .presentation-recipient {
  display: none;
}

.doc-type-quyet-dinh .presentation-subject-wrap {
  max-width: 760px;
}

.doc-type-quyet-dinh .presentation-subject {
  font-size: 18px;
}

.toolbar {
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.ql-toolbar.ql-snow {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border: 0;
  padding: 10px 14px;
}

.ql-toolbar.ql-snow .ql-formats {
  display: inline-flex;
  align-items: center;
  margin: 0 4px 0 0;
}

.ql-snow .ql-picker {
  color: var(--ink);
}

.editor {
  min-height: 56vh;
}

.ql-container.ql-snow {
  border: 0;
  font-family: "Times New Roman", Times, serif;
  font-size: 17px;
}

.ql-editor {
  min-height: 56vh;
  padding: 28px 48px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.after-content-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 18px 48px 8px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.web-document-footer {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(280px, 1.05fr);
  gap: 28px;
  align-items: start;
  padding: 18px 48px 28px;
  background: #fff;
}

.footer-recipient-field,
.signature-panel {
  min-width: 0;
}

.signature-panel {
  display: grid;
  gap: 14px;
  justify-self: stretch;
  padding-top: 2px;
}

.signature-panel .field label,
.signature-panel .field-hint {
  text-align: center;
}

.signature-panel select,
.signature-panel input,
.signature-panel textarea {
  text-align: center;
  font-weight: 700;
}

.ql-editor h1,
.ql-editor h2,
.ql-editor h3 {
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.status {
  min-height: 28px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.status.ok {
  color: var(--success);
}

.status.error {
  color: var(--danger);
}

.status a {
  color: inherit;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .presentation-top,
  .presentation-meta {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .presentation-national strong:first-child {
    white-space: normal;
  }
}

@media (max-width: 980px) {
  .metadata-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .document-presentation {
    padding-left: 24px;
    padding-right: 24px;
  }

  .hero-content {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .hero-logo {
    width: 82px;
    height: 82px;
  }

  .save-button {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (max-width: 680px) {
  .workspace {
    width: min(100% - 20px, 1220px);
    padding-top: 10px;
  }

  .app-hero {
    min-height: 0;
  }

  .hero-content {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 12px;
    min-height: 0;
    padding: 18px;
  }

  .hero-logo {
    width: 64px;
    height: 64px;
    border-width: 3px;
  }

  h1 {
    font-size: 22px;
  }

  .hero-copy p:last-child {
    font-size: 13px;
  }

  .save-button {
    width: 100%;
  }

  .metadata-grid {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .number-row {
    grid-template-columns: 1fr;
  }

  .document-presentation {
    padding: 16px 14px;
    font-size: 15px;
  }

  .presentation-top,
  .presentation-meta {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .presentation-subject-wrap,
  .doc-type-cong-van .presentation-subject-wrap {
    justify-items: center;
    max-width: none;
    margin-top: 16px;
    text-align: center;
  }

  .doc-type-cong-van .presentation-subject,
  .doc-type-cong-van .presentation-recipient {
    width: 100%;
    max-width: none;
    margin: 0;
    text-align: center;
  }

  .section-heading,
  .editor-heading {
    padding: 14px;
  }

  .ql-toolbar.ql-snow {
    padding: 8px;
  }

  .ql-toolbar.ql-snow .ql-formats {
    margin-right: 0;
  }

  .ql-editor {
    min-height: 64vh;
    padding: 20px 16px;
    font-size: 16px;
  }

  .after-content-layout,
  .web-document-footer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .web-document-footer {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .signature-panel .field label,
  .signature-panel .field-hint,
  .signature-panel select,
  .signature-panel input,
  .signature-panel textarea {
    text-align: left;
  }
}
