:root {
  --navy: #1F3864; --blue: #2E75B6; --tint: #D9E2F3; --net: #DDEBF7;
  --ink: #1d2433; --muted: #5d6779; --line: #d5dbe6; --bg: #f3f5f9; --white: #fff;
  --red: #b42318; --green: #137a3f; --amber: #9a6200;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 60px; }
h1 { font-size: 26px; color: var(--navy); margin: 8px 0 16px; }
h2 { font-size: 17px; color: var(--navy); margin: 22px 0 10px; }
a { color: var(--blue); }

.topbar { background: var(--navy); color: #fff; display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; flex-wrap: wrap; gap: 8px; }
.topbar a { color: #fff; text-decoration: none; }
.topbar .brand { font-weight: 700; font-size: 17px; }
.topbar .links a { margin-left: 18px; opacity: .85; }
.topbar .links a:hover { opacity: 1; text-decoration: underline; }

.card { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 18px; }
.card.narrow { max-width: 380px; margin: 40px auto; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; margin-bottom: 8px; }
.span2 { grid-column: span 2; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; font-weight: 400; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; background: #fff; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.card.narrow label { margin-bottom: 12px; }

.btn { display: inline-block; background: var(--blue); color: #fff; border: 0; border-radius: 6px; padding: 9px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--navy); }
.btn.ghost { background: transparent; color: var(--blue); border: 1px solid var(--blue); }
.btn.ghost:hover { background: var(--tint); }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; }
.danger { color: var(--red); }

.alert { background: #fdecea; color: var(--red); border-left: 4px solid var(--red); padding: 10px 14px; border-radius: 4px; }
.ok { background: #e7f6ec; color: var(--green); border-left: 4px solid var(--green); padding: 10px 14px; border-radius: 4px; }
.small { font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.num { text-align: right; }
.table-wrap { overflow-x: auto; }

/* Claim form lines */
table.items { width: 100%; border-collapse: collapse; margin-bottom: 10px; min-width: 720px; }
.items th { background: var(--navy); color: #fff; font-size: 13px; padding: 8px; text-align: left; }
.items td { padding: 4px; border-bottom: 1px solid var(--line); }
.items td.sn { width: 32px; text-align: center; color: var(--muted); }
.items input { margin: 0; }
.items td:nth-child(2) { width: 150px; }
.items td:nth-child(6) { width: 130px; }
.x { border: 0; background: none; color: var(--red); font-size: 20px; cursor: pointer; }
.totals { margin: 16px 0 16px auto; max-width: 340px; }
.totals div { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; gap: 12px; }
.totals input { width: 130px; margin: 0; text-align: right; }
.totals .net { background: var(--net); padding: 10px; border-radius: 6px; font-weight: 700; color: var(--navy); }

/* Lists */
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); }
.list th { background: var(--tint); color: var(--navy); font-size: 13px; text-align: left; padding: 9px 10px; }
.list td { padding: 9px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.list tfoot td { font-weight: 700; background: var(--net); color: var(--navy); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; margin-left: 10px; }
.row-actions a { margin-left: 10px; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 10px; background: #eee; }
.badge.pending { background: #fff3d6; color: var(--amber); }
.badge.approved { background: var(--tint); color: var(--navy); }
.badge.paid { background: #e7f6ec; color: var(--green); }
.badge.rejected { background: #fdecea; color: var(--red); }

.stats { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 8px; }
.stats div { background: #fff; padding: 16px; }
.stats div:first-child { background: var(--navy); color: #fff; }
.stats span { display: block; font-size: 13px; opacity: .8; }
.stats strong { font-size: 24px; }
.stats div:first-child strong { font-size: 32px; }
.stats em { display: block; font-style: normal; font-size: 13px; opacity: .8; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.filters { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; align-items: end; }
.filter-btns { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.sumline { margin: 0 0 10px; color: var(--muted); }
.sumline strong { color: var(--navy); font-size: 18px; }
.actions { display: flex; gap: 10px; margin-bottom: 14px; }

/* Printable claim sheet (matches the Excel form) */
.sheet { background: #fff; border: 1px solid var(--line); padding: 28px; max-width: 820px; margin: 0 auto; font-size: 13px; }
.s-company { background: var(--navy); color: #fff; text-align: center; font-size: 18px; font-weight: 700; padding: 14px; }
.s-address { text-align: center; color: var(--muted); padding: 4px; }
.s-title { background: var(--blue); color: #fff; text-align: center; font-weight: 700; padding: 7px; margin-top: 6px; text-transform: uppercase; }
.sheet table { width: 100%; border-collapse: collapse; }
.s-meta td { padding: 10px 4px; }
.s-bar { background: var(--navy); color: #fff; font-weight: 700; padding: 6px 8px; margin-top: 14px; text-transform: uppercase; }
.s-grid th, .s-grid td, .s-items th, .s-items td, .s-sign th, .s-sign td { border: 1px solid #b8c2d4; padding: 6px 8px; text-align: left; }
.s-grid th { background: var(--tint); width: 18%; }
.s-items th { background: var(--navy); color: #fff; }
.s-items .num { text-align: right; }
.s-items .tot td { font-weight: 700; }
.s-items .net td { background: var(--net); color: var(--navy); font-size: 14px; }
.s-decl { font-style: italic; margin: 14px 0; }
.s-sign th { background: #F2F2F2; text-align: center; }
.s-sign { table-layout: fixed; }
.s-sign .space td { height: 50px; }
.s-note { margin-top: 14px; }

@media (max-width: 760px) {
  .grid, .filters, .two-col { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats div:first-child { grid-column: 1 / -1; }
  .topbar .links a { margin: 0 14px 0 0; }
}
@media print {
  body { background: #fff; }
  .no-print, .topbar { display: none !important; }
  main { padding: 0; max-width: none; }
  .sheet { border: 0; padding: 0; max-width: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.list th.num, .items th.num { text-align: right; }

/* Company picker on claim form */
.co-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.co-card { position: relative; display: flex; flex-direction: column; gap: 4px; border: 2px solid var(--line); border-radius: 8px; padding: 14px; cursor: pointer; color: var(--ink); font-weight: 400; background: #fff; }
.co-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.co-card .co-code { font-size: 12px; font-weight: 700; color: var(--blue); }
.co-card .co-name { font-size: 15px; font-weight: 600; color: var(--navy); line-height: 1.3; }
.co-card:hover { border-color: var(--blue); }
.co-card:has(input:checked) { border-color: var(--navy); background: var(--tint); box-shadow: inset 4px 0 0 var(--navy); }
.co-card:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Company tabs used on admin pages */
.co-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.co-tabs a { padding: 7px 14px; border: 1px solid var(--line); border-radius: 20px; background: #fff; text-decoration: none; color: var(--navy); font-size: 14px; }
.co-tabs a.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; grid-column: 1 / -1; }
.quick a { font-size: 13px; }
@media (max-width: 760px) { .co-pick { grid-template-columns: 1fr 1fr; } }
@media print { .co-tabs, .filters, .sumline-actions { display: none !important; } }
.print-only { display: none; }
.report-head p { margin: 8px 0 14px; }
@media print { .print-only { display: block; } .badge { border: 1px solid #ccc; } }

/* Laravel version additions */
.topbar form { display: inline; }
.topbar .links button { background: none; border: 0; color: #fff; font: inherit; opacity: .85; cursor: pointer; margin-left: 18px; padding: 0; }
.topbar .links a.on { opacity: 1; text-decoration: underline; text-underline-offset: 6px; }
.topbar .who { font-size: 13px; opacity: .7; margin-left: 18px; }
.errors { background: #fdecea; color: var(--red); border-left: 4px solid var(--red); padding: 10px 14px 10px 30px; border-radius: 4px; }
.errors li { margin: 2px 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); font-size: 14px; }
.check input { width: auto; margin: 0; }
.req { list-style: none; padding: 0; margin: 0 0 10px; columns: 2; }
.req li { padding: 3px 0; }
.req .yes::before { content: "✓ "; color: var(--green); font-weight: 700; }
.req .no { color: var(--red); }
.req .no::before { content: "✗ "; font-weight: 700; }
.steps-note { color: var(--muted); font-size: 14px; margin-top: -8px; }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 12px; color: var(--muted); }
.pager ul { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0; }
.muted-line { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.inactive td { color: var(--muted); }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (max-width: 760px) { .req { columns: 1; } }

/* Positions & approvals */
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: #f0b429; color: var(--navy); font-size: 12px; font-weight: 700; text-align: center; }
.update-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: #fff3d6; border: 1px solid #f0d08a; color: #6b4a00; padding: 12px 14px; border-radius: 6px; margin-bottom: 16px; }
.flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 14px; font-size: 13px; }
.flow span { padding: 4px 10px; border-radius: 14px; background: #eef1f6; color: var(--muted); }
.flow span.done { background: #e7f6ec; color: var(--green); }
.flow span.now { background: var(--navy); color: #fff; font-weight: 600; }
.flow span.bad { background: #fdecea; color: var(--red); }
.flow i { color: var(--muted); font-style: normal; }
.act { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.act form { border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.act textarea, .card textarea { display: block; width: 100%; margin-top: 4px; min-height: 64px; padding: 8px 10px; font: inherit; font-weight: 400; border: 1px solid var(--line); border-radius: 6px; }
.btn.red { background: var(--red); }
.btn.red:hover { background: #8a1a12; }
.btn.green { background: var(--green); }
.btn.green:hover { background: #0e5c2f; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 14px; border-left: 3px solid var(--line); margin-left: 4px; }
.timeline li.approved, .timeline li.paid { border-color: var(--green); }
.timeline li.rejected { border-color: var(--red); }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .note { font-style: italic; color: var(--ink); }
.co-checks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 6px 0 10px; }
.role-tabs a .n { color: inherit; opacity: .7; margin-left: 4px; }
.badge.waiting { background: #fff3d6; color: var(--amber); }
.inbox-row td { vertical-align: middle; }
.inline-act { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.inline-act form { display: inline; }
.inline-act input { width: 160px; margin: 0; display: inline-block; padding: 6px 8px; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
@media (max-width: 760px) { .act { grid-template-columns: 1fr; } }

/* Left sidebar: full on desktop, icon rail when collapsed, slide-in drawer on phones */
:root { --side-w: 256px; --side-mini: 68px; }
body.with-side { display: flex; min-height: 100vh; }
body.with-side main { flex: 1; min-width: 0; margin: 0 auto; max-width: 1180px; }
.side { flex: none; width: var(--side-w); background: var(--navy); color: #fff; z-index: 40; transition: width .18s ease; }
.side-in { position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden; padding: 14px 0 16px; display: flex; flex-direction: column;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
.side a, .side button { color: #fff; text-decoration: none; }
.side .ic { flex: none; opacity: .9; }
.side .tx { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-top { display: flex; align-items: center; gap: 6px; padding: 0 10px 10px 14px; }
.side-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; min-width: 0; flex: 1; }
.logo { flex: none; width: 32px; height: 32px; border-radius: 8px; background: var(--blue); display: grid; place-items: center; font-size: 16px; }
.iconbtn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: none; border: 0; color: inherit; cursor: pointer; flex: none; }
.iconbtn:hover { background: rgba(255,255,255,.1); }
.close-btn { display: none; }
.side-user { display: flex; align-items: center; gap: 10px; margin: 0 10px 8px; padding: 8px 10px; background: rgba(255,255,255,.08); border-radius: 8px; min-width: 0; }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.side-user .tx { display: flex; flex-direction: column; min-width: 0; }
.side-user b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.side-user small { font-size: 12px; opacity: .7; }
.side nav { display: flex; flex-direction: column; padding: 0 8px; gap: 1px; }
.side nav a, .side nav button { position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 10px; border-radius: 6px; font: inherit; font-size: 14px;
  background: none; border: 0; text-align: left; cursor: pointer; width: 100%; opacity: .88; }
.side nav a:hover, .side nav button:hover { background: rgba(255,255,255,.09); opacity: 1; }
.side nav a.on { background: #fff; color: var(--navy); opacity: 1; font-weight: 600; }
.side nav a:focus-visible, .side button:focus-visible { outline: 2px solid #9cc3ff; outline-offset: -2px; }
.side-title { font-size: 12px; font-weight: 600; opacity: .55; padding: 12px 20px 4px; min-height: 32px; }
.co-tag { flex: none; font-size: 11px; font-weight: 700; background: rgba(255,255,255,.16); border-radius: 4px; padding: 3px 0; width: 38px; text-align: center; }
.side nav a.on .co-tag { background: var(--tint); }
.co-nm { flex: 1; }
.side .count { margin-left: auto; flex: none; }
.count.light { background: rgba(255,255,255,.22); color: #fff; }
.side nav a.on .count.light { background: var(--tint); color: var(--navy); }
.side-bottom { margin-top: auto; padding-top: 10px !important; border-top: 1px solid rgba(255,255,255,.12); }
.side-bottom form { display: block; }
.mobilebar, .side-backdrop { display: none; }

/* Collapsed rail (tablet default, or user choice) */
@media (min-width: 900px) {
  body.side-mini .side { width: var(--side-mini); }
  body.side-mini .side .tx, body.side-mini .side-title .tx { display: none; }
  body.side-mini .side-title { padding: 6px 0; min-height: 0; border-top: 1px solid rgba(255,255,255,.1); margin: 6px 14px 4px; }
  body.side-mini .side-top { flex-direction: column; padding: 0 0 8px; }
  body.side-mini .side-brand { flex: none; }
  body.side-mini .collapse-btn .ic { transform: rotate(180deg); }
  body.side-mini .side-user { justify-content: center; margin: 0 8px 8px; padding: 8px 0; }
  body.side-mini .side nav a, body.side-mini .side nav button { justify-content: center; padding: 6px 0; }
  body.side-mini .side .count { position: absolute; top: 2px; right: 4px; min-width: 16px; padding: 0 4px; font-size: 10px; line-height: 16px; }
  body.side-mini .co-tag { width: 42px; }
}

/* Phones and small tablets: top bar + slide-in drawer */
@media (max-width: 899px) {
  body.with-side { display: block; }
  body.with-side main { padding-top: 16px; }
  .mobilebar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30; background: var(--navy); color: #fff; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .mobilebar .brand { color: #fff; font-weight: 700; text-decoration: none; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .mb-count { display: flex; align-items: center; gap: 4px; color: #fff; text-decoration: none; padding: 6px 8px; border-radius: 8px; }
  .side { position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .22s ease, visibility .22s; visibility: hidden; }
  .side-in { height: 100%; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  body.nav-open .side { transform: none; visibility: visible; box-shadow: 4px 0 24px rgba(0,0,0,.25); }
  .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(10,20,40,.45); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .side-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .collapse-btn { display: none; }
  .close-btn { display: grid; }
  .side nav a, .side nav button { min-height: 42px; font-size: 15px; }
  main { padding-left: 12px; padding-right: 12px; }
  h1 { font-size: 22px; }
  .card { padding: 14px; }
  .actions, .filter-btns { flex-wrap: wrap; }
  .page-head { align-items: flex-start; }
  .report-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .report-tabs a { flex: none; }
}
@media (prefers-reduced-motion: reduce) { .side, .side-backdrop { transition: none; } }
@media print { body.with-side { display: block; } .side, .mobilebar, .side-backdrop { display: none !important; } }

/* Reports & logs */
.report-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.report-tabs a { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line); background: #fff; text-decoration: none; font-size: 14px; color: var(--navy); }
.report-tabs a.on { background: var(--blue); border-color: var(--blue); color: #fff; }
table.list.report td, table.list.report th { font-size: 13px; padding: 7px 8px; }
.report h2 { margin-top: 26px; }
.log-type { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 4px; background: #eef1f6; color: var(--muted); }
.log-type.claim { background: var(--tint); color: var(--navy); }
.log-type.login { background: #f3e8ff; color: #6b21a8; }
.log-type.user, .log-type.company { background: #e7f6ec; color: var(--green); }
.log-type.system { background: #fff3d6; color: var(--amber); }
.act-failed { color: var(--red); font-weight: 600; }
.filters.six { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 760px) { .filters.six { grid-template-columns: 1fr; } }
.scope { margin: -4px 0 12px; }
.scope a { margin-left: 8px; font-size: 14px; }
.scope .small { margin-left: 8px; }
.status-box { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; padding: 16px 20px; }
.status-box div { display: flex; flex-direction: column; gap: 2px; }
.status-box span { font-size: 12px; color: var(--muted); font-weight: 600; }
.status-box b { font-weight: 500; }
.status-box .bad b { color: var(--red); }
@media (max-width: 760px) { .status-box { grid-template-columns: 1fr; } }

table.report td a, table.list td:first-child a { white-space: nowrap; }

/* Signatures */
.sigpad { max-width: 500px; margin-top: 6px; }
.sigpad canvas { display: block; width: 100%; height: auto; aspect-ratio: 500 / 160; background: #fff; border: 1px dashed #9aa7bd; border-radius: 6px; touch-action: none; cursor: crosshair;
  background-image: linear-gradient(to right, #c7cfdc 50%, transparent 0); background-size: 10px 1px; background-repeat: repeat-x; background-position: 0 75%; }
.sigpad-bar { display: flex; justify-content: space-between; margin-top: 4px; }
.sig-saved { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 6px 0 10px; }
.sig-saved img { max-height: 70px; max-width: 260px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; }
.s-sign td.sigcell { height: 64px; text-align: center; vertical-align: middle; padding: 2px; }
.s-sign td.sigcell img { max-height: 56px; max-width: 100%; }
.s-sign .code { display: block; font-size: 9.5px; color: var(--muted); margin-top: 2px; letter-spacing: .3px; }
.s-verify { font-size: 11px; color: var(--muted); margin-top: 6px; }
.sig-note { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.verify-ok { border-left: 4px solid var(--green); }
.verify-bad { border-left: 4px solid var(--red); }
.sign-act { grid-template-columns: 3fr 2fr; }
@media (max-width: 760px) { .sign-act { grid-template-columns: 1fr; } }
