/* History, exports, and legal-data update center. */

.page-header {
  align-items: flex-start;
}

.page-header-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.page-header-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.page-header-tools.data-updates-hidden {
  display: none;
}

.header-tool-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #e0e3e7;
  border-radius: 12px;
  padding: 9px 12px;
  color: #4d555d;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.header-tool-button:hover {
  border-color: #cbd4dd;
  background: #f8fafc;
}

.header-tool-button:focus-visible,
.workbench-close:focus-visible,
.history-action:focus-visible {
  outline: 2px solid #2f8cff;
  outline-offset: 2px;
}

.header-tool-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  color: #2b6fae;
  background: #edf5fc;
  font-size: 13px;
  font-weight: 700;
}

.data-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa1a8;
  box-shadow: 0 0 0 3px #f0f1f2;
}

.header-tool-button[data-tone="success"] .data-status-dot {
  background: #2f9461;
  box-shadow: 0 0 0 3px #e8f5ed;
}

.header-tool-button[data-tone="attention"] .data-status-dot {
  background: #d28b22;
  box-shadow: 0 0 0 3px #fff2dc;
}

.header-tool-button[data-tone="danger"] .data-status-dot {
  background: #c44238;
  box-shadow: 0 0 0 3px #fce9e7;
}

.header-count {
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  padding: 0 6px;
  color: #2871b5;
  background: #edf5fc;
  font-size: 13px;
}

.header-count:empty {
  display: none;
}

body.workbench-open {
  overflow: hidden;
}

.workbench-overlay {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  padding-left: 24px;
  background: rgba(27, 34, 40, .34);
  backdrop-filter: blur(2px);
}

.workbench-overlay[hidden] {
  display: none;
}

.workbench-drawer {
  width: min(720px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: -18px 0 48px rgba(28, 39, 49, .16);
  animation: workbench-slide-in .18s ease-out;
}

.update-drawer {
  width: min(680px, 100%);
}

.history-drawer {
  width: min(720px, 100%);
}

@keyframes workbench-slide-in {
  from { transform: translateX(24px); opacity: .75; }
  to { transform: translateX(0); opacity: 1; }
}

.workbench-drawer-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 17px 22px;
  border-bottom: 1px solid #eceef0;
}

.workbench-drawer-header span {
  display: block;
  margin-bottom: 3px;
  color: #75808a;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.workbench-drawer-header h2 {
  margin: 0;
  color: #26313a;
  font-size: 20px;
  line-height: 1.2;
}

.workbench-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 0;
  border-radius: 10px;
  color: #606870;
  background: #f2f4f5;
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}

.workbench-close:hover {
  color: #26313a;
  background: #e8ebed;
}

.workbench-drawer-body {
  flex: 1 1 auto;
  padding: 21px 22px 32px;
  overflow-y: auto;
}

.workbench-progress {
  margin: 14px 22px 0;
  padding: 10px 12px;
  border-radius: 11px;
  color: #3c637e;
  background: #edf6fc;
  font-size: 13px;
  line-height: 1.45;
}

.workbench-progress[data-tone="success"] {
  color: #236343;
  background: #eaf7ef;
}

.workbench-progress[data-tone="danger"] {
  color: #922d27;
  background: #fcecea;
}

.workbench-loading {
  margin: 45px 0;
  color: #868d94;
  text-align: center;
  font-size: 13px;
}

.update-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding: 17px 18px;
  border: 1px solid #dce7ef;
  border-radius: 16px;
  background: linear-gradient(135deg, #f3f8fc, #fbfcfd);
}

.update-summary > div > span {
  color: #4380aa;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.update-summary h2 {
  margin: 4px 0 5px;
  font-size: 18px;
}

.update-summary p {
  max-width: 520px;
  margin: 0;
  color: #68737c;
  font-size: 13px;
  line-height: 1.5;
}

.update-generated {
  flex: 0 0 auto;
  color: #77818a;
  font-size: 13px;
  white-space: nowrap;
}

.update-dataset-list {
  display: grid;
  gap: 12px;
}

.update-dataset-card {
  border: 1px solid #e1e4e7;
  border-radius: 16px;
  padding: 16px 17px;
  background: #fff;
}

.update-dataset-card[data-tone="attention"] {
  border-color: #efd29e;
  box-shadow: 0 4px 18px rgba(132, 91, 25, .06);
}

.update-dataset-card[data-tone="danger"] {
  border-color: #efc5c1;
}

