/* OperationsHQ — Authenticated app layout: topbar, main, dashboard-specific. */

.ohq-app {
    background: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.ohq-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border-subtle);
}

.ohq-topbar__inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px var(--space-8);
    display: flex;
    align-items: center;
    gap: var(--space-6);
}

.ohq-topbar__brand {
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.5px;
    color: #000;
}

.ohq-topbar__nav {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    flex: 1;
}

.ohq-topbar__link {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
}

.ohq-topbar__link:hover {
    color: #000;
    text-decoration: none;
}

.ohq-topbar__link--active {
    color: #000;
    border-bottom-color: #000;
}

.ohq-topbar__user {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.ohq-topbar__user-meta {
    display: flex;
    flex-direction: column;
    text-align: right;
    line-height: 1.2;
}

.ohq-topbar__user-name {
    font-size: 0.875rem;
    font-weight: 500;
}

.ohq-topbar__user-role {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.ohq-topbar__logout {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

/* Hamburger — hidden on desktop, shown on mobile via the media query below */
.ohq-topbar__hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--color-border);
    background: #fff;
    border-radius: var(--radius-md);
    cursor: pointer;
    margin-left: auto;
}

.ohq-topbar__hamburger:hover { background: var(--color-bg-subtle); }
.ohq-topbar__hamburger:focus-visible {
    outline: 2px solid #000;
    outline-offset: 2px;
}

.ohq-topbar__hamburger-bar {
    display: block;
    width: 18px;
    height: 2px;
    background: #000;
    margin: 0 auto;
    border-radius: 1px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.ohq-topbar__hamburger[aria-expanded="true"] .ohq-topbar__hamburger-bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.ohq-topbar__hamburger[aria-expanded="true"] .ohq-topbar__hamburger-bar:nth-child(2) { opacity: 0; }
.ohq-topbar__hamburger[aria-expanded="true"] .ohq-topbar__hamburger-bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* Mobile drawer */
.ohq-drawer {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    visibility: hidden;
}

.ohq-drawer--open {
    pointer-events: auto;
    visibility: visible;
}

.ohq-drawer__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ohq-drawer--open .ohq-drawer__backdrop { opacity: 1; }

.ohq-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(86vw, 340px);
    background: #fff;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    padding: var(--space-5);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.ohq-drawer--open .ohq-drawer__panel { transform: translateX(0); }

.ohq-drawer__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-4);
}

.ohq-drawer__identity {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    min-width: 0;
}

.ohq-drawer__name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--color-text);
    word-break: break-word;
}

.ohq-drawer__role {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.ohq-drawer__close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--color-text);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.ohq-drawer__close:hover { background: var(--color-bg-subtle); }
.ohq-drawer__close:focus-visible { outline: 2px solid #000; outline-offset: 2px; }

.ohq-drawer__cta {
    width: 100%;
    justify-content: center;
    margin-bottom: var(--space-5);
}

.ohq-drawer__nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-height: 0;
}

.ohq-drawer__link {
    display: block;
    padding: 14px var(--space-4);
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text);
    text-decoration: none;
    border-radius: var(--radius-md);
}

.ohq-drawer__link:hover { background: var(--color-bg-subtle); text-decoration: none; }

.ohq-drawer__link--active {
    background: #000;
    color: #fff;
}

.ohq-drawer__link--active:hover { background: #000; color: #fff; }

.ohq-drawer__signout {
    margin-top: var(--space-5);
    padding: var(--space-4);
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    text-decoration: none;
    text-align: center;
    border-top: 1px solid var(--color-border);
}

.ohq-drawer__signout:hover { color: var(--color-text); text-decoration: none; }

/* Lock body scroll while drawer is open */
body.ohq-drawer-open { overflow: hidden; }

.ohq-main {
    flex: 1;
    padding: var(--space-10) 0;
}

.ohq-page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-8);
}

.ohq-page__header {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    margin-bottom: var(--space-8);
    flex-wrap: wrap;
    flex-wrap: wrap;
}

.ohq-page__title {
    font-size: 2.25rem;
    font-weight: 300;
    letter-spacing: -0.02em;
    margin: 0;
}

.ohq-page__subtitle {
    color: var(--color-text-muted);
    font-size: 0.9375rem;
    margin-top: var(--space-2);
}

.ohq-page__heading {
    flex: 1 1 auto;
    min-width: 0;
}

.ohq-page__actions {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    flex: 0 0 auto;
    margin-left: auto;
}

/* Stats row for dashboards */
.ohq-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

.ohq-stat {
    background: #fff;
    padding: var(--space-5);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
}

.ohq-stat__label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--color-text-muted);
    margin-bottom: var(--space-2);
}

