:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f8fafc;
  --accent: #1e3a8a;
  --accent-2: #3b5bdb;
  --amber-bg: #fff7e6; --amber-ink: #9a5b00; --amber-dot: #f59f00;
  --green-bg: #e9f9ef; --green-ink: #146c43; --green-dot: #2fb344;
  --red-bg: #fdecec;   --red-ink: #a61e1e;   --red-dot: #e03131;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.08);
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Top bar */
.topbar {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
}
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 18px 24px; display: flex; align-items: center; gap: 16px; }
.topbar a { color: #fff; }
.brand { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; opacity: .85; font-weight: 700; }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 700; }

/* Status badge */
.status {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  background: var(--amber-bg); color: var(--amber-ink);
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--amber-dot); }
.status.approved { background: var(--green-bg); color: var(--green-ink); }
.status.approved::before { background: var(--green-dot); }
.status.rejected { background: var(--red-bg); color: var(--red-ink); }
.status.rejected::before { background: var(--red-dot); }

/* Buttons & inputs */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-weight: 600; border-radius: 10px; padding: 9px 16px; cursor: pointer;
  border: 1px solid transparent; transition: transform .05s, filter .15s, background .15s; text-decoration: none !important;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent-2); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-approve { background: #198754; color: #fff; }
.btn-approve:hover { filter: brightness(1.08); }
.btn-reject { background: #fff; color: var(--red-ink); border-color: #f1b0b0; }
.btn-reject:hover { background: var(--red-bg); }
.btn-ghost { background: #fff; color: var(--ink); border-color: #cbd5e1; }
.btn-ghost:hover { background: var(--soft); }
.btn[disabled] { opacity: .6; cursor: default; }
input[type=text], input[type=search], input[type=date], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(59,91,219,.18); }
input[readonly], textarea[readonly] { background: var(--soft); color: var(--muted); }
label.lbl { display: block; font-size: 12.5px; font-weight: 600; margin: 0 0 5px; color: #334155; }

/* ---------- List page ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding: 24px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: 14px;
}
.tab:hover { text-decoration: none; border-color: #cbd5e1; }
.tab .n { background: var(--soft); border-radius: 999px; padding: 0 8px; font-size: 12.5px; color: var(--muted); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab.active .n { background: rgba(255,255,255,.18); color: #fff; }

.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.searchbar { display: flex; gap: 10px; padding: 14px; flex-wrap: wrap; align-items: center; }
.searchbar .grow { flex: 1 1 280px; }
.filters { border-top: 1px solid var(--line); padding: 16px 14px; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.filters .range { display: flex; gap: 8px; }
.filters .range input { flex: 1 1 0; min-width: 0; }
.filters .range-field { grid-column: span 2; }   /* two inputs need two columns of room */
@media (max-width: 640px) {
  .filters .range-field { grid-column: auto; }
  .filters .range { flex-direction: column; }
}
.filter-actions { grid-column: 1 / -1; display: flex; gap: 10px; justify-content: flex-end; }

.results-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 4px 10px; color: var(--muted); font-size: 13.5px; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
table.list th, table.list td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--soft); position: sticky; top: 0; white-space: nowrap; }
table.list th a { color: inherit; }
table.list th .arrow { font-size: 10px; margin-left: 3px; }
table.list tbody tr { cursor: pointer; transition: background .1s; }
table.list tbody tr:hover { background: #f5f7ff; }
table.list .num { text-align: right; white-space: nowrap; }
table.list td.mono { white-space: nowrap; }
table.list .desc { min-width: 260px; max-width: 380px; }
table.list .desc small { display: block; color: var(--muted); }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

/* ---------- Approval page ---------- */
.page { padding: 32px 16px 64px; }
.sheet { max-width: 860px; margin: 0 auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.back { max-width: 860px; margin: 0 auto 12px; font-size: 14px; }
.head {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff; padding: 28px 32px 24px;
  display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap;
}
.head h1 { margin: 6px 0 4px; font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.head .reqid { font-family: var(--mono); font-size: 14px; opacity: .9; }
.head .status { font-size: 13px; padding: 6px 12px; }
.sheet section { padding: 24px 32px; border-top: 1px solid var(--line); }
.sheet section:first-of-type { border-top: 0; }
.sheet h2 { margin: 0 0 14px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.part { display: flex; gap: 18px; align-items: flex-start; }
.part-icon { flex: none; width: 52px; height: 52px; border-radius: 12px; background: #eef2ff; color: var(--accent); display: grid; place-items: center; }
.part-id { font-family: var(--mono); font-size: 13px; color: var(--accent-2); font-weight: 600; }
.part-desc { font-size: 18px; font-weight: 600; margin: 2px 0 8px; line-height: 1.35; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 12.5px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 3px 9px; color: #334155; }
.chip b { font-weight: 600; color: var(--ink); }
table.line { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.line th, table.line td { padding: 12px 10px; text-align: left; }
table.line th { font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
table.line td { border-bottom: 1px solid var(--line); }
table.line .num { text-align: right; }
table.line tfoot td { border-bottom: 0; font-weight: 700; font-size: 17px; padding-top: 14px; }
table.line tfoot .label { color: var(--muted); font-weight: 600; font-size: 13px; text-align: right; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.field { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.field .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.field .v { font-weight: 600; margin-top: 2px; word-break: break-word; }
.row2 { display: grid; grid-template-columns: 1fr 200px; gap: 16px; }
.sig-wrap { margin-top: 16px; }
.sig-box { position: relative; height: 180px; border: 1.5px dashed #94a3b8; border-radius: 12px; background: #fff; touch-action: none; cursor: crosshair; overflow: hidden; }
.sig-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.sig-guide { position: absolute; left: 24px; right: 24px; bottom: 42px; border-bottom: 1px solid #cbd5e1; pointer-events: none; }
.sig-guide::before { content: "✕"; position: absolute; left: -2px; bottom: 4px; color: #94a3b8; font-size: 14px; }
.sig-hint { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font-size: 12px; color: #94a3b8; pointer-events: none; }
.sig-box.signed .sig-hint { display: none; }
.sig-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.link-btn { background: none; border: 0; color: var(--accent-2); font: inherit; font-weight: 600; cursor: pointer; padding: 4px 0; }
.link-btn:disabled { color: #94a3b8; cursor: default; }
.sig-final { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 8px; text-align: center; }
.sig-final img { max-width: 100%; height: 160px; object-fit: contain; }
.note-wrap { margin-top: 16px; }
.error { color: var(--red-ink); font-size: 13px; margin-top: 12px; min-height: 1em; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.actions .btn { padding: 11px 20px; }
.stamp { margin-top: 4px; padding: 14px 16px; border-radius: 12px; font-weight: 600; display: flex; gap: 12px; align-items: center; }
.stamp.approved { background: var(--green-bg); color: var(--green-ink); }
.stamp.rejected { background: var(--red-bg); color: var(--red-ink); }
.stamp small { display: block; font-weight: 500; opacity: .85; }
.sheet footer { padding: 16px 32px 24px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

@media (max-width: 640px) {
  .wrap { padding: 16px; }
  .topbar-inner { padding: 14px 16px; }
  .page { padding: 16px 0 40px; }
  .sheet { border-radius: 0; }
  .back { padding: 0 16px; }
  .head, .sheet section, .sheet footer { padding-left: 16px; padding-right: 16px; }
  .row2 { grid-template-columns: 1fr; }
  .part-icon { display: none; }
  table.line th:nth-child(4), table.line td:nth-child(4) { display: none; }
}
@media print {
  body { background: #fff; }
  .topbar, .back, .actions, .sig-tools, .sig-hint, .no-print { display: none !important; }
  .page { padding: 0; }
  .sheet { box-shadow: none; border-radius: 0; max-width: none; }
  .head, .status, .stamp { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Signature methods */
.sig-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: none; border: 0; border-radius: 7px; padding: 6px 14px; cursor: pointer; }
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15,23,42,.12); }
.font-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 12px; }
.font-opt { font-size: 30px; line-height: 1.3; color: #0b1f5c; background: #fff; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 14px 12px; min-height: 76px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; transition: border-color .15s, box-shadow .15s; }
.font-opt:hover { border-color: #cbd5e1; }
.font-opt.active { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(59,91,219,.18); }
.drop { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 180px; padding: 16px;
  border: 1.5px dashed #94a3b8; border-radius: 12px; background: #fff; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.drop b { color: var(--accent-2); }
.drop small { font-size: 12px; }
.drop.over { border-color: var(--accent-2); background: #f5f7ff; }
.upload-preview { display: inline-block; border-radius: 8px; padding: 6px; }
.upload-preview img { display: block; max-width: 100%; max-height: 150px; }
.checker { background-color: #fff; background-image: linear-gradient(45deg,#eef1f6 25%,transparent 25%),linear-gradient(-45deg,#eef1f6 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#eef1f6 75%),linear-gradient(-45deg,transparent 75%,#eef1f6 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
table.list .more { white-space: nowrap; display: inline-block; margin-top: 3px; font-size: 12px; font-weight: 600; color: var(--accent-2); background: #eef2ff; border-radius: 999px; padding: 1px 8px; }
.sheet h2 .count { display: inline-block; margin-left: 6px; background: #eef2ff; color: var(--accent-2); border-radius: 999px; padding: 0 8px; letter-spacing: 0; }
.table-scroll { overflow-x: auto; }
table.items td { vertical-align: top; }
table.items .ln { width: 28px; color: var(--muted); font-size: 13px; }
table.items .num { white-space: nowrap; }
.part-desc-sm { font-weight: 600; line-height: 1.35; }
.part-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.part-meta .part-id { font-size: 12.5px; }
@media (max-width: 640px) { table.items .ln { display: none; } }

/* Procurio logo */
.topbar .logo { display: inline-flex; flex: none; }
.topbar .logo img { width: 44px; height: 44px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.brand-logo { width: 22px; height: 22px; border-radius: 50%; vertical-align: -6px; margin-right: 4px; box-shadow: 0 0 0 1.5px rgba(255,255,255,.4); }
