:root {
  --bg-color: #f4f7f4;
  --primary-color: #2e7d32;
  --primary-dark: #1b5e20;
  --card-bg: #ffffff;
  --text-main: #2c3e50;
  --text-muted: #7f8c8d;
  --border-color: #e0e6ed;
  --warning-color: #e65100;
  --error-bg: #fff2f2;
  --error-color: #a82020;
  --success-bg: #eef8ef;
  --success-color: #246b2a;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  margin: 0;
  padding: 20px 0 42px;
  overflow-x: hidden;
}

.app-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 20px;
}

.header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--primary-color);
  text-align: center;
}

.header-left h1 {
  margin: 0;
  font-size: 36px;
  line-height: 1.18;
  font-weight: 800;
}

.card {
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(28, 61, 39, 0.08);
  margin-bottom: 25px;
  border: 1px solid var(--border-color);
}

.control-panel {
  padding: 25px;
}

.controls-grid {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 220px;
}

.conf-group {
  flex: 0 0 170px;
  min-width: 160px;
}

.upload-group {
  flex: 1.2;
}

.upload-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.file-action {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--primary-color);
  border-radius: 6px;
  background: #f0f8f1;
  color: var(--primary-color);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
}

.file-action input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.selected-file {
  display: block;
  min-height: 20px;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.selected-file.is-error {
  color: var(--error-color);
  font-weight: 800;
}

.input-group label {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-main);
}

.input-group input,
.input-group select {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: #f9fbf9;
  color: var(--text-main);
  outline: none;
}

.input-group input:focus,
.input-group select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.12);
}

.action-group {
  display: flex;
  align-items: center;
  gap: 15px;
  min-height: 48px;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 12px 35px;
  min-height: 48px;
  font-size: 18px;
  font-weight: 800;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: #8aa98c;
  cursor: wait;
  transform: none;
}

.hint-text {
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
}

.notice {
  margin-bottom: 25px;
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.notice.success {
  background: var(--success-bg);
  color: var(--success-color);
}

.notice.error {
  background: var(--error-bg);
  color: var(--error-color);
}

.results-area {
  margin-top: 0;
}

.dashboard-grid {
  display: flex;
  gap: 20px;
  margin-bottom: 25px;
}

.stat-card {
  flex: 1;
  background: var(--card-bg);
  padding: 22px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 24px rgba(28, 61, 39, 0.07);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 118px;
}

.stat-title {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 7px;
}

.stat-value {
  font-size: 38px;
  line-height: 1.1;
  font-weight: 850;
  color: var(--text-main);
}

.highlight-time {
  color: var(--primary-color);
}

.stat-value small {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 500;
}

.text-value {
  font-size: 30px;
}

.image-comparison {
  display: flex;
  gap: 25px;
  margin-bottom: 25px;
}

.image-box {
  flex: 1;
  min-width: 0;
  background: var(--card-bg);
  border-radius: 10px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(28, 61, 39, 0.08);
  display: flex;
  flex-direction: column;
}

.box-header {
  background: #fafafa;
  padding: 14px 20px;
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
}

.box-header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.btn-export {
  background-color: #e8f5e9;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  padding: 7px 13px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.btn-export:hover {
  background-color: var(--primary-color);
  color: #ffffff;
}

.img-wrapper {
  width: 100%;
  padding: 0;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-wrapper img {
  max-width: 100%;
  width: 100%;
  height: auto;
  display: block;
}

.table-card {
  padding: 25px;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}

.table-header h2 {
  margin: 0;
  font-size: 22px;
}

.target-count {
  color: var(--warning-color);
  font-weight: 800;
  font-size: 16px;
}

.data-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table th,
.data-table td {
  padding: 15px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 16px;
}

.data-table th {
  background-color: #f8faf8;
  color: var(--text-muted);
  font-weight: 800;
}

.label-mature,
.label-immature,
.label-default {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 14px;
}

.label-mature {
  background: #e8f5e9;
  color: var(--primary-color);
}

.label-immature {
  background: #e0f7fa;
  color: #00838f;
}

.label-default {
  background: #f5f5f5;
  color: #666666;
}

.empty {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 600;
}

.log-card {
  padding: 25px;
  margin-top: 25px;
}

.log-terminal {
  height: 138px;
  overflow: auto;
  background-color: #1e1e1e;
  color: #4caf50;
  padding: 15px;
  border-radius: 6px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.log-terminal p {
  margin: 5px 0;
}

.log-time {
  color: #888888;
  margin-right: 10px;
}

@media (max-width: 980px) {
  .header,
  .dashboard-grid,
  .image-comparison {
    flex-direction: column;
    align-items: stretch;
  }

  .header-left h1 {
    font-size: 30px;
  }

  .action-group {
    width: 100%;
  }

  .btn-primary {
    flex: 1;
  }
}

@media (max-width: 768px) {
  body {
    padding: 14px 0 28px;
  }

  .app-container {
    width: 100%;
    padding: 0 16px;
  }

  .header {
    margin-bottom: 18px;
    padding-bottom: 12px;
  }

  .header-left h1 {
    font-size: 25px;
    line-height: 1.25;
    text-align: center;
  }

  .control-panel,
  .table-card,
  .log-card {
    padding: 16px;
    border-radius: 8px;
  }

  .controls-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: stretch;
  }

  .input-group,
  .conf-group,
  .upload-group {
    min-width: 0;
    width: 100%;
    flex: none;
  }

  .input-group input,
  .input-group select,
  .btn-primary {
    width: 100%;
    min-height: 46px;
    font-size: 16px;
  }

  .action-group {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .hint-text {
    white-space: normal;
    text-align: center;
  }

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

  .stat-card {
    min-height: 98px;
    padding: 16px;
    border-radius: 8px;
  }

  .stat-card:last-child {
    grid-column: 1 / -1;
  }

  .stat-title {
    font-size: 14px;
  }

  .stat-value {
    font-size: 30px;
  }

  .text-value {
    font-size: 23px;
  }

  .image-comparison {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
  }

  .image-box {
    border-radius: 8px;
  }

  .box-header {
    padding: 12px 14px;
    font-size: 16px;
  }

  .box-header-actions {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .btn-export {
    white-space: normal;
    text-align: center;
  }

  .table-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
  }

  .table-header h2 {
    font-size: 19px;
  }

  .target-count {
    font-size: 14px;
  }

  .data-table th,
  .data-table td {
    padding: 12px;
    font-size: 15px;
  }

  .log-terminal {
    height: 150px;
    padding: 12px;
    font-size: 12px;
    white-space: normal;
  }
}

@media (max-width: 480px) {
  .app-container {
    padding: 0 12px;
  }

  .header-left h1 {
    font-size: 21px;
  }

  .card {
    margin-bottom: 16px;
  }

  .upload-actions {
    grid-template-columns: 1fr;
  }

  .file-action {
    width: 100%;
  }

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

  .stat-card:last-child {
    grid-column: auto;
  }

  .stat-value {
    font-size: 28px;
  }

  .text-value {
    font-size: 20px;
  }

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

  .label-mature,
  .label-immature,
  .label-default {
    white-space: nowrap;
  }
}
