body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f0f0;
}

.container {
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
}

.heading {
    text-align: center;
    margin-bottom: 20px;
}

.heading h1 {
    font-size: 24px;
    margin: 0;
    color: #333;
}

h2 {
    font-size: 20px;
    margin: 20px 0 10px;
    color: #555;
}

h3 {
    font-size: 18px;
    margin: 10px 0 5px;
    color: #666;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 15px;
    justify-content: space-between;
}

.form-group {
    flex-basis: calc(33.33% - 10px);
    padding: 0 10px;
    box-sizing: border-box;
    margin: 5px;
}

.form-group label {
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 14px;
    font-family: Arial, sans-serif;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #007bff;
    outline: none;
}

textarea {
    height: 100px;
    resize: vertical;
}

button,
.file-button,
input[type="submit"] {
    display: inline-block;
    padding: 5px 10px;
    margin: 4px;
    border: 1px solid #aaa;
    border-radius: 3px;
    background-color: #e9e9ef;
    color: #222;
    font-size: 14px;
    font-family: Arial, sans-serif;
    cursor: pointer;
}

.file-button input {
    display: none;
}

#documentDescription {
    color: #666;
    margin: 10px 5px;
}

#status {
    margin-top: 20px;
    padding: 12px;
    min-height: 32px;
    background-color: #eee;
    word-break: break-word;
}

#status a {
    font-weight: bold;
    color: #0645ad;
}

.json-section {
    margin-top: 10px;
}

.json-section details {
    margin: 10px 0;
}

.json-section summary {
    font-size: 18px;
    margin: 10px 0 8px;
    color: #666;
    font-weight: bold;
    cursor: pointer;
}

.json-section h2 {
    font-size: 20px;
    margin: 20px 0 10px;
    color: #555;
}

.json-section h3,
.json-section h4 {
    font-size: 18px;
    margin: 10px 0 5px;
    color: #666;
}

.document-picker {
    margin: 10px 0 18px;
    padding: 12px;
    background: #f7f7f7;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.document-picker h3 {
    margin: 8px 0 6px;
    color: #555;
}

.picker-list {
    margin-bottom: 10px;
}

.picker-item {
    display: block;
    width: 100%;
    text-align: left;
    margin: 4px 0;
    padding: 7px 10px;
}

.picker-item.active {
    border-color: #6b35ff;
    outline: 2px solid #6b35ff;
    background: #f1edff;
}

.uploaded-json-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.uploaded-json-load {
    flex: 1;
}

.delete-json-button {
    flex: 0 0 34px;
    width: 34px;
    text-align: center;
    color: #8a0000;
    font-weight: bold;
}

.picker-empty {
    color: #777;
    font-style: italic;
    padding: 4px 0 8px;
}

.dropdown-picker {
    position: relative;
    margin: 10px 0 18px;
    padding: 0;
    background: transparent;
    border: none;
}

.document-picker-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 300px;
    text-align: left;
    padding: 8px 10px;
    margin: 4px 0;
    border: 1px solid #999;
    border-radius: 4px;
    background: #e9e9ef;
    font-size: 14px;
}

.document-picker-toggle.open {
    border-color: #6b35ff;
    outline: 2px solid #6b35ff;
}

.dropdown-arrow {
    margin-left: 12px;
    font-size: 12px;
}

.document-picker-menu {
    display: none;
    position: absolute;
    z-index: 1000;
    width: 420px;
    max-height: 420px;
    overflow-y: auto;
    margin-top: 4px;
    padding: 12px;
    background: #f7f7f7;
    border: 1px solid #bbb;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.document-picker-menu.open {
    display: block;
}

.document-picker-menu h3 {
    margin: 8px 0 6px;
    color: #555;
}

.picker-list {
    margin-bottom: 10px;
}

.picker-item {
    display: block;
    width: 100%;
    text-align: left;
    margin: 4px 0;
    padding: 7px 10px;
}

.picker-item.active {
    border-color: #6b35ff;
    outline: 2px solid #6b35ff;
    background: #f1edff;
}

.uploaded-json-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.uploaded-json-load {
    flex: 1;
}

.delete-json-button {
    flex: 0 0 34px;
    width: 34px;
    text-align: center;
    color: #8a0000;
    font-weight: bold;
}

.picker-empty {
    color: #777;
    font-style: italic;
    padding: 4px 0 8px;
}

.app-header {
    background: #333;
    color: #fff;
    padding: 10px 0;
}

