/* Han Revolution — Workshop System UI
   Clean / premium / minimal / fast. No decorative animation. Touch-friendly. */

:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --ink: #171a1f;
  --ink-2: #3c4250;
  --muted: #697080;
  --line: #e4e6ea;
  --line-2: #d4d7dd;
  --red: #d7222a;
  --red-dark: #b6161d;
  --red-soft: #fdecec;
  --green: #178a4c;
  --green-soft: #e6f6ed;
  --amber: #b26a00;
  --amber-soft: #fdf3e0;
  --blue: #1d5fd2;
  --blue-soft: #e8effc;
  --teal: #0c7d74;
  --teal-soft: #e2f4f2;
  --purple: #6d3fc0;
  --purple-soft: #f0e9fb;
  --orange: #c2410c;
  --orange-soft: #feefe6;
  --gray-soft: #eef0f3;
  --wa: #1fa855;
  --sidebar-bg: #121418;
  --sidebar-ink: #a3a9b4;
  --radius: 12px;
  --radius-s: 9px;
  --shadow: 0 1px 2px rgba(20, 24, 33, 0.05), 0 1px 1px rgba(20, 24, 33, 0.03);
  --shadow-pop: 0 12px 32px rgba(15, 18, 25, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink);
  font-size: 14.5px; line-height: 1.45;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 21px; }
h2 { font-size: 15px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0.4em 0; }
.icon { flex: 0 0 auto; vertical-align: -3px; }

/* ---------------------------------------------------------------- shell */

.shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 20px 24px 90px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* sidebar */
.sidebar {
  width: 228px; flex: 0 0 228px; background: var(--sidebar-bg); color: var(--sidebar-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side-logo { padding: 20px 18px 14px; }
.side-logo a { display: block; text-decoration: none; line-height: 1.05; }
.logo-han { display: block; color: #fff; font-weight: 800; font-size: 21px; letter-spacing: 0.16em; }
.logo-rev { display: block; color: var(--red); font-weight: 800; font-size: 12.5px; letter-spacing: 0.30em; }
.logo-sub { margin-top: 7px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; color: #596070; }
.side-nav { flex: 1; padding: 6px 10px 16px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9.5px 11px; margin: 1px 0;
  border-radius: 8px; color: var(--sidebar-ink); font-weight: 500; font-size: 13.8px;
}
.nav-item:hover { background: #1c1f26; color: #e7e9ee; text-decoration: none; }
.nav-item.active { background: #23262e; color: #fff; }
.nav-item.active .icon { color: var(--red); }
.side-user {
  display: flex; align-items: center; gap: 10px; padding: 14px 14px;
  border-top: 1px solid #23262e;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
  flex: 0 0 auto;
}
.side-user-meta { min-width: 0; flex: 1; }
.side-user-name { color: #e7e9ee; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-role { font-size: 11px; color: #596070; }
.side-logout { color: var(--sidebar-ink); padding: 6px; border-radius: 7px; display: flex; }
.side-logout:hover { background: #1c1f26; color: #fff; }

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); padding: 10px 24px;
}
.icon-btn {
  border: 0; background: none; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--ink);
  display: none; align-items: center;
}
.icon-btn:hover { background: var(--gray-soft); }
.gsearch { position: relative; flex: 1; max-width: 560px; display: flex; align-items: center; }
.gsearch > .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.gsearch input {
  width: 100%; height: 42px; border: 1px solid var(--line-2); border-radius: 10px;
  padding: 0 12px 0 38px; font-size: 14.5px; background: var(--bg); color: var(--ink); outline: none;
  font-family: var(--font);
}
.gsearch input:focus { border-color: var(--ink-2); background: #fff; }
.gsearch-results {
  display: none; position: absolute; top: 48px; left: 0; right: 0; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop);
  max-height: 70vh; overflow-y: auto; z-index: 60;
}
.gsearch-results.open { display: block; }
.gr-group { padding: 8px 0 2px; }
.gr-head { padding: 4px 14px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.gr-item { display: block; padding: 8px 14px; color: var(--ink); }
.gr-item:hover, .gr-item.sel { background: var(--gray-soft); text-decoration: none; }
.gr-item .gr-main { font-weight: 600; font-size: 13.8px; }
.gr-item .gr-sub { font-size: 12px; color: var(--muted); }
.gr-empty { padding: 14px; color: var(--muted); font-size: 13.5px; }
.topbar-newjob { white-space: nowrap; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  border-radius: var(--radius-s); padding: 0 14px; height: 40px; font-size: 13.8px;
  font-weight: 600; cursor: pointer; text-decoration: none; font-family: var(--font);
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: #178a45; border-color: #178a45; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--gray-soft); border-color: transparent; }
.btn-danger { color: var(--red); border-color: #f3c2c4; background: #fff; }
.btn-danger:hover { border-color: var(--red); }
.btn-sm { height: 33px; padding: 0 11px; font-size: 12.8px; border-radius: 8px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 11px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.inline-form { display: inline-flex; }
button.linklike { border: 0; background: none; color: var(--blue); cursor: pointer; padding: 0; font: inherit; }
button.linklike:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ---------------------------------------------------------------- page structure */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin: 2px 0 16px; flex-wrap: wrap; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; display: block; }
.crumb a { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -2px 0 12px; }
.card-head h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.card-head-actions { display: flex; gap: 8px; align-items: center; }
.card-tight { padding: 6px 0 0; overflow: hidden; }
.card-tight .table-wrap { margin: 0; }
.card-tight table td:first-child, .card-tight table th:first-child { padding-left: 18px; }
.card-tight table td:last-child, .card-tight table th:last-child { padding-right: 18px; }

.grid { display: grid; gap: 12px; margin-bottom: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 13px 15px; color: var(--ink); display: block; }
a.stat:hover { text-decoration: none; border-color: var(--line-2); }
.stat-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 23px; font-weight: 750; margin-top: 3px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-value.red { color: var(--red); }
.stat-value.green { color: var(--green); }
.stat-value.amber { color: var(--amber); }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; min-height: 1em; }

.section-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin: 20px 0 8px; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; margin: 0 -2px; }
table { width: 100%; border-collapse: collapse; font-size: 13.8px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 10.5px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
tr.row-link { cursor: pointer; }
.strong { font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.money { font-variant-numeric: tabular-nums; }

.empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px;
  font-weight: 650; white-space: nowrap; letter-spacing: 0.01em;
}
.b-gray { background: var(--gray-soft); color: var(--ink-2); }
.b-red { background: var(--red-soft); color: var(--red); }
.b-green { background: var(--green-soft); color: var(--green); }
.b-green-dark { background: var(--green); color: #fff; }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-orange { background: var(--orange-soft); color: var(--orange); }
.b-blue { background: var(--blue-soft); color: var(--blue); }
.b-teal { background: var(--teal-soft); color: var(--teal); }
.b-purple { background: var(--purple-soft); color: var(--purple); }

/* ---------------------------------------------------------------- forms */

form.stack { display: block; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid .span2 { grid-column: span 2; }
.field { display: block; min-width: 0; }
.field-label { display: block; font-size: 12px; font-weight: 650; color: var(--ink-2); margin-bottom: 5px; letter-spacing: 0.02em; }
.req { color: var(--red); }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.input {
  width: 100%; height: 42px; border: 1px solid var(--line-2); border-radius: var(--radius-s);
  padding: 0 12px; font-size: 14.5px; font-family: var(--font); color: var(--ink); background: #fff;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--ink-2); outline: none; }
select.input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23697080' stroke-width='2.4'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.input-money { text-align: right; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; align-items: center; }
.checkline { display: flex; gap: 9px; align-items: center; font-size: 13.8px; cursor: pointer; }
.checkline input { width: 18px; height: 18px; accent-color: var(--red); }

/* lookup suggestion chip (quick job) */
.suggest-box { position: relative; }
.suggest-pop {
  display: none; position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-pop);
  max-height: 300px; overflow-y: auto;
}
.suggest-pop.open { display: block; }
.suggest-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.suggest-item:last-child { border-bottom: 0; }
.suggest-item:hover, .suggest-item.sel { background: var(--gray-soft); }
.suggest-main { font-weight: 600; font-size: 13.5px; }
.suggest-sub { font-size: 12px; color: var(--muted); }
.linked-chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--green-soft); color: var(--green);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 650; margin-top: 6px;
}
.linked-chip button { border: 0; background: none; color: inherit; cursor: pointer; font-weight: 700; padding: 0 2px; }

/* ---------------------------------------------------------------- item editor */

.items-editor { border: 1px solid var(--line); border-radius: var(--radius-s); overflow: visible; }
.items-head, .item-row { display: grid; grid-template-columns: minmax(200px, 2.2fr) 64px 110px 96px 110px 34px; gap: 8px; align-items: start; padding: 8px 10px; }
.items-head { border-bottom: 1px solid var(--line); background: #fafbfc; border-radius: var(--radius-s) var(--radius-s) 0 0; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); padding: 7px 10px; }
.item-row { border-bottom: 1px solid var(--line); position: relative; }
.item-row .input { height: 38px; font-size: 13.8px; }
.item-row textarea.input { height: auto; min-height: 0; padding: 6px 10px; font-size: 12.8px; margin-top: 6px; }
.item-name-cell { position: relative; }
.item-total { height: 38px; display: flex; align-items: center; justify-content: flex-end; font-weight: 650; font-variant-numeric: tabular-nums; font-size: 13.8px; padding-right: 2px; }
.item-remove { border: 0; background: none; color: var(--muted); cursor: pointer; height: 38px; width: 30px; border-radius: 7px; font-size: 16px; }
.item-remove:hover { color: var(--red); background: var(--red-soft); }
.items-footer { display: flex; justify-content: space-between; align-items: center; padding: 9px 10px; gap: 8px; flex-wrap: wrap; }
.items-col-label { display: none; }

.totals-box { margin-left: auto; max-width: 340px; width: 100%; }
.totals-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px; font-size: 14px; gap: 12px; }
.totals-row .input { max-width: 130px; height: 36px; }
.totals-row.grand { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 750; }
.totals-row.grand .money { font-size: 21px; }

/* ---------------------------------------------------------------- filters/tabs */

.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar .input { width: auto; height: 38px; }
.filter-bar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tabs { display: inline-flex; background: #e9ebee; padding: 3px; border-radius: 10px; gap: 2px; flex-wrap: wrap; }
.tab { padding: 6.5px 13px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; padding: 5.5px 12px; border-radius: 999px; font-size: 12.5px;
  font-weight: 600; border: 1px solid var(--line-2); color: var(--ink-2); background: #fff;
}
.chip:hover { border-color: var(--ink-2); text-decoration: none; }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 16px 0; }
.pager .muted { font-size: 12.5px; }

/* ---------------------------------------------------------------- detail pages */

.doc-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13.8px; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.contact-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.tl-date { flex: 0 0 84px; font-size: 12px; color: var(--muted); padding-top: 2px; }
.tl-body { flex: 1; min-width: 0; }
.tl-title { font-weight: 600; font-size: 13.8px; }
.tl-sub { font-size: 12.5px; color: var(--muted); }
.tl-amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

.status-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.photo-grid a { display: block; aspect-ratio: 1; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }

.sig-box { border: 1.5px dashed var(--line-2); border-radius: 10px; padding: 14px; text-align: center; }
.sig-box img { max-height: 110px; max-width: 100%; }

/* ---------------------------------------------------------------- toast / modal */

.toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 13.8px; font-weight: 600; box-shadow: var(--shadow-pop); max-width: 92vw;
}
.toast-warn { background: var(--amber); }
.toast-err { background: var(--red); }

.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(10, 12, 16, 0.55); z-index: 300;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-pop); width: 100%; max-width: 560px; padding: 18px; max-height: 92vh; overflow-y: auto; }
.modal h2 { margin-bottom: 12px; font-size: 16px; }
#sigCanvas { width: 100%; height: 220px; border: 1.5px dashed var(--line-2); border-radius: 10px; touch-action: none; background: #fff; display: block; }

/* ---------------------------------------------------------------- calendar */

.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-title { font-size: 16px; font-weight: 700; }
.cal-month { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-month th { text-align: center; padding: 6px 4px; }
.cal-month td { vertical-align: top; height: 96px; padding: 5px 6px; border: 1px solid var(--line); }
.cal-month td:hover { background: #fafbfc; }
.cal-daynum { font-size: 12px; font-weight: 650; color: var(--ink-2); }
.cal-today .cal-daynum { color: #fff; background: var(--red); border-radius: 999px; padding: 1px 7px; display: inline-block; }
.cal-other { background: #fafbfc; }
.cal-other .cal-daynum { color: var(--line-2); }
.cal-evt { display: block; font-size: 11.5px; padding: 2px 6px; margin-top: 3px; border-radius: 6px; background: var(--blue-soft); color: var(--blue); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.cal-evt:hover { text-decoration: none; }
.cal-more { font-size: 11px; color: var(--muted); margin-top: 2px; display: block; }
.day-list .tl-date { flex: 0 0 70px; font-weight: 650; color: var(--ink); }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.week-col { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 140px; }
.week-col.today { border-color: var(--red); }
.week-day { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 6px; }
.week-col.today .week-day { color: var(--red); }

/* ---------------------------------------------------------------- reports */

.bar-row { display: grid; grid-template-columns: 92px 1fr 92px; gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; }
.bar-track { background: var(--gray-soft); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { background: var(--red); height: 100%; border-radius: 6px; min-width: 2px; }
.bar-fill.alt { background: var(--ink-2); }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------------------------------------------------------------- auth / bare pages */

body.bare { background: var(--sidebar-bg); }
.bare-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: #fff; border-radius: 16px; padding: 30px 28px; width: 100%; max-width: 400px; box-shadow: var(--shadow-pop); }
.auth-logo { text-align: center; margin-bottom: 20px; line-height: 1.05; }
.auth-logo .logo-han { color: var(--ink); font-size: 26px; }
.auth-logo .logo-rev { font-size: 15px; }
.auth-logo .logo-sub { margin-top: 8px; }
.auth-card .field { margin-bottom: 13px; }
.error-page { text-align: center; padding: 60px 20px; }
.error-code { font-size: 54px; font-weight: 800; color: var(--line-2); }
.bare .error-page { color: #fff; }

/* ---------------------------------------------------------------- quick actions */

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.qa {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 650; font-size: 13.8px;
  border-radius: 11px; padding: 0 16px; height: 46px; border: 1px solid var(--line-2);
  background: #fff; color: var(--ink);
}
.qa:hover { border-color: var(--ink-2); text-decoration: none; }
.qa-primary { background: var(--red); border-color: var(--red); color: #fff; }
.qa-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }

/* sticky bottom action bar (mobile job flow) */
.sticky-actions {
  position: sticky; bottom: 0; z-index: 30; display: flex; gap: 10px; padding: 12px 0 14px;
  background: linear-gradient(to top, var(--bg) 78%, transparent);
}
.sticky-actions .btn { flex: 1; }

/* ---------------------------------------------------------------- responsive */

.show-m { display: none; }

@media (max-width: 980px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; height: 100%;
    transform: translateX(-104%); transition: transform 0.18s ease-out; width: 258px;
  }
  .sidebar.open { transform: translateX(0); }
  .backdrop { display: none; position: fixed; inset: 0; background: rgba(10, 12, 16, 0.45); z-index: 90; }
  .backdrop.open { display: block; }
  .icon-btn { display: inline-flex; }
  .show-m { display: inline-flex; }
  .hide-m { display: none; }
  .topbar { padding: 9px 12px; gap: 8px; }
  .content { padding: 14px 12px 110px; }
  .doc-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .form-grid .span2 { grid-column: span 2; }
  .week-grid { grid-template-columns: 1fr; }
  .week-col { min-height: 0; }
  .cal-month td { height: 64px; padding: 3px 4px; }
  .cal-evt { display: none; }
  .cal-count { display: inline-block; background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; margin-top: 4px; }
}

@media (min-width: 981px) {
  .cal-count { display: none; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  h1 { font-size: 19px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  .grid-stats { grid-template-columns: 1fr 1fr; }
  .page-actions .btn { height: 42px; }
  /* item editor collapses to stacked cards */
  .items-head { display: none; }
  .item-row { grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 10px; }
  .item-row > * { grid-column: span 1; }
  .item-row .item-name-cell { grid-column: span 2; }
  .items-col-label { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 3px; }
  .item-total { justify-content: flex-start; font-size: 15px; }
  .item-remove { position: absolute; top: 8px; right: 8px; }
  .kv { grid-template-columns: 108px 1fr; }
  .qa { flex: 1 1 44%; justify-content: center; }
}

@media print {
  .sidebar, .topbar, .page-actions, .sticky-actions, .toast, .quick-actions { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; }
}

/* ---------------------------------------------------------------- progress bar (status changes, saves, page loads) */
#hrProgress { position: fixed; top: 0; left: 0; height: 4px; width: 0; background: var(--red); z-index: 9999;
  opacity: 0; transition: width .45s ease, opacity .2s; pointer-events: none; }
#hrProgress.on { opacity: 1; }
#hrBusy { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 999px; z-index: 9999; opacity: 0;
  pointer-events: none; transition: opacity .2s; display: flex; align-items: center; gap: 9px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); }
#hrBusy.on { opacity: 1; }
#hrBusy::before { content: ""; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: hrSpin .8s linear infinite; }
@keyframes hrSpin { to { transform: rotate(360deg); } }
