/*
 * HubSpot Import - styles.
 * Order: tokens, base, app bar, layout, buttons, forms, alerts, upload, preview, security.
 * House rules: 5px corners, no shadows, hairline borders only where they separate content.
 */

/* Tokens ---------------------------------------------------------------------------------------------------- */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #f4f5f7;
  --text: #1a1d23;
  --muted: #6b7280;
  --border: #e2e5ea;
  --border-strong: #c9ced6;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --language-bg: #f3e8ff;
  --language-fg: #7e22ce;
  --success-bg: #d1fae5;
  --success-fg: #065f46;
  --warning-bg: #fef3c7;
  --warning-fg: #92400e;
  --danger-bg: #fef2f2;
  --danger-fg: #b91c1c;
  --radius: 5px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-muted: #11141a;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --border: #2a2f38;
    --border-strong: #3a414d;
    --accent: #4f8cff;
    --accent-hover: #6b9fff;
    --accent-soft: #1a2333;
    --language-bg: #2a1f3d;
    --language-fg: #d8b4fe;
    --success-bg: #0f2e22;
    --success-fg: #6ee7b7;
    --warning-bg: #3a2a0c;
    --warning-fg: #fcd34d;
    --danger-bg: #3a1515;
    --danger-fg: #fca5a5;
  }
}

/* Base ------------------------------------------------------------------------------------------------------ */

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }
code { font-family: var(--mono); font-size: .92em; }
a { color: var(--accent); }
.icon { width: 16px; height: 16px; flex: none; }
.truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* App bar --------------------------------------------------------------------------------------------------- */

.appbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.appbar-inner {
  max-width: 1432px; margin: 0 auto; padding: 0 16px; height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 650; color: var(--text); text-decoration: none; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: var(--radius); }
.brand-mark .icon { width: 17px; height: 17px; }
.appbar-nav { display: flex; align-items: center; gap: 6px; }
.appbar-nav form { margin: 0; }
.nav-link { display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 12px; font-size: 14px; border-radius: var(--radius); }
.nav-link { color: var(--text); text-decoration: none; font-weight: 500; }
.nav-link:hover { background: var(--surface-muted); }
.nav-link .icon { color: var(--muted); }

/* Layout ---------------------------------------------------------------------------------------------------- */

.main { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 16px; padding: 16px 16px 32px; } /* one spacing: 16px above, between and beside blocks */
.main > * { width: 100%; max-width: 1400px; min-width: 0; }
.divider-v { width: 1px; height: 28px; background: var(--border); flex: none; }

/* Buttons --------------------------------------------------------------------------------------------------- */

.btn {
  height: 40px; padding: 0 16px; margin: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 500 14px/1 var(--font); color: var(--text); white-space: nowrap; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-muted); border-color: var(--border-strong); }
.btn:focus-visible, .link-button:focus-visible, .nav-link:focus-visible, .brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn .icon { color: var(--muted); }
.btn-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.btn-primary .icon { color: currentColor; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger-fg); }
.btn-danger:hover { color: var(--danger-fg); background: var(--danger-bg); border-color: var(--danger-fg); }
.btn-block { width: 100%; height: 50px; font-size: 15px; font-weight: 600; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; font-weight: 600; }
.btn-icon { width: 40px; padding: 0; }
.link-button { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }

/* Cards and forms ------------------------------------------------------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.card-title { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.card-subtitle { margin-top: 4px; font-size: 14px; color: var(--muted); }
.form { display: grid; gap: 18px; }

.field { display: grid; gap: 6px; min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { font-size: 13px; font-weight: 600; }
.label-code { font-family: var(--mono); }
.label-hint { margin-left: 6px; font-weight: 400; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); }

input[type=text], input[type=password], textarea {
  width: 100%; padding: 11px 12px; font: inherit; color: var(--text);
  background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s;
}
input[type=text]:focus, input[type=password]:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { font: 13px/1.6 var(--mono); resize: vertical; }

@media (max-width: 520px) {
  .card { padding: 24px 20px; }
  .field-row { grid-template-columns: 1fr; }
}

/* Alerts and notices ---------------------------------------------------------------------------------------- */

.alert { padding: 12px 14px; font-size: 14px; border-radius: var(--radius); }
.alert-error { color: var(--danger-fg); background: var(--danger-bg); }
.alert-warning { color: var(--warning-fg); background: var(--warning-bg); }
.alert-success { color: var(--success-fg); background: var(--success-bg); }

.notice {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.notice-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: none; color: var(--accent); background: var(--accent-soft); border-radius: var(--radius); }
.notice-icon .icon { width: 19px; height: 19px; }
.notice-text { flex: 1; display: grid; gap: 1px; min-width: 0; font-size: 13px; color: var(--muted); }
.notice-text strong { font-size: 14px; font-weight: 600; color: var(--text); }
@media (max-width: 520px) { .notice { flex-wrap: wrap; } .notice .btn { width: 100%; } }

