/* ═══════════════════ Invoices page — header ═══════════════════ */

.page-invoices .app-header {
    height: 64px;
    padding: 16px;
    gap: 16px;
}

.page-invoices .app-header-title {
    font-size: 20px;
    line-height: 28px;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inv-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.icon-btn {
    width: 32px;
    height: 32px;
    padding: 4px;
    border: none;
    border-radius: 6px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.icon-btn svg {
    width: 24px;
    height: 24px;
}

#inv-search-btn svg {
    transform: translate(1px, -.25px);
}

/* Filter toggle: no bg when closed, gray when open, blue dot when filters exist */
#inv-filter-btn {
    background: transparent;
}

#inv-filter-btn.active {
    background: #f2f2f2;
}

.filter-dot {
    display: none;
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3b82f6;
    border: 2px solid #fff;
}

#inv-filter-btn:hover .filter-dot,
#inv-filter-btn.active .filter-dot {
    border-color: #f2f2f2;
}

#inv-filter-btn.has-filters .filter-dot {
    display: block;
}

/* Search: 32px button that expands leftwards into a bordered field */
.inv-search {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    transition: width 200ms ease, border-color 200ms ease;
    flex-shrink: 0;
}

.inv-search.open {
    width: 240px;
    border-color: #e6e6e6;
    background: #fff;
}

.inv-search.open .icon-btn {
    background: transparent;
}

.inv-search-input {
    flex: 1;
    min-width: 0;
    width: 0;
    border: none;
    outline: none;
    background: transparent;
    padding: 0 0 0 12px;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 16px;
    font-weight: 450;
    line-height: 24px;
    color: #1f1f1f;
    opacity: 0;
    transition: opacity 150ms ease;
}

.inv-search.open .inv-search-input {
    opacity: 1;
}

.inv-search-input::placeholder {
    color: #767676;
}

/* New button: 4px vertical / 8px horizontal padding, 4px gap to caret */
.btn-new {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 32px;
    padding: 4px 8px;
    border: none;
    border-radius: 6px;
    background: #1f1f1f;
    color: #fff;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 16px;
    font-weight: 500;
    line-height: 24px;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-new svg path {
    fill: #fff;
}

/* ═══════════════════ Filter row ═══════════════════ */

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 4px 16px 16px;
}

.filter-row.hidden {
    display: none;
}

.filter-add-btn {
    width: 32px;
    height: 32px;
    padding: 4px;
    border: none;
    border-radius: 6px;
    background: #f2f2f2;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
    .filter-add-btn:hover,
    .icon-btn:hover {
        background: #e8e8e8;
    }
    #inv-filter-btn:not(.active):hover {
        background: rgba(0, 0, 0, 0.04);
    }
    .btn-new:hover {
        background: #000;
    }
    .btn-tertiary:hover {
        background: rgba(0, 0, 0, 0.04);
    }
}

.btn-tertiary {
    display: flex;
    align-items: center;
    height: 32px;
    padding: 4px 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #1f1f1f;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 16px;
    font-weight: 500;
    line-height: 24px;
    cursor: pointer;
    flex-shrink: 0;
}

/* ═══════════════════ Filter tag ═══════════════════
   Tag is 32px tall; the clickable segments inside are 28px. */

.ftag {
    display: flex;
    align-items: center;
    height: 32px;
    padding: 0 1px;
    border: 1px solid #e6e6e6;
    border-radius: 6px;
    background: #fff;
}

.ftag-seg {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 2px 4px;
    border: none;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 16px;
    font-weight: 450;
    line-height: 24px;
    white-space: nowrap;
}

.ftag-seg + .ftag-seg {
    margin-left: -4px;
}

.ftag-label.pinned {
    padding-left: 2px;
}

@media (hover: hover) and (pointer: fine) {
    .ftag-seg:hover {
        background: #f2f2f2;
    }
}

.ftag-seg.open {
    background: #f2f2f2;
}

.ftag-label {
    color: #767676;
}

.ftag-label .pin-ic {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.ftag-label .pin-ic path {
    fill: #767676;
}

.ftag-sym {
    color: #1f1f1f;
    font-weight: 450;
}

.ftag-value {
    color: #1f1f1f;
    font-weight: 450;
}

.ftag-value .ph {
    color: #b0b0b0;
    font-weight: 450;
}

.st-ic {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.ftag-value .st-ic + .st-ic {
    margin-left: -2px;
}

/* Inline editing input inside a tag */
.ftag-input {
    height: 28px;
    padding: 2px 4px;
    border: 1px solid #d2d2d7;
    outline: none;
    border-radius: 4px;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 16px;
    font-weight: 450;
    line-height: 22px;
    color: #1f1f1f;
    box-sizing: border-box;
}

.ftag-input:focus {
    border-color: #1f1f1f;
}

.ftag-input::placeholder {
    color: #b0b0b0;
    font-weight: 450;
}

/* ═══════════════════ Popovers ═══════════════════ */

.popover {
    position: fixed;
    z-index: 300;
    display: flex;
    flex-direction: column;
    min-width: 240px;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    font-family: "IBM Plex Sans", sans-serif;
}

.pop-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid #ececec;
}

.pop-search svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.pop-search svg path {
    fill: #767676;
}

.pop-search input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 16px;
    font-weight: 450;
    line-height: 24px;
    color: #000;
}