.ohq-stat__value {
    font-size: 2.25rem;
    font-weight: 300;
    letter-spacing: -0.02em;
    line-height: 1;
}

.ohq-stat__value--danger { color: var(--color-danger); }
.ohq-stat__value--success { color: var(--color-success); }
.ohq-stat__value--warning { color: var(--color-warning); }

/* Two-column grid for dashboards */
.ohq-grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-6);
    align-items: start;
}

.ohq-grid-1-1 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
}

/* Grid children default to min-content width; set to 0 so wide tables / long
   strings can't force the grid track wider than the viewport on mobile. */
.ohq-grid-2 > *,
.ohq-grid-1-1 > *,
.ohq-stack > * {
    min-width: 0;
}

/* Section blocks */
.ohq-block {
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.ohq-block__header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.ohq-block__title {
    font-size: 1.125rem;
    font-weight: 500;
    margin: 0;
    letter-spacing: 0;
}

.ohq-block__body {
    padding: var(--space-5);
    overflow-x: auto; /* wide tables scroll inside the card, not across the page */
}

.ohq-block__body--tight { padding: 0; overflow-x: auto; }

/* Auth pages */
.ohq-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    background: var(--color-bg);
}

.ohq-auth__card {
    background: #fff;
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-card);
    padding: var(--space-10);
    width: 100%;
    max-width: 480px;
}

.ohq-auth__brand {
    font-weight: 700;
    font-size: 1.25rem;
    margin-bottom: var(--space-4);
}

.ohq-auth__title {
    font-size: 1.75rem;
    font-weight: 300;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-2);
}

.ohq-auth__subtitle {
    color: var(--color-text-muted);
    font-size: 0.9375rem;
    margin-bottom: var(--space-6);
}

.ohq-auth__toggle {
    display: flex;
    gap: var(--space-2);
    background: var(--color-bg);
    padding: var(--space-1);
    border-radius: var(--radius-pill);
    margin-bottom: var(--space-6);
}

.ohq-auth__toggle-btn {
    flex: 1;
    padding: 8px 16px;
    background: transparent;
    color: var(--color-text-secondary);
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
}

.ohq-auth__toggle-btn--active {
    background: #fff;
    color: #000;
    box-shadow: var(--shadow-card);
}

.ohq-auth__footer {
    margin-top: var(--space-5);
    text-align: center;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.ohq-auth__footer a { font-weight: 500; }

/* Filter bar */
.ohq-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-4);
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    margin-bottom: var(--space-5);
    align-items: flex-end;
}

.ohq-filter-bar .ohq-field {
    margin-bottom: 0;
    min-width: 160px;
    flex: 1;
}

/* Command bar — tabs on the left, filter pills on the right */
.ohq-command-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}

