/* JHTC TDR app — palette from the JHTC logo: slate navy + mountain blue-grey */
:root {
  --navy: #3f4f6b;
  --navy-dark: #2f3c52;
  --mist: #b6c0d4;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #dde3ec;
  --text: #23293a;
  --muted: #6b7488;
  --orange: #c77a2d;
  --green: #2e7d4f;
  --red: #b23a3a;
  --yellow: #b98a1d;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", -apple-system, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* top bar */
#topbar { display: flex; align-items: center; gap: 16px; background: var(--card); border-bottom: 2px solid var(--navy); padding: 8px 16px; position: sticky; top: 0; z-index: 20; }
#logo { height: 44px; }
#appTitle { font-size: 17px; font-weight: 600; color: var(--navy-dark); margin: 0 24px 0 0; white-space: nowrap; }
#nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; white-space: nowrap; }
#nav button { background: none; border: none; padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
#nav button.active { color: var(--navy-dark); border-bottom-color: var(--orange); }
#nav button:hover { color: var(--navy-dark); }
#userbox { display: flex; align-items: center; gap: 10px; }
#userbox .who { text-align: right; line-height: 1.2; }
#userbox .who .name { font-weight: 600; }
#userbox .who .role { font-size: 12px; color: var(--muted); }

#mockbar { background: #fff5e5; border-bottom: 1px solid #e8c896; color: #7a5510; padding: 6px 16px; display: flex; gap: 24px; align-items: center; font-size: 13px; }
#mockbar[hidden] { display: none; }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }

/* generic */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.orange { color: var(--orange); }
h2 { font-size: 18px; color: var(--navy-dark); margin: 0 0 12px; }
h3 { font-size: 15px; color: var(--navy-dark); margin: 16px 0 8px; }

.btn { background: var(--navy); color: #fff; border: none; border-radius: 5px; padding: 8px 16px; font-weight: 600; }
.btn:hover { background: var(--navy-dark); }
.btn.secondary { background: #e8ecf3; color: var(--navy-dark); }
.btn.secondary:hover { background: var(--mist); }
.btn.danger { background: var(--red); }
.btn.green { background: var(--green); }
.btn.sm { padding: 4px 10px; font-weight: 500; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

input[type="text"], input[type="number"], input[type="date"], select, textarea {
  border: 1px solid var(--line); border-radius: 5px; padding: 7px 10px; background: #fff; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.03em; }
label.field.required > span::after { content: " *"; color: var(--red); }

/* tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 7px 16px; color: var(--muted); font-weight: 600; }
.tabs button.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.tabs button .cnt { background: rgba(0,0,0,0.15); border-radius: 10px; padding: 1px 7px; margin-left: 6px; font-size: 12px; }
.tabs button.active .cnt { background: var(--orange); }

/* status badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 700; }
.badge.draft { background: #e8ecf3; color: var(--navy-dark); }
.badge.awaitingAP { background: #fdf3d7; color: var(--yellow); }
.badge.accepted { background: #e3edfa; color: #2c5e9e; }
.badge.paid { background: #e2f2e8; color: var(--green); }
.badge.rejected { background: #f9e3e3; color: var(--red); }

/* TDR cards */
.tdr-card { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; overflow: hidden; background: var(--card); }
.tdr-card .head { background: var(--navy-dark); color: #fff; display: flex; gap: 14px; align-items: center; padding: 8px 14px; font-size: 13px; }
.tdr-card .head .id { font-weight: 700; }
.tdr-card .head .file { color: var(--mist); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tdr-card .body { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 20px; padding: 12px 14px; }
.tdr-card .kv .k { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.tdr-card .kv .v { font-weight: 600; }
.tdr-card .foot { display: flex; gap: 8px; padding: 0 14px 12px; align-items: center; }
.tdr-card .hint { color: var(--orange); font-size: 13px; padding: 0 14px 8px; }
.tdr-card .reject { color: var(--red); font-size: 13px; padding: 0 14px 8px; }

/* tables */
table.grid { width: 100%; border-collapse: collapse; background: var(--card); }
table.grid th { text-align: left; font-size: 12px; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--line); padding: 8px 10px; letter-spacing: 0.03em; }
table.grid td { border-bottom: 1px solid var(--line); padding: 8px 10px; }
table.grid tr.click:hover { background: #f0f3f8; cursor: pointer; }

/* edit screen */
.edit-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }
.timeline .step { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline .step:last-child { border-bottom: none; }
.timeline .dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 3px; flex: none; }
.dot.done { background: var(--green); }
.dot.wait { background: var(--yellow); }
.dot.no { background: var(--line); }
.dot.bad { background: var(--red); }
.timeline .lbl { font-weight: 600; }
.timeline .sub { font-size: 12px; color: var(--muted); }

.doc-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.doc-row:last-child { border-bottom: none; }
.doc-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-slot { border: 1px dashed var(--mist); border-radius: 6px; padding: 8px 12px; margin: 6px 0; display: flex; align-items: center; gap: 10px; }
.attach-slot.ok { border-style: solid; border-color: var(--green); background: #f3faf6; }
.attach-slot .t { flex: 1; font-size: 13px; font-weight: 600; }

.dropzone { border: 2px dashed var(--mist); border-radius: 8px; padding: 24px; text-align: center; cursor: pointer; color: var(--muted); transition: border-color 0.15s, background 0.15s; }
.dropzone.over { border-color: var(--orange); background: #fff8ef; color: var(--navy-dark); }
.dropzone .filelist { list-style: none; margin: 10px 0 0; padding: 0; text-align: left; }
.dropzone .filelist li { display: flex; align-items: center; gap: 8px; padding: 4px 0; color: var(--text); }

.errbox { background: #fdf0f0; border: 1px solid #ecc8c8; color: var(--red); border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; }
.errbox ul { margin: 4px 0 0 18px; padding: 0; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(30, 38, 55, 0.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--card); border-radius: 10px; padding: 20px; width: min(560px, 92vw); max-height: 88vh; overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,0.25); }
.modal h3 { margin-top: 0; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* toast */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy-dark); color: #fff; padding: 10px 18px; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.3); animation: fadein 0.2s; max-width: 420px; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* trust selector */
.selector-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pick-list { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.pick-list label { display: flex; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; }
.pick-list label:hover { background: #f0f3f8; }
.group-box { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; }
.group-box .g-head { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: #f0f3f8; cursor: pointer; }
.group-box .g-members { padding: 4px 12px 8px 30px; font-size: 13px; color: var(--muted); }

/* admin */
.admin-layout { display: grid; grid-template-columns: 230px 1fr; gap: 16px; align-items: start; }
.admin-menu { display: flex; flex-direction: column; gap: 2px; }
.admin-menu button { text-align: left; background: none; border: none; padding: 10px 12px; border-radius: 6px; color: var(--muted); font-weight: 600; }
.admin-menu button.active { background: var(--navy); color: #fff; }
.admin-menu button:hover:not(.active) { background: #e8ecf3; color: var(--navy-dark); }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 70vh; }
.login-card { text-align: center; max-width: 460px; }
.login-card img { height: 80px; margin-bottom: 16px; }
code.principal { background: #eef1f6; padding: 2px 8px; border-radius: 4px; font-size: 12px; word-break: break-all; display: inline-block; }

/* print sheets: on-screen app is hidden while printing; #print-root holds one
   formal sheet per TDR (all fields, Q&A, comments — no backup-doc list) */
#print-root { display: none; }
@media print {
  #app { display: none !important; }
  #toast-root, #modal-root { display: none !important; }
  body { background: #fff; }
  #print-root { display: block; }
}
.print-sheet { page-break-after: always; font-size: 12px; color: #111; padding: 8px 2px; }
.print-sheet .ps-head { display: flex; align-items: center; gap: 16px; border-bottom: 2px solid #3f4f6b; padding-bottom: 8px; margin-bottom: 10px; }
.print-sheet .ps-head img { height: 40px; }
.print-sheet .ps-head h1 { font-size: 16px; margin: 0; flex: 1; }
.print-sheet table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.print-sheet th { text-align: left; font-size: 10px; text-transform: uppercase; color: #555; border-bottom: 1px solid #999; padding: 3px 6px; }
.print-sheet td { border-bottom: 1px solid #ddd; padding: 4px 6px; vertical-align: top; }
.print-sheet td.k { width: 34%; font-weight: 600; color: #333; }
.print-sheet .ps-section { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #3f4f6b; margin: 10px 0 4px; }
.print-sheet .ps-comments { border: 1px solid #ccc; padding: 8px; min-height: 40px; white-space: pre-wrap; }
@media (max-width: 1000px) {
  .edit-layout, .selector-cols, .admin-layout { grid-template-columns: 1fr; }
  .tdr-card .body, .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1180px) {
  #appTitle { display: none; }
}
