/* Valiant Group — Vendor Compliance & Invoice Platform
   Rebuilt against the actual Valiant Group brand guide (real hex values,
   real typefaces) — not an approximation. Sonar Sans is the brand's true
   body typeface but requires Adobe Fonts licensing this app doesn't have;
   the brand guide itself names Poppins as the sanctioned free substitute,
   so that's used here rather than an unrelated font. */

:root {
  --ink: #1d1d1d;        /* Black — primary text, topbar, primary buttons */
  --bronze: #7f6b42;     /* primary accent — links, active states, focus rings */
  --pale-gold: #ad9978;  /* secondary accent — gradient partner, soft highlights */
  --ivory: #eae7e1;      /* page background */
  --cream: #d6c9b9;      /* secondary tint — badge/alert backgrounds */
  --card: #ffffff;
  --gray: #9d958e;       /* borders / dividers, true brand gray */
  --text: #1d1d1d;
  --text-muted: #6f665c; /* darkened from brand gray for accessible body text */
  --forest: #4a6b4f;     /* compliant/approved — coordinated with the warm palette */
  --forest-bg: #e8ede6;
  --rust: #a13333;       /* errors/rejected — deliberately cooler/more red than the
      brand's warm bronze/gold family, so a danger action never reads as an accidental
      brand color or trends toward the overused warm-terracotta "AI design" look */
  --rust-bg: #f5e6e2;
  --radius: 10px;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--ivory);
  color: var(--text);
  margin: 0;
  line-height: 1.55;
}

a { color: var(--bronze); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--bronze);
  outline-offset: 2px;
}

h1, h2, h3 { font-family: "Playfair Display", Georgia, serif; font-weight: 800; color: var(--ink); }
h1 { font-size: 1.7rem; margin: 0 0 6px; }
h2 { font-size: 1.2rem; font-weight: 700; margin: 0 0 16px; }
p.subtitle { color: var(--text-muted); margin: 0 0 24px; }

/* ---- Topbar: the signature — a hairline of the brand's own Pale
   Gold → Bronze gradient (used within their real logo, sanctioned for use
   "throughout branding") sits at the very top, once, deliberately. ---- */
