/* Groundwork — shared styles for the admin console and the freelancer workspace. */
:root {
  --bg: #f2f3f3; --card: #fff; --text: #16191f; --muted: #5f6b7a; --faint: #8d99a8; --line: #e1e4e8; --line2: #c9ced6;
  --nav: #16191f; --nav2: #232f3e; --accent: #0972d3; --accent-dark: #065daa; --accent-soft: #e8f2fd;
  --green: #037f0c; --green-soft: #e9f7ea; --amber: #8a5300; --amber-soft: #fff4dc; --red: #d91515; --red-soft: #fdeceb;
  --violet: #6741d9; --violet-soft: #efebfb;
  --viz-series-1: #2a78d6; --viz-grid: #e6e8eb;
  --radius: 10px;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
h1, h2, h3 { letter-spacing: -.01em; }
[hidden] { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }

/* ---- Buttons & inputs ---- */
button, .btn {
  font: inherit; font-weight: 600; font-size: .9rem; border-radius: 999px; padding: 6px 16px; border: 1.5px solid var(--line2);
  background: var(--card); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
button:hover, .btn:hover { border-color: var(--text); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.dangerfill { background: var(--red); border-color: var(--red); color: #fff; }
button.danger { color: var(--red); }
button.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; border-radius: 6px; font-weight: 600; }
button.link:hover { text-decoration: underline; }
button.icon { padding: 5px 9px; border-radius: 8px; }
button.sm { padding: 3px 11px; font-size: .82rem; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 7px 10px; border-radius: 8px; border: 1.5px solid var(--line2); background: #fff; color: var(--text);
}
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
input[type=color] { width: 38px; height: 34px; padding: 2px; cursor: pointer; }
textarea { resize: vertical; }
label { display: block; font-weight: 650; font-size: .86rem; margin: 14px 0 5px; }
label .hint, .hint { font-weight: 400; color: var(--muted); font-size: .84rem; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; margin: 10px 0 0; }
.check input { margin-top: 3px; }

/* ---- Console layout ---- */
.topbar { height: 48px; background: var(--nav); color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 18px; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1.02rem; color: #fff; text-decoration: none; }
.brand .logo { width: 24px; height: 24px; border-radius: 6px; background: conic-gradient(from 210deg, #ff9900, #ff5f6d, #0972d3, #00c7be, #ff9900); position: relative; }
.brand .logo::after { content: ''; position: absolute; inset: 6px; border-radius: 3px; background: var(--nav); clip-path: polygon(0 100%, 30% 20%, 60% 70%, 100% 0, 100% 100%); background: #fff; }
.topbar .spacer { flex: 1; }
.topbar button { background: transparent; color: #fff; border-color: #ffffff55; }
.topbar button:hover { border-color: #fff; }
.topbar .who { color: #c6ccd5; font-size: .88rem; }
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 48px); }
.sidenav { background: var(--card); border-right: 1px solid var(--line); padding: 18px 10px; }
.sidenav .section { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); margin: 4px 10px 8px; }
.sidenav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 550; }
.sidenav a:hover { background: var(--bg); }
.sidenav a.on { background: var(--accent-soft); color: var(--accent); }
.sidenav a svg { width: 18px; height: 18px; flex: none; }
.sidenav .foot { margin: 28px 10px 0; font-size: .8rem; color: var(--muted); }
.content { padding: 22px 28px 60px; min-width: 0; }
.crumbs { font-size: .86rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { text-decoration: none; }
.pagehead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead h1 { font-size: 1.55rem; margin: 0; flex: 1; min-width: 12rem; }
.pagehead .desc { flex-basis: 100%; color: var(--muted); margin-top: -8px; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidenav { display: flex; gap: 4px; padding: 8px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidenav .section, .sidenav .foot { display: none; }
  .content { padding: 16px 14px 60px; }
}

/* ---- Cards, stats ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px #0000000d; }
.card > header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card > header h2 { font-size: 1.05rem; margin: 0; flex: 1; }
.card .pad { padding: 16px 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: .84rem; font-weight: 550; }
.stat .value { font-size: 1.6rem; font-weight: 650; margin-top: 2px; letter-spacing: -.01em; }
.stat .sub { color: var(--muted); font-size: .82rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; }

/* ---- Tables ---- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8rem; font-weight: 700; color: var(--muted); padding: 9px 14px; border-bottom: 1px solid var(--line); background: #fafbfb; white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: #f7f9fc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .two { display: block; font-size: .82rem; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 42px 16px; }
.empty b { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }

/* ---- Badges & progress ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.queued { background: #eef0f3; color: #4a5565; }
.badge.in_progress, .badge.active, .badge.working { background: var(--accent-soft); color: var(--accent); }
.badge.submitted { background: var(--violet-soft); color: var(--violet); }
.badge.approved, .badge.ok { background: var(--green-soft); color: var(--green); }
.badge.rework, .badge.paused, .badge.invited, .badge.skipped { background: var(--amber-soft); color: var(--amber); }
.badge.rejected, .badge.off, .badge.expired { background: var(--red-soft); color: var(--red); }
.badge.completed { background: #e7e9ec; color: #39424e; }
.progress { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: #e9ebee; gap: 2px; }
.progress span { display: block; height: 100%; }
.progress .p-approved { background: #2e9a3a; } .progress .p-submitted { background: #8b6fe0; } .progress .p-in_progress { background: #4a9ae6; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 7px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---- Job cards ---- */
.jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.job { padding: 16px 18px; cursor: pointer; display: flex; flex-direction: column; gap: 10px; transition: box-shadow .15s, border-color .15s; text-decoration: none; color: inherit; }
.job:hover { border-color: var(--line2); box-shadow: 0 4px 14px #0000001a; }
.job h3 { margin: 0; font-size: 1.05rem; display: flex; gap: 8px; align-items: center; }
.job h3 span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job p { margin: 0; color: var(--muted); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.job .facts { display: flex; gap: 16px; font-size: .84rem; color: var(--muted); flex-wrap: wrap; }
.job .facts b { color: var(--text); font-weight: 650; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 16px; overflow-x: auto; }
.tabs button { border: 0; border-radius: 0; background: none; padding: 9px 14px; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs button .count { font-weight: 600; font-size: .78rem; background: var(--bg); border-radius: 999px; padding: 0 7px; margin-left: 2px; }

/* ---- Images grid ---- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { width: 220px; }
.toolbar select { width: auto; }
.toolbar .spacer { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--line2); background: var(--card); border-radius: 999px; padding: 4px 12px; font-size: .84rem; font-weight: 600; cursor: pointer; color: var(--text); }
.chip.on { background: var(--text); color: #fff; border-color: var(--text); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.thumb { background: var(--card); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; cursor: pointer; text-align: left; padding: 0; display: block; font-weight: 400; border-width: 1px; transition: box-shadow .15s; }
.thumb:hover { box-shadow: 0 4px 14px #00000026; border-color: var(--line2); }
.thumb .pic { aspect-ratio: 4 / 3; background: #dfe3e8 center / cover no-repeat; position: relative; }
.thumb .pic .badge { position: absolute; left: 7px; top: 7px; box-shadow: 0 1px 3px #0003; }
.thumb .pic .n { position: absolute; right: 7px; bottom: 7px; background: #000a; color: #fff; font-size: .74rem; font-weight: 700; border-radius: 6px; padding: 1px 7px; }
.thumb .meta { padding: 7px 10px 9px; font-size: .8rem; }
.thumb .meta b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; }
.thumb .meta span { color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; color: var(--muted); }

.drop { border: 2px dashed var(--line2); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); background: var(--card); margin-bottom: 16px; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop b { color: var(--text); }
.uploadbar { margin-top: 12px; text-align: left; }
.uploadbar .progress { height: 10px; }
.uploadbar .progress span { background: var(--accent); }
.uploadbar .msg { font-size: .86rem; margin-top: 6px; }
.uploadbar .errs { font-size: .82rem; color: var(--red); margin-top: 4px; max-height: 6em; overflow: auto; }

/* ---- Dialogs ---- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(36rem, calc(100vw - 24px)); background: var(--card); color: var(--text); box-shadow: 0 24px 70px #0007; max-height: calc(100vh - 32px); }
dialog.wide { width: min(52rem, calc(100vw - 24px)); }
dialog::backdrop { background: #0f172a8c; }
dialog form { padding: 20px 22px; }
dialog h3 { margin: 0 0 6px; font-size: 1.2rem; }
dialog p { margin: 6px 0; color: var(--muted); }
.formbtns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; position: sticky; bottom: -20px; background: var(--card); padding: 12px 0 2px; }
.err { color: var(--red); font-size: .88rem; min-height: 1.2em; margin-top: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.labelrows { display: flex; flex-direction: column; gap: 6px; }
.labelrow { display: flex; gap: 8px; align-items: center; }
.labelrow .key { width: 22px; text-align: center; font-size: .78rem; color: var(--faint); font-weight: 700; }
.labelrow .used { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.teampick { max-height: 200px; overflow: auto; border: 1.5px solid var(--line2); border-radius: 8px; padding: 4px 10px; }
.teampick .check { margin: 6px 0; }
.copybox { display: flex; gap: 6px; margin-top: 10px; }
.copybox input { font-family: ui-monospace, monospace; font-size: .82rem; }
.note { background: var(--amber-soft); color: #5c3a00; border-radius: 8px; padding: 10px 12px; font-size: .88rem; margin: 10px 0; }
.note.info { background: var(--accent-soft); color: #08386b; }

/* ---- Review viewer ---- */
.review { position: fixed; inset: 0; z-index: 50; background: #0b0f14; display: grid; grid-template-columns: 1fr 360px; grid-template-rows: 52px 1fr; color: #e6e9ee; }
.review > header { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 0 14px; background: #161b22; border-bottom: 1px solid #262d36; }
.review > header .title { flex: 1; min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review > header button { background: #222a34; color: #e6e9ee; border-color: #3a4452; }
.review canvas { width: 100%; height: 100%; display: block; outline: none; background: #0b0f14; }
.review aside { background: #161b22; border-left: 1px solid #262d36; overflow: auto; padding: 14px 16px 24px; }
.review aside h4 { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: #8c97a6; margin: 18px 0 8px; }
.review aside h4:first-child { margin-top: 2px; }
.review .actions { display: flex; flex-direction: column; gap: 8px; }
.review .actions button { justify-content: center; background: #222a34; color: #e6e9ee; border-color: #3a4452; }
.review .actions button.primary { background: #2e9a3a; border-color: #2e9a3a; color: #fff; }
.review .actions button.warn { background: #b26b00; border-color: #b26b00; color: #fff; }
.review .kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .86rem; }
.review .kv span { color: #8c97a6; }
.review .objlist { display: flex; flex-direction: column; gap: 2px; }
.review .objlist button { background: none; border: 0; border-radius: 6px; color: #e6e9ee; justify-content: flex-start; padding: 5px 8px; font-weight: 500; width: 100%; }
.review .objlist button:hover, .review .objlist button.on { background: #232b36; }
.review .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.review .attempt { border: 1px solid #2b333e; border-radius: 8px; padding: 9px 11px; margin-bottom: 8px; font-size: .84rem; }
.review .attempt .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.review .attempt .badge { background: #232b36; }
.review .feedback { background: #3b2a0d; color: #ffd591; border-radius: 8px; padding: 9px 11px; font-size: .86rem; white-space: pre-wrap; }
.review .canvaswrap { position: relative; min-height: 0; }
.review .zoomctl { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; }
.review .zoomctl button { background: #222a34e6; color: #e6e9ee; border-color: #3a4452; }
.review .draftnote { position: absolute; left: 12px; top: 12px; background: #3b2a0dee; color: #ffd591; padding: 6px 10px; border-radius: 8px; font-size: .84rem; }
@media (max-width: 860px) { .review { grid-template-columns: 1fr; grid-template-rows: 52px 55vh auto; overflow: auto; } }

/* ---- Time log chart ---- */
.viz { position: relative; }
.viz svg { display: block; width: 100%; height: 190px; overflow: visible; }
.viz .grid line { stroke: var(--viz-grid); stroke-width: 1; }
.viz .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz .bar { fill: var(--viz-series-1); }
.viz .hit { fill: transparent; cursor: default; outline: none; }
.viz .bar.on { fill: #5598e7; }
.viz .tip { position: absolute; pointer-events: none; background: var(--nav); color: #fff; border-radius: 8px; padding: 7px 10px; font-size: .82rem; transform: translate(-50%, -100%); white-space: nowrap; box-shadow: 0 6px 18px #0004; }
.viz .tip b { font-size: .95rem; display: block; }
.viz .tip span { color: #c6ccd5; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters label { margin: 0 0 4px; font-size: .78rem; color: var(--muted); }
.filters > div { min-width: 0; }
.filters input[type=date] { width: 150px; }
.filters select { width: 190px; }

/* ---- Toast ---- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); background: var(--nav); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 550; z-index: 100; transition: transform .25s; max-width: calc(100vw - 32px); box-shadow: 0 8px 26px #0005; }
#toast.show { transform: translate(-50%, 0); }
#toast.error { background: var(--red); }

/* ---- Sign-in ---- */
.signin { max-width: 380px; margin: 11vh auto 0; padding: 0 16px; }
.signin .card { padding: 26px 26px 22px; }
.signin h1 { font-size: 1.35rem; margin: 14px 0 4px; }
.signin p { color: var(--muted); margin: 0 0 6px; }
.signin button.primary { width: 100%; justify-content: center; margin-top: 18px; padding: 9px; }

/* ---- Instructions text ---- */
.md { line-height: 1.6; }
.md p { margin: 0 0 10px; color: inherit; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md h3, .md h4, .md h5 { margin: 14px 0 6px; }
.md code { background: #8881; border-radius: 4px; padding: 0 4px; }

/* ---- Instructions write / preview ---- */
.instrhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1.5px solid var(--line2); border-radius: 999px; padding: 2px; margin-bottom: 5px; }
.seg button { border: 0; border-radius: 999px; padding: 3px 12px; font-size: .82rem; background: none; color: var(--muted); }
.seg button.on { background: var(--text); color: #fff; }
.instrpreview { border: 1.5px dashed var(--line2); border-radius: 8px; padding: 10px 14px; background: #fafbfb; max-height: 50vh; overflow: auto; }
