/* Valve Market Analyzer — AVK brand stylesheet (avkvalves.com visual identity) */
:root {
  --avk-blue:   #002395;   /* AVK primary blue */
  --avk-blue2:  #19389F;   /* AVK secondary blue */
  --avk-blue-bg:#EEF1FA;   /* light blue tint for subtle backgrounds */
  --avk-red:    #C8102E;   /* AVK brand red */
  --avk-dark:   #1D1D1B;   /* near-black body text */
  --avk-grey:   #6B6F72;   /* medium grey */
  --avk-light:  #E2E4E8;   /* borders / dividers */
  --text:       #1D1D1B;
  --white:      #FFFFFF;
  --radius:     3px;
  --shadow:     0 2px 8px rgba(0,0,0,.09);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Helvetica Neue", Arial, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: #F5F6F9;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: var(--white);
  border-bottom: 3px solid var(--avk-blue);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  box-shadow: 0 1px 5px rgba(0,0,0,.07);
  position: relative;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
}
.logo {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: .06em;
  color: var(--avk-blue);
  line-height: 1.2;
  user-select: none;
  white-space: nowrap;
  flex: 0 0 auto;
}
.logo-sub {
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--avk-grey);
  display: block;
  margin-top: 1px;
  text-transform: uppercase;
}
.header-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: .82rem;
  font-weight: 700;
  color: var(--avk-dark);
  text-transform: uppercase;
  letter-spacing: .1em;
  white-space: nowrap;
  pointer-events: none;
}
.header-user {
  margin-left: auto;
  font-size: .82rem;
  color: var(--avk-grey);
  flex: 0 0 auto;
}
.header-link {
  color: var(--avk-blue);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  margin-left: 1rem;
}
.header-link:hover { text-decoration: underline; color: #001570; }

/* ── Layout ── */
main {
  max-width: 880px;
  margin: 2rem auto;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Card ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  border-top: 3px solid var(--avk-blue);
}
.card h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--avk-blue);
  margin-bottom: .4rem;
  letter-spacing: -.01em;
}
.card h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--avk-blue);
  margin-bottom: 1rem;
}
.subtitle { color: var(--avk-grey); margin-bottom: 1.5rem; line-height: 1.55; }
.job-id-label code { font-family: "Consolas", "Courier New", monospace; font-size: .82rem; }

/* ── Form ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.field { display: flex; flex-direction: column; gap: .35rem; }
/* Pin a field to column 2 of the form-grid — used for Country so it lands
   below Sub-Region instead of starting a new row in column 1. */
