:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17212b;
  --muted: #657487;
  --line: #d8dee6;
  --primary: #1668dc;
  --danger: #c62828;
  --ok: #137333;
  --warn: #b26a00;
  --violet: #5443e8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
}

body.locked {
  overflow: hidden;
}

.license-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f5f6fa;
  overflow: auto;
}

.license-gate[hidden] {
  display: none;
}

.license-hero {
  position: absolute;
  inset: 0 0 auto;
  height: 34vh;
  min-height: 220px;
  background: var(--violet);
  border-bottom-left-radius: 56px;
  border-bottom-right-radius: 56px;
}

.license-hero::after {
  content: "";
  position: absolute;
  right: 12%;
  top: 28%;
  width: 130px;
  height: 110px;
  opacity: 0.12;
  background: #fff;
  clip-path: polygon(50% 0, 100% 45%, 70% 45%, 50% 100%, 30% 45%, 0 45%);
}

.license-card {
  position: relative;
  width: min(100%, 430px);
  margin-top: 64px;
  border-radius: 24px;
  padding: 34px 28px 24px;
  background: #fff;
  box-shadow: 0 20px 46px rgba(15, 23, 42, 0.18);
}

.license-icon {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  margin: -4px auto 18px;
  border-radius: 18px;
  background: var(--violet);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(84, 67, 232, 0.28);
}

.license-card h1 {
  margin: 0;
  text-align: center;
  font-size: 28px;
}

.license-card p {
  margin: 10px 0 24px;
  text-align: center;
  color: #98a1ad;
}

.license-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.license-card input[type="text"],
#licenseInput {
  width: 100%;
  min-height: 56px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

.license-remember {
  display: flex !important;
  grid-template-columns: none;
  flex-direction: row;
  align-items: center;
  gap: 8px !important;
  margin: 14px 0 18px;
  font-weight: 500 !important;
}

.license-remember input {
  width: 18px;
  min-height: 18px;
}

#activateBtn {
  width: 100%;
  min-height: 56px;
  border-radius: 12px;
  background: var(--violet);
  border-color: var(--violet);
  font-size: 18px;
  font-weight: 800;
}

.license-message {
  min-height: 22px;
  margin-top: 12px;
  text-align: center;
  color: var(--warn);
}

.device-code {
  margin-top: 16px;
  text-align: center;
  color: #a5adba;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.device-code b {
  display: block;
  margin-top: 6px;
  color: #7d8795;
  font-weight: 600;
}

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

button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  filter: brightness(0.96);
}

.file-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.file-button:hover {
  filter: brightness(0.96);
}

#imageOcrInput {
  display: none;
}

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

button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

button.plain {
  background: transparent;
  border-color: transparent;
  color: var(--primary);
  padding: 4px 6px;
}

button.danger-text {
  color: var(--danger);
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 104, 220, 0.12);
  outline: none;
}

textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  padding: 12px;
  line-height: 1.6;
}

.zodiac-risk-box {
  margin-top: 10px;
}

input,
select {
  min-height: 36px;
  padding: 0 10px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.app-header h1,
.panel h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: 22px;
}

.app-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.privacy-badge {
  display: inline-flex;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef7f0;
  color: var(--ok);
  font-size: 12px;
  font-weight: 700;
}

