/* MG DSR Upload Portal — design system (handoff 2026-06-29)
   Premium automotive/enterprise: graphite/black + white, restrained MG-red accent,
   thin rules, generous spacing. Fonts: Archivo (UI) + IBM Plex Mono (codes). */

:root {
  --ink: #0E0E10;
  --header-grad: linear-gradient(160deg, #161719 0%, #0C0C0E 60%, #070708 100%);
  --app-bg: #F4F4F5;
  --card: #FFFFFF;
  --card-border: #E6E6E8;
  --row-divider: #F2F2F3;
  --section-divider: #EEEEF0;
  --text-strong: #3A3A3D;
  --text-muted: #6B6B70;
  --text-faint: #9A9A9E;
  --input-border: #D9D9DC;
  --mg-red: #CD1316;
  /* Primary action / active accent — configurable via BrandingOptions (default ink). */
  --accent: var(--brand-accent, #0E0E10);

  --font-ui: "Archivo", "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

  --radius-card: 8px;
  --radius-ctrl: 5px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--app-bg);
  color: var(--text-strong);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.mono { font-family: var(--font-mono); }

/* ---------- App header ---------- */
.app-header {
  background: var(--header-grad);
  color: #fff;
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 24px;
}

.app-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }

.logo-badge {
  background: #fff;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: none;
}

.logo-badge img { width: 26px; height: 26px; object-fit: contain; filter: brightness(0); }

.app-brand .brand-name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.1; letter-spacing: -.2px; }
.app-brand .brand-sub { font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(255,255,255,.55); }

.app-nav { display: flex; gap: 6px; margin-left: 8px; }
.app-nav a {
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-ctrl);
}
.app-nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.app-nav a.active { color: #fff; background: rgba(255,255,255,.12); }

.app-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.op-id { display: flex; align-items: center; gap: 8px; }
.op-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.14); color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
}
.op-code { font-family: var(--font-mono); font-size: 12px; letter-spacing: .5px; color: rgba(255,255,255,.85); }

.btn-logout {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid rgba(255,255,255,.25);
  color: #fff; background: transparent;
  padding: 7px 14px; border-radius: var(--radius-ctrl);
  font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn-logout:hover { background: rgba(255,255,255,.10); }
.btn-logout svg { width: 15px; height: 15px; }

/* ---------- Page shell ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 36px 32px 56px; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-muted); margin: 0 0 8px;
}
.eyebrow.accent { color: var(--accent); }

.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
h1.page-title { font-size: 34px; font-weight: 800; letter-spacing: -1px; color: var(--ink); margin: 0; }
.last-deposit { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.last-deposit .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #0F7A43; margin-right: 7px; vertical-align: middle; }
.last-deposit strong { color: var(--text-strong); font-weight: 600; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 18px 20px; position: relative; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--kpi-bar, var(--ink)); }
.kpi .kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.kpi .kpi-value { font-family: var(--font-mono); font-size: 30px; font-weight: 600; color: var(--ink); line-height: 1; }
.kpi.k-blue { --kpi-bar: #1B5FC4; }
.kpi.k-green { --kpi-bar: #0F7A43; }
.kpi.k-red { --kpi-bar: var(--mg-red); }
.kpi.k-ink { --kpi-bar: var(--ink); }

/* ---------- Two-column area ---------- */
.cols { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
.card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 26px;
}
.card h2 { font-size: 16px; font-weight: 700; color: var(--ink); margin: 0 0 4px; letter-spacing: -.2px; }

.pill {
  display: inline-block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px;
  text-transform: uppercase; padding: 5px 12px; border-radius: 20px;
  background: #FBEAEA; color: var(--mg-red); border: 1px solid #F0C9CA; margin-bottom: 18px;
}

/* ---------- Form controls ---------- */
.field { margin-bottom: 20px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-strong); margin-bottom: 8px; }
.field-label.required::after { content: " *"; color: var(--mg-red); }

.select, .text-input {
  width: 100%; font-family: var(--font-ui); font-size: 14px; color: var(--ink);
  background: #fff; border: 1px solid var(--input-border); border-radius: var(--radius-ctrl);
  padding: 12px 14px;
}
.select:disabled { background: #FAFAFB; color: var(--text-strong); }
.text-input:focus, .select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(14,14,16,.08); }

