:root {
  --ink: #071012;
  --muted: #516267;
  --faint: #74868b;
  --line: #d4e0e3;
  --panel: #ffffff;
  --panel-2: #f7fbfc;
  --page: #eef6f7;
  --accent: #0c9aad;
  --accent-dark: #075e6b;
  --accent-soft: rgba(12, 154, 173, 0.14);
  --error: #a92525;
  --working: #8a5d00;
  --done: #176530;
  --shadow:
    0 0 0 1px rgba(7, 16, 18, 0.06),
    0 8px 24px rgba(7, 16, 18, 0.08);
  --shadow-strong:
    0 0 0 1px rgba(7, 16, 18, 0.08),
    0 18px 52px rgba(7, 16, 18, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(12, 154, 173, 0.14), rgba(12, 154, 173, 0) 240px),
    var(--page);
  color: var(--ink);
  font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 4vw, 2.65rem);
  line-height: 0.98;
  letter-spacing: -0.01em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 2.2vw, 1.55rem);
  line-height: 1.08;
}

h3 {
  margin-bottom: 0;
  font-size: 1.02rem;
  line-height: 1.15;
}

.app-shell {
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 92px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
}

.brand-lockup {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: start;
  gap: 9px;
  align-items: start;
}

.brand-lockup img {
  display: block;
  width: clamp(118px, 13vw, 175px);
  height: auto;
}

.captain-greeting {
  font-style: italic;
  text-align: left;
}

