/* ==========================================================================
   OROD HQ — layout + component styles.
   Reuses the design tokens already defined in index.html's <style> block
   (--primary, --surface, --bg, --text, --muted, --line, --ok, --error,
   --pending, --test, --radius). No new colour system.
   Status colour rule (never colour alone — always a label/icon too):
     red    = urgent / overdue        -> --error
     amber  = due soon / at risk      -> --pending
     blue   = active / in progress    -> --primary
     green  = completed / achieved    -> --ok
     grey   = not started / inactive  -> --muted
   ========================================================================== */

/* ---- App shell: sidebar + content ------------------------------------- */
.hq-shell { display: flex; align-items: stretch; gap: 0; }
.hq-sidebar {
  flex: 0 0 220px; background: var(--surface); border-right: 1px solid var(--line);
  padding: 14px 10px 40px; align-self: stretch;
}
.hq-sidebar .grp { margin-bottom: 18px; }
.hq-sidebar .grp > .grp-label {
  font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  color: var(--muted); padding: 4px 10px 6px;
}
.hq-sidebar button.navlink {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 9px 10px; border: 0; background: none; border-radius: 8px;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--text); cursor: pointer;
}
.hq-sidebar button.navlink:hover { background: var(--bg); }
.hq-sidebar button.navlink[aria-pressed="true"] { background: var(--primary); color: #fff; }
.hq-sidebar button.navlink .ic { width: 16px; text-align: center; flex: 0 0 16px; }
.hq-sidebar button.navlink .badge {
  margin-left: auto; background: var(--error); color: #fff; border-radius: 999px;
  font-size: 10px; font-weight: 800; padding: 1px 6px; min-width: 16px; text-align: center;
}
.hq-sidebar button.navlink[aria-pressed="true"] .badge { background: rgba(255,255,255,.28); }

.hq-content { flex: 1 1 auto; min-width: 0; padding: 22px 0 0 22px; }

/* collapsed (desktop toggle) */
.hq-shell.collapsed .hq-sidebar { flex-basis: 54px; }
.hq-shell.collapsed .hq-sidebar .grp-label,
.hq-shell.collapsed .hq-sidebar .navlink span.txt,
.hq-shell.collapsed .hq-sidebar .navlink .badge { display: none; }
.hq-shell.collapsed .hq-sidebar .navlink { justify-content: center; padding: 10px 0; }
.hq-shell.collapsed .hq-content { padding-left: 16px; }

.hq-railbtn {
  background: rgba(255,255,255,.16); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 12px; font-size: 13px; font-weight: 700; cursor: pointer;
}

/* ---- Mobile: sidebar becomes a slide-over drawer -------------------- */
@media (max-width: 760px) {
  .hq-shell { flex-direction: column; }
  .hq-sidebar {
    position: fixed; z-index: 50; inset: 0 30% 0 0; flex-basis: auto;
    transform: translateX(-100%); transition: transform .18s ease;
    overflow-y: auto; box-shadow: 2px 0 18px rgba(0,0,0,.25);
  }
  .hq-shell.drawer-open .hq-sidebar { transform: translateX(0); }
  .hq-backdrop {
    position: fixed; inset: 0; z-index: 49; background: rgba(0,0,0,.4);
    display: none;
  }
  .hq-shell.drawer-open .hq-backdrop { display: block; }
  .hq-content { padding: 16px 0 0; }
  .hq-shell.collapsed .hq-sidebar { flex-basis: auto; }
}

/* ---- Generic HQ pieces --------------------------------------------- */
.hq-page-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
}
.hq-page-head h2 { margin: 0; font-size: 18px; flex: 1 1 auto; }
.hq-btn {
  padding: 9px 15px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
  font-weight: 700; cursor: pointer;
}
.hq-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.hq-btn.danger  { background: var(--error-bg); border-color: #f5c6c2; color: var(--error); }
.hq-btn:disabled { opacity: .5; cursor: not-allowed; }
.hq-btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }

.hq-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.hq-toolbar input[type="search"], .hq-toolbar select, .hq-field input, .hq-field select,
.hq-field textarea, .hq-field input[type="date"] {
  padding: 8px 10px; font: inherit; font-size: 13px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--text);
}
.hq-toolbar input[type="search"] { min-width: 180px; flex: 1 1 200px; max-width: 340px; }

/* view chips (All / Mine / Due today / ...) */
.hq-views { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.hq-views button {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 12px;
  font-weight: 700; cursor: pointer;
}
.hq-views button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---- Cards / rows ------------------------------------------------- */
.hq-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
}
.hq-card .row1 { display: flex; align-items: flex-start; gap: 8px; }
.hq-card .row1 .ttl { font-weight: 700; font-size: 14px; flex: 1 1 auto; cursor: pointer; }
.hq-card .row1 .ttl.done { text-decoration: line-through; color: var(--muted); }
.hq-card .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.hq-card .meta b { color: var(--text); font-weight: 600; }