.header-actions,
.toolbar,
.risk-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.header-actions {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

.header-actions button {
  min-height: 36px;
  border-color: transparent;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.header-actions button:first-child {
  border-color: rgba(22, 104, 220, 0.18);
  background: #eff6ff;
  color: var(--primary);
}

.header-actions button.danger {
  border-color: rgba(198, 40, 40, 0.26);
  background: #fff5f5;
  color: var(--danger);
}

.header-actions input {
  width: 110px;
}

.blessing-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 16px 0;
  padding: 10px 12px;
  border: 1px solid #f1d4a8;
  border-radius: 10px;
  background: linear-gradient(90deg, #fff8ec, #fffdf8);
  box-shadow: 0 2px 8px rgba(150, 91, 18, 0.08);
  overflow: hidden;
}

.blessing-card img {
  width: 118px;
  height: 66px;
  border-radius: 8px;
  object-fit: cover;
  object-position: center;
  flex: 0 0 auto;
}

.blessing-card b {
  display: block;
  color: #8a3d16;
  font-size: 20px;
  line-height: 1.2;
}

.blessing-card span {
  display: block;
  margin-top: 4px;
  color: #7c5a32;
  font-size: 13px;
}

.settings-dialog {
  width: min(940px, calc(100vw - 24px));
  max-height: min(86vh, 820px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  color: var(--text);
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}

.settings-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.settings-dialog.fallback-open {
  position: fixed;
  inset: 12px;
  z-index: 120;
  display: block;
  width: auto;
  max-width: none;
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.dialog-head h2,
.dialog-head p,
.customer-create-panel h3 {
  margin: 0;
}

.dialog-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.customer-create-panel {
  display: grid;
  gap: 10px;
  margin: 16px 16px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.settings-dialog .settings-tools {
  margin: 12px 16px 16px;
}

#customerNameInput {
  width: 140px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(420px, 1.1fr) minmax(360px, 0.9fr);
  gap: 14px;
  padding: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.order-entry,
.orders-panel,
.customer-panel {
  grid-column: 1 / -1;
}

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

.panel-title.compact {
  margin-top: 14px;
  margin-bottom: 8px;
}

.panel-title h2 {
  font-size: 18px;
}

.panel-title h3 {
  font-size: 15px;
}

.panel-title span,
.summary-line {
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #334155;
  font-weight: 600;
}

td small {
  color: var(--muted);
}

.targets-cell {
  min-width: 340px;
  white-space: normal;
}

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

.customer-settings-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.customer-settings-head label,
.odds-setting-row label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.customer-settings-head select,
.customer-settings-head input {
  min-width: 120px;
}

.settings-tools {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 8px 10px;
}

.settings-tools summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.settings-tools summary span {
  font-size: 20px;
}

.settings-tools summary small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}

.customer-settings-body {
  margin-top: 12px;
}

.odds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.entry-folders {
  margin-bottom: 10px;
}

.entry-tools {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfd;
}

.entry-tools summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
}

.entry-tools-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.6fr) minmax(260px, 1fr);
  gap: 14px;
  margin-top: 10px;
}

.entry-tools-grid h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.customer-create-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.help-content {
  margin-top: 8px;
  max-width: 720px;
  color: var(--muted);
  line-height: 1.6;
}

.help-content p {
  margin: 0 0 8px;
}

.help-content p:last-child {
  margin-bottom: 0;
}

.odds-setting-row {
  display: grid;
  grid-template-columns: 70px minmax(80px, 1fr) minmax(80px, 1fr);
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fbfcfd;
}

.odds-setting-row b {
  align-self: center;
}

.stats-grid div,
.risk-extremes div,
.zodiac-grid div,
.mini-list div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfd;
}

.stats-grid b,
.risk-extremes b {
  display: block;
  font-size: 22px;
  margin-bottom: 4px;
}

.stats-grid span,
.risk-extremes span {
  color: var(--muted);
  font-size: 13px;
}

.mini-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 120px 160px 1fr;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.summary-line {
  margin-top: 12px;
  padding: 10px;
  background: #f8fafc;
  border-radius: 6px;
}

.risk-controls {
  margin-bottom: 12px;
}

.smart-limit-btn {
  min-height: 38px;
}

#smartRiskLimitText {
  color: var(--muted);
  font-size: 12px;
}

.risk-extremes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

#maxProfit {
  color: var(--ok);
}

#maxLoss {
  color: var(--danger);
}

.risk-table table {
  min-width: 620px;
}

.risk-table input {
  width: 86px;
}

.order-edit-number {
  width: 86px;
}

.risk-workspace {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) minmax(260px, 340px);
  gap: 12px;
  align-items: start;
}

.report-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #ffffff;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

#reportText {
  min-height: 140px;
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
  background: #fff7ed;
  color: var(--danger);
}

.risk-over {
  background: #fff7ed;
}

.muted-cell {
  color: var(--muted);
  text-align: center;
}

.source-cell {
  color: var(--muted);
  font-size: 12px;
  max-width: 220px;
  white-space: normal;
  word-break: break-word;
}

.source-cell summary {
  cursor: pointer;
  color: var(--ink);
  white-space: nowrap;
}

.source-cell details div {
  margin-top: 4px;
}

.draw-blessing {
  margin-top: 10px;
  border: 1px solid #f1d4a8;
  border-radius: 8px;
  background: #fffaf0;
  overflow: hidden;
}

.draw-blessing video {
  display: block;
  width: 100%;
  max-height: 360px;
  background: #111827;
}

.report-table {
  margin-top: 8px;
  margin-bottom: 12px;
}