.dealer-field {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--input-border); border-radius: var(--radius-ctrl);
  padding: 12px 14px; background: #FAFAFB; color: var(--text-strong); font-size: 14px;
}
.dealer-field .mono { color: var(--text-muted); font-size: 12px; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 1.5px dashed #C7C7CC; border-radius: var(--radius-card);
  background: #FBFBFC; padding: 30px 20px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 10px; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--ink); background: #F5F5F6; }
.dropzone .dz-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--ink); display: grid; place-items: center; }
.dropzone .dz-icon svg { width: 22px; height: 22px; color: #fff; }
.dropzone .dz-main { font-weight: 600; color: var(--text-strong); }
.dropzone .dz-main span { color: var(--text-muted); font-weight: 400; }
.dropzone .dz-hint { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); letter-spacing: .3px; }
.file-input-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--font-ui); font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius-ctrl); padding: 12px 20px; text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.15); }
.btn-primary:disabled { background: #2A2A2D; opacity: .85; cursor: default; }
.btn-block { width: 100%; }

.note { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--text-muted); margin-top: 14px; line-height: 1.5; }
.note svg { width: 15px; height: 15px; flex: none; margin-top: 1px; color: #0F7A43; }

/* ---------- Status chips ---------- */
.chip {
  display: inline-flex; align-items: center; font-size: 12px; font-weight: 600;
  padding: 4px 12px; border-radius: 20px; border: 1px solid transparent; white-space: nowrap;
}
.chip-ok     { background: #E8F5EE; color: #0F7A43; border-color: #BFE6CF; }
.chip-progress { background: #E8F0FE; color: #1B5FC4; border-color: #C5D9F7; }
.chip-wait   { background: #F0F0F1; color: #6B6B70; border-color: #E0E0E2; }
.chip-error  { background: #FBEAEA; color: #B41419; border-color: #F0C9CA; }
.chip-dup    { background: #FCF3E6; color: #9A6212; border-color: #F0DCB8; }

/* ---------- Recent deposits ---------- */
.deposit-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.deposit-head .seven { font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-faint); }
.deposit { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--row-divider); }
.deposit:first-of-type { border-top: none; }
.pdf-tag { font-family: var(--font-mono); font-size: 9px; font-weight: 600; letter-spacing: .5px; color: var(--text-muted); background: #F2F2F3; border: 1px solid var(--card-border); border-radius: 4px; padding: 6px 7px; }
.deposit-body { min-width: 0; flex: 1; }
.deposit-name { font-family: var(--font-mono); font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deposit-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin-top: 3px; }

/* ---------- Selected files table ---------- */
.files-card { margin-top: 20px; }
.files-table { width: 100%; }
.files-row { display: grid; grid-template-columns: 1fr 110px 160px 44px; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--row-divider); }
.files-row.head { border-top: none; padding-top: 0; }
.files-row.head span { font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-faint); }
.files-row .fname { font-family: var(--font-mono); font-size: 13px; color: var(--ink); display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; min-width: 0; }
.files-row .fname-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.frow-reason { flex-basis: 100%; font-family: var(--font-ui); font-size: 11px; color: #B41419; }
.faction { display: flex; justify-content: flex-end; }
.file-remove { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--card-border); background: #fff; color: var(--text-muted); font-size: 16px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0; }
.file-remove:hover { border-color: #F0C9CA; color: #B41419; background: #FBEAEA; }
.submit-hint { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin: 10px 0 0; text-align: center; min-height: 14px; }
.files-row .fname span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-row .fsize { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.progress-wrap { display: flex; align-items: center; gap: 10px; }
.progress-track { flex: 1; height: 6px; background: var(--section-divider); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--ink); transition: width .3s ease; }
.progress-pct { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); width: 34px; text-align: right; }
.empty-state { color: var(--text-muted); font-size: 13px; padding: 16px 0; }

/* ---------- Footer ---------- */
.app-footer { border-top: 1px solid var(--card-border); color: var(--text-faint); font-size: 12px; padding: 22px 32px; max-width: 1120px; margin: 0 auto; }
.app-footer strong { color: var(--text-muted); font-weight: 600; }

/* ---------- Login landing ---------- */
.login-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--ink); }
.login-band {
  background: #fff; position: relative; overflow: hidden;
  flex: 0 0 auto; padding: 52px 64px 44px;
  display: flex; flex-direction: column; justify-content: flex-start;
}
.login-band .octagon { position: absolute; border: 1px solid #EDEDEE; width: 220px; height: 220px;
  clip-path: polygon(30% 0,70% 0,100% 30%,100% 70%,70% 100%,30% 100%,0 70%,0 30%); }
.login-band .octagon.tr { right: -60px; top: -70px; }
.login-band .octagon.br { right: 120px; bottom: -150px; }
.login-brandline { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; position: relative; }
.login-brandline img { width: 50px; height: 50px; object-fit: contain; filter: brightness(0); }
.login-brandline .wordmark { font-family: var(--font-mono); font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: var(--text-muted); }
.login-rule { width: 44px; height: 3px; background: var(--accent); margin-bottom: 22px; }
.login-band h1 { font-size: 40px; font-weight: 800; letter-spacing: -1.2px; color: var(--ink); margin: 0 0 14px; line-height: 1.05; }
.login-band p { font-size: 16px; color: var(--text-muted); max-width: 560px; margin: 0; line-height: 1.5; }

.login-zone { flex: 1; background: var(--header-grad); display: grid; place-items: center; padding: 48px 24px; }
.signin-card { background: #fff; border-radius: 10px; box-shadow: var(--shadow-modal); width: 100%; max-width: 400px; padding: 34px; }
.signin-card .eyebrow { margin-bottom: 10px; }
.signin-card h2 { font-size: 22px; font-weight: 700; color: var(--ink); margin: 0 0 8px; letter-spacing: -.3px; }
.signin-card .lead { font-size: 14px; color: var(--text-muted); margin: 0 0 22px; }
.ms-btn { width: 100%; }
.ms-logo { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 16px; height: 16px; }
.ms-logo i { display: block; width: 100%; height: 100%; }
.ms-logo i:nth-child(1){ background:#F25022 } .ms-logo i:nth-child(2){ background:#7FBA00 }
.ms-logo i:nth-child(3){ background:#00A4EF } .ms-logo i:nth-child(4){ background:#FFB900 }
.signin-foot { margin-top: 20px; font-size: 12px; color: var(--text-faint); line-height: 1.6; }
.signin-foot strong { color: var(--text-muted); font-weight: 600; }

/* ---------- Animation ---------- */
@keyframes mgRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.mg-rise { animation: mgRise .5s cubic-bezier(.2,.7,.2,1) both; }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .cols { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .page { padding: 24px 18px 40px; }
  .app-header { padding: 0 16px; gap: 12px; }
  .app-nav, .op-id .op-code { display: none; }
  .login-band { padding: 40px 28px; }
  .login-band h1 { font-size: 34px; }
  .files-row { grid-template-columns: 1fr 120px 40px; }
  .files-row .fsize, .files-row.head span:nth-child(2) { display: none; }
}
