.tsg-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

.tsg-panel {
  border: 1px solid var(--border, #d0d7de);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(150deg, #f8fbff, #eef4ff);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

.tsg-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.tsg-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-items: start;
}

@media (max-width: 720px) {
  .tsg-grid-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .tsg-grid-2 {
    grid-template-columns: 1fr;
  }
}

.tsg-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  font-weight: 600;
}

.tsg-field input,
.tsg-field select,
.tsg-field textarea {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border, #d0d7de);
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 10px 24px rgba(15, 23, 42, 0.06);
  font-size: 15px;
  line-height: 1.5;
}

.tsg-field textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
}

.tsg-field input:focus-visible,
.tsg-field select:focus-visible,
.tsg-field textarea:focus-visible {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.18);
}

.tsg-checkline {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 600;
  margin: 6px 0 12px;
}

.tsg-checkline input[type='checkbox'] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.tsg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 12px 0 0;
}

.tsg-actions .button {
  flex: 1 1 180px;
}

@media (max-width: 520px) {
  .tsg-actions .button {
    flex: 1 1 100%;
  }
}

.tsg-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 10px 0 12px;
}

.tsg-chart {
  --tsg-chart-line: var(--primary-bg, #2563eb);
  width: 100%;
  min-height: 260px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: rgba(226, 232, 240, 0.55);
}

.tsg-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 14px;
}

.tsg-table th,
.tsg-table td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.4);
  padding: 6px 8px;
  text-align: left;
}

.tsg-summary {
  margin-top: 10px;
  font-weight: 600;
}

.tsg-dialog {
  max-width: 720px;
  width: calc(100% - 32px);
  border: 1px solid rgba(148, 163, 184, 0.6);
  border-radius: 16px;
  padding: 0;
}

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

.tsg-dialog-body {
  padding: 16px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

.tsg-toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.35);
  transform: translateY(8px);
  opacity: 0;
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
  z-index: 9999;
}

.tsg-toast.is-show {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-color-scheme: dark) {
  .tsg-panel {
    background: linear-gradient(150deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.92));
    border-color: rgba(226, 232, 240, 0.18);
    box-shadow: 0 18px 44px rgba(10, 19, 35, 0.55);
    color: #e2e8f0;
  }

  .tsg-field input,
  .tsg-field select,
  .tsg-field textarea {
    border-color: rgba(226, 232, 240, 0.22);
    background: rgba(2, 6, 23, 0.55);
    color: #e2e8f0;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  }

  .tsg-chart {
    --tsg-chart-line: #60a5fa;
    border-color: rgba(226, 232, 240, 0.22);
    background: rgba(148, 163, 184, 0.12);
  }

  .tsg-toast {
    background: rgba(226, 232, 240, 0.95);
    color: #0f172a;
    box-shadow: 0 18px 44px rgba(10, 19, 35, 0.55);
  }
}
