:root { --navy:#0F2847; --navy2:#16365f; --gold:#F2B84B; --blue:#1f6fd1; --text:#1A1F2C; --muted:#5B6575; --border:#dfe4ec; --bg:#f4f6f9; --red:#c62828; --redbg:#fde8e8; }
* { box-sizing:border-box; }
body { margin:0; font-family:"Segoe UI",system-ui,-apple-system,sans-serif; color:var(--text); background:var(--bg); font-size:13px; }
a { color:var(--blue); }
.muted { color:var(--muted); } .small { font-size:11px; } .pad { padding:16px; } .nowrap { white-space:nowrap; } .red { color:var(--red); }
.err { color:var(--red); min-height:1em; margin:6px 0; }
.btn { border:1px solid var(--border); background:#fff; color:var(--text); padding:7px 14px; border-radius:6px; cursor:pointer; font:inherit; font-weight:600; text-decoration:none; display:inline-block; }
.btn:hover { background:#f0f3f8; } .btn:disabled { opacity:.45; cursor:default; }
.btn.primary { background:var(--blue); border-color:var(--blue); color:#fff; } .btn.primary:hover { background:#185bb0; }
.btn.danger { color:var(--red); border-color:#f2b8b8; } .btn.small { padding:4px 10px; font-size:12px; } .btn.ghost { background:transparent; }
.btn.wide { width:100%; }
.editor-only { display:none !important; } body.can-edit .editor-only { display:inline-block !important; }
/* header */
.top { background:var(--navy); color:#fff; display:flex; align-items:center; gap:18px; padding:0 18px; height:56px; position:sticky; top:0; z-index:50; }
.brand img { height:32px; display:block; }
nav { display:flex; gap:2px; } nav a { color:#dfe7f3; text-decoration:none; padding:8px 12px; border-radius:6px; font-weight:600; font-size:14px; }
nav a.on, nav a:hover { background:var(--navy2); color:#fff; box-shadow: inset 0 -3px 0 var(--gold); }
.search { flex:1; display:flex; justify-content:flex-end; } .search input { width:min(360px,100%); padding:8px 12px; border-radius:6px; border:0; font:inherit; }
.me { display:flex; align-items:center; gap:8px; white-space:nowrap; } .me .btn { color:#fff; border-color:#35547d; }
.role { background:var(--gold); color:#222; border-radius:10px; padding:1px 8px; font-size:11px; font-weight:700; }
main { padding:14px 18px 40px; }
.page-head { display:flex; justify-content:space-between; align-items:flex-end; gap:12px; margin-bottom:10px; flex-wrap:wrap; }
h1 { margin:0; font-size:22px; color:var(--navy); letter-spacing:.02em; } h2 { margin:0 0 8px; font-size:18px; color:var(--navy); } h3 { color:var(--navy); margin:14px 0 6px; font-size:14px; }
.actions { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.dd { position:relative; } .dd-menu { display:none; position:absolute; right:0; top:110%; background:#fff; border:1px solid var(--border); border-radius:6px; box-shadow:0 6px 20px rgba(0,0,0,.12); z-index:40; min-width:220px; }
.dd-menu.open { display:block; } .dd-menu a { display:block; padding:9px 12px; text-decoration:none; color:var(--text); } .dd-menu a:hover { background:#f0f3f8; }
.filters { display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end; background:#fff; border:1px solid var(--border); border-radius:8px; padding:10px 12px; margin-bottom:10px; }
.filters label { display:flex; flex-direction:column; font-size:11px; font-weight:600; color:var(--muted); gap:3px; }
.filters select, .filters input { min-width:120px; padding:6px 8px; border:1px solid var(--border); border-radius:5px; font:inherit; color:var(--text); background:#fff; }
/* grid */
.grid-wrap { overflow:auto; max-height:62vh; background:#fff; border:1px solid var(--border); border-radius:8px; }
table.grid { border-collapse:separate; border-spacing:0; font-size:12px; width:max-content; }
.grid th { position:sticky; top:0; background:var(--navy); color:#fff; font-weight:600; font-size:11px; padding:6px 6px 14px; text-align:left; vertical-align:bottom; border-right:1px solid #2b4a74; cursor:pointer; user-select:none; z-index:3; line-height:1.2; white-space:normal; }
.grid th small { display:block; font-weight:400; opacity:.8; } .colk { font-size:9px; opacity:.55; margin-left:3px; font-weight:400; }
.grid th .colk { position:absolute; right:4px; bottom:2px; }
.grid td { padding:4px 6px; border-bottom:1px solid #edf0f4; border-right:1px solid #f1f3f6; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; background:#fff; }
.grid td.t-money, .grid th.t-money, .grid td.t-num, .grid td.t-pct { text-align:right; font-variant-numeric:tabular-nums; }
.grid td.t-note { max-width:380px; } .grid.co td.t-note { max-width:320px; }
.grid tr.main td { font-weight:600; } .grid tr.sub td { font-weight:400; color:#445; background:#fafbfd; }
.grid tr.main td.cA, .grid tr.main td.cB { font-weight:700; }
/* frozen Job # + name */
.grid:not(.co) .cA { position:sticky; left:0; z-index:2; min-width:64px; max-width:64px; }
.grid:not(.co) .cB { position:sticky; left:64px; z-index:2; min-width:230px; max-width:230px; box-shadow: 2px 0 0 #d5dbe4; }
.grid:not(.co) th.cA, .grid:not(.co) th.cB { z-index:5; }
.grid tbody tr:hover td { background:#eef5ff; } .grid tr.sel td { background:#e3efff !important; }
.grid tr.closed td { color:#999; text-decoration:line-through; }
.grid td.notbilled { color:var(--red); background:var(--redbg); font-weight:700; }
.grid td.typed sup { color:#a05a00; margin-left:2px; } .grid td.err { color:var(--red); }
.grid tfoot td { position:sticky; bottom:0; background:#ccffcc; font-weight:700; border-top:2px solid #8fcf8f; z-index:2; }
.grid tfoot td.cA, .grid tfoot td.cB { z-index:4; }
.grid td.empty { text-align:center; padding:20px; color:var(--muted); }
.grid.co td:first-child a { font-weight:700; } .grid tr.sep td { height:8px; background:var(--bg); border:0; padding:0; }
.pill { display:inline-block; padding:1px 8px; border-radius:10px; font-size:11px; font-weight:700; border:1px solid transparent; }
.pill.green { background:#e3f6e8; color:#1b7a36; border-color:#bfe6c9; } .pill.amber { background:#fff4d6; color:#8a5a00; border-color:#f3dc9a; }
.pill.red { background:#fde8e8; color:var(--red); border-color:#f5c0c0; } .pill.blue { background:#e6f0ff; color:#1f58b8; border-color:#c3d7fb; } .pill.gray { background:#f0f2f5; color:#667; }
.under-grid { margin:6px 2px 14px; font-size:12px; }
/* detail */
.detail { background:#fff; border:1px solid var(--border); border-radius:8px; padding:14px; }
.detail-head { display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; border-bottom:1px solid var(--border); padding-bottom:8px; margin-bottom:8px; }
.detail-body { display:grid; grid-template-columns:minmax(0,1fr) 300px; gap:16px; }
.tabs { display:flex; gap:4px; border-bottom:1px solid var(--border); margin-bottom:12px; }
.tab { border:1px solid transparent; background:none; padding:8px 14px; font:inherit; font-weight:600; color:var(--muted); cursor:pointer; border-radius:6px 6px 0 0; }
.tab.on { color:var(--navy); border-color:var(--border); border-bottom-color:#fff; margin-bottom:-1px; background:#fff; box-shadow: inset 0 3px 0 var(--blue); }
.formgrid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px 18px; } .formgrid.two { grid-template-columns:repeat(2,minmax(0,1fr)); }
.fld { display:flex; flex-direction:column; gap:3px; margin-bottom:8px; } .fld.wide { grid-column:1 / -1; }
.fld label { font-size:11px; font-weight:600; color:var(--muted); }
.fld input, .fld select, .fld textarea, .addnote input { padding:6px 8px; border:1px solid #cfd6e0; border-radius:5px; font:inherit; color:var(--text); background:#fff; width:100%; }
.fld input.t-money { text-align:right; } .fld input:disabled, .fld textarea:disabled, .fld select:disabled { background:#f6f7f9; color:#333; }
.calc { padding:6px 8px; background:#eef1f5; border-radius:5px; text-align:right; font-weight:700; font-variant-numeric:tabular-nums; } .calc.notbilled { background:var(--redbg); color:var(--red); }
.chk { font-size:11px; color:var(--muted); display:flex; gap:4px; align-items:center; }
.subline { border:1px dashed #cfd6e0; border-radius:6px; padding:8px; margin-bottom:8px; } .subhead { font-weight:700; margin-bottom:6px; display:flex; gap:8px; align-items:center; }
.subgrid { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:4px 10px; }
.side .card { margin-bottom:12px; } .card { background:#fff; border:1px solid var(--border); border-radius:8px; padding:12px 14px; margin-bottom:12px; }
.side .card h3 { margin:0 0 8px; background:#eaf1fb; margin:-12px -14px 10px; padding:10px 14px; border-radius:8px 8px 0 0; }
.kv { display:flex; justify-content:space-between; padding:5px 0; border-bottom:1px solid #f0f2f5; font-variant-numeric:tabular-nums; } .kv.b span, .kv.b b { font-weight:800; } .kv.red span, .kv.red b { color:var(--red); font-weight:800; }
.addnote { display:flex; gap:8px; align-items:center; margin:8px 0; flex-wrap:wrap; } .addnote input { flex:1; min-width:200px; width:auto; }
.notelist .note { border-left:3px solid var(--gold); padding:4px 10px; margin:6px 0; background:#fcfaf3; }
table.mini { border-collapse:collapse; width:100%; font-size:12px; } .mini th, .mini td { border-bottom:1px solid #edf0f4; padding:5px 6px; text-align:left; vertical-align:top; }
.mini th { background:#f3f6fa; font-size:11px; color:var(--muted); } .mini td.money { text-align:right; }
.mini td.old { color:#8a1c1c; background:#fff5f5; } .mini td.new { color:#145c2c; background:#f3fbf5; } .hist tr.tagged td { background:#fffbea; }
.hist-wrap { max-height:60vh; overflow:auto; }
.chips { margin-bottom:8px; }
.legend { margin-top:8px; display:flex; flex-wrap:wrap; gap:12px; align-items:center; font-size:12px; } .lg i { display:inline-block; width:14px; height:14px; border:1px solid #ccc; vertical-align:middle; margin-right:4px; }
/* upload */
.upl { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.sumcards { display:grid; grid-template-columns:repeat(auto-fill,minmax(110px,1fr)); gap:8px; margin:10px 0; } .sumcards div { background:#f3f6fa; border-radius:6px; padding:8px; font-size:11px; color:var(--muted); } .sumcards b { display:block; font-size:20px; color:var(--navy); }
.sumcards .warn { background:#fff4d6; } .sumcards .bad { background:#fde8e8; }
.box { border-radius:6px; padding:8px 12px; margin:8px 0; } .box.ok { background:#e3f6e8; } .box.bad { background:#fde8e8; } .box.warn { background:#fff8e6; }
details.chg { border:1px solid var(--border); border-radius:6px; padding:6px 10px; margin:6px 0; } details summary { cursor:pointer; }
.actions.sticky { position:sticky; bottom:0; background:#fff; padding:10px 0; border-top:1px solid var(--border); margin-top:10px; }
/* modal / toast */
.modal { position:fixed; inset:0; background:rgba(15,28,46,.45); display:flex; align-items:flex-start; justify-content:center; z-index:100; overflow:auto; padding:30px 10px; } .modal.hidden { display:none; }
.modal-card { background:#fff; border-radius:10px; padding:18px 20px; width:min(860px,100%); box-shadow:0 20px 60px rgba(0,0,0,.3); }
.calcrow { margin:6px 0; }
.toast { position:fixed; bottom:18px; left:50%; transform:translateX(-50%); background:#1b2b44; color:#fff; padding:10px 18px; border-radius:6px; opacity:0; transition:opacity .2s; z-index:200; pointer-events:none; } .toast.show { opacity:1; } .toast.bad { background:var(--red); }
.loading { padding:40px; text-align:center; color:var(--muted); }
/* login */
.login-body { min-height:100vh; display:flex; align-items:center; justify-content:center; background:var(--navy) url('/login-bg.jpg') center/cover no-repeat fixed; }
.login-card { background:#fff; border-radius:12px; padding:28px; width:min(380px,92vw); box-shadow:0 20px 60px rgba(0,0,0,.35); }
.login-logo { width:180px; display:block; margin:0 auto 10px; } .login-card h1 { text-align:center; font-size:19px; } .login-card p { text-align:center; margin:4px 0 16px; }
.login-card label { display:flex; flex-direction:column; gap:4px; font-weight:600; font-size:12px; color:var(--muted); margin-bottom:12px; }
.login-card input { padding:10px; border:1px solid #cfd6e0; border-radius:6px; font:inherit; font-size:15px; }
/* responsive */
@media (max-width: 900px) {
  .top { height:auto; flex-wrap:wrap; padding:8px 10px; gap:8px; position:static; } nav { order:3; width:100%; overflow-x:auto; } nav a { font-size:13px; padding:6px 9px; white-space:nowrap; }
  .search { order:4; width:100%; } .search input { width:100%; } .me { margin-left:auto; }
  main { padding:10px; } .detail-body { grid-template-columns:1fr; } .formgrid, .formgrid.two { grid-template-columns:1fr; } .subgrid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .filters label { flex:1 1 45%; } .filters select { min-width:0; width:100%; }
  .grid:not(.co) .cB { min-width:150px; max-width:150px; } .grid-wrap { max-height:70vh; }
  h1 { font-size:18px; }
}
@media print { .top, .filters, .actions, .tabs, .under-grid { display:none !important; } .grid-wrap { max-height:none; overflow:visible; } }