.pop-search input::placeholder {
    color: #767676;
}

.pop-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.pop-row {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 450;
    line-height: 24px;
    color: #000;
    flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
    .pop-row:hover {
        background: #f2f2f2;
    }
}

.pop-row.current {
    background: #f2f2f2;
}

.pop-row .grow {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pop-row .dot-active {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3b82f6;
    flex-shrink: 0;
}

/* 12px between dot and chevron; 16px chevron slot even when absent */
.pop-row .chev-slot {
    width: 16px;
    height: 16px;
    margin-left: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pop-row .dot-active + .chev-slot {
    margin-left: 12px;
}

.pop-section {
    padding: 8px 8px 0;
    font-size: 12px;
    font-weight: 450;
    line-height: 16px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #767676;
    flex-shrink: 0;
}

/* Category option rows */
.opt-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 450;
    line-height: 24px;
    color: #000;
    flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
    .opt-row:hover {
        background: #f2f2f2;
    }
}

.opt-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.opt-sub {
    font-size: 13px;
    font-weight: 450;
    line-height: 18px;
    color: #767676;
}

.cb {
    width: 16px;
    height: 16px;
    border: 1.5px solid #d2d2d7;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #fff;
    align-self: flex-start;
    margin-top: 4px;
}

.cb svg {
    display: none;
    width: 12px;
    height: 12px;
}

.cb.on {
    background: #1f1f1f;
    border-color: #1f1f1f;
}

.cb.on svg {
    display: block;
}

/* Label (operator / pin / delete) menu */
.menu-pop {
    min-width: 240px;
}

.menu-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    font-size: 16px;
    font-weight: 450;
    line-height: 24px;
    color: #000;
    cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
    .menu-row:hover {
        background: #fafafa;
    }
}

.menu-row:first-child {
    border-radius: 11px 11px 0 0;
}

.menu-row:last-child {
    border-radius: 0 0 11px 11px;
}

.menu-row .grow {
    flex: 1;
}

.menu-row svg {
    flex-shrink: 0;
}

.menu-row .mi-ic path {
    fill: #767676;
}

.menu-row.current {
    background: #f2f2f2;
}

.menu-sep {
    height: 1px;
    background: #ececec;
}

/* Amount range toggle */
.switch {
    width: 32px;
    height: 20px;
    border-radius: 10px;
    background: #ccc;
    position: relative;
    flex-shrink: 0;
    transition: background 150ms ease;
}

.switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: left 150ms ease;
}

.switch.on {
    background: #008847;
}

.switch.on::after {
    left: 14px;
}

/* ═══════════════════ Filter tag v2 ═══════════════════
   The whole tag is one click target; editing happens in a
   combined popover (search → operator → values → pin/delete). */

.ftag-v2 {
    position: relative;
    gap: 4px;
    padding: 2px 8px;
    cursor: pointer;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 16px;
    font-weight: 450;
    line-height: 24px;
    white-space: nowrap;
    overflow: hidden;
}

/* Delete affordance: on hover a soft gradient fades in over the tag's right
   edge so the value text behind it blends out smoothly. The gradient itself is
   just decoration (non-interactive); only the 32×32 button is clickable, so the
   click target stays tight even though the fade spans further left. Nothing shifts. */
