/* ─────────────────────────────────────────────────────────────────────
   ox-portal — shared stylesheet.
   Borrows the proj-v2 grammar from fiscalox-onprem (flat surfaces,
   slate text, blue primary CTAs, rectangular badges) but stays
   standalone — no Bootstrap dependency, just a tiny base + the
   page-level layout primitives every portal page reuses.
   ──────────────────────────────────────────────────────────────────── */

:root {
    --pv-body: #f3f3f4;
    --pv-line: #e7eaec;
    --pv-text: #5a6471;
    --pv-heading: #2f4050;
    --pv-muted: #8095a8;
    --pv-blue: #0d6efd;
    --pv-blue-hover: #0a58ca;
    --pv-green: #1ab394;
    --pv-amber: #f59e0b;
    --pv-red: #ed5565;
    --pv-card-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: 13px;
    color: var(--pv-text);
    background: var(--pv-body);
    min-height: 100vh;
}
a { color: var(--pv-blue); text-decoration: none; }
a:hover { color: var(--pv-blue-hover); text-decoration: underline; }

/* ── App shell ─────────────────────────────────────────────────── */
.portal-shell { min-height: 100vh; display: flex; flex-direction: column; }
.portal-header {
    background: #fff; border-bottom: 1px solid var(--pv-line);
    padding: 6px 24px; min-height: 56px; display: flex; align-items: center; gap: 16px;
}
/* Fiscal Ox logo (ox + wordmark) as the brand; links back to the dashboard. */
.portal-brand { display: flex; align-items: center; text-decoration: none; }
.portal-brand:hover { text-decoration: none; }
.portal-brand img { height: 46px; width: auto; display: block; }
.portal-nav { display: flex; gap: 4px; margin-left: 24px; }
.portal-nav a {
    padding: 8px 14px; font-size: 13px; color: var(--pv-text);
    font-weight: 500; border-radius: 3px; text-decoration: none;
}
.portal-nav a:hover { background: var(--pv-body); color: var(--pv-heading); }
.portal-nav a.active { background: #eff6ff; color: var(--pv-blue); font-weight: 600; }
.portal-user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--pv-muted); }
.portal-user .email { color: var(--pv-heading); font-weight: 500; }
.portal-content { padding: 22px 28px; max-width: 1240px; width: 100%; margin: 0 auto; flex: 1; }

/* ── Page header strip ─────────────────────────────────────────── */
.crumbs { font-size: 11px; color: var(--pv-muted); margin-bottom: 4px; }
.crumbs b { color: var(--pv-heading); }
.ph-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.ph-title { font-size: 19px; color: var(--pv-heading); font-weight: 600; margin: 0; }
.ph-sub { margin: 2px 0 0; font-size: 12px; color: var(--pv-muted); }

/* ── Panel ─────────────────────────────────────────────────────── */
/* Card surface for grouped form content. The slight box-shadow lifts
   the panel off the page; rounded 4px corners feel softer than the
   prior 3px without going pillish. */
.pv-panel {
    background: #fff; border: 1px solid var(--pv-line); border-radius: 4px;
    margin-bottom: 16px; box-shadow: var(--pv-card-shadow);
    transition: box-shadow .15s ease, border-color .15s ease;
}
.pv-panel-body { padding: 18px 20px; }
/* Optional header strip — use as a sibling of .pv-panel-body when
   the panel needs a heavier title bar (e.g., with action buttons). */
.pv-panel-header {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 12px 18px; border-bottom: 1px solid var(--pv-line);
    background: #fafbfc;
}
.pv-panel-header .pv-panel-title {
    font-size: 13px; font-weight: 600; color: var(--pv-heading); margin: 0;
    flex: 1 1 auto;
}
.pv-panel-header .pv-panel-tools { display: flex; gap: 6px; align-items: center; }
/* Inline section title (typically inside .pv-panel-body, marking a
   sub-group of fields). */
.pv-section-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
    color: var(--pv-muted); font-weight: 700; margin: 0 0 14px;
    padding-bottom: 8px; border-bottom: 1px solid var(--pv-line);
    display: flex; align-items: center; gap: 6px;
}
.pv-section-title .lucide { width: 14px; height: 14px; color: var(--pv-blue); }
/* Two-column form grid for inside .pv-panel-body. Wraps to single
   column under ~640px so phones see one field per row. */
