[data-panel="history"] {
  --history-warm: #fbf8ef;
  --history-brown: #963100;
  --history-line: #e3e1da;
  color: #202020;
}
.history-filters {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 20px;
}
.history-filters label {
  font-size: 13px;
  margin: 0;
  width: 160px;
  color: #535a64;
}
.history-filters input,
.history-filters select {
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 7px;
  font-size: 13px;
}
.history-filter-actions {
  display: flex;
  gap: 8px;
}
.history-search,
.history-save {
  background: #963100;
  color: white;
  border-radius: 10px;
  padding: 9px 18px;
  border: 1px solid #963100;
  min-height: 36px;
}
.history-search:hover,
.history-save:hover {
  background: #7c2800;
}
.history-button {
  border: 1px solid #e0ded7;
  border-radius: 9px;
  background: #fbf9f3;
  padding: 7px 13px;
  min-height: 34px;
  color: #272727;
}
.history-button:hover {
  background: #f3efe5;
}
.history-count {
  margin-left: auto;
  font-size: 12px;
  color: #737a84;
  padding-bottom: 9px;
}
.history-panel {
  background: white;
  border: 1px solid #deded9;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 2px 8px #00000005;
}
.history-scroll {
  overflow: auto;
}
.history-table {
  width: 100%;
  min-width: 1170px;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
  text-align: left;
  color: #222;
}
.history-table th {
  padding: 24px 16px 14px;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 1px solid #ddd;
  background: #fff;
}
.history-table td {
  padding: 16px;
  border-bottom: 1px solid #dfdfdb;
  vertical-align: middle;
  line-height: 1.6;
}
.history-table tbody tr:nth-child(even) {
  background: #f8f7f3;
}
.history-table tbody tr:last-child td {
  border-bottom: 0;
}
.history-table tbody tr:hover {
  background: #f5f8fc;
}
.history-issue {
  font-weight: 500;
}
.history-lottery-name {
  display: block;
  color: #8b8b87;
  font-size: 11px;
  margin-top: 3px;
}
.history-table .status-pill {
  font-size: 12px;
  background: #e1faef;
  color: #1b8757;
  padding: 3px 8px;
  border-radius: 3px;
}
.history-table .status-pill.pending {
  background: #eef4ff;
  color: #567cc1;
}
.history-table .status-pill.cancelled {
  background: #eee;
  color: #888;
}
.history-ball-grid {
  display: grid;
  grid-template-columns: repeat(3, 32px);
  gap: 10px 5px;
  width: max-content;
}
.history-number {
  display: flex;
  align-items: center;
  flex-direction: column;
  line-height: 1.1;
  gap: 4px;
  font-size: 12px;
  text-align: center;
  min-width: 32px;
}
.history-ball {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fa2945;
  color: #fff;
  font:
    600 13px/1 Arial,
    sans-serif;
}
.history-ball.blue {
  background: #2e7cf5;
}
.history-ball.green {
  background: #00c56b;
}
.history-number small {
  font-size: 12px;
  color: #303030;
}
.history-no-result {
  color: #939798;
  font-size: 12px;
  white-space: normal;
  max-width: 120px;
}
.history-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.history-edit-button {
  border: 1px solid #e0dfda;
  border-radius: 9px;
  background: #fff;
  padding: 4px 10px;
  color: #272727;
  font-size: 12px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.history-edit-button:hover {
  background: #f1eee7;
}
.history-delete-button {
  background: #cb0b2d;
  color: #fff;
  border-radius: 9px;
  padding: 7px 14px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.history-row-actions .history-delete-button {
  width: 36px;
  height: 28px;
  padding: 0;
}
.history-delete-button:hover {
  background: #aa0825;
}
.history-pagination {
  border-top: 1px solid #e4e3de;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 18px 20px;
  font-size: 12px;
  background: white;
  color: #686f76;
  flex-wrap: wrap;
}
.history-pagination > div {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.history-pagination label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
}
.history-pagination select,
.history-pagination input {
  margin: 0;
  width: 78px;
  min-height: 32px;
  padding: 5px 7px;
  border-radius: 7px;
  font-size: 12px;
}
.history-page-jump input {
  width: 48px;
}
.history-page-jump .history-button {
  padding: 5px 8px;
}
.history-note {
  font-size: 12px;
  line-height: 1.9;
  color: #8b939e;
  margin: 16px 3px;
}
.history-error {
  padding: 13px 16px;
  border: 1px solid #eccaca;
  background: #fff3f0;
  color: #a23b2a;
  border-radius: 9px;
  margin-bottom: 15px;
  font-size: 13px;
}
.history-dialog {
  width: 500px;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid #e3ddd2;
  border-radius: 0;
  background: #fbf8ef;
  color: #191919;
  box-shadow: -10px 0 40px #18264120;
  overflow: auto;
}
.history-dialog[open] {
  display: flex;
  flex-direction: column;
}
.history-dialog::backdrop {
  background: #13233c50;
}
.history-dialog-head {
  padding: 20px 20px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.history-dialog-head h2 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}
.history-dialog-head button {
  font-size: 24px;
  background: none;
  color: #777;
  line-height: 20px;
  padding: 0;
}
.history-edit-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.history-form-body {
  padding: 7px 20px 15px;
}
.history-basics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.history-dialog label {
  font-size: 14px;
  font-weight: 400;
  margin-bottom: 18px;
  min-width: 0;
}
.history-dialog input:not([type="radio"]) {
  background: #fbf8ef;
  border: 1px solid #e2dfd4;
  border-radius: 9px;
  box-shadow: 0 1px 3px #00000005;
  padding: 8px 12px;
  min-height: 37px;
  margin-top: 7px;
  color: #222;
  font-size: 14px;
  min-width: 0;
}
.history-dialog input:focus {
  border-color: #ac642f;
  box-shadow: 0 0 0 2px #aa663d55;
}
.history-basics input[name="draw_at"] {
  font-size: 12px;
  padding: 7px;
}
.history-status-field {
  border: 0;
  padding: 0;
  margin: 3px 0 25px;
  display: flex;
  gap: 17px;
  align-items: center;
}
.history-status-field legend {
  font-size: 14px;
  margin-bottom: 10px;
  padding: 0;
}
.history-status-field label {
  display: flex;
  gap: 7px;
  align-items: center;
  margin: 0;
  font-size: 14px;
}
.history-status-field input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: #168bf0;
  box-shadow: none;
}
.history-form-body h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 20px;
}
.history-number-inputs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: 16px;
  row-gap: 0;
}
.history-number-inputs label {
  margin-bottom: 18px;
}
.history-special-input {
  margin-top: 0;
}
.history-number-tip {
  font-size: 12px;
  color: #8e7e67;
  line-height: 1.8;
  margin: 5px 0 12px;
}
.history-dialog-actions {
  margin-top: auto;
  padding: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  position: sticky;
  bottom: 0;
  background: #fbf8ef;
}
.history-dialog-actions button {
  min-height: 36px;
  font-size: 14px;
}
.history-delete-dialog {
  border-radius: 12px;
  background: #fbf8ef;
  border-color: #e3dfd5;
}
.history-delete-dialog .modal-head {
  background: #fbf8ef;
}
.history-delete-warning {
  font-size: 13px;
  line-height: 1.9;
  color: #8e5e48;
}
.history-dialog input:disabled {
  opacity: 0.6;
}
@media (max-width: 760px) {
  .history-filters {
    padding: 15px;
    gap: 12px;
  }
  .history-filters label {
    width: calc(50% - 6px);
  }
  .history-filter-actions {
    width: auto;
  }
  .history-count {
    width: 100%;
    margin: 0;
    padding: 0;
  }
  .history-pagination {
    padding: 14px;
  }
  .history-pagination > div {
    gap: 7px;
  }
  .history-page-jump {
    display: none !important;
  }
  .history-dialog {
    width: min(500px, 100vw);
  }
  .history-basics {
    gap: 12px;
  }
  .history-form-body,
  .history-dialog-head,
  .history-dialog-actions {
    padding-left: 18px;
    padding-right: 18px;
  }
  .history-number-inputs {
    column-gap: 12px;
  }
}

/* Keep edit/delete reachable on normal laptops while wider metadata remains scrollable. */
.history-scroll {
  max-height: max(360px, calc(100dvh - 350px));
}
.history-table th:last-child,
.history-table td:last-child {
  position: sticky;
  right: 0;
  background: #fff;
  box-shadow: -6px 0 10px #00000004;
  z-index: 1;
}
.history-table tbody tr:nth-child(even) td:last-child {
  background: #f8f7f3;
}
.history-table tbody tr:hover td:last-child {
  background: #f5f8fc;
}