/* Upload ---------------------------------------------------------------------------------------------------- */

.upload-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.upload-step { display: grid; grid-template-rows: auto 1fr; gap: 16px; padding: 24px 20px 28px 16px; min-width: 0; }
.upload-step + .upload-step { border-left: 1px solid var(--border); }
.step-title { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 650; }
.step-number {
  width: 24px; height: 24px; display: grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: var(--radius);
}
.step-hint { margin-left: 2px; font-size: 13px; font-weight: 400; color: var(--muted); }
.upload-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 20px 16px 16px; border-top: 1px solid var(--border);
}
.upload-footer .alert { flex: 1; }
@media (max-width: 860px) {
  .upload-body { grid-template-columns: 1fr; }
  .upload-step + .upload-step { border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 520px) {
  .upload-footer { flex-direction: column; align-items: stretch; }
}

.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  justify-content: center; min-height: 220px; padding: 30px 16px; border: 2px dashed var(--border); border-radius: var(--radius);
  font-weight: 400; cursor: pointer; transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone .icon { width: 36px; height: 36px; color: var(--accent); }
.dropzone strong { font-size: 15px; }
.dropzone span { font-size: 13px; color: var(--muted); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.utm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-wide { grid-column: 1 / -1; }
@media (max-width: 520px) { .utm-grid { grid-template-columns: 1fr; } }

/* Preview: header and summary ------------------------------------------------------------------------------- */

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-header {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px;
  padding: 16px 20px 16px 16px; border-bottom: 1px solid var(--border);
}
.panel-heading { display: flex; align-items: center; gap: 16px; min-width: 0; }
.panel-titles { display: grid; gap: 2px; min-width: 0; }
.panel-title { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.panel-subtitle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.panel-subtitle .truncate { max-width: 60ch; }
.panel-subtitle .icon { width: 14px; height: 14px; }
.panel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.panel-alert { padding: 10px 16px; font-size: 13px; color: var(--warning-fg); background: var(--warning-bg); border-bottom: 1px solid var(--border); }

/* Summary figures: label, value, note - text colours only. */
.kpis {
  margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); color: #fff; background: var(--accent); /* the button blue */
}
.kpi { padding: 16px 20px 16px 16px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid rgba(255, 255, 255, .18); }
.kpi dt { font-size: 12px; color: rgba(255, 255, 255, .8); }
.kpi dd { margin: 0; }
.kpi-value { margin-top: 4px; font-size: 22px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.kpi-note { margin-top: 3px; font-size: 12px; color: rgba(255, 255, 255, .8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(odd) { border-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid rgba(255, 255, 255, .18); }
}

/* Preview: company rows ------------------------------------------------------------------------------------- */

.company + .company { border-top: 1px solid var(--border); }
.company summary { display: flex; align-items: center; gap: 16px; padding: 16px 20px 16px 16px; cursor: pointer; list-style: none; }
.company summary::-webkit-details-marker { display: none; }
.company summary:focus { outline: none; }
.chevron { width: 24px; height: 24px; display: grid; place-items: center; flex: none; }
.chevron::before {
  content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s;
}
.company[open] .chevron::before { transform: rotate(45deg); }
.company-id { min-width: 150px; font-size: 14px; white-space: nowrap; flex: none; }
.tag { flex: none; padding: 2px 8px; font-size: 12px; white-space: nowrap; border-radius: var(--radius); }
.tag-cars { color: var(--accent); background: var(--accent-soft); }
.tag-language { color: var(--language-fg); background: var(--language-bg); }
/* Thumbnails start under the toolbar buttons; the width is measured by app.js. */
.thumbs { display: flex; gap: 6px; margin-left: auto; width: var(--actions-width, 366px); }
.thumbs img { width: 56px; height: 38px; object-fit: cover; border-radius: var(--radius); }
@media (max-width: 640px) {
  .thumbs { display: none; }
  .company summary { flex-wrap: wrap; gap: 8px; }
  .company-id { min-width: 0; }
}

/* Preview: one card per car - photo, then the exact HubSpot properties --------------------------------------- */

.company-body { display: grid; gap: 16px; padding: 0 16px 16px; container-type: inline-size; }
.car { display: grid; grid-template-columns: 340px minmax(0, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.car-photo { position: relative; margin: 16px; min-height: 220px; overflow: hidden; background: var(--surface-muted); border-radius: var(--radius); } /* fills the card height, 16px space around */
.car-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.badge { position: absolute; top: 8px; left: 8px; padding: 3px 9px; font-size: 12px; font-weight: 600; color: #fff; background: rgba(17, 24, 39, .72); border-radius: var(--radius); }

/* The exact HubSpot properties of one car: name column, value column, hairline rows. */
.properties { margin: 0; border-left: 1px solid var(--border); container-type: inline-size; }
.properties div { display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.properties div + div { border-top: 1px solid var(--border); }
.properties dt, .properties dd { display: flex; align-items: center; padding: 11px 16px; }
.properties dt { font-size: 13px; color: var(--text); background: var(--surface-muted); border-right: 1px solid var(--border); }
.properties dd { margin: 0; font-size: 14px; color: var(--text); white-space: pre-line; overflow-wrap: anywhere; }
.pill { padding: 2px 10px; font-size: 12px; font-weight: 600; color: var(--success-fg); background: var(--success-bg); border-radius: var(--radius); }

@container (max-width: 720px) {
  .car { grid-template-columns: 1fr; }
  .car-photo { margin: 16px 16px 0; min-height: 0; aspect-ratio: 4 / 3; }
  .properties { margin-top: 16px; border-left: 0; border-top: 1px solid var(--border); }
}
@container (max-width: 560px) {
  .properties div { grid-template-columns: minmax(0, 1fr); }
  .properties dt { border-right: 0; padding-bottom: 0; background: none; }
  .properties dd { padding-top: 4px; }
}

/* Security page --------------------------------------------------------------------------------------------- */

.page-head {
  display: flex; align-items: center; gap: 16px; padding: 16px 20px 16px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; } /* cards stretch to equal height */
@media (max-width: 960px) { .settings-grid { grid-template-columns: 1fr; } }
.page-title { font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.setting { display: flex; flex-direction: column; gap: 20px; padding: 24px; }
/* Steps on top, actions pinned to the bottom, so the button rows of both cards line up. */
.setting-body { flex: 1; display: flex; flex-direction: column; gap: 18px; }
.setting-actions { margin-top: auto; display: grid; gap: 18px; }
.field-fill { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.field-fill textarea { flex: 1; min-height: 140px; }
.setting-head { display: flex; align-items: flex-start; gap: 14px; }
.setting-text { flex: 1; min-width: 0; }
.setting-text h2 { font-size: 16px; font-weight: 650; }
.setting-text p { margin-top: 2px; font-size: 14px; color: var(--muted); }
.status { flex: none; padding: 3px 10px; font-size: 12px; font-weight: 600; border-radius: var(--radius); }
.status-on { color: var(--success-fg); background: var(--success-bg); }
.status-off { color: var(--muted); background: var(--surface-muted); }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 14px; font-size: 14px; }
.steps li::marker { color: var(--muted); }
.enrol { margin-top: 12px; display: flex; align-items: center; gap: 20px; }
.enrol-manual { flex: 1; min-width: 0; display: grid; gap: 8px; }
.qr-frame { flex: none; width: 176px; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.qr { display: block; width: 100%; height: auto; }
@media (max-width: 520px) { .enrol { flex-direction: column; align-items: flex-start; } }
.secret { display: flex; align-items: center; gap: 10px; }
.secret code { flex: 1; min-width: 0; padding: 10px 12px; font-size: 14px; letter-spacing: .06em; overflow-wrap: anywhere; background: var(--surface-muted); border-radius: var(--radius); }

/* Sign-in screen: brand panel (CSS only) beside the form -------------------------------------------------- */

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }

.auth-visual {
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  padding: 48px 56px; color: #fff; overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px) 0 0 / 36px 36px,
    var(--accent);
}
.brand-inverse { color: #fff; }
.brand-inverse .brand-mark { background: rgba(255, 255, 255, .16); }
.auth-pitch { max-width: 470px; }
.auth-pitch h2 { font-size: 32px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
.auth-pitch p { margin-top: 14px; font-size: 16px; color: rgba(255, 255, 255, .82); }

/* A stylised glimpse of the preview list - decoration only (aria-hidden on the panel). */
.auth-mock { max-width: 520px; display: grid; gap: 8px; }
.auth-mock-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; font-size: 13px;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16); border-radius: var(--radius);
}
.auth-mock-id { min-width: 132px; white-space: nowrap; }
.auth-mock-tag { padding: 1px 8px; font-size: 12px; white-space: nowrap; background: rgba(255, 255, 255, .16); border-radius: var(--radius); }
.auth-mock-thumbs { margin-left: auto; display: flex; gap: 6px; }
.auth-mock-thumbs i { display: block; width: 40px; height: 27px; background: rgba(255, 255, 255, .22); border-radius: var(--radius); }

.auth-points { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; font-size: 14px; color: rgba(255, 255, 255, .88); }
.auth-points li { display: flex; align-items: center; gap: 10px; }

.auth-panel { display: grid; place-items: center; padding: 48px 24px; }
.auth-form { width: 100%; max-width: 380px; }
.auth-form .card-title { font-size: 26px; }
.auth-brand-small { display: none; }
.auth-foot { font-size: 12px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-panel { place-items: start center; padding-top: 48px; }
  .auth-brand-small { display: inline-flex; margin-bottom: 12px; }
}