.app-header-inner {
    max-width: 840px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-title {
    font-size: 18px;
    font-weight: bold;
}

.app-nav {
    display: flex;
    gap: 6px;
}

.nav-button {
    background: #555;
    color: #fff;
    border: 1px solid #777;
}

.nav-button.active {
    background: #007bff;
    border-color: #007bff;
}

.app-view {
    display: none;
}

.app-view.active {
    display: block;
}

.main-page-content {
    min-height: 180px;
    padding: 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fafafa;
    line-height: 1.5;
}

.main-page-content:focus {
    border-color: #007bff;
    outline: none;
}

.home-actions {
    margin-top: 12px;
}

.tool-launch-link {
    display: inline-block;
    padding: 8px 12px;
    background: #007bff;
    color: #fff;
    border-radius: 5px;
    text-decoration: none;
}

.tool-launch-link:hover {
    background: #0056b3;
}

.tool-button-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
    margin: 10px 0 18px;
}

.tool-action-button,
button.tool-action-button,
label.tool-action-button {
    width: 125px;
    height: 34px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    margin: 0;
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
    text-align: center;
}

.file-button.tool-action-button input {
    display: none;
}

@media (max-width: 760px) {
    .tool-button-row {
        gap: 5px;
    }

    .tool-action-button,
    button.tool-action-button,
    label.tool-action-button {
        width: 118px;
        font-size: 12px;
        padding: 5px 6px;
    }
}



body.app-loading .container {
    opacity: 0;
}

.container {
    transition: opacity 120ms ease-out;
}

.tool-button-row {
    overflow-x: auto;
    padding-bottom: 2px;
}

.tool-action-button,
button.tool-action-button,
label.tool-action-button {
    flex: 0 0 120px;
}

.excel-transfer-row {
    display: flex;
    align-items: end;
    gap: 10px;
    margin: 12px 0 22px 0;
    flex-wrap: wrap;
}

.excel-transfer-row label {
    font-weight: 700;
}

.excel-transfer-row select {
    min-width: 260px;
    flex: 1 1 260px;
}

.excel-transfer-row .tool-action-button {
    height: 34px;
}

#exportExcelButton:not(:disabled) {
    cursor: pointer;
    opacity: 1;
}

#exportExcelButton:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.native-hidden-select {
    display: none !important;
}

.excel-transfer-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin: 12px 0 14px 0;
    flex-wrap: wrap;
}

.template-picker-row {
    margin: 0 0 22px 0;
}

.custom-select-block {
    flex: 1 1 320px;
    min-width: 260px;
}

.custom-select-block label {
    display: block;
    font-weight: 700;
    margin-bottom: 5px;
}

.custom-picker {
    position: relative;
    width: 100%;
}

.custom-picker-button {
    width: 100%;
    min-height: 36px;
    text-align: left;
    padding: 7px 34px 7px 10px;
    border: 1px solid #bbb;
    border-radius: 4px;
    background: #fff;
    color: #111;
    font: inherit;
    cursor: pointer;
    position: relative;
}

.custom-picker-button::after {
    content: "▾";
    position: absolute;
    right: 10px;
    top: 7px;
    color: #444;
}

.custom-picker-menu {
    display: none;
    position: absolute;
    z-index: 50;
    left: 0;
    right: 0;
    top: calc(100% + 3px);
    max-height: 340px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #aaa;
    border-radius: 4px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}

.custom-picker.open .custom-picker-menu {
    display: block;
}

.custom-picker-group-label {
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 700;
    color: #555;
    background: #f1f1f1;
    border-bottom: 1px solid #ddd;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.custom-picker-option {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-bottom: 1px solid #eee;
    background: #fff;
    text-align: left;
    font: inherit;
    color: #111;
    cursor: pointer;
}

.custom-picker-option:hover,
.custom-picker-option.selected {
    background: #eaf2ff;
}

#downloadExcelTemplateButton,
#exportExcelButton {
    flex: 0 0 145px;
}

.excel-transfer-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin: 14px 0 18px 0;
    flex-wrap: wrap;
}

.excel-map-block {
    flex: 1 1 360px;
    min-width: 260px;
}

.template-picker-row {
    margin: 0 0 22px 0;
}

.template-picker-row label,
.excel-map-block label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}

.styled-select {
    width: 100%;
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid #999;
    border-radius: 4px;
    background: #fff;
    color: #111;
    font: inherit;
}

#downloadExcelTemplateButton,
#exportExcelButton,
.excel-transfer-row .file-button {
    flex: 0 0 auto;
    min-height: 38px;
}

.document-type-caption {
  font-size: 0.82rem;
  color: #8a8a8a;
  margin-top: 6px;
  margin-bottom: 14px;
  line-height: 1.3;
}

.excel-transfer-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0 18px 0;
}

.select-block {
  flex: 1 1 340px;
  min-width: 260px;
}

.template-picker-row {
  margin: 0 0 22px 0;
}

.template-picker-row label,
.select-block label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.uploaded-template-manager {
  margin-top: 10px;
  border-top: 1px solid #ddd;
  padding-top: 10px;
}

.uploaded-template-manager-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.uploaded-template-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.uploaded-template-name {
  font-size: 0.92rem;
  color: #333;
  word-break: break-word;
}