.update-dataset-heading,
.update-dataset-heading > div {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.update-dataset-heading {
  justify-content: space-between;
}

.update-status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  margin-top: 5px;
  border-radius: 50%;
  background: #8f999f;
}

.update-dataset-card[data-tone="success"] .update-status-dot { background: #3c9a68; }
.update-dataset-card[data-tone="attention"] .update-status-dot { background: #d28b22; }
.update-dataset-card[data-tone="danger"] .update-status-dot { background: #c44238; }

.update-dataset-heading h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

.update-dataset-heading p {
  margin: 3px 0 0;
  color: #858d94;
  font-size: 13px;
}

.update-version {
  flex: 0 0 auto;
  border-radius: 8px;
  padding: 5px 7px;
  color: #476b85;
  background: #eef4f8;
  font-size: 13px;
}

.update-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 13px 0 0;
}

.update-meta div {
  padding: 9px 10px;
  border-radius: 10px;
  background: #f7f8f9;
}

.update-meta dt {
  color: #8b9298;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.update-meta dd {
  margin: 4px 0 0;
  color: #465058;
  font-size: 13px;
  line-height: 1.4;
}

.update-error {
  margin-top: 11px;
  padding: 9px 10px;
  border-radius: 10px;
  color: #912d27;
  background: #fcecea;
  font-size: 13px;
  line-height: 1.45;
}

.update-dataset-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid #eceef0;
}

.update-dataset-footer > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.update-dataset-footer > a,
.update-dataset-footer > span {
  color: #4779a2;
  font-size: 13px;
  text-decoration: none;
}

.update-dataset-footer > a:hover { text-decoration: underline; }

.primary-button.compact,
.secondary-button.compact,
.text-button.compact {
  min-height: 32px;
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 13px;
}

.secondary-button {
  border: 1px solid #cfd8e0;
  color: #356d99;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}

.secondary-button:hover { background: #f5f9fc; }
.secondary-button:disabled,
.primary-button:disabled { opacity: .6; cursor: wait; }

.update-manual-label {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  color: #7b838a;
  font-size: 13px;
}

.update-candidate {
  margin-top: 13px;
  padding: 12px 13px;
  border-radius: 12px;
  background: #fff7e8;
}

.update-candidate-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.update-candidate-heading span {
  display: block;
  color: #8e743e;
  font-size: 13px;
  text-transform: uppercase;
}

.update-candidate-heading strong {
  display: block;
  margin-top: 3px;
  color: #574527;
  font-size: 13px;
}

.update-candidate-badge {
  border-radius: 999px;
  padding: 5px 7px;
  color: #805d1d !important;
  background: #ffe9be;
  font-weight: 650;
  white-space: nowrap;
}

.update-change-table {
  margin-top: 10px;
  border: 1px solid #efdbb4;
  border-radius: 9px;
  overflow: hidden;
}

.update-change-table > div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 7px 9px;
  color: #604e2d;
  background: rgba(255, 255, 255, .56);
  font-size: 13px;
}

.update-change-table > div + div { border-top: 1px solid #efdbb4; }
.update-change-table .update-change-head { color: #8c7548; background: #fcebc9; font-size: 13px; text-transform: uppercase; }
.update-change-table strong { font-size: 13px; }

.update-candidate-empty {
  margin: 9px 0 0;
  color: #765f34;
  font-size: 13px;
  line-height: 1.45;
}

.update-candidate-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.update-candidate-actions small {
  color: #8b754d;
  font-size: 13px;
  line-height: 1.4;
}

.update-audit {
  margin-top: 15px;
  padding: 0 14px 13px;
  border: 1px solid #e4e7e9;
  border-radius: 13px;
}

.update-audit summary {
  padding-top: 13px;
  color: #54738b;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.update-audit-list {
  margin: 11px 0 0;
  padding: 0;
  list-style: none;
}

.update-audit-list li {
  display: grid;
  grid-template-columns: 118px 1fr auto;
  gap: 9px;
  padding: 7px 0;
  border-top: 1px solid #eceef0;
  font-size: 13px;
}

.update-audit-list span { color: #899198; }
.update-audit-list strong { color: #48535b; }
.update-audit-list em { color: #71808a; font-style: normal; }
.update-empty-audit { margin: 12px 0 0; color: #8a9299; font-size: 13px; }

.result-workbench-actions {
  position: relative;
  z-index: 8;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 9px;
  margin: 0 0 15px;
}

.productivity-action {
  min-height: 42px;
  border: 1px solid #d9dfe4;
  border-radius: 11px;
  padding: 9px 13px;
  color: #4c5963;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.productivity-action:hover {
  border-color: #bfcbd5;
  background: #f7fafc;
}

.productivity-action.save {
  border-color: #2f8cff;
  color: #fff;
  background: #2f8cff;
}

.productivity-action.save:hover {
  border-color: #1674e8;
  background: #1674e8;
}

.productivity-action:focus-visible,
.productivity-menu-list button:focus-visible {
  outline: 2px solid #2f8cff;
  outline-offset: 2px;
}

.productivity-menu {
  position: relative;
}

.productivity-menu-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  width: 270px;
  padding: 8px;
  border: 1px solid #dde2e6;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(31, 43, 55, .16);
}

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

.productivity-menu-list button {
  width: 100%;
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 10px;
  border: 0;
  border-radius: 10px;
  padding: 11px 12px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.productivity-menu-list button:hover { background: #f2f7fb; }
.productivity-menu-list button:disabled { opacity: .62; cursor: wait; }
.productivity-menu-list strong { color: #326d9c; font-size: 14px; line-height: 1.4; }
.productivity-menu-list span { color: #727d85; font-size: 13px; line-height: 1.45; }

.history-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 15px;
  padding: 15px 22px;
  border-bottom: 1px solid #eceef0;
  background: #fafbfc;
}

.history-search {
  flex: 1 1 320px;
}

.history-search > span {
  display: block;
  margin-bottom: 5px;
  color: #6f7880;
  font-size: 13px;
  font-weight: 600;
}

.history-search input {
  min-height: 34px;
  border-radius: 10px;
  font-size: 13px;
}

.history-backup-actions {
  display: flex;
  gap: 7px;
}

.history-status {
  margin-top: 12px;
}

.history-list {
  display: grid;
  align-content: start;
  gap: 11px;
}

.history-card {
  padding: 15px 16px;
  border: 1px solid #e0e4e7;
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(31, 43, 55, .035);
}

.history-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
}

.history-card-heading > div > span {
  color: #3778aa;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.history-card-heading h3 {
  margin: 4px 0 0;
  color: #2d373f;
  font-size: 14px;
  line-height: 1.4;
}

.history-card-heading time {
  flex: 0 0 auto;
  color: #92999f;
  font-size: 13px;
}

.history-card-meta {
  margin: 8px 0 0;
  color: #626e77;
  font-size: 13px;
}

.history-card-note {
  margin: 7px 0 0;
  color: #7b838a;
  font-size: 13px;
  line-height: 1.45;
}

.history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.history-tags span {
  border-radius: 999px;
  padding: 4px 7px;
  color: #617482;
  background: #f0f4f6;
  font-size: 13px;
}

.history-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid #eceef0;
}

.history-action {
  min-height: 30px;
  border: 1px solid #d8dee3;
  border-radius: 8px;
  padding: 6px 9px;
  color: #59656e;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.history-action:hover { background: #f6f8fa; }
.history-action.primary { border-color: #d3e3f2; color: #2670aa; background: #edf6fc; }
.history-action.danger { margin-left: auto; border-color: transparent; color: #a6443d; }

.history-empty {
  margin: 52px auto;
  color: #7f888f;
  text-align: center;
}

.history-empty strong {
  display: block;
  color: #4c5962;
  font-size: 14px;
}

.history-empty p {
  max-width: 340px;
  margin: 7px 0 0;
  font-size: 13px;
  line-height: 1.5;
}

.save-backdrop {
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.save-dialog {
  width: min(590px, 100%);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 20px 55px rgba(24, 34, 43, .2);
}

.save-dialog form {
  display: grid;
  gap: 15px;
  padding: 20px 22px 22px;
}

.save-dialog .field > span {
  display: block;
  margin-bottom: 6px;
  color: #424b52;
  font-size: 13px;
}

.save-dialog .field small {
  color: #8a9298;
  font-weight: 400;
}

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

.save-local-note {
  margin: 0;
  padding: 10px 11px;
  border-radius: 10px;
  color: #637684;
  background: #f2f7fa;
  font-size: 13px;
  line-height: 1.45;
}

.save-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 2px;
}

/* Readable, compact drawers for data status and saved calculations. */
.workbench-drawer-header > div > span,
.update-summary > div > span,
.update-generated {
  font-size: 13px;
  line-height: 1.4;
}

.workbench-drawer-header h2 {
  font-size: 22px;
}

.update-summary {
  gap: 18px;
  padding: 15px 16px;
}

.update-summary h2 {
  font-size: 20px;
}

.update-summary p {
  font-size: 14px;
  line-height: 1.55;
}

.update-dataset-card {
  padding: 15px 16px;
}

.update-dataset-heading h3 {
  font-size: 16px;
}

.update-dataset-heading p,
.update-version,
.update-meta dt,
.update-dataset-footer > a,
.update-dataset-footer > span,
.update-manual-label,
.update-candidate-heading span,
.update-change-table > div,
.update-candidate-empty,
.update-candidate-actions small,
.update-audit summary,
.update-audit-list li,
.update-empty-audit {
  font-size: 13px;
  line-height: 1.45;
}

.update-meta {
  grid-template-columns: repeat(2, minmax(0, 220px));
}

.update-meta dd,
.update-error,
.update-candidate-heading strong {
  font-size: 13px;
  line-height: 1.5;
}

.primary-button.compact,
.secondary-button.compact,
.text-button.compact {
  min-height: 36px;
  padding: 8px 11px;
  font-size: 13px;
}

.history-search > span {
  font-size: 13px;
}

.history-search input {
  min-height: 40px;
  font-size: 14px;
}

.history-card-heading > div > span,
.history-card-heading time,
.history-tags span {
  font-size: 13px;
  line-height: 1.4;
}

.history-card-heading h3 {
  font-size: 16px;
}

.history-card-meta,
.history-card-note {
  font-size: 13px;
  line-height: 1.5;
}

.history-action {
  min-height: 36px;
  padding: 8px 11px;
  font-size: 13px;
}

.history-empty strong {
  font-size: 16px;
}

.history-empty p {
  font-size: 13px;
}

@media (max-width: 900px) {
  .page-header {
    flex-wrap: wrap;
  }

  .page-header-tools {
    width: 100%;
    margin-left: 34px;
  }
}

@media (max-width: 620px) {
  .page-header-tools {
    margin-left: 0;
    overflow-x: auto;
  }

  .header-tool-button {
    min-height: 44px;
    padding: 7px 9px;
    font-size: 13px;
  }

  .workbench-overlay {
    padding-left: 0;
    height: 100vh;
    height: 100dvh;
  }

  .workbench-drawer {
    height: 100vh;
    height: 100dvh;
  }

  .workbench-drawer-header,
  .workbench-drawer-body {
    padding-left: 15px;
    padding-right: 15px;
  }

  .workbench-drawer-header {
    padding-top: max(17px, env(safe-area-inset-top));
  }

  .workbench-drawer-body {
    padding-bottom: max(32px, env(safe-area-inset-bottom));
  }

  .workbench-progress {
    margin-left: 15px;
    margin-right: 15px;
  }

  .update-summary,
  .update-dataset-footer,
  .update-candidate-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .update-generated {
    white-space: normal;
  }

  .update-meta {
    grid-template-columns: 1fr;
  }

  .update-audit-list li {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .history-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding-left: 15px;
    padding-right: 15px;
  }

  .history-search {
    flex-basis: auto;
  }

  .history-backup-actions {
    flex-wrap: wrap;
  }

  .history-card-heading {
    flex-direction: column;
    gap: 6px;
  }

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

  .result-workbench-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .result-workbench-actions .productivity-menu {
    position: static;
  }

  .result-workbench-actions .productivity-menu-list {
    left: 0;
    right: auto;
    width: min(270px, 100%);
  }

  .productivity-action {
    min-height: 44px;
  }

  .workbench-close,
  .history-action,
  .primary-button.compact,
  .secondary-button.compact,
  .text-button.compact {
    min-width: 44px;
    min-height: 44px;
  }

  .save-backdrop {
    padding: 12px;
  }

  .save-dialog {
    max-height: calc(100dvh - 24px);
  }
}

@media print {
  @page {
    margin: 15mm 13mm;
  }

  body {
    min-width: 0;
    color: #111;
    background: #fff;
  }

  .sidebar,
  .page-header,
  .form-grid,
  .form-actions,
  .error-box,
  .sidebar-backdrop,
  .workbench-overlay,
  footer,
  .copy-button,
  .result-workbench-actions {
    display: none !important;
  }

  .app-shell {
    display: block;
    min-height: 0;
  }

  .workspace,
  .calculator-panel,
  .result-area {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .result-card,
  .publication-result,
  .bankruptcy-result,
  .auction-result {
    border: 0 !important;
    box-shadow: none !important;
    break-inside: auto;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    width: 100%;
    font-size: 10pt;
  }

  tr {
    break-inside: avoid;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}