.pv-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
@media (max-width: 640px) { .pv-form-grid { grid-template-columns: 1fr; } }
.pv-form-grid .pv-fg-full { grid-column: 1 / -1; }

/* ── Form fields ───────────────────────────────────────────────── */
.pv-fg { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.pv-fg > label {
    font-size: 11.5px; font-weight: 600; color: var(--pv-heading); margin: 0;
    letter-spacing: .01em;
}
.pv-fg .pv-req { color: var(--pv-red); }
.pv-fg .pv-hint, .pv-fg .pv-help {
    font-size: 11px; color: var(--pv-muted); margin-top: 2px; line-height: 1.45;
}

/* Base input chrome — applies to text, number, email, password, date,
   time, tel, url, search, select, textarea. Color choices: white surface,
   #d1d5db default border (a shade darker than --pv-line so the box reads
   as a real input not just a tile), 8px×12px padding for finger reach. */
.pv-fg input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
.pv-fg select,
.pv-fg textarea {
    border: 1px solid #d1d5db; border-radius: 4px;
    padding: 8px 12px; font-size: 13px; color: var(--pv-heading);
    background: #fff; font-family: inherit; min-width: 0;
    line-height: 1.4; width: 100%;
    transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
    -webkit-appearance: none; appearance: none;
}
/* Subtle hover — darker border so the input invites click. */
.pv-fg input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):hover:not(:disabled),
.pv-fg select:hover:not(:disabled),
.pv-fg textarea:hover:not(:disabled) {
    border-color: #94a3b8;
}
/* Focus ring — 3px translucent blue halo + solid blue border so the
   active field is unmistakable from across the page. */
.pv-fg input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):focus,
.pv-fg select:focus,
.pv-fg textarea:focus {
    outline: none; border-color: var(--pv-blue);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .15);
}
/* Disabled state — washed-out surface, no hover affordance. */
.pv-fg input:disabled,
.pv-fg select:disabled,
.pv-fg textarea:disabled {
    background: #f3f4f6; color: #94a3b8; cursor: not-allowed;
    border-color: #e5e7eb;
}
/* Read-only — keeps the value readable but signals immutability. */
.pv-fg input[readonly]:not(:focus),
.pv-fg textarea[readonly]:not(:focus) {
    background: #fafbfc; color: var(--pv-text);
}
/* Validation error — toggled by adding `.is-invalid` to the input
   OR `.pv-fg-error` to the .pv-fg wrapper. */
.pv-fg.pv-fg-error input,
.pv-fg.pv-fg-error select,
.pv-fg.pv-fg-error textarea,
.pv-fg input.is-invalid,
.pv-fg select.is-invalid,
.pv-fg textarea.is-invalid {
    border-color: var(--pv-red);
}
.pv-fg.pv-fg-error input:focus,
.pv-fg input.is-invalid:focus,
.pv-fg.pv-fg-error select:focus,
.pv-fg select.is-invalid:focus,
.pv-fg.pv-fg-error textarea:focus,
.pv-fg textarea.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(237, 85, 101, .18);
}
.pv-fg .pv-err-msg {
    font-size: 11px; color: var(--pv-red); margin-top: 2px;
    display: flex; align-items: center; gap: 4px;
}
.pv-fg.pv-fg-error .pv-hint { color: var(--pv-red); }

/* Placeholder colour — explicit grey so it doesn't get inherited from
   the field's body text colour. */
.pv-fg ::placeholder { color: #94a3b8; opacity: 1; }

/* Textarea — taller, vertical-only resize. */
.pv-fg textarea { resize: vertical; min-height: 96px; }

/* Select — custom chevron via inline SVG background so we lose the
   inconsistent native arrow on Windows/Linux while keeping native
   keyboard + accessibility. */
.pv-fg select {
    padding-right: 32px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%238095a8'><path fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.06l3.71-3.83a.75.75 0 111.08 1.04l-4.25 4.39a.75.75 0 01-1.08 0L5.21 8.27a.75.75 0 01.02-1.06z' clip-rule='evenodd'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
}
.pv-fg select:disabled {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23cbd5e1'><path fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.06l3.71-3.83a.75.75 0 111.08 1.04l-4.25 4.39a.75.75 0 01-1.08 0L5.21 8.27a.75.75 0 01.02-1.06z' clip-rule='evenodd'/></svg>");
}

/* Date / time inputs — calendar icon styled to match the chevron. */
.pv-fg input[type="date"]::-webkit-calendar-picker-indicator,
.pv-fg input[type="time"]::-webkit-calendar-picker-indicator,
.pv-fg input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(56%) sepia(8%) saturate(513%) hue-rotate(166deg) brightness(91%) contrast(86%);
    cursor: pointer; opacity: .8;
}