.eyebrow,
.card-kicker {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-actions,
.admin-nav form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.captain-name {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.modal-stats div {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 0 1px rgba(7, 16, 18, 0.06);
  padding: 12px 14px;
}

.modal-stats dd {
  display: block;
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 850;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.modal-stats dt {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.login-panel {
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.submission-panel,
.status-panel {
  padding: 6px 0 18px;
}

.dash-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  gap: 0;
}

.tab-btn {
  border: 0;
  background: none;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  min-height: 0;
  transition: color 150ms, border-color 150ms;
}

.tab-btn:hover:not(.active) {
  color: var(--ink);
}

.tab-btn.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* Admin is a real link (navigates away), styled to match the in-page tabs and pinned right. */
.tab-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  margin-left: auto;
  color: var(--accent-dark);
}

.tab-link:hover {
  color: var(--accent);
}

.tab-link.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.referral-banner {
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  font-weight: 700;
}

.referral-banner strong {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.08em;
}

.referral-hint {
  font-weight: 600;
  color: var(--muted);
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-tile {
  display: grid;
  gap: 4px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 850;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.stat-sub {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--faint);
}

.chart-card {
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.chart-card h3 {
  margin-bottom: 14px;
}

.revenue-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.revenue-chart .empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 24px 0;
}

@media (max-width: 520px) {
  .stat-tiles {
    grid-template-columns: 1fr;
  }
}

.status-panel {
  margin-top: 16px;
  animation: fade-up 240ms cubic-bezier(0.2, 0, 0, 1) both;
}

.status-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.panel-heading,
.submit-row,
.card-head,
.fish-head,
.status-customer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-heading {
  margin-bottom: 16px;
}

.panel-heading p,
.screen-popup-card p,
.status-customer p {
  margin-bottom: 0;
  color: var(--muted);
  text-wrap: pretty;
}

.customer-list,
.fish-list,
.status-list {
  display: grid;
  gap: 12px;
}

.customer-card {
  display: grid;
  gap: 14px;
  border-radius: 8px;
  background: var(--panel-2);
  box-shadow: 0 0 0 1px rgba(7, 16, 18, 0.06);
  padding: 16px;
  animation: fade-up 200ms cubic-bezier(0.2, 0, 0, 1) both;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 11px;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out, outline-color 150ms ease-out;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.fish-card {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 12px 0 0;
}

.fish-card.has-error .fish-head input {
  border-color: var(--error);
}

.fish-head {
  display: grid;
  grid-template-columns: 1fr 38px;
  align-items: end;
  gap: 8px;
}

.fish-calibration {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.fish-calib-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.calib-opt {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.calib-opt input[type="radio"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.fish-length-wrap label {
  display: grid;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 700;
}

.upload-box {
  display: grid;
  gap: 4px;
  cursor: pointer;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(12, 154, 173, 0.1), rgba(12, 154, 173, 0.035));
  box-shadow: 0 0 0 1px rgba(12, 154, 173, 0.22);
  padding: 13px;
  color: var(--ink);
  transition: box-shadow 150ms ease-out, transform 150ms ease-out;
}

.upload-box:hover {
  box-shadow: 0 0 0 1px rgba(12, 154, 173, 0.38), 0 8px 22px rgba(12, 154, 173, 0.12);
}

.upload-box:active {
  transform: scale(0.99);
}

.upload-box input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.upload-box span {
  font-weight: 850;
}

.upload-box small {
  color: var(--muted);
  font-weight: 750;
}

.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.file-list span,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: #e6eef0;
  padding: 4px 9px;
  font-size: 0.76rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.file-list span {
  max-width: min(320px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A selected-file chip carries its name plus a remove (×) button. Scoped under .file-list so
   these win over the broad `.file-list span` pill rule above. */
.file-list .file-chip {
  gap: 6px;
  padding-right: 5px;
}

.file-list .file-chip-name {
  background: none;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  max-width: min(260px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list .file-chip-remove {
  border: none;
  padding: 0;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  line-height: 1;
  font-weight: 900;
  cursor: pointer;
  background: rgba(7, 16, 18, 0.12);
  color: #071012;
}

.file-list .file-chip-remove:hover {
  background: #c0392b;
  color: #fff;
}

.pill.processing,
.pill.processing_with_errors,
.pill.measuring,
.pill.queued,
.pill.running {
  background: #fff1d6;
  color: var(--working);
}

.pill.done {
  background: #dff0e4;
  color: var(--done);
}

.pill.error {
  background: #f5dddd;
  color: var(--error);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.login-panel button,
.ghost-link {
  border-radius: 7px;
  cursor: pointer;
  font-weight: 850;
  text-decoration: none;
  transition: background-color 150ms ease-out, color 150ms ease-out, box-shadow 150ms ease-out, scale 150ms ease-out;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.icon-button:active,
.login-panel button:active,
.ghost-link:active {
  scale: 0.96;
}

.primary-button,
.login-panel button {
  border: 0;
  background: var(--accent);
  color: #ffffff;
  padding: 0 18px;
}

.primary-button:hover,
.login-panel button:hover {
  background: var(--accent-dark);
}

.primary-button:disabled,
.login-panel button:disabled,
.icon-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.icon-button:disabled {
  cursor: not-allowed;
}

.secondary-button {
  border: 0;
  background: #dceff2;
  color: var(--accent-dark);
  padding: 0 14px;
}

.secondary-button.compact {
  justify-self: start;
}

.ghost-button,
.ghost-link {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  color: var(--accent-dark);
  padding: 0 12px;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  background: #e6eef0;
  color: var(--ink);
}

.submit-row {
  position: sticky;
  bottom: 10px;
  z-index: 10;
  margin-top: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  padding: 12px;
  backdrop-filter: blur(8px);
}

.status-text {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 850;
}

.status-text.error,
.error-text {
  color: var(--error);
}

.status-text.working,
.status-text.warning {
  color: var(--working);
}

.status-text.done {
  color: var(--done);
}

.screen-popup {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(7, 16, 18, 0.36);
  backdrop-filter: blur(6px);
}

.screen-popup[hidden] {
  display: none;
}

.screen-popup-card {
  display: grid;
  justify-items: start;
  gap: 14px;
  width: min(480px, 100%);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow-strong);
  padding: 24px;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
}

.screen-popup.is-visible .screen-popup-card {
  animation: popup-enter 260ms cubic-bezier(0.2, 0, 0, 1) forwards;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  margin: 2px 0 0;
}

.modal-stats dd {
  margin: 0;
}

.screen-popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  width: 100%;
  margin-top: 6px;
}

.success-popup .screen-popup-card {
  justify-items: center;
  text-align: center;
}

.success-check {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--done);
}

.success-check.large {
  width: 58px;
  height: 58px;
}

.success-check::after {
  content: "";
  width: 18px;
  height: 10px;
  border-bottom: 3px solid #ffffff;
  border-left: 3px solid #ffffff;
  transform: rotate(-45deg) scale(0.8);
  transform-origin: center;
  animation: check-pop 360ms cubic-bezier(0.2, 0, 0, 1) 120ms both;
}

.success-check.large::after {
  width: 24px;
  height: 14px;
  border-bottom-width: 4px;
  border-left-width: 4px;
}

.status-customer {
  border-radius: 8px;
  background: var(--panel-2);
  box-shadow: 0 0 0 1px rgba(7, 16, 18, 0.06);
  padding: 14px;
}

.status-row {
  display: grid;
  grid-template-columns: 150px 120px minmax(0, 1fr) 110px;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 10px 0;
  font-variant-numeric: tabular-nums;
}

.status-row .error-text {
  grid-column: 1 / -1;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  display: grid;
  gap: 15px;
  padding: 26px;
}

.login-brand {
  grid-template-columns: 1fr;
  justify-items: center;
  text-align: center;
}

.pw-wrap {
  position: relative;
  display: block;
}

.pw-wrap input {
  width: 100%;
  padding-right: 64px;
}

/* Scoped under .login-panel to beat the `.login-panel button` fill rule. */
.login-panel .pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  min-height: 0;
  border: 0;
  background: none;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 6px 8px;
  cursor: pointer;
}

.login-panel .pw-toggle:hover {
  color: var(--accent);
}

.login-brand img {
  width: min(260px, 70vw);
  margin-inline: auto;
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-table {
  display: grid;
  gap: 4px;
  margin-top: 18px;
}

.admin-row {
  display: grid;
  grid-template-columns: 72px 170px minmax(160px, 1fr) 100px 80px minmax(220px, 1.2fr);
  gap: 12px;
  align-items: center;
  border-radius: 7px;
  color: var(--ink);
  padding: 10px 12px;
  text-decoration: none;
}

.admin-row:not(.admin-row-head):hover {
  background: #e9f5f7;
}

.admin-row-head,
.debug-dl dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.empty-state {
  margin: 16px 0 0;
  color: var(--muted);
}

.review-approve {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--accent-soft);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--accent-dark);
}

.review-approve button {
  min-height: 40px;
}

.debug-summary {
  margin-bottom: 20px;
}

.debug-dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
}

.debug-dl div,
.debug-item {
  display: grid;
  gap: 6px;
}

.debug-dl dd {
  margin: 0;
  font-weight: 750;
}

.debug-item {
  border-top: 1px solid var(--line);
  gap: 16px;
  margin-top: 18px;
  padding: 18px 0 0;
}

.debug-item h3,
.debug-item h4 {
  margin-bottom: 4px;
}

.debug-item code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.86em;
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.debug-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.debug-list a {
  color: var(--accent-dark);
  font-weight: 800;
}

.debug-json {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px 12px;
}

.debug-json summary {
  cursor: pointer;
  font-weight: 850;
}

.debug-json pre {
  overflow: auto;
  max-height: 380px;
  margin: 12px 0 0;
  font-size: 0.78rem;
}

.form-error {
  margin-bottom: 0;
  color: var(--error);
  font-weight: 800;
}

.field-error {
  margin: -2px 0 0;
  color: var(--error);
  font-size: 0.82rem;
  font-weight: 850;
}

.upload-summary {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: 22px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .brand-lockup {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
  }

  .brand-lockup img {
    order: 2;
    justify-self: end;
    width: min(96px, 30vw);
  }

  .brand-lockup > div {
    order: 1;
    min-width: 0;
  }

  .captain-greeting {
    font-size: clamp(1.75rem, 8vw, 2.25rem);
    line-height: 1;
  }

  .account-actions {
    justify-content: space-between;
  }

  .captain-name {
    display: none;
  }

  .panel-heading,
  .submit-row {
    align-items: stretch;
    flex-direction: column;
  }

  .field-grid,
  .admin-row,
  .debug-dl,
  .debug-grid {
    grid-template-columns: 1fr;
  }

  .status-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .status-row > span {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
  }

  .status-row > span::before {
    content: attr(data-label);
    color: var(--faint);
    font-size: 0.7rem;
    font-weight: 850;
    text-transform: uppercase;
  }

  .status-row .pill {
    justify-self: start;
  }

  .customer-card {
    padding: 14px;
  }

  .submit-row {
    bottom: 8px;
  }

  .submit-row .primary-button {
    width: 100%;
  }

  .screen-popup {
    align-items: end;
    padding: 12px;
  }

  .screen-popup-card {
    padding: 20px;
  }

  .screen-popup-actions {
    flex-direction: column-reverse;
  }

  .screen-popup-actions button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 1.65rem;
  }

  .fish-head {
    grid-template-columns: 1fr 38px;
  }

  .fish-head label {
    min-width: 0;
  }

  .modal-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popup-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes check-pop {
  from {
    opacity: 0;
    transform: rotate(-45deg) scale(0.25);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: rotate(-45deg) scale(1);
    filter: blur(0);
  }
}
