/* CSR page (/) on top of /styles.css. Built to fit one screen on a desktop monitor. */

body.csr { height: 100vh; font-size: 15px; line-height: 1.4; }
body.csr > .center { flex: 1; }
.app { flex: 1; min-height: 0; display: flex; flex-direction: column; }
button { font-family: inherit; }
kbd { font: 600 .72rem var(--f-body); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; color: var(--muted); }
.hintline { font-weight: 400; color: var(--muted); }

/* header */
.csr .hdr-in { min-height: 48px; padding: 0 20px; }
.jump { margin-left: 12px; }
.jump input { width: 130px; padding: 5px 10px; background: #1B2820; border-color: #2E3F34; color: #fff; font-size: .9rem; }
.jump input::placeholder { color: #9BB0A2; }

/* request bar */
.bar { flex: none; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 8px 20px; flex-wrap: wrap; }
.bar h1 { font-size: 1.35rem; }
.pill { font-size: .78rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); }
.pill.ok { background: rgba(0,116,86,.12); color: var(--brand-2); }
.pill.done { background: var(--surface-2); color: var(--muted); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.meta { color: var(--muted); font-size: .88rem; }
.bar .acts { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.left { font-size: .85rem; color: var(--muted); }
.left b { color: var(--danger); }
.btn { padding: 8px 18px; font-size: .95rem; }
.btn.sm { padding: 4px 10px; font-size: .85rem; border-radius: 8px; }
.btn.link { padding: 0; color: var(--brand-2); font-weight: 600; background: none; border: 0; }
.btn.primary:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.btn.danger { color: var(--danger); }
.btn.ghost.danger { border-color: var(--line); background: transparent; }
dialog .btn.danger { background: var(--danger); color: #fff; }

/* workspace */
.ws { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0,1.55fr) minmax(360px,1fr); gap: 14px; padding: 14px 20px; }
.form { min-height: 0; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-content: start; }
.csr .card { padding: 14px 16px; min-width: 0; }
.step { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.step .r { margin-left: auto; }
.num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font: 700 .85rem var(--f-display); background: var(--surface-2); color: var(--muted); flex: none; }
.done .num { background: var(--brand); color: #fff; }
.step h2 { font-size: 1.12rem; }
.issue { grid-column: 1 / -1; }

.csr label, .lbl { display: grid; gap: 3px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.csr input, .csr select, .csr textarea { font-size: .95rem; padding: 7px 10px; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fg { display: grid; gap: 8px; }
.mt { margin-top: 10px; }
.rq::after { content: " *"; color: var(--danger); }

/* search boxes */
.search { position: relative; }
.search input { padding-left: 34px; font-size: 1rem; padding-top: 9px; padding-bottom: 9px; }
.search::before { content: ""; position: absolute; left: 12px; top: 50%; width: 12px; height: 12px; border: 2px solid var(--muted); border-radius: 50%; transform: translateY(-60%); }
.search::after { content: ""; position: absolute; left: 23px; top: 58%; width: 6px; height: 2px; background: var(--muted); transform: rotate(45deg); }
.dd { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.14); z-index: 30; max-height: 320px; overflow: auto; }
.dd button { all: unset; box-sizing: border-box; display: grid; gap: 1px; width: 100%; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.dd button:hover, .dd button.on { background: var(--surface-2); }
.dd b { font-family: var(--f-display); font-size: 1.02rem; }
.dd .new { color: var(--brand-2); font-weight: 600; }
.dd .cg { border-left: 3px solid var(--accent); }
.dd .none { padding: 10px 12px; color: var(--muted); font-size: .9rem; }
.chip { display: flex; align-items: flex-start; gap: 10px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.chip .t { flex: 1; min-width: 0; }
.chip b { font-family: var(--f-display); font-size: 1.1rem; display: block; }

/* reasons, segments */
.reasons { display: flex; flex-wrap: wrap; gap: 6px; }
.reasons button { font: 600 .88rem var(--f-body); background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.reasons button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.reasons select { width: auto; min-width: 130px; max-width: 240px; border-radius: 999px; padding: 5px 10px; font-size: .88rem; }
.reasons select.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); }
.seg button { flex: 1; font: 600 .88rem var(--f-body); background: none; color: var(--muted); border: 0; border-right: 1px solid var(--line); padding: 7px 8px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.seg button.hi[aria-pressed="true"] { background: var(--danger); }
.seg button:disabled { opacity: .5; cursor: default; }
.quick { display: flex; gap: 6px; margin-top: 4px; }
.quick button { white-space: nowrap; font: 600 .78rem var(--f-body); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--muted); cursor: pointer; }
.row4 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 12px; align-items: start; margin-top: 12px; }
details.more { margin-top: 10px; }
details.more summary { cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--brand-2); }
details.more .g3 { margin-top: 8px; }
.warn { display: flex; gap: 10px; align-items: center; background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 6px; padding: 7px 10px; font-size: .88rem; margin-bottom: 10px; }
.warn .btn { margin-left: auto; }
.toggle { display: flex !important; align-items: center; gap: 8px; font-size: .88rem !important; color: var(--ink) !important; cursor: pointer; margin-top: 10px; }
.toggle input { width: auto; }

/* context panel */
.ctx { min-height: 0; display: flex; flex-direction: column; padding: 0 !important; overflow: hidden; }
.ctx .tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 12px; flex: none; overflow-x: auto; }
.ctx .tab { font: 600 .92rem var(--f-body); background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 9px 8px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.ctx .tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.cnt { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--surface-2); font-size: .75rem; text-align: center; }
.cnt.hot { background: var(--danger); color: #fff; }
.pane { flex: 1; min-height: 0; overflow: auto; padding: 14px 16px; }
.sec + .sec { margin-top: 16px; }
.sec h3 { font: 700 .78rem var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.alert { padding: 8px 10px; border-radius: 8px; background: var(--bg); border-left: 3px solid var(--line); font-size: .92rem; white-space: pre-wrap; }
.alert + .alert { margin-top: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.mgr { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.mgr:last-of-type { border-bottom: 0; }
.star { all: unset; cursor: pointer; width: 22px; height: 22px; display: grid; place-items: center; font-size: 1.1rem; color: var(--line); }
.star[aria-pressed="true"] { color: #E0A800; }
.star:disabled { cursor: default; opacity: .4; }
.mgr .n { position: relative; min-width: 0; }
.mgr .n b { display: block; font-weight: 600; }
.mgr .n span { font-size: .8rem; color: var(--muted); }
.mgr .n .swap { font-size: .8rem; margin-left: 6px; }
.mgr .n input { padding: 4px 8px; font-size: .88rem; }
.mgr .term { color: var(--danger); font-weight: 700; }
.nt { display: flex; gap: 4px; }
.nt button { font: 600 .75rem var(--f-body); border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 6px; padding: 2px 7px; cursor: pointer; }
.nt button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.nt button:disabled { opacity: .4; cursor: default; }
.csr table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.csr th, .csr td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.csr th { color: var(--muted); font-weight: 600; }
.rowlink { cursor: pointer; }
.rowlink:hover td { background: var(--surface-2); }
.tag { font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.ok { background: rgba(0,116,86,.12); color: var(--brand-2); }
.tag.hot { background: var(--danger-soft); color: var(--danger); }
.pempty { display: grid; place-items: center; align-content: center; text-align: center; gap: 6px; height: 100%; color: var(--muted); padding: 24px; }
.pempty b { font-family: var(--f-display); font-size: 1.2rem; color: var(--ink); }

/* history */
.act { padding: 10px 0; border-bottom: 1px solid var(--line); }
.act:last-child { border-bottom: 0; }
.act .h { display: flex; gap: 8px; align-items: baseline; font-size: .85rem; color: var(--muted); }
.act .h b { color: var(--ink); }
.act p { margin: 4px 0 0; white-space: pre-wrap; font-size: .92rem; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.thumbs img, .thumbs .file { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; background: var(--surface-2); }
.thumbs .file { display: grid; place-items: center; font-size: .7rem; text-align: center; padding: 4px; overflow: hidden; color: var(--muted); }

/* ask ai */
.aiw { display: flex; flex-direction: column; gap: 10px; }
.msgs { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.m { max-width: 88%; padding: 8px 12px; border-radius: 12px; font-size: .92rem; white-space: pre-wrap; }
.m.bot { background: var(--surface-2); align-self: flex-start; border-bottom-left-radius: 4px; }
.m.me { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.m.wait { color: var(--muted); font-style: italic; }
.sugg { display: flex; flex-wrap: wrap; gap: 6px; }
.sugg button { font: 600 .8rem var(--f-body); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; color: var(--brand-2); cursor: pointer; }
.ask { display: flex; gap: 8px; }

/* dialogs, viewer */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; max-width: 560px; width: calc(100% - 32px); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(10,20,14,.5); }
dialog form { padding: 20px; display: grid; gap: 12px; }
dialog h2 { font-size: 1.4rem; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.err { color: var(--danger); margin: 0; font-weight: 600; }
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 60; padding: 20px; }
.viewer img { max-width: 100%; max-height: calc(100vh - 80px); border-radius: 8px; }
.viewer .btn { position: absolute; top: 16px; right: 16px; background: #fff; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #101A14; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 70; max-width: calc(100% - 32px); }

@media (max-width: 1150px) { body.csr { height: auto; } .ws { grid-template-columns: 1fr; } .ctx { min-height: 480px; } }
@media (max-width: 720px) {
  .form { grid-template-columns: 1fr; }
  .row4, .g2, .g3 { grid-template-columns: 1fr; }
  .brand span, .meta, .jump { display: none; }
  .bar { padding: 8px var(--gutter); gap: 8px; }
  .bar .acts { margin-left: 0; flex-wrap: wrap; min-width: 0; }
}

/* remove a file (History tab) */
.fwrap { position: relative; display: inline-block; }
.fdel { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-weight: 700; cursor: pointer; line-height: 1; }
.fdel:hover { background: var(--danger); }

/* action dialog: AI note clean up */
.aiwrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 10px; }

/* long words and links wrap instead of widening the page */
.act p, .m, .alert { overflow-wrap: anywhere; }

/* Still need: each item jumps to the problem */
.left .need { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--danger); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.flash { outline: 3px solid var(--danger); outline-offset: 3px; border-radius: 8px; transition: outline-color .3s; }

/* keyboard hint only where there is a keyboard */
@media (hover: none) and (pointer: coarse) { #save kbd { display: none; } }

/* phones and tablets: keep Save and "Still need" in view, wrap tabs and status buttons */
@media (max-width: 1150px) {
  .bar { position: sticky; top: 0; z-index: 30; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
  .ctx .tabs { flex-wrap: wrap; overflow-x: visible; }
}
@media (max-width: 720px) {
  .seg { flex-wrap: wrap; }
  .seg button { flex: 1 1 30%; border-bottom: 1px solid var(--line); }
}
@media (hover: none) and (pointer: coarse) {
  .quick { flex-wrap: wrap; }
  .quick button { min-height: 40px; padding-left: 12px; padding-right: 12px; }
  .reasons button, .reasons select, .seg button, #prio button, #raised button { min-height: 40px; }
  details > summary { padding: 10px 0; }   /* taller tap area, keeps the arrow */
}
