@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@500;600&display=swap');

:root {
  --color-navy: #150B4D;
  --color-gold: #FFB900;
  --color-white: #FFFFFF;
  --color-body-text: #333333;
  --color-border-light: #E8E8E8;
  --color-muted: #ADADAD;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--color-white);
  color: var(--color-body-text);
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 500;
}

h1, h2, h3, label, .btn { font-weight: 600; }

.topnav {
  background: var(--color-navy);
  color: var(--color-white);
}
.topnav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand { font-size: 18px; color: var(--color-white); text-decoration: none; }
.brand:hover { opacity: 0.9; }
.accent { color: var(--color-gold); }
.topnav-link {
  color: var(--color-white);
  text-decoration: none;
  opacity: 0.85;
}
.topnav-link:hover { opacity: 1; text-decoration: underline; }

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.page-header { margin-bottom: 32px; }
.eyebrow {
  display: inline-block;
  color: var(--color-gold);
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.page-header h1 { font-size: 32px; margin: 4px 0 8px; color: var(--color-navy); }
.lede { color: var(--color-body-text); font-size: 15px; }
.muted { color: var(--color-muted); font-size: 14px; }

.flash-stack { margin-bottom: 24px; }
.flash {
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 10px;
  font-size: 14px;
}
.flash-error { background: var(--color-gold); color: var(--color-navy); }
.flash-message { background: var(--color-border-light); color: var(--color-body-text); }
.flash-notice { background: var(--color-navy); color: var(--color-white); }

.card {
  background: var(--color-white);
  border: 1px solid var(--color-border-light);
  border-radius: 20px;
  padding: 28px;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 767px) {
  .panel-grid { grid-template-columns: 1fr; }
}

.panel h2 { color: var(--color-navy); font-size: 20px; margin-top: 0; }

.panel {
  display: flex;
  flex-direction: column;
}
.panel form {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.panel form .form-fields {
  flex: 1;
}
.panel form .btn-block {
  margin-top: 24px;
}

.panel-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-heading-row h2 { margin-bottom: 0; }

.panel form label, .login-form label {
  display: block;
  margin: 14px 0 6px;
  font-size: 14px;
  color: var(--color-navy);
}
.panel form input[type="text"],
.panel form input[type="date"],
.panel form input[type="password"],
.panel form input[type="file"],
.panel form select,
.login-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border-light);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--color-body-text);
}
.checkbox-row input { width: auto; }

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
  /* The row owns the vertical spacing, not the label. A label's own
     margin (14px top, 6px bottom) is asymmetric, and align-items: center
     centres its margin box - which sits its text below the button's by half
     the difference. The row also needs more room than a bare label, since a
     button is taller and would otherwise crowd the fields either side. */
  margin: 26px 0 10px;
}
/* Qualified with .panel form so this outweighs the `.panel form label` rule
   above, which is more specific than a bare `.label-row label` and would
   otherwise keep its asymmetric margin. */
.panel form .label-row label,
.panel form .label-row .btn { margin: 0; }

/* The first row follows the panel's description rather than a field, and that
   paragraph already brings its own margin - 26px on top of it would leave the
   sensor picker floating away from the text that introduces it. */
.panel form .form-fields > .label-row:first-child { margin-top: 6px; }

.device-lookup {
  margin-top: 14px;
  padding: 4px 16px 16px;
  border: 1px dashed var(--color-border-light);
  border-radius: 10px;
}
.device-lookup[hidden] { display: none; }
.status-error { color: var(--color-navy); font-weight: 600; }

/* A disabled button still looks like a button, so say plainly that it is not
   taking clicks - otherwise a long fetch reads as an unresponsive page. */
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn.is-busy { cursor: progress; }

.panel form input[type="search"] {
  width: 100%;
  margin-bottom: 6px;
  padding: 10px 12px;
  border: 1px solid var(--color-border-light);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
}

.progress {
  height: 6px;
  margin-top: 8px;
  border-radius: 3px;
  background: var(--color-border-light);
  overflow: hidden;
}
.progress[hidden] { display: none; }
.progress-bar {
  width: 0;
  height: 100%;
  border-radius: 3px;
  background: var(--color-gold);
  transition: width 200ms ease;
}

.lookup-or {
  margin: 14px 0 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  text-align: center;
}

/* Greyed out rather than merely inert, so it's visible which control the form
   is actually going to submit. */
.panel form input:disabled,
.panel form select:disabled {
  background: var(--color-border-light);
  color: var(--color-muted);
  cursor: not-allowed;
}

.file-picker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  padding: 10px;
  border: 1px dashed var(--color-border-light);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.file-picker:hover { border-color: var(--color-gold); }
.file-picker.is-dragover {
  border-color: var(--color-gold);
  background: rgba(255, 185, 0, 0.08);
}
.file-picker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--color-gold);
  color: var(--color-navy);
  padding: 8px 20px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.file-picker-name {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  line-height: 1;
  color: var(--color-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-picker-name.has-file { color: var(--color-body-text); }
.file-picker-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 20px;
  padding: 15px 50px;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-block { width: 100%; margin-top: 22px; }
.btn-small { padding: 8px 20px; font-size: 13px; border-radius: 14px; white-space: nowrap; }
.btn-primary { background: var(--color-navy); color: var(--color-white); }
.btn-primary:hover { background: #241a63; }
.btn-secondary { background: var(--color-gold); color: var(--color-navy); }
.btn-secondary:hover { background: #ffc433; }

.login-wrap {
  display: flex;
  justify-content: center;
  padding-top: 60px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  border-radius: 20px;
  border: 1px solid var(--color-border-light);
  overflow: hidden;
}
.login-header {
  background: var(--color-navy);
  color: var(--color-white);
  padding: 32px 28px 24px;
}
.login-header h1 { margin: 4px 0 0; font-size: 26px; color: var(--color-white); }
.login-form { padding: 24px 28px 28px; }

.plot-card { margin-bottom: 24px; text-align: center; }
.plot-card img { max-width: 100%; border-radius: 10px; }

.coef-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.coef-table th { text-align: left; color: var(--color-navy); padding: 8px 0; }
.coef-table td { text-align: right; padding: 8px 0; }
.coef-table tr + tr { border-top: 1px solid var(--color-border-light); }

.recent-runs-card { margin-top: 24px; }

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

.runs-table { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; }
.runs-table th {
  text-align: left;
  color: var(--color-navy);
  padding: 8px 16px 8px 0;
  border-bottom: 1px solid var(--color-border-light);
}
.runs-table td { text-align: left; padding: 10px 16px 10px 0; }
.runs-table tr:not(:last-child) td { border-bottom: 1px solid var(--color-border-light); }
.runs-table td:last-child { text-align: right; padding-right: 0; }

.link-back {
  display: inline-block;
  margin-top: 16px;
  color: var(--color-navy);
  font-size: 14px;
  text-decoration: none;
}
.link-back:hover { text-decoration: underline; }

.accordion {
  margin-top: 24px;
  border: 1px solid var(--color-border-light);
  border-radius: 20px;
  padding: 20px 28px;
}
.accordion summary {
  cursor: pointer;
  color: var(--color-gold);
  font-weight: 600;
}
.accordion summary::marker { color: var(--color-navy); }
.accordion-body { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 16px; }
.accordion-body img { max-width: 100%; border-radius: 10px; }