/* Number input — keep the spinner but quieter. */
.pv-fg input[type="number"]::-webkit-inner-spin-button,
.pv-fg input[type="number"]::-webkit-outer-spin-button { opacity: .55; }

/* ── Checkbox & radio ──────────────────────────────────────────── */
.pv-fg.pv-fg-check { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 8px; }
.pv-fg.pv-fg-check > label { font-weight: 500; font-size: 12.5px; color: var(--pv-text); }
.pv-fg input[type="checkbox"], .pv-fg input[type="radio"] {
    width: 16px; height: 16px; margin: 0;
    accent-color: var(--pv-blue);
    cursor: pointer; flex: 0 0 auto;
}
.pv-fg input[type="checkbox"]:disabled,
.pv-fg input[type="radio"]:disabled { cursor: not-allowed; opacity: .6; }

/* ── File upload ───────────────────────────────────────────────── */
/* The native <input type="file"> is hidden behind .pv-file-trigger,
   a button-like label. Use as:
       <label class="pv-file">
           <input type="file" />
           <span class="pv-file-trigger">
               <i data-lucide="upload"></i> Choose file…
           </span>
           <span class="pv-file-name">No file selected</span>
       </label>
   Update the .pv-file-name text via JS on the input's `change` event. */
.pv-file {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    border: 1px dashed #cbd5e1; border-radius: 4px;
    padding: 8px 10px; background: #fafbfc; cursor: pointer;
    transition: border-color .12s ease, background .12s ease;
}
.pv-file:hover { border-color: var(--pv-blue); background: #f0f6ff; }
.pv-file input[type="file"] {
    /* visually hidden but accessible to assistive tech */
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.pv-file:focus-within { border-color: var(--pv-blue); box-shadow: 0 0 0 3px rgba(13,110,253,.15); }
.pv-file .pv-file-trigger {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; font-size: 12.5px; font-weight: 600;
    color: var(--pv-blue); background: #fff;
    border: 1px solid var(--pv-blue); border-radius: 3px;
    line-height: 1.2; user-select: none;
}
.pv-file:hover .pv-file-trigger { background: var(--pv-blue); color: #fff; }
.pv-file .pv-file-trigger .lucide { width: 14px; height: 14px; }
.pv-file .pv-file-name {
    font-size: 12px; color: var(--pv-text); font-weight: 500;
    min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pv-file.has-file .pv-file-name { color: var(--pv-heading); }
/* Drag-over state — JS toggles `.is-dragging` on dragenter/dragleave. */
.pv-file.is-dragging { border-color: var(--pv-blue); background: #e0eaff; }
.pv-file .pv-file-clear {
    background: transparent; border: 0; color: var(--pv-muted);
    cursor: pointer; padding: 2px 4px; border-radius: 3px;
    display: inline-flex; align-items: center;
}
.pv-file .pv-file-clear:hover { color: var(--pv-red); background: #fef2f2; }

/* Compact panel — for cases where the standard 16/18 padding is too much. */
.pv-panel.pv-panel-compact .pv-panel-body { padding: 12px 14px; }
.pv-panel.pv-panel-compact .pv-fg { margin-bottom: 12px; }

/* ── Buttons ───────────────────────────────────────────────────── */
.pv-btn {
    font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 3px;
    cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--pv-line); background: #fff; color: var(--pv-heading);
    line-height: 1.2;
}
.pv-btn:hover { background: var(--pv-body); }
.pv-btn:disabled { opacity: .5; cursor: not-allowed; }
.pv-btn-pri { background: var(--pv-blue); border-color: var(--pv-blue); color: #fff; }
.pv-btn-pri:hover { background: var(--pv-blue-hover); border-color: var(--pv-blue-hover); color: #fff; }
.pv-btn-ghost { background: transparent; border-color: transparent; }
.pv-btn-ghost:hover { background: var(--pv-body); }

/* ── Banners ───────────────────────────────────────────────────── */
.pv-banner {
    padding: 12px 16px; border-radius: 3px; margin-bottom: 16px; font-size: 13px;
    display: flex; gap: 10px; align-items: flex-start;
}
.pv-banner-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.pv-banner-ok   { background: #dcfce7; border: 1px solid #bbf7d0; color: #166534; }
.pv-banner-warn { background: #fef3c7; border: 1px solid #fde68a; color: #92400e; }
.pv-banner-err  { background: #fee2e2; border: 1px solid #fecaca; color: #991b1b; }

/* ── Status badges (rectangular, 3px radius) ──────────────────── */
.pv-badge {
    display: inline-block; padding: 3px 9px; border-radius: 3px;
    font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.pv-badge-info     { background: #e0f2fe; color: #075985; }
.pv-badge-ok       { background: #dcfce7; color: #166534; }
.pv-badge-warn     { background: #fef3c7; color: #92400e; }
.pv-badge-err      { background: #fee2e2; color: #991b1b; }
.pv-badge-neutral  { background: #f1f5f9; color: #64748b; }
.pv-badge-blue     { background: #dbeafe; color: #1e40af; }

/* ── KPI cards (used on Dashboard) ─────────────────────────────── */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 880px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.kpi {
    background: #fff; border: 1px solid var(--pv-line); border-radius: 3px;
    padding: 14px 16px; box-shadow: var(--pv-card-shadow);
}
.kpi .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--pv-muted); font-weight: 700; }
.kpi .val { font-size: 22px; color: var(--pv-heading); font-weight: 700; margin-top: 4px; }
.kpi .sub { font-size: 11px; color: var(--pv-muted); margin-top: 2px; }

/* ── Tables ────────────────────────────────────────────────────── */
.pv-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.pv-tbl thead th {
    background: #fafbfc; color: var(--pv-heading); font-weight: 600;
    text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--pv-line);
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap;
}
.pv-tbl tbody td { padding: 9px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.pv-tbl tbody tr:hover { background: #fafbfc; }
.pv-tbl tbody tr:last-child td { border-bottom: 0; }

/* ── Question card (Vendor Qualification) ──────────────────────── */
.vq-section { background: #fff; border: 1px solid var(--pv-line); border-radius: 3px; margin-bottom: 14px; }
.vq-section-head { padding: 10px 16px; border-bottom: 1px solid var(--pv-line); font-weight: 600; color: var(--pv-heading); font-size: 13px; background: #fafbfc; }
.vq-section-body { padding: 4px 16px; }
.vq-q { padding: 14px 0; border-bottom: 1px solid #f1f5f9; }
.vq-q:last-child { border-bottom: 0; }
.vq-q-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.vq-q-seq { font-weight: 700; color: var(--pv-muted); font-size: 12px; min-width: 26px; }
.vq-q-text { font-size: 13.5px; color: var(--pv-heading); font-weight: 500; }
.vq-q-req { font-size: 11px; color: var(--pv-amber); margin-left: 6px; font-weight: 600; }
.vq-q-input { margin-left: 36px; max-width: 640px; }
.vq-doc-list { margin-left: 36px; margin-top: 8px; font-size: 12px; color: var(--pv-muted); }
.vq-doc-list .doc-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.vq-doc-list .doc-row .doc-name { color: var(--pv-blue); font-weight: 500; }

/* ── Audit-request cards ───────────────────────────────────────── */
.audit-card { background: #fff; border: 1px solid var(--pv-line); border-radius: 3px; padding: 14px 16px; margin-bottom: 10px; }
.audit-card .audit-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.audit-card .audit-title { font-weight: 600; color: var(--pv-heading); font-size: 14px; }
.audit-card .audit-scope { color: var(--pv-text); font-size: 12.5px; margin-bottom: 10px; }
.audit-card .audit-row { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--pv-muted); }
.audit-card .audit-row .v { color: var(--pv-heading); font-weight: 500; margin-left: 4px; }
.audit-card .audit-actions { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.audit-card .audit-alt-form { display: none; margin-top: 10px; padding: 10px; background: #fafbfc; border: 1px solid var(--pv-line); border-radius: 3px; }
.audit-card.is-alt-open .audit-alt-form { display: block; }