.ftag-del-fade {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 44px;
    border-radius: 0 6px 6px 0;
    background: linear-gradient(to right, rgba(242, 242, 242, 0) 0%, #f2f2f2 55%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease;
}

.ftag-del {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease;
}

.ftag-del svg {
    display: block;
    flex-shrink: 0;
}

@media (hover: hover) and (pointer: fine) {
    .ftag-v2:hover .ftag-del-fade,
    .ftag-v2:hover .ftag-del {
        opacity: 1;
    }

    .ftag-v2:hover .ftag-del {
        pointer-events: auto;
    }
}

@media (hover: hover) and (pointer: fine) {
    .ftag-v2:hover {
        background: #f2f2f2;
    }
}

.ftag-v2.open {
    background: #f2f2f2;
}

.ftag-v2 .pin-ic {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-left: -4px;
}

.ftag-v2 .pin-ic path {
    fill: #767676;
}

.ftag-label-txt {
    color: #767676;
}

.ftag-value-txt {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #1f1f1f;
}

.ftag-value-txt .ph {
    color: #b0b0b0;
}

.ftag-value-txt .st-ic + .st-ic {
    margin-left: -2px;
}

/* Plain input row inside the v2 editor popover (text / amount) */
.pop-inputrow {
    display: flex;
    gap: 8px;
    padding: 8px;
}

.pop-inputrow input {
    flex: 1;
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    outline: none;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 16px;
    font-weight: 450;
    line-height: 24px;
    color: #1f1f1f;
}

.pop-inputrow input:focus {
    border-color: #1f1f1f;
}

.pop-inputrow input::placeholder {
    color: #b0b0b0;
}

/* Floating v1/v2 switch for testers */
.ver-switch {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 400;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 6px 6px 16px;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 15px;
    font-weight: 450;
    color: #767676;
}

.ver-switch button {
    border: none;
    background: transparent;
    border-radius: 999px;
    padding: 6px 14px;
    cursor: pointer;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: #767676;
}

@media (hover: hover) and (pointer: fine) {
    .ver-switch button:not(.active):hover {
        background: #f2f2f2;
    }
}

.ver-switch button.active {
    background: #1f1f1f;
    color: #fff;
}

/* ═══════════════════ Date popover ═══════════════════ */

.date-pop {
    width: 272px;
}

.date-inputs {
    display: flex;
    gap: 8px;
    padding: 8px;
}

.date-inputs input {
    flex: 1;
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    outline: none;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 16px;
    font-weight: 450;
    line-height: 24px;
    color: #1f1f1f;
}

.date-inputs input:focus,
.date-inputs input.target {
    border-color: #1f1f1f;
}

.date-inputs input::placeholder {
    color: #b0b0b0;
}

.cal {
    padding: 0 12px 12px;
}

.cal-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.cal-nav {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

@media (hover: hover) and (pointer: fine) {
    .cal-nav:hover {
        background: #f2f2f2;
    }
}

.cal-head .spacer-flex {
    flex: 1;
}

.cal-select {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid #e6e6e6;
    border-radius: 8px;
    background: #fff url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 5.5h10L8 11z' fill='%23767676'/%3E%3C/svg%3E") no-repeat right 6px center;
    padding: 2px 22px 2px 8px;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 16px;
    font-weight: 450;
    line-height: 24px;
    color: #1f1f1f;
    cursor: pointer;
    outline: none;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 32px);
    justify-content: center;
}

.cal-dow {
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 450;
    color: #767676;
}

.cal-day {
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 16px;
    font-weight: 450;
    line-height: 24px;
    color: #1f1f1f;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.cal-day.adj {
    color: #c4c4c4;
}

@media (hover: hover) and (pointer: fine) {
    .cal-day:hover {
        background: #f2f2f2;
    }
}

.cal-day.sel {
    background: #1f1f1f;
    color: #fff;
}

.cal-day.inrange {
    background: #f2f2f2;
}

/* ═══════════════════ Body / footer ═══════════════════ */

.inv-body {
    flex: 1;
    overflow: auto;
    padding: 0 0 0 16px;
}

.inv-table {
    width: 100%;
    min-width: 960px;
    border-collapse: collapse;
    font-family: "IBM Plex Sans", sans-serif;
}

.inv-table th {
    height: 40px;
    padding: 0 12px;
    border-bottom: 1px solid #e6e6e6;
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #767676;
    white-space: nowrap;
}

.inv-th-actions,
.inv-td-actions {
    width: 40px;
    padding-right: 0;
}

.inv-table th:first-child,
.inv-table td:first-child {
    padding-left: 0;
}

.inv-table td {
    height: 56px;
    padding: 0 12px;
    border-bottom: 1px solid #ececec;
    font-size: 16px;
    font-weight: 450;
    line-height: 24px;
    color: #1f1f1f;
    white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
    .inv-table tbody tr:hover td {
        background: #fafafa;
    }
}

.inv-cell-state {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inv-cell-stack {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.inv-cell-primary {
    font-size: 16px;
    font-weight: 450;
    line-height: 24px;
    color: #1f1f1f;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.inv-cell-sub {
    font-size: 13px;
    font-weight: 450;
    line-height: 18px;
    color: #767676;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.inv-table th.inv-th-amount {
    text-align: right;
}

.inv-table td.inv-cell-amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #D3394B;
}

.inv-table td.inv-cell-amount.positive {
    color: #03B15E;
}

.inv-row-actions {
    width: 32px;
    height: 32px;
    padding: 4px;
    border: none;
    border-radius: 6px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
    .inv-row-actions:hover {
        background: #e8e8e8;
    }
}

.inv-footer {
    padding: 16px;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 14px;
    font-weight: 450;
    line-height: 22px;
    color: #767676;
}

.inv-footer b {
    color: #1f1f1f;
    font-weight: 500;
}

@media (max-width: 768px) {
    .inv-search.open {
        width: 160px;
    }
}
