* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #e5e5e5;
  color: #111827;
  font-family: "Segoe UI", Tahoma, sans-serif;
}

.page {
  width: min(1320px, calc(100% - 48px));
  margin: 0 auto;
  padding: 48px 0 64px;
}

.top-nav {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.top-nav a {
  color: #1f2937;
  text-decoration: none;
  padding: 8px 12px;
  border: 1px solid #c9ced6;
  border-radius: 6px;
  background: #ffffff;
}

.top-nav a.active {
  background: #1677ff;
  border-color: #1677ff;
  color: #ffffff;
}

h1 {
  margin: 0 0 28px;
  text-align: center;
  font-size: 46px;
  font-weight: 700;
}

.translator {
  display: grid;
  gap: 14px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar-field {
  min-width: 220px;
  flex: 1 1 220px;
}

.toolbar-field label {
  display: block;
  margin-bottom: 6px;
}

select,
input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #c9ced6;
  border-radius: 6px;
  background: #ffffff;
  font-size: 15px;
}

.secondary-link {
  color: #1677ff;
  text-decoration: none;
}

.notice {
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 15px;
}

.notice-success {
  background: #ecfdf3;
  border: 1px solid #86efac;
  color: #166534;
}

.notice-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.notice-warning {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
}

.notice-info {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1d4ed8;
}

.column-head,
.column-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
}

.column-head label {
  font-size: 17px;
}

textarea,
.result-box {
  width: 100%;
  min-height: 500px;
  padding: 12px;
  border: 1px solid #c9ced6;
  border-radius: 6px;
  background: #ffffff;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.55;
}

textarea {
  resize: vertical;
}

.result-box {
  margin: 0;
  overflow: auto;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-line {
  display: inline;
}

.result-line-manual {
  color: #dc2626;
}

.result-note {
  font-style: italic;
}

.result-empty {
  color: #6b7280;
}

.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

.actions-left {
  justify-content: flex-start;
}

.force-sync-form {
  margin-top: 12px;
}

.inline-note {
  color: #6b7280;
  font-size: 14px;
}

button {
  border: 0;
  border-radius: 8px;
  background: #1677ff;
  color: #ffffff;
  padding: 12px 20px;
  font-size: 18px;
  cursor: pointer;
}

.secondary-btn {
  background: #111827;
}

.danger-btn {
  background: #dc2626;
  padding: 8px 14px;
  font-size: 14px;
}

.small-btn {
  padding: 8px 14px;
  font-size: 14px;
}

.nav-user {
  margin-left: auto;
  color: #374151;
  font-size: 14px;
}

.auth-page {
  max-width: 520px;
}

.auth-card {
  background: #ffffff;
  border: 1px solid #c9ced6;
  border-radius: 8px;
  padding: 24px;
}

.customer-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 24px;
}

.customer-left-stack {
  display: grid;
  gap: 16px;
}

.customer-form,
.copy-config-form,
.data-panel {
  background: #ffffff;
  border: 1px solid #c9ced6;
  border-radius: 6px;
  padding: 18px;
}

.customer-form {
  display: grid;
  gap: 10px;
}

.copy-config-form {
  display: grid;
  gap: 10px;
}

.copy-config-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.copy-source-note {
  padding: 10px 12px;
  border-radius: 6px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.rate-card {
  display: grid;
  gap: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px;
  background: #f9fafb;
}

.rate-head,
.rate-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.rate-head {
  font-weight: 700;
}

.rate-label {
  font-weight: 600;
}

.small-textarea {
  min-height: 120px;
}

.data-panel h2 {
  margin: 0 0 16px;
}

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

.compact-status-grid {
  margin-bottom: 6px;
}

.recent-panel {
  margin-top: 24px;
}

.simple-table {
  display: grid;
}

.inline-form {
  margin: 0;
}

.table-head,
.table-row {
  display: grid;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #e5e7eb;
}

.table-head {
  font-weight: 700;
}

.table-row a {
  color: #1677ff;
  text-decoration: none;
}

.row-actions {
  display: grid;
  gap: 6px;
}

.row-actions-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.action-btn-danger {
  background: #dc2626;
  color: #ffffff;
}

.action-btn-dark {
  background: #111827;
  color: #ffffff;
}

.rate-summary {
  line-height: 1.5;
}

.customer-list-table {
  gap: 0;
}

.customer-list-grid {
  grid-template-columns: 70px minmax(160px, 1fr) minmax(180px, 1.2fr) 110px 170px;
  align-items: center;
}

.customer-list-head {
  background: #d40000;
  color: #ffffff;
  border-radius: 6px 6px 0 0;
  padding: 14px 16px;
}

.customer-list-table .table-row {
  padding: 14px 16px;
  border-left: 1px solid #d1d5db;
  border-right: 1px solid #d1d5db;
  background: #f8fafc;
}

.customer-list-table .table-row:last-child {
  border-bottom: 1px solid #d1d5db;
  border-radius: 0 0 6px 6px;
}

.recent-grid {
  grid-template-columns: 80px minmax(140px, 1fr) 120px 120px 180px 170px;
}

.result-grid {
  grid-template-columns: 140px 160px 100px 100px 180px;
}

.detail-grid {
  grid-template-columns: 80px 140px 1fr 120px 120px;
}

.normalized-grid {
  grid-template-columns: 100px 140px 180px 1fr 120px;
}

.reconcile-grid {
  grid-template-columns: 70px 110px 150px 110px 120px 130px 100px 110px;
}

.day-summary-grid {
  grid-template-columns: 1.2fr 80px 90px 150px 150px 140px 1fr;
}

.result-win {
  color: #166534;
  font-weight: 600;
}

.result-loss {
  color: #991b1b;
}

.result-inline-note {
  padding: 0 0 10px;
  color: #92400e;
  font-size: 14px;
}

.summary-top-grid {
  align-items: stretch;
}

.summary-copy-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.chat-summary-box {
  width: 100%;
  min-height: 500px;
  padding: 12px;
  border: 1px solid #c9ced6;
  border-radius: 6px;
  background: #f8fafc;
  font-family: "Courier New", monospace;
  font-size: 15px;
  line-height: 1.55;
  resize: none;
}

.empty-copy {
  margin: 0;
  color: #6b7280;
}

@media (max-width: 900px) {
  .page {
    width: min(100% - 24px, 1320px);
    padding-top: 24px;
  }

  h1 {
    font-size: 34px;
  }

  .column-head,
  .column-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .toolbar,
  .customer-layout,
  .rate-head,
  .rate-row,
  .copy-config-row,
  .status-grid,
  .recent-grid,
  .result-grid,
  .table-head,
  .table-row {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: stretch;
  }

  textarea,
  .result-box {
    min-height: 360px;
  }
}
