/* Copyright (c) 2025-2026 Payquity. All rights reserved. */

/* MRLD Frontend — brand: #1a365d (primary), #2c5282 (header) */

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

:root {
  --primary:       #1a365d;
  --primary-light: #2c5282;
  --primary-hover: #2a4a7f;
  --accent:        #3b82f6;
  --accent-hover:  #2563eb;
  --success:       #16a34a;
  --success-bg:    #f0fdf4;
  --danger:        #dc2626;
  --danger-bg:     #fef2f2;
  --warning:       #d97706;
  --gray-50:       #f8fafc;
  --gray-100:      #f1f5f9;
  --gray-200:      #e2e8f0;
  --gray-300:      #cbd5e1;
  --gray-400:      #94a3b8;
  --gray-500:      #64748b;
  --gray-600:      #475569;
  --gray-700:      #334155;
  --gray-900:      #0f172a;
  --white:         #ffffff;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.04);
  --shadow-lg:     0 4px 20px rgba(0,0,0,.10);
  --transition:    .2s ease;
  --font:          'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: var(--primary);
  color: var(--white);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.header-inner {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.logo { font-size: 1.25rem; font-weight: 700; letter-spacing: .04em; }
.header-subtitle { font-size: .8rem; opacity: .7; font-weight: 400; }

.auth-status { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.auth-user { font-size: .82rem; opacity: .85; }
.btn-signout {
  background: rgba(255,255,255,.12); color: var(--white);
  border: 1px solid rgba(255,255,255,.25); border-radius: var(--radius-sm);
  padding: .3rem .7rem; font-size: .8rem; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: background var(--transition);
}
.btn-signout:hover { background: rgba(255,255,255,.22); }

.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-field { display: flex; flex-direction: column; gap: .35rem; }
.login-field span { font-size: .85rem; font-weight: 500; color: var(--gray-700); }
.login-field input {
  font-family: inherit; font-size: .95rem; padding: .65rem .8rem;
  border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  background: var(--white); color: var(--gray-900); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.login-field input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.mfa-setup { display: flex; flex-direction: column; gap: 1rem; }
.mfa-setup-lead {
  margin: 0; font-size: .9rem; color: var(--gray-700); text-align: center;
}
.mfa-qr-wrap {
  display: flex; justify-content: center; padding: .75rem;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
}
.mfa-qr-wrap canvas { display: block; border-radius: 4px; }
.mfa-manual {
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  padding: .5rem .75rem; background: var(--gray-50);
}
.mfa-manual summary {
  cursor: pointer; font-size: .85rem; font-weight: 500; color: var(--gray-700);
  user-select: none;
}
.mfa-manual-body {
  display: flex; flex-direction: column; gap: .75rem;
  margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--gray-200);
}
.mfa-secret {
  display: block; padding: .6rem .75rem; font-size: .8rem; line-height: 1.4;
  word-break: break-all; background: var(--white);
  border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
}

.main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
  transition: opacity var(--transition), transform var(--transition);
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.step-indicator { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.25rem; }

.step-label { font-size: 1.05rem; font-weight: 600; color: var(--gray-700); }

.file-error {
  font-size: .85rem; color: var(--danger); background: var(--danger-bg);
  padding: .6rem .85rem; border-radius: var(--radius-sm);
  border-left: 3px solid var(--danger); margin-top: .75rem;
  animation: fadeSlideIn .25s ease both;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.5rem; font-size: .9rem; font-weight: 600;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--transition), transform .1s ease, box-shadow var(--transition);
  font-family: inherit;
}
.btn:active:not(:disabled) { transform: scale(.97); }

.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 2px 8px rgba(37,99,235,.3); }
.btn-primary:disabled { background: var(--gray-300); color: var(--gray-500); cursor: not-allowed; }

.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }

.btn-start-full { width: 100%; margin-top: 1.5rem; padding: .85rem; font-size: .95rem; }

.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: var(--white);
  border-radius: 50%; animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.status-badge {
  display: inline-block; padding: .2rem .65rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap;
}
/* In a table, a badge is smaller and the cell does not stretch the row. */
.data-table .status-badge { padding: .12rem .5rem; font-size: .68rem; letter-spacing: .02em; }