.ohq-command-bar__tabs {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

.ohq-command-bar__search {
    flex: 1 1 260px;
    min-width: 180px;
    max-width: 360px;
    position: relative;
    display: flex;
    align-items: center;
}

.ohq-command-bar__search-input {
    width: 100%;
    height: 34px;
    padding: 0 12px 0 34px;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1;
    color: var(--color-text);
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23777169' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='m21 21-4.3-4.3'/></svg>");
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 14px 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ohq-command-bar__search-input:hover { border-color: var(--color-text-muted); }

.ohq-command-bar__search-input:focus {
    outline: none;
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

.ohq-command-bar__search-input::placeholder { color: var(--color-text-muted); }

.ohq-command-bar__pills {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    align-items: center;
    margin-left: auto;
}

/* Filter pill — select (or button) styled as a rounded pill with inline label */
.ohq-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px 7px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    background: #fff;
    font-size: 0.875rem;
    line-height: 1;
    color: var(--color-text);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    position: relative;
}

.ohq-pill:hover { border-color: var(--color-text-muted); }

.ohq-pill:focus-within {
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

.ohq-pill--active {
    border-color: #000;
    background: #f7f7f6;
}

.ohq-pill__label {
    color: var(--color-text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.ohq-pill--active .ohq-pill__label { color: var(--color-text); }

.ohq-pill__select {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    font-weight: 500;
    padding: 0 16px 0 0;
    margin: 0;
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6' fill='%23777169'><path d='M5 6 0 0h10z'/></svg>");
    background-repeat: no-repeat;
    background-position: right center;
    background-size: 8px 6px;
    max-width: 200px;
    text-overflow: ellipsis;
    overflow: hidden;
}

.ohq-pill__select:focus { outline: none; }

.ohq-pill__trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    font-weight: 500;
    cursor: pointer;
    padding: 0 16px 0 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6' fill='%23777169'><path d='M5 6 0 0h10z'/></svg>");
    background-repeat: no-repeat;
    background-position: right center;
    background-size: 8px 6px;
}

.ohq-pill__trigger:focus-visible { outline: none; }

.ohq-pill__value { color: inherit; font-weight: 500; }

/* Popover for date-range and other multi-field pills */
.ohq-pill__popover {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-pop);
    padding: var(--space-4);
    z-index: 60;
    min-width: 240px;
}

.ohq-pill__popover[hidden] { display: none; }

.ohq-pill__popover .ohq-field + .ohq-field { margin-top: var(--space-3); }
.ohq-pill__popover .ohq-field { margin-bottom: 0; }

.ohq-pill__popover-actions {
    display: flex;
    justify-content: space-between;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

/* Active filters — chips below the command bar, only rendered if any filter is set */
.ohq-active-filters {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
    min-height: 1px;
}

.ohq-active-filters:empty { display: none; }

.ohq-active-filters__chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px 5px 12px;
    background: #f2f2f2;
    border-radius: var(--radius-pill);
    font-size: 0.8125rem;
    color: var(--color-text);
    white-space: nowrap;
}

.ohq-active-filters__chip-label { color: var(--color-text-muted); }

.ohq-active-filters__chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0,0,0,0.08);
    color: var(--color-text-secondary);
    font-size: 14px;
    line-height: 1;
    text-decoration: none;
}

.ohq-active-filters__chip-remove:hover {
    background: #000;
    color: #fff;
    text-decoration: none;
}

.ohq-active-filters__clear {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-left: auto;
    text-decoration: none;
}

.ohq-active-filters__clear:hover { color: var(--color-text); text-decoration: underline; }

/* List region — swap target for fetch-based filter updates */
.ohq-list-region { position: relative; }

.ohq-list-region.ohq-is-loading {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

/* Mobile — command bar stacks, search grows full width, pills wrap to their own row */
@media (max-width: 768px) {
    .ohq-command-bar__search { max-width: none; flex-basis: 100%; }
    .ohq-command-bar__pills { margin-left: 0; width: 100%; }
    .ohq-pill__select { max-width: none; }
    .ohq-pill__popover { right: auto; left: 0; }
}

/* Task detail layout */
.ohq-task-detail {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-6);
    align-items: start;
}

.ohq-task-meta-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border-subtle);
    font-size: 0.875rem;
}

.ohq-task-meta-row:last-child { border-bottom: none; }

.ohq-task-meta-row__label {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.7px;
}

/* Comments */
.ohq-comment {
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border-subtle);
}

.ohq-comment:last-child { border-bottom: none; }

.ohq-comment__author {
    font-weight: 500;
    font-size: 0.875rem;
    margin-right: var(--space-2);
}

.ohq-comment__time {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.ohq-comment__body {
    margin-top: var(--space-2);
    font-size: 0.9375rem;
    color: var(--color-text);
    line-height: 1.5;
    white-space: pre-wrap;
}

/* Role pill */
.ohq-role-tag {
    display: inline-block;
    padding: 4px 12px;
    background: var(--color-bg);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 1024px) {
    .ohq-stats { grid-template-columns: repeat(2, 1fr); }
    .ohq-grid-2 { grid-template-columns: 1fr; }
    .ohq-grid-1-1 { grid-template-columns: 1fr; }
    .ohq-task-detail { grid-template-columns: 1fr; }
    .ohq-topbar__nav { gap: var(--space-3); }
    .ohq-topbar__link { font-size: 0.875rem; }
}

@media (max-width: 768px) {
    .ohq-topbar__inner {
        gap: var(--space-3);
        padding: var(--space-3);
        justify-content: space-between;
    }
    .ohq-topbar__nav,
    .ohq-topbar__user { display: none; }
    .ohq-topbar__hamburger { display: inline-flex; }
    .ohq-page { padding: 0 var(--space-4); }
    .ohq-stats { grid-template-columns: 1fr 1fr; }
    .ohq-stat__value { font-size: 1.75rem; }
    .ohq-page__title { font-size: 1.75rem; }

    .ohq-page__header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-4);
    }
    .ohq-page__heading { flex: 0 0 auto; }
    .ohq-page__actions { margin-left: 0; }
    .ohq-page__actions > .ohq-btn { flex: 1 1 auto; justify-content: center; }
}

/* Footer (app) */
.ohq-footer {
    padding: var(--space-8) 0;
    border-top: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    margin-top: var(--space-12);
}

.ohq-footer__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-8);
    text-align: center;
}

.ohq-footer__dot { margin: 0 var(--space-2); }