.topbar {
  background: var(--ink);
  color: white;
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  position: relative;
}
.topbar::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--pale-gold), var(--bronze));
}
.topbar .brand { font-family: "Playfair Display", Georgia, serif; font-weight: 800; font-size: 1.15rem; }
.topbar .brand small {
  font-family: "Poppins", sans-serif; font-weight: 500; opacity: 0.65; display: block;
  font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 1px;
}
.topbar a, .topbar button {
  color: rgba(255,255,255,0.82);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.topbar a:hover, .topbar button:hover, .topbar a:focus-visible {
  color: #fff;
  border-bottom-color: var(--pale-gold);
}
.topbar form { display: inline; }

.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.container.narrow { max-width: 560px; }

.card {
  background: var(--card);
  border: 1px solid var(--gray);
  border-color: #e3ddd2;
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
a.card:hover { border-color: var(--bronze); box-shadow: 0 4px 16px rgba(29,29,29,0.08); }

table { width: 100%; border-collapse: collapse; }
/* Keeps the name column a consistent width across separate tables sharing
   a page (e.g. the four Vendor Setup categories) — without this, each
   table auto-sizes independently based on its own longest name, so the
   status/action columns start at a different position card to card. */
table.fixed-cols td:first-child, table.fixed-cols th:first-child { width: 220px; }
th, td { text-align: left; padding: 11px 8px; border-bottom: 1px solid #e3ddd2; font-size: 0.92rem; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f7f4ee; }

.btn {
  display: inline-flex;
  align-items: center;
  background: var(--ink);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: #333; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: white; color: var(--ink); border: 1px solid #e3ddd2; }
.btn.secondary:hover { border-color: var(--bronze); background: var(--ivory); }
.btn.danger { background: var(--rust); }
.btn.danger:hover { background: #7e2828; }
.btn.danger-strong { background: #7e2828; } /* Force Delete — a deliberately darker
    shade of the same rust family, not a mismatched maroon, so it reads as "more
    serious than Delete" while staying visually coordinated */
.btn.danger-strong:hover { background: #601d1d; }
.btn.small { padding: 6px 12px; font-size: 0.82rem; }

/* Action-button groups (table row actions, page-header actions) — a
   consistent flex row with real gap, so multiple buttons/forms next to
   each other don't crowd together or wrap at arbitrary points. Wrap each
   button/form in a plain element with this class instead of inline
   display:inline forms with no spacing between them. */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.btn-row form { margin: 0; }

/* Generic fallback: action buttons/forms sitting directly inside a table
   cell (the common "row actions" pattern across every list page) get
   consistent inline spacing automatically, without needing a .btn-row
   wrapper in every single view. */
td > form, td > a.btn { display: inline-flex; vertical-align: middle; margin-bottom: 4px; }
td > form:not(:last-child), td > a.btn:not(:last-child) { margin-right: 8px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.option-label {
  display: flex !important; align-items: center; font-weight: 400 !important;
  font-size: 0.9rem !important; margin-bottom: 8px !important; cursor: pointer;
}

/* Source picker — attachments and links shown as distinct, scannable
   option cards instead of a flat radio list, so a photo, a PDF, and a
   payment link are visually distinguishable at a glance. */
.option-group-label {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin: 18px 0 8px;
}
.option-group-label:first-of-type { margin-top: 4px; }
.option-card {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid #e3ddd2; border-radius: 8px; padding: 10px 14px;
  margin-bottom: 8px; cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease;
}
.option-card:hover { border-color: var(--pale-gold); }
.option-card:has(input:checked) { border-color: var(--bronze); background: #faf6ef; }
.option-card input[type="radio"] { margin: 0; flex-shrink: 0; width: auto; }
.option-card .thumb { width: 42px; height: 42px; border-radius: 6px; object-fit: cover; flex-shrink: 0; border: 1px solid #e3ddd2; }
.option-card .file-icon {
  width: 42px; height: 42px; border-radius: 6px; background: var(--ivory);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.02em; color: var(--bronze); flex-shrink: 0;
}
.option-card .option-title { font-size: 0.9rem; color: var(--text); }
.option-card .option-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }

.option-group {
  border: 1px solid #e3ddd2; border-radius: 8px; margin-bottom: 8px; overflow: hidden;
}
.option-group summary {
  list-style: none; cursor: pointer; padding: 10px 14px;
  font-size: 0.85rem; font-weight: 600; color: var(--ink);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ivory);
}
.option-group summary::-webkit-details-marker { display: none; }
.option-group summary::after { content: "▾"; color: var(--text-muted); font-weight: 400; transition: transform 0.15s ease; }
.option-group[open] summary::after { transform: rotate(180deg); }
.option-group summary:hover { background: #f2ede2; }
.option-group .option-group-body { padding: 10px 14px; }
.option-group .option-card { margin-bottom: 8px; }
.option-group .option-card:last-child { margin-bottom: 0; }

/* Inbox detail popup — fetches the same content the full page would show,
   injected into an overlay instead of navigating away from the list. */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(27,30,36,0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; z-index: 1000; overflow-y: auto;
}
.modal-panel {
  background: var(--ivory); border-radius: 10px; max-width: 720px; width: 100%;
  position: relative; padding: 32px 24px 24px;
}
.modal-close {
  position: absolute; top: 12px; right: 12px; width: 32px; height: 32px;
  border-radius: 50%; border: none; background: white; color: var(--ink);
  font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.modal-close:hover { background: var(--cream); }
.field input:not([type="radio"]):not([type="checkbox"]), .field select, .field textarea {
  width: 100%; padding: 9px 10px; border: 1px solid #e3ddd2; border-radius: 6px;
  font-size: 0.92rem; font-family: inherit; background: white; color: var(--text);
  transition: border-color 0.15s ease;
}
.field input:focus:not([type="radio"]):not([type="checkbox"]), .field select:focus, .field textarea:focus {
  border-color: var(--bronze); outline: none; box-shadow: 0 0 0 3px rgba(127,107,66,0.15);
}
.field input[type="radio"], .field input[type="checkbox"] {
  width: auto; margin-right: 8px; accent-color: var(--bronze);
}
.field .hint { color: var(--text-muted); font-size: 0.8rem; margin-top: 4px; }

/* ---- Badges: a quiet dot + label instead of a filled pill ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.78rem; font-weight: 500; color: var(--text);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--gray); }
.badge.compliant::before, .badge.approved::before { background: var(--forest); }
.badge.compliant, .badge.approved { color: var(--forest); }
.badge.expiring_soon::before, .badge.pending_review::before, .badge.uploaded::before,
.badge.reverted::before, .badge.assigned::before, .badge.held::before { background: var(--bronze); }
.badge.expiring_soon, .badge.pending_review, .badge.uploaded, .badge.reverted, .badge.assigned, .badge.held { color: var(--bronze); }
.badge.non_compliant::before, .badge.rejected::before, .badge.expired::before, .badge.missing::before { background: var(--rust); }
.badge.non_compliant, .badge.rejected, .badge.expired, .badge.missing { color: var(--rust); }
.badge.pending_onboarding, .badge.action_required, .badge.waived, .badge.pending_assignment, .badge.superseded { color: var(--text-muted); }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 0.9rem; border: 1px solid transparent; }
.alert.error { background: var(--rust-bg); color: var(--rust); border-color: #e6cabc; }
.alert.info { background: var(--cream); color: #5a4a2f; border-color: #c9b8a2; }
.alert.success { background: #e8efe3; color: #3d5a2f; border-color: #c5d4b8; }

.checklist-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid #e3ddd2; }
.checklist-item:last-child { border-bottom: none; }
.checklist-item .meta { color: var(--text-muted); font-size: 0.82rem; margin-top: 2px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

/* Dollar amounts and dates get tabular figures for clean alignment —
   Poppins doesn't have a mono companion, so this stays in-family rather
   than introducing an unrelated third typeface. */
.num { font-variant-numeric: tabular-nums; font-weight: 500; }

@media (max-width: 640px) {
  .container { padding: 20px 16px; }
  .two-col { grid-template-columns: 1fr; }
  .topbar { padding: 14px 16px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .topbar > div:not(.brand) { display: flex; flex-wrap: wrap; gap: 4px 14px; row-gap: 8px; width: 100%; }
  .topbar a, .topbar button { font-size: 0.82rem; }

  /* Tables are the most common thing on every page in this app and none
     of them were wrapped for narrow screens — without this, a 6-7 column
     table just overflows the viewport and drags the whole page sideways.
     display:block on the table itself (browsers still render the
     thead/tbody/tr/td children with normal table layout inside that
     scrollable block) keeps columns aligned while making just the table
     scroll horizontally, not the whole page. */
  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  /* A fixed 220px first column is fine on desktop but eats more than
     half of a typical phone screen — let it size to content instead. */
  table.fixed-cols td:first-child, table.fixed-cols th:first-child { width: auto; min-width: 140px; }

  .modal-panel { padding: 24px 16px 16px; max-width: 100%; }
  .btn-row { gap: 6px; }
  .option-card { flex-wrap: wrap; }
}
.nav-count { display:inline-block; min-width:18px; padding:0 6px; border-radius:9px; background:var(--pale-gold, #AD9978); color:#1D1D1D; font-size:0.72rem; font-weight:600; text-align:center; line-height:18px; }
.wait-warn { color:#8a6a1f; font-weight:600; }
.wait-late { color:#a13333; font-weight:600; }
.line-table td, .line-table th { vertical-align: middle; }
