:root {
  --navy: #2c3e50;
  --teal: #1abc9c;
  --gold: #f1c40f;
  --coral: #e74c3c;
  --bg: #f0f4f8;
  --card: #ffffff;
  --text: #2c3e50;
  --border: #dde3ea;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------
   Layout
----------------------------------- */
.main-content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px;
  flex: 1;
}

/* --------------------------------
   Header
----------------------------------- */
.page-header {
  text-align: center;
  margin-bottom: 20px;
}

.header-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.header-left {
  justify-self: start;
}

.page-title {
  margin: 0;
  justify-self: center;
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 700;
}

.header-actions {
  justify-self: end;
}

/* --------------------------------
   Aim box
----------------------------------- */
.aim-box {
  background: rgba(26, 188, 156, 0.1);
  border: 2px solid var(--teal);
  border-radius: 10px;
  padding: 15px 20px;
  margin-bottom: 20px;
  text-align: center;
  color: var(--navy);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* --------------------------------
   Two-panel layout
----------------------------------- */
.sim-layout {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 24px;
  align-items: start;
}

.panel {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

/* Apparatus panel */
.apparatus-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.apparatus-panel canvas {
  display: block;
  max-width: 100%;
  height: auto;
  touch-action: none;
}

/* Controls panel */
.controls-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --------------------------------
   Data table
----------------------------------- */
.data-section h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.data-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

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

.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: center;
}

.data-table th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.85rem;
}

.data-table td input {
  width: 80px;
  padding: 4px 6px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.data-table td input:focus {
  border-color: var(--teal);
}

/* --------------------------------
   Buttons
----------------------------------- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn--disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  background-color: #556366;
  color: #fff;
}

.gold-btn {
  background-color: var(--gold);
  color: var(--navy);
}

.gold-btn:hover {
  background-color: rgba(241, 196, 15, 0.7);
}

.btn-add {
  background: var(--teal);
  color: #fff;
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  font-size: 0.9rem;
}

.btn-add:hover {
  background: #16a085;
}

.btn-clear {
  background: transparent;
  color: var(--coral);
  border: 1.5px solid var(--coral);
  padding: 6px 12px;
}

.btn-clear:hover {
  background: var(--coral);
  color: #fff;
}

.btn-download {
  background: var(--navy);
  color: #fff;
  padding: 6px 12px;
}

.btn-download:hover {
  background: #34495e;
}

.row-delete {
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--coral);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}

.row-delete:hover {
  background: rgba(231, 76, 60, 0.1);
  color: #c0392b;
}

/* --------------------------------
   Investigation section
----------------------------------- */
.investigation-section {
  margin-top: 24px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.investigation-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--navy);
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.investigation-toggle:hover {
  background: #34495e;
}

.chevron {
  transition: transform 0.3s;
}

.investigation-toggle.open .chevron {
  transform: rotate(180deg);
}

.investigation-body {
  display: none;
  background: var(--card);
  padding: 20px 24px;
}

.investigation-body.open {
  display: block;
}

.investigation-body ol {
  margin: 0;
  padding-left: 1.5rem;
}

.investigation-body li {
  margin-bottom: 10px;
  font-size: 0.9rem;
  line-height: 1.65;
}

.investigation-body li:last-child {
  margin-bottom: 0;
}

/* --------------------------------
   Footer
----------------------------------- */
.site-footer {
  background: var(--navy);
  color: #fff;
  text-align: center;
  padding: 16px;
  font-size: 0.8rem;
  margin-top: 32px;
}

.site-footer p {
  margin: 0;
}

/* --------------------------------
   Focus
----------------------------------- */
a:focus,
button:focus,
input:focus {
  outline: 3px solid rgba(26, 188, 156, 0.18);
  outline-offset: 2px;
}

/* --------------------------------
   Responsive
----------------------------------- */
@media (max-width: 800px) {
  .sim-layout {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 16px 12px;
  }

  .controls-panel {
    padding: 16px;
  }

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

  .header-grid {
    grid-template-columns: 1fr;
    grid-auto-flow: row;
    text-align: left;
  }

  .page-title {
    justify-self: start;
  }

  .header-actions {
    justify-self: start;
    width: 100%;
    margin-top: 8px;
  }
}