/* status + priority tags — always text, never colour alone */
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 800; white-space: nowrap; border: 1px solid transparent;
}
.tag::before { content: attr(data-ic); font-weight: 400; }
.tag.s-grey   { background: var(--bg);          color: var(--muted);   border-color: var(--line); }
.tag.s-blue   { background: #e7f0fb;            color: var(--primary); }
.tag.s-green  { background: var(--ok-bg);       color: var(--ok); }
.tag.s-amber  { background: var(--pending-bg);  color: var(--pending); }
.tag.s-red    { background: var(--error-bg);    color: var(--error); }
@media (prefers-color-scheme: dark) { .tag.s-blue { background: #16324f; } }

.overdue-flag {
  color: var(--error); font-weight: 800; font-size: 11px; letter-spacing: .3px;
}
.overdue-flag::before { content: "\26A0\FE0F  "; }
.deadline-needed { color: var(--pending); font-weight: 700; font-size: 11px; }

/* progress bar */
.hq-prog { height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; border: 1px solid var(--line); }
.hq-prog > span { display: block; height: 100%; background: var(--primary); }
.hq-prog.at_risk > span { background: var(--pending); }
.hq-prog.missed > span  { background: var(--error); }
.hq-prog.achieved > span{ background: var(--ok); }

/* summary cards on the overview */
.hq-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.hq-summary button {
  text-align: left; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; cursor: pointer; font: inherit; color: var(--text);
}
.hq-summary button:hover { border-color: var(--primary); }
.hq-summary .n { font-size: 26px; font-weight: 800; }
.hq-summary .l { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.hq-summary button.warn .n { color: var(--pending); }
.hq-summary button.bad  .n { color: var(--error); }
.hq-summary button.ok   .n { color: var(--ok); }

.hq-section-h { font-size: 14px; font-weight: 800; margin: 26px 0 10px; display: flex; gap: 8px; align-items: baseline; }
.hq-section-h .c { color: var(--muted); font-weight: 700; font-size: 12px; }

/* ---- Kanban ------------------------------------------------------ */
.hq-kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.hq-kanban .col { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.hq-kanban .col > h4 { margin: 2px 4px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.hq-kanban .col .hq-card { padding: 10px; }
.hq-kanban .col .hq-card select { width: 100%; margin-top: 8px; }

/* ---- Modal / drawer ------------------------------------------------ */
.hq-modal-back {
  position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow-y: auto;
}
.hq-modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  width: 100%; max-width: 640px; padding: 20px; box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.hq-modal h3 { margin: 0 0 4px; font-size: 16px; }
.hq-modal .sub { color: var(--muted); font-size: 12px; margin: 0 0 16px; }
.hq-field { margin-bottom: 12px; }
.hq-field > label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 5px; }
.hq-field input, .hq-field select, .hq-field textarea { width: 100%; }
.hq-field textarea { min-height: 64px; resize: vertical; font-family: inherit; }
.hq-field .err { color: var(--error); font-size: 11px; margin-top: 4px; display: none; }
.hq-field.invalid .err { display: block; }
.hq-field.invalid input, .hq-field.invalid select, .hq-field.invalid textarea { border-color: var(--error); }
.hq-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .hq-grid2 { grid-template-columns: 1fr; } }
.hq-modal .foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; align-items: center; }
.hq-modal .foot .msg { margin-right: auto; font-size: 12px; font-weight: 700; }
.hq-modal .foot .msg.bad { color: var(--error); } .hq-modal .foot .msg.ok { color: var(--ok); }

/* ---- States ----------------------------------------------------- */
.hq-empty { text-align: center; color: var(--muted); padding: 44px 12px; font-size: 14px; }
.hq-empty .big { font-size: 30px; display: block; margin-bottom: 6px; opacity: .5; }
.hq-error { text-align: center; color: var(--error); padding: 30px 12px; font-size: 13px; }
.hq-error button { margin-top: 10px; }
.hq-skel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.hq-skel .bar { height: 12px; background: var(--bg); border-radius: 6px; margin: 6px 0; animation: hqpulse 1.4s infinite; }
.hq-skel .bar.w60 { width: 60%; } .hq-skel .bar.w40 { width: 40%; } .hq-skel .bar.w80 { width: 80%; }
@keyframes hqpulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* ---- Comments / updates / activity ------------------------------- */
.hq-thread { margin-top: 6px; }
.hq-thread .c { border-left: 2px solid var(--line); padding: 6px 0 6px 12px; margin-bottom: 8px; }
.hq-thread .c .h { font-size: 11px; color: var(--muted); }
.hq-thread .c .b { font-size: 13px; white-space: pre-wrap; margin-top: 2px; }
.hq-activity-row { font-size: 12px; color: var(--muted); padding: 5px 0; border-bottom: 1px dashed var(--line); }
.hq-activity-row b { color: var(--text); font-weight: 600; }

/* ---- Checklist -------------------------------------------------- */
.hq-checklist { margin: 6px 0; }
.hq-checklist .it { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }
.hq-checklist .it.done label { text-decoration: line-through; color: var(--muted); }
.hq-checklist .it input { width: auto; }
.hq-checklist .prog { font-size: 11px; color: var(--muted); font-weight: 700; margin-left: 4px; }

/* ---- Calendar ------------------------------------------------- */
.hq-cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.hq-cal-head .mo { font-weight: 800; font-size: 15px; min-width: 150px; text-align: center; }
.hq-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.hq-cal-grid .dow { font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--muted); text-align: center; padding: 4px 0; }
.hq-cal-grid .cell { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; min-height: 82px; padding: 4px 5px; font-size: 11px; }
.hq-cal-grid .cell.other { opacity: .4; }
.hq-cal-grid .cell.today { border-color: var(--primary); border-width: 2px; }
.hq-cal-grid .cell .dn { font-weight: 700; color: var(--muted); }
.hq-cal-grid .cell .ev { display: block; margin-top: 2px; padding: 1px 4px; border-radius: 4px; background: var(--bg); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hq-cal-grid .cell .ev.t-deadline { background: var(--error-bg); color: var(--error); }
.hq-cal-grid .cell .ev.t-goal { background: var(--pending-bg); color: var(--pending); }
.hq-cal-grid .cell .ev.t-meeting { background: #e7f0fb; color: var(--primary); }
@media (max-width: 640px) {
  .hq-cal-grid .cell { min-height: 54px; }
  .hq-cal-grid .cell .ev { font-size: 0; padding: 3px; }
  .hq-cal-grid .cell .ev::before { content: "\2022"; font-size: 12px; }
}