.field--col-2 { grid-column: 2; }
.field label {
  font-weight: 600;
  font-size: .82rem;
  color: var(--avk-dark);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.hint { font-weight: 400; color: var(--avk-grey); font-size: .8rem; text-transform: none; letter-spacing: 0; }
.field input, .field select {
  padding: .55rem .75rem;
  border: 1px solid #C8CAD0;
  border-radius: var(--radius);
  font-size: .93rem;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--avk-blue);
  box-shadow: 0 0 0 3px rgba(0,35,149,.10);
}
.field select:disabled { background: #F5F6F9; color: var(--avk-grey); }

.form-actions {
  margin-top: 1.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.runtime-note { font-size: .83rem; color: var(--avk-grey); }

/* ── Buttons ── */
.btn {
  padding: .62rem 1.6rem;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  letter-spacing: .03em;
  text-transform: uppercase;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-primary {
  background: var(--avk-blue);
  color: var(--white);
  border-color: var(--avk-blue);
}
.btn-primary:hover {
  background: #001570;
  border-color: #001570;
}
.btn-secondary {
  background: var(--white);
  color: var(--avk-blue);
  border-color: var(--avk-blue);
}
.btn-secondary:hover {
  background: var(--avk-blue);
  color: var(--white);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Alerts ── */
.alert {
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  font-size: .9rem;
  line-height: 1.5;
}
.alert-warn  { background: #FFF8E1; border-left: 4px solid #F5A623; }
.alert-error { background: #FDE8EB; border-left: 4px solid var(--avk-red); color: #8C0000; }

/* ── Progress ── */
.progress-wrap {
  height: 6px;
  background: var(--avk-light);
  border-radius: 3px;
  overflow: hidden;
  margin: 1rem 0 .4rem;
}
.progress-bar {
  height: 100%;
  background: var(--avk-blue);
  border-radius: 3px;
  transition: width .4s ease;
}
.pct-label {
  font-size: .78rem;
  color: var(--avk-grey);
  text-align: right;
  margin-bottom: 1.2rem;
}

/* ── Step indicators ── */
.steps {
  display: flex;
  align-items: center;
  margin-bottom: 1.5rem;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  flex: 0 0 auto;
}
.step-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--avk-light);
  transition: background .3s, border-color .3s;
}
.step.active .step-dot   { background: var(--avk-blue);  border-color: var(--avk-blue); }
.step.done .step-dot     { background: #2A9D2A;           border-color: #2A9D2A; }
.step.error .step-dot    { background: var(--avk-red);    border-color: var(--avk-red); }
.step-label { font-size: .72rem; text-align: center; color: var(--avk-grey); }
.step.active .step-label { color: var(--avk-blue); font-weight: 700; }
.step-line { flex: 1; height: 2px; background: var(--avk-light); min-width: 20px; }

/* ── Log ── */
.log-box {
  background: #F7F8FC;
  border: 1px solid var(--avk-light);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .82rem;
  font-family: "Consolas", "Courier New", monospace;
  color: #444;
  max-height: 280px;
  overflow-y: auto;
  line-height: 1.7;
}

/* ── Run stats ── */
.run-stats {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  font-size: .85rem;
  color: var(--avk-grey);
  margin-bottom: 1rem;
}
.run-stats strong { color: var(--text); }
.stats-sep { color: var(--avk-light); margin: 0 .1rem; }
.stat-highlight { color: #1E7C1E; font-weight: 600; }
.stat-highlight strong { color: #1E7C1E; font-size: 1.1rem; }

/* ── QA verdict banner ── */
.qa-banner {
  display: flex;
  align-items: baseline;
  gap: .65rem;
  padding: .7rem 1rem;
  border-radius: var(--radius);
  border-left: 5px solid;
  margin-bottom: 1.1rem;
  font-size: .9rem;
  line-height: 1.5;
}
.qa-banner.qa-pass   { background: #F0FAF0; border-color: #2A9D2A; }
.qa-banner.qa-review { background: #FFF8E1; border-color: #D4900A; }
.qa-banner.qa-fail   { background: #FDE8EB; border-color: var(--avk-red); }
.qa-verdict-label {
  font-weight: 800;
  font-size: .8rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: .18rem .55rem;
  border-radius: 2px;
  color: var(--white);
}
.qa-pass   .qa-verdict-label { background: #2A9D2A; }
.qa-review .qa-verdict-label { background: #D4900A; }
.qa-fail   .qa-verdict-label { background: var(--avk-red); }
.qa-summary-text { color: var(--avk-dark); }

/* ── Downloads ── */
.downloads-title {
  color: #1E7C1E;
  margin-bottom: 1rem;
  font-size: 1.05rem;
  font-weight: 700;
}
.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .75rem;
}
.dl-card {
  border: 1px solid var(--avk-light);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  background: #FAFBFD;
}
.dl-card .dl-label { font-size: .76rem; color: var(--avk-grey); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.dl-card a.btn { width: 100%; text-align: center; font-size: .8rem; padding: .4rem .6rem; }
.downloads-actions { display: flex; gap: .75rem; margin-top: 1.5rem; align-items: center; }

/* ── Recent runs table ── */
.recent-runs table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.recent-runs th, .recent-runs td {
  padding: .55rem .75rem;
  border-bottom: 1px solid var(--avk-light);
  text-align: left;
}
.recent-runs th {
  font-weight: 700;
  color: var(--avk-dark);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: #F7F8FC;
}
.recent-runs tbody tr:hover td { background: #EEF1FA; }
.status-running  { color: var(--avk-blue);  font-weight: 600; }
.status-complete { color: #1E7C1E;          font-weight: 600; }
.status-failed   { color: var(--avk-red);   font-weight: 600; }
.status-queued   { color: var(--avk-grey); }

/* ── Confirmation modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,16,60,.50);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--white);
  border-radius: var(--radius);
  border-top: 3px solid var(--avk-blue);
  box-shadow: 0 8px 32px rgba(0,0,0,.20);
  padding: 2rem;
  width: min(480px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.modal-box h2 { font-size: 1.1rem; color: var(--avk-blue); font-weight: 700; }
.modal-intro  { color: var(--avk-grey); font-size: .9rem; }
.modal-params {
  background: #F5F6F9;
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .3rem .8rem;
  font-size: .88rem;
}
.modal-params dt { color: var(--avk-grey); font-weight: 600; white-space: nowrap; }
.modal-params dd { color: var(--text); font-weight: 500; }
.modal-note {
  font-size: .82rem;
  color: var(--avk-grey);
  line-height: 1.5;
  border-left: 3px solid var(--avk-blue);
  padding-left: .7rem;
}
.modal-actions { display: flex; gap: .75rem; margin-top: .25rem; }

/* ── Valve-category multi-select ── */
.valve-cats {
  border: 1px solid #E2E5EA;
  border-radius: var(--radius);
  padding: .8rem 1rem 1rem;
  margin: 1rem 0;
}
.valve-cats legend {
  font-weight: 600;
  font-size: .9rem;
  padding: 0 .35rem;
  color: var(--avk-blue);
}
.valve-cats-cols {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.valve-cats-col-title {
  margin: 0 0 .4rem 0;
  font-size: .78rem;
  font-weight: 700;
  color: var(--avk-grey);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid #E2E5EA;
  padding-bottom: .3rem;
}
.valve-cats-list {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.valve-cats-empty {
  font-size: .8rem;
  color: var(--avk-grey);
  margin: .3rem 0;
  font-style: italic;
}
.valve-cat {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .3rem .4rem;
  border-radius: 4px;
  cursor: pointer;
}
.valve-cat:hover { background: #F5F6F9; }
.valve-cat input { flex-shrink: 0; }
.valve-cat-name {
  flex: 1;
  font-size: .9rem;
  /* Some category names are long — wrap rather than ellipsis so the user
     always sees the full identifier. */
  overflow-wrap: anywhere;
}
.valve-cat-help {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #E2E5EA;
  color: var(--avk-grey);
  font-size: .72rem;
  font-weight: 700;
  font-family: inherit;
  cursor: help;
  transition: background .15s, color .15s;
}
.valve-cat-help:hover,
.valve-cat-help:focus-visible {
  background: var(--avk-blue);
  color: white;
  outline: none;
}

/* ── Help popup (click on ? icon) ── */
.valve-cat-popup {
  position: absolute;
  z-index: 1000;
  max-width: 360px;
  padding: .7rem 2rem .7rem .85rem;
  background: white;
  color: var(--text);
  border: 1px solid #D5D9E0;
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(15, 30, 60, 0.18);
  font-size: .82rem;
  line-height: 1.45;
}
.valve-cat-popup-body {
  white-space: pre-wrap;
}
.valve-cat-popup-close {
  position: absolute;
  top: .25rem;
  right: .4rem;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--avk-grey);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.valve-cat-popup-close:hover { background: #F0F2F5; color: var(--avk-blue); }

/* ── Responsive ── */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  /* On a single-column grid the column pinning isn't meaningful; let it
     flow naturally so we don't leave a blank row above Country. */
  .field--col-2 { grid-column: auto; }
  .steps { flex-wrap: wrap; gap: .5rem; }
  .step-line { display: none; }
}