.settlement-customer-cell {
  min-width: 180px;
  white-space: normal;
}

.settlement-customer-cell summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
}

.settlement-detail {
  margin-top: 8px;
  max-width: 520px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.settlement-formula {
  color: var(--ink);
  font-weight: 700;
}

.settlement-winners {
  margin-top: 6px;
  color: var(--muted);
}

.settlement-winners div {
  padding-top: 3px;
}

.report-table table {
  min-width: 0;
}

.parsed-edit {
  width: 100%;
  min-width: 74px;
}

.parsed-targets {
  min-width: 320px;
  min-height: 64px;
  resize: vertical;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.parsed-number {
  min-width: 82px;
}

.zodiac-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.zodiac-risk-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.zodiac-risk-card span {
  color: var(--muted);
  font-size: 13px;
}

.zodiac-risk-card b {
  font-size: 18px;
}

.combo-risk-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.combo-risk-title {
  color: var(--text);
  font-weight: 800;
}

.combo-risk-empty {
  color: var(--muted);
  font-size: 13px;
}

.combo-risk-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.combo-risk-item span {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.combo-risk-item b {
  font-size: 17px;
}

.combo-risk-item em {
  grid-column: 1 / -1;
  color: var(--warn);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.combo-risk-warn {
  border-color: #f3c46a;
  background: #fffaf0;
}

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

.bad {
  color: var(--danger);
}

.warn {
  color: var(--warn);
}

@media (max-width: 980px) {
  .layout,
  .form-grid,
  .risk-workspace,
  .entry-tools-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

.mobile-float-nav {
  display: none;
}

@media (max-width: 640px) {
  html {
    overflow-x: hidden;
  }

  body {
    background: #fff;
    overflow-x: hidden;
  }

  .app-header {
    position: static;
    padding: 14px 12px 10px;
    gap: 12px;
    background: #fff;
  }

  .app-header h1 {
    font-size: 21px;
    line-height: 1.12;
  }

  .dialog-head {
    padding: 12px;
  }

  .settings-dialog {
    width: calc(100vw - 12px);
    max-height: 90vh;
  }

  .customer-create-panel,
  .settings-dialog .settings-tools {
    margin-left: 10px;
    margin-right: 10px;
  }

  .app-header p,
  .privacy-badge {
    display: none;
  }

  .blessing-card {
    gap: 8px;
    margin: 8px 8px 0;
    padding: 7px 8px;
    border-radius: 8px;
  }

  .blessing-card img {
    width: 78px;
    height: 48px;
    border-radius: 7px;
  }

  .blessing-card b {
    font-size: 16px;
  }

  .blessing-card span {
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.25;
  }

  .toolbar,
  .customer-settings-head,
  .risk-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    width: 100%;
    gap: 6px;
    padding: 6px;
    border-radius: 8px;
  }

  .header-actions > *,
  .toolbar > *,
  .risk-controls > * {
    width: 100%;
  }

  .header-actions button {
    min-height: 38px;
    padding: 6px 4px;
    font-size: 13px;
    line-height: 1.2;
    white-space: normal;
  }

  .layout {
    padding: 8px 8px 12px;
    gap: 10px;
  }

  .panel {
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 5px rgba(15, 23, 42, 0.05);
  }

  .panel-title {
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
  }

  .panel-title h2 {
    font-size: 16px;
  }

  .panel-title h3 {
    font-size: 14px;
  }

  .panel-title span,
  .summary-line {
    font-size: 12px;
  }

  textarea {
    min-height: 96px;
    font-size: 16px;
  }

  #orderInput {
    min-height: 78px;
    max-height: 120px;
  }

  button,
  .file-button,
  input,
  select {
    min-height: 38px;
  }

  button,
  .file-button {
    padding: 8px 9px;
  }

  .toolbar {
    gap: 6px;
  }

  .toolbar button,
  .toolbar .file-button {
    min-height: 36px;
    font-size: 14px;
  }

  .entry-tools {
    padding: 7px 9px;
  }

  .entry-tools summary {
    font-size: 15px;
  }

  .table-wrap {
    max-height: 48vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .order-entry .table-wrap {
    max-height: 36vh;
  }

  .risk-table {
    max-height: 54vh;
  }

  .parsed-table,
  .orders-table,
  .settlement-table {
    max-height: none;
    overflow: visible;
    border: 0;
    margin-top: 8px;
  }

  .parsed-table table,
  .orders-table table,
  .settlement-table table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .parsed-table thead,
  .orders-table thead,
  .settlement-table thead {
    display: none;
  }

  .parsed-table tbody,
  .orders-table tbody,
  .settlement-table tbody {
    display: grid;
    gap: 8px;
  }

  .parsed-table tr,
  .orders-table tr,
  .settlement-table tr {
    display: grid;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
  }

  .parsed-table td,
  .orders-table td,
  .settlement-table td {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    min-width: 0;
    padding: 8px 10px;
    white-space: normal;
    word-break: break-word;
  }

  .parsed-table td::before,
  .orders-table td::before,
  .settlement-table td::before {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  .parsed-table td:nth-child(1)::before { content: "区域"; }
  .parsed-table td:nth-child(2)::before { content: "玩法"; }
  .parsed-table td:nth-child(3)::before { content: "内容"; }
  .parsed-table td:nth-child(4)::before { content: "金额"; }
  .parsed-table td:nth-child(5)::before { content: "赔率"; }
  .parsed-table td:nth-child(6)::before { content: "总额"; }
  .parsed-table td:nth-child(7)::before { content: "提示"; }
  .parsed-table td:nth-child(8)::before { content: "操作"; }

  .settlement-table td:nth-child(1)::before { content: "客户"; }
  .settlement-table td:nth-child(2)::before { content: "注单数"; }
  .settlement-table td:nth-child(3)::before { content: "总金额"; }
  .settlement-table td:nth-child(4)::before { content: "中奖"; }
  .settlement-table td:nth-child(5)::before { content: "返水"; }
  .settlement-table td:nth-child(6)::before { content: "净结算"; }

  .orders-table td:nth-child(1)::before { content: "时间"; }
  .orders-table td:nth-child(2)::before { content: "客户"; }
  .orders-table td:nth-child(3)::before { content: "区域"; }
  .orders-table td:nth-child(4)::before { content: "玩法"; }
  .orders-table td:nth-child(5)::before { content: "内容"; }
  .orders-table td:nth-child(6)::before { content: "金额"; }
  .orders-table td:nth-child(7)::before { content: "赔率"; }
  .orders-table td:nth-child(8)::before { content: "返水"; }
  .orders-table td:nth-child(9)::before { content: "总额"; }
  .orders-table td:nth-child(10)::before { content: "状态"; }
  .orders-table td:nth-child(11)::before { content: "盈亏"; }
  .orders-table td:nth-child(12)::before { content: "操作"; }

  .parsed-table input,
  .parsed-table textarea,
  .orders-table input,
  .orders-table textarea {
    width: 100%;
    min-width: 0;
  }

  .targets-cell,
  .parsed-targets,
  .settlement-customer-cell {
    min-width: 0;
    max-width: none;
  }

  .risk-workspace > .risk-table table {
    width: 100%;
    min-width: 0;
    font-size: 12px;
  }

  .risk-workspace > .risk-table th:nth-child(4),
  .risk-workspace > .risk-table td:nth-child(4),
  .risk-workspace > .risk-table th:nth-child(6),
  .risk-workspace > .risk-table td:nth-child(6),
  .risk-workspace > .risk-table th:nth-child(8),
  .risk-workspace > .risk-table td:nth-child(8) {
    display: none;
  }

  .risk-workspace > .risk-table input {
    width: 58px;
  }

  .report-table {
    max-height: 30vh;
  }

  table {
    min-width: 760px;
    font-size: 13px;
  }

  .risk-table table {
    min-width: 600px;
  }

  .report-table table {
    min-width: 420px;
  }

  th,
  td {
    padding: 7px 8px;
  }

  th {
    position: sticky;
    top: 0;
    z-index: 1;
  }

  .settings-tools summary {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .odds-setting-row {
    grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
  }

  .odds-setting-row input {
    width: 100%;
    min-width: 0;
  }

  .stats-grid,
  .risk-extremes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stats-grid div,
  .risk-extremes div,
  .zodiac-grid div,
  .mini-list div {
    padding: 8px;
  }

  .stats-grid b,
  .risk-extremes b {
    font-size: 18px;
  }

  .zodiac-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .zodiac-risk-card {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .zodiac-risk-card span {
    font-size: 12px;
  }

  .zodiac-risk-card b {
    font-size: 15px;
  }

  .customer-create-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .help-content {
    max-height: 160px;
    overflow: auto;
  }

  #reportText {
    min-height: 96px;
    font-size: 14px;
  }

  .parsed-targets {
    min-width: 220px;
  }

  .parsed-table,
  .orders-table {
    max-height: 56vh;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 8px;
  }

  .parsed-table table,
  .orders-table table {
    display: table;
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
  }

  .parsed-table table {
    min-width: 660px;
  }

  .orders-table table {
    min-width: 780px;
  }

  .parsed-table thead,
  .orders-table thead {
    display: table-header-group;
  }

  .parsed-table tbody,
  .orders-table tbody {
    display: table-row-group;
  }

  .parsed-table tr,
  .orders-table tr {
    display: table-row;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .parsed-table th,
  .parsed-table td,
  .orders-table th,
  .orders-table td {
    display: table-cell;
    padding: 4px 5px;
    white-space: nowrap;
    vertical-align: middle;
    word-break: normal;
  }

  .orders-table th:nth-child(5),
  .orders-table td:nth-child(5) {
    width: 150px;
    max-width: 150px;
    white-space: normal;
  }

  .orders-table td:nth-child(5) {
    max-height: 42px;
    overflow: auto;
    line-height: 1.25;
    word-break: break-word;
  }

  .parsed-table td::before,
  .orders-table td::before {
    content: none !important;
  }

  .parsed-table input,
  .parsed-table select,
  .parsed-table textarea,
  .orders-table input,
  .orders-table select,
  .orders-table textarea {
    min-height: 30px;
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 12px;
  }

  .parsed-table .targets-cell {
    min-width: 150px;
    white-space: normal;
  }

  .parsed-table .parsed-targets {
    width: 150px;
    min-width: 150px;
    min-height: 34px;
    max-height: 58px;
    line-height: 1.25;
  }

  .parsed-table .parsed-number,
  .orders-table .order-edit-number {
    width: 52px;
    min-width: 52px;
  }

  .license-card {
    padding: 30px 22px 22px;
    border-radius: 22px;
  }
}

@media (max-width: 640px) {
  body {
    padding-bottom: 12px;
  }

  .mobile-float-nav {
    position: static;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin: 0 0 8px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .mobile-float-nav button {
    min-height: 34px;
    padding: 6px 2px;
    border-radius: 7px;
    font-size: 13px;
    line-height: 1.1;
  }

  .sheet-close {
    position: sticky;
    top: 0;
    z-index: 2;
    float: right;
    min-height: 32px;
    margin: -4px 0 8px 8px;
    padding: 5px 10px;
    border: 1px solid var(--line);
    background: #fff5f5;
    color: var(--danger);
  }

  #orderInput {
    min-height: 118px;
    max-height: none;
    overflow: hidden;
  }

  .order-entry {
    padding-bottom: 10px;
  }

  .stats-panel,
  .draw-panel,
  .risk-panel,
  .order-entry .zodiac-risk-box {
    display: none;
  }

  .mobile-panel-open {
    position: fixed;
    inset: 54px 8px 10px;
    z-index: 70;
    display: block !important;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.22);
  }

  .order-entry .zodiac-risk-box.mobile-panel-open {
    padding: 12px;
  }

  body.mobile-panel-active::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(15, 23, 42, 0.18);
    pointer-events: none;
  }

  body.mobile-settlement-mode .risk-panel > .panel-title,
  body.mobile-settlement-mode .risk-panel > .risk-controls,
  body.mobile-settlement-mode .risk-panel > .risk-extremes,
  body.mobile-settlement-mode .risk-panel > .risk-workspace {
    display: none;
  }

  body.mobile-settlement-mode .risk-panel .settlement-fold {
    display: block;
  }

  body.mobile-risk-mode .risk-panel .settlement-fold {
    display: none;
  }

  .orders-panel {
    display: block;
    margin-top: -2px;
    padding: 10px 8px;
  }

  .orders-panel .panel-title {
    align-items: center;
    margin-bottom: 4px;
  }

  .orders-panel .panel-title h2 {
    font-size: 14px;
  }

  .orders-panel #orderSearch {
    max-width: 170px;
    min-height: 28px;
    padding: 4px 8px;
    font-size: 12px;
  }

  .parsed-table,
  .orders-table,
  .risk-workspace > .risk-table {
    max-height: none !important;
    overflow: visible !important;
  }

  .parsed-table table {
    min-width: 0 !important;
    table-layout: fixed;
    font-size: 11px;
  }

  .parsed-table th,
  .parsed-table td {
    padding: 3px 3px !important;
  }

  .parsed-table th:nth-child(1),
  .parsed-table td:nth-child(1),
  .parsed-table th:nth-child(2),
  .parsed-table td:nth-child(2) {
    display: none;
  }

  .parsed-table th:nth-child(3),
  .parsed-table td:nth-child(3) {
    width: 42%;
  }

  .parsed-table th:nth-child(4),
  .parsed-table td:nth-child(4),
  .parsed-table th:nth-child(5),
  .parsed-table td:nth-child(5),
  .parsed-table th:nth-child(6),
  .parsed-table td:nth-child(6) {
    width: 19%;
  }

  .parsed-table th:nth-child(7),
  .parsed-table td:nth-child(7),
  .parsed-table th:nth-child(8),
  .parsed-table td:nth-child(8) {
    display: none;
  }

  .parsed-table select,
  .parsed-table input,
  .parsed-table textarea {
    min-height: 28px !important;
    padding: 2px 3px !important;
    font-size: 12px !important;
  }

  .parsed-table .parsed-targets {
    width: 100% !important;
    min-width: 0 !important;
    max-height: 42px;
  }

  .parsed-table .parsed-number {
    width: 100% !important;
    min-width: 0 !important;
  }

  .orders-table table {
    min-width: 0 !important;
    table-layout: fixed;
    font-size: 10.5px;
  }

  .orders-table th,
  .orders-table td {
    padding: 3px 2px !important;
    line-height: 1.15;
  }

  .orders-table th:nth-child(1),
  .orders-table td:nth-child(1) {
    display: none;
  }

  .orders-table th:nth-child(2),
  .orders-table td:nth-child(2),
  .orders-table th:nth-child(3),
  .orders-table td:nth-child(3),
  .orders-table th:nth-child(4),
  .orders-table td:nth-child(4),
  .orders-table th:nth-child(10),
  .orders-table td:nth-child(10),
  .orders-table th:nth-child(11),
  .orders-table td:nth-child(11) {
    display: none;
  }

  .orders-table th:nth-child(5),
  .orders-table td:nth-child(5) {
    width: 84px;
    max-width: none;
    white-space: normal;
    word-break: break-word;
  }

  .orders-table td:nth-child(5)::before {
    content: attr(data-mobile-meta);
  }

  .orders-table td:nth-child(5) {
    position: relative;
    padding-top: 18px !important;
    font-size: 13px;
    font-weight: 800;
  }

  .orders-table td:nth-child(5)::before {
    position: absolute;
    top: 2px;
    left: 3px;
    right: 3px;
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .orders-table th:nth-child(6),
  .orders-table td:nth-child(6),
  .orders-table th:nth-child(7),
  .orders-table td:nth-child(7),
  .orders-table th:nth-child(8),
  .orders-table td:nth-child(8),
  .orders-table th:nth-child(9),
  .orders-table td:nth-child(9) {
    width: 42px;
  }

  .orders-table th:nth-child(12),
  .orders-table td:nth-child(12) {
    width: 48px;
  }

  .orders-table .order-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    min-width: 44px;
    padding: 3px 6px;
    border-radius: 6px;
    background: #fff1f1;
    color: var(--danger);
    font-size: 12px;
    font-weight: 800;
  }

  .orders-table .order-edit-number {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 24px !important;
    padding: 1px 3px !important;
  }

  #ordersPanel .orders-table {
    max-height: 190px !important;
    overflow: auto !important;
    border-radius: 7px;
  }

  .risk-workspace > .risk-table table {
    min-width: 0 !important;
    table-layout: fixed;
    font-size: 12px;
  }

  .risk-workspace > .risk-table th,
  .risk-workspace > .risk-table td {
    padding: 6px 4px;
  }

  .risk-workspace > .risk-table th:nth-child(1),
  .risk-workspace > .risk-table td:nth-child(1) {
    width: 44px;
  }

  .risk-workspace > .risk-table th:nth-child(2),
  .risk-workspace > .risk-table td:nth-child(2) {
    width: 48px;
  }

  .risk-workspace > .risk-table th:nth-child(3),
  .risk-workspace > .risk-table td:nth-child(3),
  .risk-workspace > .risk-table th:nth-child(5),
  .risk-workspace > .risk-table td:nth-child(5),
  .risk-workspace > .risk-table th:nth-child(7),
  .risk-workspace > .risk-table td:nth-child(7) {
    width: 68px;
  }

  .risk-workspace > .risk-table input {
    width: 58px;
    min-width: 0;
  }
}
