/* ============================================================
   Production Monitor — Apple Light Theme
   ============================================================ */

/* ── Base & Reset ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  background-color: #f5f5f7;
  color: #1d1d1f;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  line-height: 1.55;
  margin: 0;
}

.d-none {
  display: none !important;
}

/* ── Upload Screen ────────────────────────────────────────── */
.upload-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.upload-card {
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 2px 24px rgba(0, 0, 0, 0.10);
  padding: 2.5rem 2rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.upload-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1d1d1f;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.upload-subtitle {
  font-size: 0.88rem;
  color: #6e6e73;
  margin: 0 0 1.5rem;
  line-height: 1.55;
}

/* ── Drop Zone ────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed #d2d2d7;
  border-radius: 12px;
  padding: 2rem 1rem;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease;
  position: relative;
  overflow: hidden;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: #0071e3;
  background-color: rgba(0, 113, 227, 0.04);
}

.drop-zone-text {
  font-size: 0.93rem;
  font-weight: 500;
  color: #1d1d1f;
  margin-bottom: 0.3rem;
}

.drop-zone-hint {
  font-size: 0.78rem;
  color: #6e6e73;
}

.drop-status {
  margin-top: 1rem;
  font-size: 0.82rem;
  color: #6e6e73;
}

/* ── Top Bar ──────────────────────────────────────────────── */
.top-bar {
  background: #ffffff;
  border-bottom: 1px solid #d2d2d7;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.top-bar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1d1d1f;
  letter-spacing: -0.01em;
}

.file-badge {
  background: #e8f0fd;
  color: #0071e3;
  border-radius: 6px;
  padding: 0.2em 0.6em;
  font-size: 0.78rem;
  font-weight: 500;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary-sm {
  background: #0071e3;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.45rem 1rem;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary-sm:hover {
  background: #0077ed;
}

.btn-primary-sm:active {
  background: #006edb;
}

.btn-secondary-sm {
  background: #ffffff;
  color: #1d1d1f;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  padding: 0.45rem 1rem;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}

.btn-secondary-sm:hover {
  background: #f5f5f7;
  border-color: #b0b0b8;
}

/* ── Filter Bar ───────────────────────────────────────────── */
.filter-bar-wrap {
  padding: 0.75rem 1.5rem 0.5rem;
  background: #f5f5f7;
}

/* Machine selector chips */
.machine-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.5rem 0 0.25rem;
}

.machine-chip {
  border: 1.5px solid var(--chip-color, #d2d2d7);
  background: transparent;
  color: #6e6e73;
  border-radius: 20px;
  padding: 0.2rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  line-height: 1.6;
}

.machine-chip.active {
  background: var(--chip-color, #0071e3);
  color: #ffffff;
  border-color: var(--chip-color, #0071e3);
}

.filter-bar {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  padding: 0.65rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #6e6e73;
  white-space: nowrap;
}

.filter-input {
  background: #ffffff;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.84rem;
  color: #1d1d1f;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
  min-width: 140px;
}

.filter-input:focus {
  border-color: #0071e3;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.filter-input-sm {
  min-width: 90px;
  max-width: 110px;
}

#datalogSearch {
  min-width: 180px;
  max-width: 220px;
}

.snapshot-count {
  margin-left: auto;
  font-size: 0.82rem;
  color: #6e6e73;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Dashboard Body ───────────────────────────────────────── */
.dashboard-body {
  padding: 0 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Section Card ─────────────────────────────────────────── */
.section-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

/* ── Stats Container ──────────────────────────────────────── */
.stats-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stats-row {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.stats-machine-label {
  display: flex;
  flex-direction: column;
  min-width: 140px;
  gap: 0.15rem;
}

.stats-machine-ip {
  font-size: 0.88rem;
  font-weight: 600;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
}

.stats-machine-name {
  font-size: 0.78rem;
  color: #6e6e73;
}

.stats-values {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
}

.stat-item {
  background: #f5f5f7;
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  min-width: 80px;
  flex: 1 1 80px;
  text-align: center;
}

.stat-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6e6e73;
  margin-bottom: 0.2rem;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1d1d1f;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ── Chart ────────────────────────────────────────────────── */
.chart-section {
  padding: 1.25rem;
}

.chart-wrapper {
  position: relative;
  height: 320px;
  width: 100%;
}

.chart-wrapper canvas {
  width: 100% !important;
}

/* ── Datalog ──────────────────────────────────────────────── */
.datalog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #d2d2d7;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.datalog-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1d1d1f;
  flex-shrink: 0;
}

.datalog-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* Sortable table headers */
.sortable {
  cursor: pointer;
  user-select: none;
}

.sortable:hover {
  background: #ececed !important;
}

.sort-icon {
  font-size: 0.7rem;
  color: #aeaeb2;
  margin-left: 3px;
}

.datalog-wrapper {
  max-height: 500px;
  overflow-y: auto;
}

.datalog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.datalog-table thead th {
  background: #f5f5f7;
  color: #6e6e73;
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #d2d2d7;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.datalog-table tbody tr {
  border-bottom: 1px solid #f0f0f2;
  transition: background-color 0.1s ease;
}

.datalog-table tbody tr:hover {
  background: #f9f9fb;
}

.datalog-table tbody td {
  padding: 0.5rem 1rem;
  color: #1d1d1f;
  vertical-align: middle;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
}

.table-truncated-note {
  color: #6e6e73;
  font-style: italic;
  text-align: center;
  padding: 0.75rem 1rem !important;
  font-family: inherit !important;
}

/* ── Settings Overlay ─────────────────────────────────────── */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: #f5f5f7;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.settings-overlay.d-none {
  display: none !important;
}

.settings-header {
  background: #ffffff;
  border-bottom: 1px solid #d2d2d7;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.settings-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1d1d1f;
  letter-spacing: -0.01em;
}

.settings-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-body {
  padding: 1.5rem;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.settings-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #6e6e73;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
}

.settings-description {
  font-size: 0.85rem;
  color: #6e6e73;
  margin-bottom: 1.25rem;
}

/* ── Settings Machine List ────────────────────────────────── */
.settings-machine-row {
  background: #ffffff;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.settings-machine-ip {
  font-size: 0.93rem;
  font-weight: 600;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  min-width: 130px;
}

.settings-machine-name {
  font-size: 0.82rem;
  color: #6e6e73;
  flex: 1;
  min-width: 100px;
}

.settings-machine-controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.settings-multiplier-label {
  font-size: 0.82rem;
  color: #6e6e73;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.settings-multiplier-input {
  background: #ffffff;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.84rem;
  color: #1d1d1f;
  font-family: inherit;
  outline: none;
  width: 80px;
  transition: border-color 0.15s ease;
}

.settings-multiplier-input:focus {
  border-color: #0071e3;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.settings-toggle-label {
  font-size: 0.82rem;
  color: #6e6e73;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.settings-divider {
  border: none;
  border-top: 1px solid #d2d2d7;
  margin: 0 0 0.75rem;
}

/* ── Toggle Switch ────────────────────────────────────────── */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  width: 44px;
  height: 26px;
  background: #d2d2d7;
  border-radius: 13px;
  transition: background 0.2s;
  position: relative;
}

.toggle-switch input:checked + .toggle-track {
  background: #0071e3;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
}

/* ── Flatpickr Light Overrides ────────────────────────────── */
.flatpickr-input {
  background: #ffffff !important;
  border: 1px solid #d2d2d7 !important;
  color: #1d1d1f !important;
  border-radius: 8px !important;
}

.flatpickr-input:focus {
  border-color: #0071e3 !important;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12) !important;
}

.flatpickr-calendar {
  background: #ffffff !important;
  border: 1px solid #d2d2d7 !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12) !important;
  border-radius: 14px !important;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif !important;
}

.flatpickr-month,
.flatpickr-weekdays,
.flatpickr-weekday {
  background: #ffffff !important;
  color: #6e6e73 !important;
}

.flatpickr-current-month span.cur-month,
.flatpickr-current-month input.cur-year {
  color: #1d1d1f !important;
}

.flatpickr-day {
  color: #1d1d1f !important;
  border-radius: 8px !important;
}

.flatpickr-day:hover,
.flatpickr-day.inRange {
  background: rgba(0, 113, 227, 0.08) !important;
  border-color: transparent !important;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: #0071e3 !important;
  border-color: #0071e3 !important;
  color: #ffffff !important;
}

.flatpickr-day.flatpickr-disabled {
  color: #c7c7cc !important;
}

.flatpickr-time input {
  background: #f5f5f7 !important;
  color: #1d1d1f !important;
  border-radius: 8px !important;
}

.flatpickr-time .flatpickr-time-separator,
.flatpickr-time .flatpickr-am-pm {
  color: #6e6e73 !important;
}

.numInputWrapper span.arrowUp,
.numInputWrapper span.arrowDown {
  border-color: #d2d2d7 !important;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c7c7cc;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a1a1a6;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .dashboard-body {
    padding: 0 0.75rem 1.5rem;
  }

  .filter-bar-wrap {
    padding: 0.65rem 0.75rem;
  }

  .filter-bar {
    gap: 0.5rem;
  }

  .top-bar {
    padding: 0.75rem 1rem;
  }

  .stats-row {
    padding: 0.85rem 1rem;
  }

  .settings-body {
    padding: 1rem;
  }

  .chart-section {
    padding: 0.85rem;
  }
}

@media (max-width: 576px) {
  html {
    font-size: 14px;
  }

  .filter-input {
    min-width: 110px;
  }

  .snapshot-count {
    width: 100%;
    text-align: right;
  }
}