.status-badge.created  { background: var(--gray-200); color: var(--gray-600); }
.status-badge.running  { background: #dbeafe; color: #1d4ed8; }
.status-badge.succeeded { background: #dcfce7; color: #15803d; }
.status-badge.failed   { background: #fee2e2; color: #b91c1c; }

.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }

.footer { text-align: center; padding: 1.25rem; font-size: .78rem; color: var(--gray-400); }
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer-sep { margin: 0 .4rem; }

.hidden { display: none !important; }

/* ----- App navigation (tab bar under the header) ----- */
.app-nav {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 56px;
  z-index: 90;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.app-nav-inner {
  display: flex;
  gap: .25rem;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1rem;
  overflow-x: auto;
}
.nav-link {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: .85rem .9rem;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.nav-link:hover { color: var(--gray-700); }
.nav-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ----- Views ----- */
.view { display: flex; flex-direction: column; gap: 1.25rem; }
.view-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: 1.25rem;
}
.view-head .step-indicator { margin-bottom: 0; }

/* ----- Buttons (extra variants) ----- */
.btn-sm { padding: .5rem 1rem; font-size: .82rem; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; box-shadow: 0 2px 8px rgba(220,38,38,.3); }

.form-success {
  font-size: .85rem; color: var(--success); background: var(--success-bg);
  padding: .6rem .85rem; border-radius: var(--radius-sm);
  border-left: 3px solid var(--success); margin-top: .25rem;
  animation: fadeSlideIn .25s ease both;
}

/* ----- History ----- */
.history-hint { font-size: .85rem; color: var(--gray-500); }
.history-list { list-style: none; display: flex; flex-direction: column; gap: .65rem; }
.history-item {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.1rem; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); background: var(--gray-50);
}
.history-meta { min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
.history-row1 { display: flex; align-items: center; gap: .6rem; }
.history-date { font-size: .82rem; color: var(--gray-600); }
.chip {
  display: inline-block; white-space: nowrap;
  font-size: .72rem; font-weight: 600; color: var(--gray-700);
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 999px; padding: .12rem .55rem;
}
.history-more-wrap { display: flex; justify-content: center; margin-top: 1rem; }

/* ----- Profile key/value ----- */
.kv { display: flex; flex-direction: column; gap: .1rem; }
.kv-row {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .6rem 0; border-bottom: 1px solid var(--gray-100);
}
.kv-row:last-child { border-bottom: none; }
.kv-row dt { font-size: .85rem; color: var(--gray-500); }
.kv-row dd { font-size: .9rem; font-weight: 600; color: var(--gray-900); text-align: right; word-break: break-word; }

.code-area {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: .8rem; line-height: 1.5; padding: .75rem;
  border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  background: var(--gray-50); color: var(--gray-900); width: 100%;
  resize: vertical; outline: none; min-height: 240px;
}
.code-area:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.danger-card { border: 1px solid #fecaca; }

@media (max-width: 600px) {
  .main { margin: 1rem auto; }
  .card { padding: 1.25rem; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }
  .history-item { flex-direction: column; align-items: stretch; }
}

/* ===================== Report pipeline views (E15) ===================== */
.muted { color: var(--gray-400); font-size: .85rem; }
.small { font-size: .78rem; }
.inline { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; margin-right: 1rem; }
.chip-warn { background: #fef3c7; color: #92400e; }
.chip-ok { background: #dcfce7; color: #15803d; }
.chip-bad { background: var(--danger-bg); color: #991b1b; }
.link-btn { background: none; border: none; padding: 0; color: var(--accent); cursor: pointer;
  font: inherit; text-decoration: underline; }
.file-list { margin: 0 0 .5rem 1.25rem; font-size: .9rem; }
.form-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.form-row .login-field { flex: 1 1 10rem; }
.table-scroll { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin: .5rem 0 1rem; }
.data-table th, .data-table td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid
  var(--gray-200); vertical-align: top; }
.data-table th { color: var(--gray-500); font-weight: 600; background: var(--gray-50); }
.data-table input, .data-table select { width: 100%; min-width: 6rem; font: inherit; padding: .2rem; }
.data-table tr.sev-blocker td:nth-child(2) { color: var(--danger); font-weight: 700; }
.data-table tr.sev-major td:nth-child(2) { color: var(--warning); font-weight: 700; }

.timeline { display: flex; list-style: none; padding: 0; margin: .5rem 0 1rem; gap: .25rem; }
.timeline li { flex: 1; text-align: center; padding: .45rem .25rem; font-size: .8rem;
  background: var(--gray-100); color: var(--gray-500); border-radius: var(--radius-sm); }
.timeline li.done { background: #dcfce7; color: #15803d; }
.timeline li.current { background: #dbeafe; color: #1d4ed8; font-weight: 700; }
.timeline li.current.bad { background: #fee2e2; color: #b91c1c; }

.month-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .6rem; }
.month-cell { border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: .6rem;
  display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; background: var(--white); }
.month-cell.has-data { border-color: #86efac; }
.month-name { font-weight: 700; text-transform: capitalize; color: var(--gray-700); }
.annual-row { margin-top: 1rem; font-size: .95rem; }
.stale-banner { margin-top: .4rem; padding: .5rem .75rem; border-radius: var(--radius-sm);
  background: #fef3c7; color: #92400e; font-size: .85rem; }

.rejection { margin-top: 1rem; }
.rejection-text, .diff { white-space: pre-wrap; background: var(--gray-50); border: 1px solid
  var(--gray-200); border-radius: var(--radius-sm); padding: .75rem; font-size: .82rem;
  max-height: 28rem; overflow: auto; }
.diff .diff-add { color: #15803d; background: #f0fdf4; }
.diff .diff-del { color: #b91c1c; background: #fef2f2; }
.diff .diff-ctx { color: var(--gray-500); }
.problem-list { margin: .4rem 0 0 1.25rem; }
.profile-file { margin: .5rem 0; }
.profile-file h4 { margin: .75rem 0 .25rem; font-size: .9rem; }

.narrative-form fieldset { border: none; padding: 0; margin: 0; display: flex; flex-direction: column;
  gap: .75rem; }
.narrative-form h4 { margin: .5rem 0 0; }
.repeat-item { border-left: 3px solid var(--gray-200); padding-left: .75rem; display: flex;
  flex-direction: column; gap: .4rem; }
.narrative-form textarea, .narrative-form input[type="text"] { width: 100%; font: inherit;
  padding: .5rem; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); }

/* The profile, the admin view and the login keep the narrow column; the
   pipeline views use the wide one (tables of the analyst). */
#view-profile, #view-admin, .login-card {
  max-width: 720px; width: 100%; margin-left: auto; margin-right: auto; }
.narrative-form .btn-sm, .login-form .form-actions .btn-sm { align-self: flex-start; }
.login-field select, .login-field textarea {
  font-family: inherit; font-size: .95rem; padding: .55rem .7rem;
  border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  background: var(--white); color: var(--gray-900); }
.login-form .btn-sm { align-self: flex-start; }

/* The month states (platform review UX-6) and the downloads (UX-7). */
.month-cell.state-rejected, .month-cell.state-overdue { border-color: #fca5a5; }
.month-cell.state-future, .month-cell.state-current, .month-cell.state-before_start {
  background: var(--gray-50); border-style: dashed; }
.month-cell.state-future .month-name, .month-cell.state-before_start .month-name {
  color: var(--gray-400); }
.month-due { font-size: .75rem; color: var(--gray-600); }
.month-report { margin-top: auto; }
.month-cell .link-btn { text-align: left; }
.grid-legend { margin: .75rem 0 0; font-size: .8rem; color: var(--gray-600); }
.download-list { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .45rem; }
/* 1 row for each file: the button in a column of 1 width, the recipient next to it. */
.download-row { display: grid; grid-template-columns: minmax(16rem, 26rem) 1fr; gap: .75rem;
  align-items: center; }
.download-row .btn { justify-content: flex-start; text-align: left; }
.download-note { font-size: .8rem; color: var(--gray-600); }
.older-files summary { cursor: pointer; font-size: .85rem; color: var(--gray-600); }
@media (max-width: 700px) { .download-row { grid-template-columns: 1fr; gap: .2rem; } }
/* The reasons of a disabled accept and the finding parameters (UX-14). */
.accept-problems { font-size: .85rem; color: #92400e; margin: .5rem 0; padding-left: 1.2rem; }
.kv-list { list-style: none; padding: 0; margin: 0; }
