/* ==========================================================================
   Proofreading Hub — frontend styles.
   A single, small stylesheet using CSS variables for the palette so the look
   stays consistent and is easy to retheme. Mirrors the original PoC design.
   ========================================================================== */

:root {
  --navy: #0B5FA5; --navy-d: #083f6f; --teal: #0E9488; --amber: #C2410C;
  --ink: #1f2328; --muted: #6b7178; --line: #e7ebf0; --bg: #f4f6f8; --card: #fff;
}

* { box-sizing: border-box; font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; }
body { margin: 0; background: var(--bg); color: var(--ink); }
.muted { color: var(--muted); font-size: 12px; }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(120deg, var(--navy), var(--navy-d)); padding: 20px; }
.login-card { background: #fff; border-radius: 14px; padding: 28px; width: 100%; max-width: 360px;
  box-shadow: 0 18px 40px rgba(8, 63, 111, .25); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; color: var(--navy); }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: #374151; margin-top: 14px; }
.login-card input { width: 100%; margin-top: 5px; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; }
.login-card .btn { width: 100%; margin-top: 18px; }
.login-error { color: var(--amber); font-size: 13px; margin: 12px 0 0; }

/* ---------- Header / nav ---------- */
header { background: linear-gradient(120deg, var(--navy), var(--navy-d)); color: #fff;
  padding: 16px 26px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
header h1 { margin: 0; font-size: 20px; font-weight: 700; }
header p { margin: 3px 0 0; font-size: 13px; opacity: .85; }
.brand { display: flex; align-items: center; gap: 14px; }
/* White chip so any logo (light or dark) reads on the navy header. */
.logo-chip { background: #fff; border-radius: 8px; padding: 5px 9px; display: flex; align-items: center; }
.logo-chip img { height: 26px; display: block; }
.logo-login { display: block; height: 38px; margin-bottom: 10px; }
.userbar { display: flex; align-items: center; gap: 12px; }
.who { font-size: 13px; opacity: .95; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; background: rgba(255,255,255,.16); }
.badge.live { background: #0E9488; }
.badge.demo { background: #C2410C; }

nav { display: flex; gap: 6px; padding: 0 22px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
nav button { border: 0; background: none; padding: 13px 16px; font-size: 14px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; }
nav button.active { color: var(--navy); border-bottom-color: var(--navy); }

main { padding: 20px 26px; max-width: 1280px; }
h2 { font-size: 16px; margin: 0 0 12px; }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; }
.stat .n { font-size: 25px; font-weight: 700; color: var(--navy); line-height: 1; }
.stat .l { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.stat.teal .n { color: var(--teal); }
.stat.amber .n { color: var(--amber); }

/* ---------- Cards / tables ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 9px 12px; border-bottom: 1px solid #f1f3f5; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }

select, input, textarea { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff; color: var(--ink); }
select.st { font-weight: 600; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.cov-Staffed { background: #e9f6f4; color: var(--teal); }
.cov-Needsbackup { background: #fff6e6; color: #b45309; }
.cov-GapAIinterim, .cov-Gapunstaffed { background: #fbe4da; color: var(--amber); }

/* ---------- Forms ---------- */
form.entry { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; max-width: 100%; }
/* Big side-by-side panes for the full-page proofreading editor. */
.editor-pane { width: 100%; min-height: 55vh; padding: 12px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; font-size: 14px; line-height: 1.5; resize: vertical; }
textarea.editor-pane[readonly] { background: var(--bg); }
/* Read-only source pane rendered as a div so variables/tags can be highlighted. */
.editor-pane.readonly { background: var(--bg); overflow: auto; white-space: pre-wrap;
  box-sizing: border-box; }

/* Protected tokens ({{ }} / {% %} / <tags>) that must never be translated. */
mark.tok { background: #fff3cd; color: #7a5b00; border-radius: 3px; padding: 0 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
.tok-legend { font-weight: 400; font-size: 11px; }

/* Variable-integrity warning shown when the draft breaks a variable/tag. */
.token-warn { margin-top: 10px; padding: 8px 12px; border-radius: 8px; font-size: 13px;
  background: #fdecea; color: #8a1c12; border: 1px solid #f5c6c0; }

/* Sticky action bar for the proofreader editor — stays visible no matter how
   much content is above it, and the primary action reads big. */
.action-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-top: 16px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 -4px 14px rgba(14,23,38,.08); }
.action-bar .action-notes { flex: 1; min-width: 200px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; font-size: 14px; }
.action-bar .action-hours { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: #374151; }
.action-bar .action-hours input { width: 84px; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; font-size: 15px; text-align: right; }
.btn.btn-lg { font-size: 15px; padding: 11px 20px; font-weight: 700; }

/* Translation-memory suggestions (reuse a previously-approved translation). */
.tm-suggest { margin-top: 10px; padding: 8px 12px; border-radius: 8px; font-size: 13px;
  background: #eaf5ec; color: #1f6b3b; border: 1px solid #bfe3ca; }
.tm-suggest .btn { margin-left: 6px; }
.tm-chip { margin-top: 4px; color: #1f6b3b; border-color: #bfe3ca; }

/* "Changes vs AI draft" diff panel. */
.diff-panel { margin-top: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); white-space: pre-wrap; font-size: 14px; line-height: 1.6; max-height: 40vh; overflow: auto; }
.diff-panel ins { background: #d7f5dd; color: #12633a; text-decoration: none; }
.diff-panel del { background: #fdd8d5; color: #8a1c12; }
.field { margin-bottom: 13px; display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: #374151; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }

/* ---------- Attachments (images + files) ---------- */
.attach-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0; }
.attach-item { width: 132px; border: 1px solid var(--line); border-radius: 8px; padding: 6px;
  background: var(--card); }
.attach-thumb { width: 118px; height: 84px; object-fit: cover; border-radius: 5px; background: var(--bg);
  display: block; cursor: zoom-in; }
.attach-thumb.thumb-failed { min-height: 84px; }
.attach-item.attach-file { display: flex; flex-direction: column; justify-content: center; min-height: 96px; }
.attach-meta { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 11px; }
.attach-meta .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* Upload drop zone. */
.att-drop { display: flex; align-items: center; gap: 8px; margin: 8px 0; padding: 8px;
  border: 1px dashed var(--line); border-radius: 8px; }
.att-drop.dropping { border-color: var(--brand); background: #eef4ff; }
.att-hint { font-size: 12px; }
.att-linkrow { display: flex; gap: 8px; margin: 6px 0; }
.att-url { flex: 1; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; }

/* Full-size image viewer overlay. */
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.8);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 24px; }
.lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 8px; background: #fff; }
.lightbox figcaption { color: #fff; text-align: center; margin-top: 10px; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn { background: var(--navy); color: #fff; border: 0; border-radius: 8px; padding: 10px 18px;
  font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--navy-d); }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--navy); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.x { color: #c0392b; cursor: pointer; font-weight: 700; border: 0; background: none; font-size: 15px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }

/* ---------- Progress bars (dashboard + Crowdin) ---------- */
.bar-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.bar-row .label { width: 140px; font-size: 12px; }
.bar-track { flex: 1; background: #eef0f3; border-radius: 5px; height: 18px; }
.bar-fill { background: var(--navy); height: 100%; border-radius: 5px; }
.bar-fill.teal { background: var(--teal); }
.bar-row .val { width: 42px; text-align: right; font-size: 12px; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 50; }
.toast.error { background: var(--amber); }

/* ---------- Status pills (requests + assignment stages) ---------- */
.st-Intake, .st-Awaitingdraft { background: #f1f3f5; color: #5f5e5a; }
.st-Drafting, .st-Drafted { background: #e6f1fb; color: #185fa5; }
.st-Inproofreading { background: #fff6e6; color: #b45309; }
.st-Approved { background: #eef0fb; color: #534ab7; }
.st-Published { background: #e9f6f4; color: var(--teal); }
.st-AIinterim { background: #f3effe; color: #534ab7; }
.st-Recurring { background: #f1f3f5; color: var(--muted); }

/* ---------- Clickable rows + deadline urgency colouring ---------- */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f7fbff; }
tr.due td:first-child { border-left: 4px solid transparent; }
tr.due-overdue td:first-child { border-left-color: #e24b4a; }
tr.due-soon td:first-child { border-left-color: #ef9f27; }
tr.due-ok td:first-child { border-left-color: #1d9e75; }
.due-tag { font-size: 11px; font-weight: 600; }
.due-tag.overdue { color: #c0392b; }
.due-tag.soon { color: #b45309; }

/* ---------- Hover tooltip ---------- */
.tip { position: fixed; z-index: 60; max-width: 320px; background: var(--ink); color: #fff;
  padding: 9px 12px; border-radius: 8px; font-size: 12.5px; line-height: 1.45; white-space: pre-line;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); pointer-events: none; }
.tip strong { color: #cfe3f3; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(11,31,51,.45); display: flex;
  align-items: flex-start; justify-content: center; padding: 20px 16px; z-index: 70; overflow-y: auto; }
.modal-card { background: #fff; border-radius: 14px; padding: 24px 30px; width: 96vw; max-width: 1280px;
  box-shadow: 0 24px 60px rgba(8,63,111,.3); }
.modal-card .kv { grid-template-columns: 160px 1fr 160px 1fr; }
.modal-card .modal-note { font-size: 14px; }
.modal-card h2 { font-size: 18px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; }
.modal-head .grow { flex: 1; }
.modal-close { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; font-size: 13px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.modal-note { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  font-size: 13px; white-space: pre-wrap; margin: 6px 0 14px; }

/* ---------- Market picker (new request) ---------- */
.picker { border: 1px solid var(--line); border-radius: 8px; max-height: 230px; overflow-y: auto; padding: 6px; }
.picker label { display: flex; align-items: center; gap: 8px; padding: 5px 6px; font-size: 13px;
  font-weight: 400; border-radius: 6px; cursor: pointer; }
.picker label:hover { background: var(--bg); }
.picker input[type="checkbox"] { width: auto; }
.picker .lang { color: var(--muted); font-size: 12px; }
.picker-count { font-size: 12px; color: var(--navy); font-weight: 600; }
textarea.big { min-height: 120px; resize: vertical; }

/* ---------- Roster edit + my work ---------- */
.row-actions { display: flex; gap: 6px; }
.inline-edit { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; }
.section-title h2 { margin: 0; }

/* ---------- Notifications bell ---------- */
.bell { position: relative; }
.bell button { background: rgba(255,255,255,.16); color: #fff; border: 0; border-radius: 20px;
  padding: 5px 10px; font-size: 13px; cursor: pointer; }
.bell .count { background: #e24b4a; color: #fff; border-radius: 10px; font-size: 11px;
  font-weight: 700; padding: 0 6px; margin-left: 4px; }
.notif-panel { position: absolute; right: 0; top: 36px; width: 320px; max-height: 380px; overflow-y: auto;
  background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 14px 40px rgba(8,63,111,.25); z-index: 65; padding: 8px; }
.notif-item { padding: 8px 10px; border-bottom: 1px solid #f1f3f5; font-size: 13px; }
.notif-item:last-child { border-bottom: 0; }
.notif-item.unread { background: #f3f8ff; }
.notif-item .when { color: var(--muted); font-size: 11px; }

/* ---------- Workflow draft display + actions ---------- */
.draft-box { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  font-size: 13px; white-space: pre-wrap; margin: 6px 0; max-height: 220px; overflow-y: auto; }
.stage-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; align-items: center; }
.overview-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.bucket { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.bucket h3 { margin: 0 0 8px; font-size: 13px; font-weight: 500; }
.bucket .n { font-size: 22px; font-weight: 700; color: var(--navy); }
.bucket.warn .n { color: var(--amber); }
.bucket ul { margin: 8px 0 0; padding-left: 0; list-style: none; }
.bucket li { font-size: 12.5px; padding: 3px 0; border-top: 1px solid #f1f3f5; cursor: pointer; }
.bucket li:hover { color: var(--navy); }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}

/* ---------- Spreadsheet requests (mode toggle + grid) ---------- */
/* Segmented control on the "New request" form (single text vs spreadsheet). */
/* Hug the buttons — the parent .field is a flex column, which would otherwise
   stretch this control to the full card width. */
.seg { display: inline-flex; width: fit-content; align-self: flex-start;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 6px; }
.seg-btn { background: #fff; border: 0; padding: 8px 14px; font-size: 13px; cursor: pointer; color: var(--ink); }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.active { background: var(--navy); color: #fff; }

/* The English-vs-language proofreading grid (row per source string). */
table.grid-table { width: 100%; border-collapse: collapse; }
table.grid-table th, table.grid-table td { border: 1px solid var(--line); padding: 8px 10px; vertical-align: top; text-align: left; }
table.grid-table th { background: var(--bg); font-size: 12px; }
.grid-table .gr-num { width: 36px; text-align: center; color: var(--muted); font-size: 12px; }
.grid-table .gr-src { width: 45%; font-size: 13px; white-space: pre-wrap; }
.grid-table td.gr-src { background: var(--bg); }
.grid-table .gr-tgt { width: 52%; }
.grid-table textarea.cell-edit { width: 100%; min-height: 44px; resize: vertical; font-size: 13px;
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
/* Inside a grid cell the read-only box is plain text, not a bordered panel. */
.grid-table .draft-box { margin: 0; border: 0; background: transparent; padding: 0; max-height: none; }

/* Make the status chips legible on the white page, not only in the dark header. */
.badge.demo, .badge.live { color: #fff; }

/* The expanded per-market panel in the request popup (the grid or draft box). */
.draft-row > td { padding: 12px; background: var(--bg); }
.grid-actions { align-items: center; }
.grid-actions .pill { align-self: center; }