.small-delete-button {
  border: 1px solid #bbb;
  background: #f7f7f7;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}

#downloadExcelTemplateButton,
#exportExcelButton,
.excel-transfer-row .file-button {
  min-height: 38px;
  flex: 0 0 auto;
}

/* unified dropdown styling */
#documentTypeSelect,
#excelMapSelect,
#legacyTemplateSelect {
  width: 100%;
  min-height: 38px;
  padding: 7px 34px 7px 10px;
  border: 1px solid #9f9f9f;
  border-radius: 4px;
  background-color: #eeeef4;
  color: #222;
  font: inherit;
  line-height: 1.25;
  box-sizing: border-box;
}

#documentTypeSelect {
  max-width: 390px;
}

#excelMapSelect {
  min-width: 0;
}

#legacyTemplateSelect {
  width: 100%;
}

/* small light-gray profile caption */
#documentTypeDescription,
.document-type-description,
.profile-description,
[data-role="document-type-description"] {
  font-size: 0.82rem !important;
  color: #8a8a8a !important;
  line-height: 1.3 !important;
  margin: 6px 0 14px 0 !important;
  font-weight: 400 !important;
}

/* tighter Excel row */
#excelTransferRow,
.excel-transfer-row {
  display: grid !important;
  grid-template-columns: minmax(260px, 1fr) auto auto auto;
  gap: 10px;
  align-items: end;
  margin: 12px 0 18px 0;
}

#excelTransferRow label,
.excel-transfer-row label {
  font-weight: 700;
  margin-bottom: 6px;
}

#excelTransferRow .file-button,
.excel-transfer-row .file-button,
#downloadExcelTemplateButton,
#exportExcelButton {
  min-height: 38px;
  white-space: nowrap;
}

/* template selector below Excel row */
#legacyTemplateRow,
.template-picker-row {
  margin: 0 0 22px 0;
}

#legacyTemplateRow label,
.template-picker-row label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

@media (max-width: 760px) {
  #excelTransferRow,
  .excel-transfer-row {
    grid-template-columns: 1fr;
  }

  #downloadExcelTemplateButton,
  #exportExcelButton,
  #excelTransferRow .file-button,
  .excel-transfer-row .file-button {
    width: 100%;
  }
}

.uploaded-template-manager {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #ddd;
}

.uploaded-template-manager-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #555;
  margin-bottom: 6px;
}

.uploaded-template-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 5px 0;
}

.uploaded-template-name {
  font-size: 0.86rem;
  color: #444;
  word-break: break-word;
}

.small-delete-button {
  border: 1px solid #bbb;
  background: #f6f6f6;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.8rem;
  cursor: pointer;
}


/* final legal UI overrides */
#documentTypeSelect,
#excelMapSelect,
#legacyTemplateSelect,
.same-dropdown-style {
  width: 100% !important;
  min-height: 38px !important;
  padding: 7px 34px 7px 10px !important;
  border: 1px solid #9f9f9f !important;
  border-radius: 4px !important;
  background-color: #eeeef4 !important;
  color: #222 !important;
  font: inherit !important;
  line-height: 1.25 !important;
  box-sizing: border-box !important;
}

#documentTypeSelect {
  max-width: 390px !important;
}

.legal-profile-caption {
  font-size: 0.82rem !important;
  color: #8a8a8a !important;
  line-height: 1.3 !important;
  margin: 6px 0 14px 0 !important;
  font-weight: 400 !important;
}

#excelTransferRow,
.excel-transfer-row {
  display: grid !important;
  grid-template-columns: minmax(260px, 1fr) auto auto auto !important;
  gap: 10px !important;
  align-items: end !important;
  margin: 12px 0 18px 0 !important;
}

#legacyTemplateRow,
.template-picker-row {
  margin: 0 0 22px 0 !important;
}

.uploaded-template-manager {
  margin-top: 10px !important;
  padding-top: 10px !important;
  border-top: 1px solid #ddd !important;
}

.uploaded-template-manager-title {
  font-size: 0.85rem !important;
  font-weight: 700 !important;
  color: #555 !important;
  margin-bottom: 6px !important;
}

.uploaded-template-row {
  display: flex !important;
  justify-content: space-between !important;
  gap: 10px !important;
  align-items: center !important;
  padding: 5px 0 !important;
}

.uploaded-template-name {
  font-size: 0.86rem !important;
  color: #444 !important;
  word-break: break-word !important;
}

.small-delete-button {
  border: 1px solid #bbb !important;
  background: #f6f6f6 !important;
  border-radius: 4px !important;
  padding: 4px 8px !important;
  font-size: 0.8rem !important;
  cursor: pointer !important;
}

@media (max-width: 760px) {
  #excelTransferRow,
  .excel-transfer-row {
    grid-template-columns: 1fr !important;
  }
}
