/* SwiftMaintenance — shadcn-inspired component library
   All components consume tokens from theme.css. */

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    height: 38px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 60ms ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn .icon { width: 16px; height: 16px; }

.btn-primary {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}
.btn-primary:hover:not(:disabled) {
    background: var(--brand-primary-600);
    border-color: var(--brand-primary-600);
    color: #fff;
    text-decoration: none;
}

.btn-secondary {
    background: var(--brand-accent);
    color: #06283c;
    border-color: var(--brand-accent);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--brand-accent-600);
    border-color: var(--brand-accent-600);
    color: #06283c;
    text-decoration: none;
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-outline:hover:not(:disabled) {
    background: var(--bg-muted);
    color: var(--text);
    text-decoration: none;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
    background: var(--bg-muted);
    color: var(--text);
    text-decoration: none;
}

.btn-destructive {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-destructive:hover:not(:disabled) {
    filter: brightness(0.92);
    color: #fff;
    text-decoration: none;
}

.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn-lg { height: 44px; padding: 0 var(--space-6); font-size: var(--text-md); }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }

.btn-block { width: 100%; }

/* ========== Card ========== */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    /* overflow:visible so popovers (datepicker, monthpicker, dropdown) can escape
       the card. Internal elements that need their own rounded clipping (table
       wrap, card-footer) handle it themselves. */
}
.card-header {
    padding: var(--space-5) var(--space-5) var(--space-3);
    border-bottom: 1px solid var(--border);
}
.card-header.no-border { border-bottom: none; padding-bottom: 0; }
.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin: 0;
    color: var(--text);
}
.card-description {
    margin-top: var(--space-1);
    color: var(--text-subtle);
    font-size: var(--text-sm);
}
.card-content { padding: var(--space-5); }
.card-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    background: var(--bg-muted);
    /* Keep the muted-bg footer inside the card's rounded corners now that
       the parent card no longer clips overflow. */
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

/* ========== Form inputs ========== */
.form-group { margin-bottom: var(--space-4); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

.label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text);
}

.input,
.textarea,
.select {
    display: block;
    width: 100%;
    padding: 0 var(--space-3);
    height: 38px;
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--text-base);
    line-height: 1.4;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.textarea {
    height: auto;
    min-height: 96px;
    padding: var(--space-3);
    resize: vertical;
}
/* Fixed-size textarea: locked height, no resize handle. Use for description/note/comment fields. */
.textarea-fixed {
    height: 120px;
    min-height: 120px;
    max-height: 120px;
    resize: none;
    overflow-y: auto;
}
/* Compact fixed textarea for inline note/comment boxes. */
.textarea-fixed.textarea-sm {
    height: 76px;
    min-height: 76px;
    max-height: 76px;
}
.select {
    /* Suppress every browser's native select chrome — we draw our own chevron. */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: var(--space-8);
    cursor: pointer;
}
.select:hover {
    border-color: var(--brand-primary);
}
/* Hide the IE/Edge legacy expand button. */
.select::-ms-expand { display: none; }
/* Lighter chevron in dark mode so it stays visible against the dark surface. */
[data-theme="dark"] .select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
/* When a select is showing an error state, tint the chevron red too. */
.select.is-invalid {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%23dc2626' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
[data-theme="dark"] .select.is-invalid {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%23f87171' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
.select option {
    /* Make the dropdown popup readable in dark mode. Native popup but at least
       the colors are sane. */
    background: var(--bg-elevated);
    color: var(--text);
}
/* ========== Custom select (select.js progressive enhancement) ==========
   The native <select> stays in the DOM (visually hidden) as the form source of
   truth; these styles are for the sibling control select.js builds next to it. */
.select-custom {
    position: relative;
    width: 100%;
}
.select-native-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    border: 0;
}
.select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    width: 100%;
    padding: 0 var(--space-3);
    height: 38px;
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--text-base);
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.select-trigger-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.select-chevron {
    flex-shrink: 0;
    display: inline-flex;
    color: var(--text-subtle);
}
.select-custom.is-open .select-chevron { transform: rotate(180deg); }
.select-trigger:hover { border-color: var(--brand-primary); }
.select-trigger:focus,
.select-trigger:focus-visible {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--ring);
}
.select-custom.is-disabled .select-trigger,
.select-trigger:disabled {
    background: var(--bg-muted);
    color: var(--text-subtle);
    cursor: not-allowed;
}
.select-custom.is-invalid .select-trigger {
    border-color: var(--danger);
}
.select-custom.is-invalid .select-trigger:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25);
}
.select-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 260px;
    overflow: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: var(--space-1);
    display: none;
    z-index: 50;
}
.select-custom.is-open .select-menu { display: block; }
.select-option {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: var(--text-sm);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.select-option:hover,
.select-option.is-active { background: var(--bg-muted); }
.select-option.is-selected { color: var(--brand-primary); font-weight: 600; }
.select-option.is-disabled { color: var(--text-subtle); cursor: not-allowed; }

/* ========== Category icons (templates/components/icons.html) ========== */
.category-icon {
    width: 14px;
    height: 14px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ========== Upload modal (templates/components/upload-modal.html) ========== */
.modal-content.modal-lg { max-width: 560px; }
.upload-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-6) var(--space-4);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-muted);
    transition: border-color 120ms ease, background-color 120ms ease;
}
.upload-dropzone.is-drop-target {
    border-color: var(--brand-primary);
    background: var(--brand-primary-50);
}
.upload-file-list { margin-top: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.upload-file-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--text);
}
.upload-file-row .upload-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-file-row .upload-file-size { color: var(--text-subtle); font-size: var(--text-xs); flex-shrink: 0; }
.upload-file-row .upload-file-remove {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    padding: 2px;
    border-radius: var(--radius-sm);
    line-height: 0;
}
.upload-file-row .upload-file-remove:hover { color: var(--danger); background: var(--bg-elevated); }

.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }

/* Hide native number spin buttons — keeps shadcn-clean look in both themes */
.input[type="number"]::-webkit-inner-spin-button,
.input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}
.input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--ring);
}
.input.is-invalid, .textarea.is-invalid, .select.is-invalid {
    border-color: var(--danger);
}
.input.is-invalid:focus, .textarea.is-invalid:focus, .select.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25);
}
.input:disabled, .textarea:disabled, .select:disabled {
    background: var(--bg-muted);
    color: var(--text-subtle);
    cursor: not-allowed;
}
.help-text { display: block; margin-top: var(--space-1); font-size: var(--text-xs); color: var(--text-subtle); }
.error-text { display: block; margin-top: var(--space-1); font-size: var(--text-xs); color: var(--danger); }

/* Input with leading icon */
.input-wrap { position: relative; }
.input-wrap .input { padding-left: 36px; }
.input-wrap .input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-subtle);
    pointer-events: none;
}

/* Checkbox + radio */
.checkbox, .radio {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    color: var(--text);
    font-size: var(--text-base);
}
.checkbox input[type="checkbox"],
.radio input[type="radio"] {
    appearance: none;
    width: 16px;
    height: 16px;
    margin: 0;
    border: 1.5px solid var(--border-strong);
    background: var(--bg-elevated);
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease;
    flex-shrink: 0;
}
.checkbox input[type="checkbox"] { border-radius: 4px; }
.radio input[type="radio"] { border-radius: 50%; }
.checkbox input[type="checkbox"]:checked,
.radio input[type="radio"]:checked {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
}
.checkbox input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='10' viewBox='0 0 12 10' fill='none'><path d='M1 5L4.5 8.5L11 1.5' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: center;
}
.radio input[type="radio"]:checked {
    box-shadow: inset 0 0 0 3px var(--bg-elevated);
}
.checkbox input[type="checkbox"]:focus-visible,
.radio input[type="radio"]:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

/* Switch */
.switch {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    color: var(--text);
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
    position: relative;
    width: 38px;
    height: 22px;
    background: var(--border-strong);
    border-radius: var(--radius-full);
    transition: background-color 150ms ease;
    flex-shrink: 0;
}
.switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform 150ms ease;
}
.switch input:checked + .switch-track { background: var(--brand-primary); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--ring); }

/* ========== Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    height: 22px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge-default { background: var(--brand-primary-50); color: var(--brand-primary); }
.badge-secondary { background: var(--bg-muted); color: var(--text-muted); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-destructive { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-outline { background: transparent; border-color: var(--border-strong); color: var(--text-muted); }

.badge-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}

/* ========== Modal / Dialog ========== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-4);
    animation: fade-in 150ms ease;
}
.modal-backdrop.is-open { display: flex; }
[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, 0.7); }

.modal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 80px);
    overflow: auto;
    animation: zoom-in 150ms ease;
}
.modal-header {
    padding: var(--space-5) var(--space-5) var(--space-3);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
}
.modal-title { margin: 0; font-size: var(--text-lg); font-weight: 600; }
.modal-description { color: var(--text-subtle); font-size: var(--text-sm); margin-top: var(--space-1); }
.modal-body { padding: 0 var(--space-5) var(--space-4); }
.modal-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    line-height: 0;
}
.modal-close:hover { background: var(--bg-muted); color: var(--text); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes zoom-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

/* ========== Calendar ========== */
.calendar {
    width: 280px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    box-shadow: var(--shadow-md);
}
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}
.calendar-title { font-weight: 600; color: var(--text); }
.calendar-nav {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
}
.calendar-nav:hover { background: var(--bg-muted); color: var(--text); }
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.calendar-dow {
    font-size: var(--text-xs);
    color: var(--text-subtle);
    text-align: center;
    padding: var(--space-1) 0;
    font-weight: 500;
}
.calendar-day {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background-color 100ms ease, color 100ms ease;
}
.calendar-day:hover { background: var(--bg-muted); }
.calendar-day.is-outside { color: var(--text-subtle); opacity: 0.5; }
.calendar-day.is-today {
    border: 1px solid var(--brand-primary);
    color: var(--brand-primary);
    font-weight: 600;
}
.calendar-day.is-selected {
    background: var(--brand-primary);
    color: #fff;
    font-weight: 600;
}
.calendar-day.is-selected:hover { background: var(--brand-primary-600); }

/* ========== Month picker (12-month grid + year nav) ========== */
.monthpicker-wrap { position: relative; display: inline-block; }
.monthpicker-wrap .input {
    cursor: pointer;
    padding-right: 36px;
    min-width: 200px;
    /* Hide the YYYY-MM value visually; .monthpicker-display shows the friendly label on top. */
    color: transparent;
    caret-color: transparent;
}
.monthpicker-wrap .input::selection { background: transparent; }
.monthpicker-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-subtle);
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.monthpicker-toggle:hover { color: var(--brand-primary); }
.monthpicker-display {
    pointer-events: none;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text);
    font-size: var(--text-base);
}
.monthpicker-popover {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 50;
    display: none;
}
.monthpicker-popover.is-open { display: block; }

.monthpicker {
    width: 260px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    box-shadow: var(--shadow-md);
}
.monthpicker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}
.monthpicker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.monthpicker-cell {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
    color: var(--text);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background-color 100ms ease, color 100ms ease, border-color 100ms ease;
}
.monthpicker-cell:hover { background: var(--bg-muted); }
.monthpicker-cell.is-today {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    font-weight: 600;
}
.monthpicker-cell.is-selected {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
    font-weight: 600;
}
.monthpicker-cell.is-selected:hover { background: var(--brand-primary-600); }

/* ========== Datepicker ========== */
.datepicker { position: relative; }
.datepicker .input { padding-right: 36px; }
.datepicker-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-subtle);
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.datepicker-toggle:hover { color: var(--brand-primary); }
.datepicker-popover {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 50;
    display: none;
}
.datepicker-popover.is-open { display: block; }

/* ========== Messages / Alerts / Toasts ========== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
}
.alert-icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; color: var(--text); margin: 0 0 2px; font-size: var(--text-sm); }
.alert-message { color: var(--text-muted); margin: 0; font-size: var(--text-sm); }
.alert-close {
    background: transparent;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    padding: 2px;
    border-radius: var(--radius-sm);
    line-height: 0;
}
.alert-close:hover { color: var(--text); background: var(--bg-muted); }

.alert-info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert-info .alert-icon { color: var(--info); }
.alert-success { background: var(--success-bg); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert-success .alert-icon { color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert-warning .alert-icon { color: var(--warning); }
.alert-error { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-error .alert-icon { color: var(--danger); }

/* Toast container */
.toast-region {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    width: min(360px, calc(100vw - 32px));
}
.toast {
    box-shadow: var(--shadow-lg);
    animation: slide-in 200ms ease;
}
@keyframes slide-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========== Table ========== */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--text-sm);
}
.table thead th {
    text-align: left;
    font-weight: 600;
    color: var(--text-subtle);
    background: var(--bg-muted);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    position: sticky;
    top: 0;
    z-index: 1;
}
.table tbody td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-muted); }
.table .table-num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    /* Scroll wide tables horizontally instead of clipping them (key on small screens). */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-elevated);
}

/* ========== Tabs ========== */
.tab-list {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border);
    gap: 4px;
    overflow-x: auto;
}
.tab-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    margin-bottom: -1px; /* sit on top of border */
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
    border-top-left-radius: var(--radius-sm);
    border-top-right-radius: var(--radius-sm);
}
.tab-link:hover {
    color: var(--text);
    background: var(--bg-muted);
    text-decoration: none;
}
.tab-link.is-active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}
.tab-link .tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--radius-full);
    background: var(--bg-muted);
    color: var(--text-subtle);
    font-size: var(--text-xs);
    font-weight: 600;
}
.tab-link.is-active .tab-count {
    background: var(--brand-primary-50);
    color: var(--brand-primary);
}
.tab-panel { padding-top: var(--space-4); }

/* ========== Stat card (KPI tile) ========== */
.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
}
.stat-card-label {
    color: var(--text-subtle);
    font-size: var(--text-sm);
    font-weight: 500;
    margin-bottom: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.stat-card-label .icon-pill {
    width: 28px; height: 28px;
    background: var(--brand-primary-50);
    color: var(--brand-primary);
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 150ms ease, color 150ms ease;
}
.stat-card-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-card-delta {
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-subtle);
}
.stat-card-delta.up { color: var(--success); }
.stat-card-delta.down { color: var(--danger); }

/* ========== Dropdown ========== */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 180px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: var(--space-1);
    display: none;
    z-index: 50;
}
.dropdown-menu.is-open { display: block; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: var(--text-sm);
    text-align: left;
    cursor: pointer;
    text-decoration: none;
}
.dropdown-item:hover { background: var(--bg-muted); color: var(--text); text-decoration: none; }
.dropdown-separator { height: 1px; background: var(--border); margin: var(--space-1) 0; }

/* ========== Avatar ========== */
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 40px; height: 40px; font-size: var(--text-sm); }

/* ========== Misc utilities ========== */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.inline-flex { display: inline-flex; align-items: center; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.m-0   { margin: 0; }
.my-2  { margin-top: var(--space-2); margin-bottom: var(--space-2); }
.mt-2  { margin-top: var(--space-2); }
.mt-3  { margin-top: var(--space-3); }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mb-2  { margin-bottom: var(--space-2); }
.mb-3  { margin-bottom: var(--space-3); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.text-muted   { color: var(--text-muted); }
.text-subtle  { color: var(--text-subtle); }
.text-danger  { color: var(--danger); }

/* @mention typeahead (mentions.js) */
.mention-anchor { position: relative; display: block; }
.mention-popover {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 50;
    max-height: 240px;
    overflow-y: auto;
    margin-top: 4px;
    background: var(--bg-surface, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: var(--radius-md, 8px);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12));
    padding: 4px;
}
.mention-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 8px;
    border: 0;
    background: transparent;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
}
.mention-option:hover,
.mention-option.is-active { background: var(--bg-muted, #f3f4f6); }
.mention-option-name { font-size: var(--text-sm); }
.text-xs      { font-size: var(--text-xs); }
.text-sm      { font-size: var(--text-sm); }
.text-base    { font-size: var(--text-base); }
.text-lg      { font-size: var(--text-lg); }
.font-semibold { font-weight: 600; }
.font-mono    { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.uppercase    { text-transform: uppercase; }
.text-right   { text-align: right; }
.cursor-pointer { cursor: pointer; }
.w-full { width: 100%; }

/* Strip default browser button styling so the underlying element can act as a plain control
   (e.g. dropdown trigger). Combine with .cursor-pointer for hover-friendliness. */
.btn-reset {
    background: transparent;
    border: none;
    padding: 0;
    color: inherit;
    font: inherit;
    text-align: inherit;
}

/* Password field with show/hide eye toggle */
.password-field { position: relative; }
.password-field .input { padding-right: 40px; }
.password-field .password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-subtle);
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}
.password-field .password-toggle:hover { color: var(--text); background: var(--surface-hover, rgba(0,0,0,0.05)); }
.password-field .password-toggle:focus-visible {
    outline: 2px solid var(--primary, #405daa);
    outline-offset: 1px;
}
.password-field .password-toggle .eye-off { display: none; }
.password-field.is-revealed .password-toggle .eye { display: none; }
.password-field.is-revealed .password-toggle .eye-off { display: inline-block; }

/* Paginated data-table primitives (see docs/ARCHITECTURE.md §24) */
.data-table-form    { margin-bottom: 16px; }
.data-table-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Filter button + active-count badge */
.data-table-filter-toggle { display: inline-flex; align-items: center; gap: 6px; }
.data-table-filter-toggle.has-active { border-color: var(--primary, #405daa); color: var(--primary, #405daa); }
.data-table-filter-toggle.is-open { background: var(--bg-muted); }
.filter-count-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--primary, #405daa); color: #fff; font-size: 11px; font-weight: 600;
}
.filter-count-badge[hidden] { display: none; }

/* Collapsible filter bar above the table */
.data-table-filters {
    display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end;
    margin-top: 12px; padding: 14px 16px;
    border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--bg-elevated);
}
.data-table-filters[hidden] { display: none; }
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field[hidden] { display: none; }
.filter-label { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: 600; color: var(--text-subtle); }
.filter-label svg { width: 14px; height: 14px; flex-shrink: 0; }
.data-filter-clear { margin-left: auto; align-self: flex-end; color: var(--text-muted); }
.filter-daterange { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.filter-daterange[hidden] { display: none; }
.data-table-footer  { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; gap: 12px; flex-wrap: wrap; }
.pagination         { display: inline-flex; gap: 4px; align-items: center; }
.sortable           { color: inherit; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
.sortable:hover     { color: var(--text); }

/* Single-line cell: clip overflowing text to one line with an ellipsis (hover shows full via title=). */
.cell-truncate      { max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-truncate a    { color: inherit; }
/* Ticket "Type" cell: icon + label on one line. */
.type-cell          { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* ----- Detail list (label:value rows) ----- */
.detail-list                { display: grid; grid-template-columns: minmax(160px, max-content) minmax(0, 1fr); gap: 0.875rem 1.5rem; align-items: baseline; margin: 0; }
.detail-list dt             { color: var(--text-subtle, #6b7280); font-weight: 500; margin: 0; }
.detail-list dd             { margin: 0; word-break: break-word; }
.detail-list .person        { display: inline-flex; align-items: center; gap: 0.5rem; }

@media (max-width: 720px) {
    .detail-list            { grid-template-columns: minmax(0, 1fr); gap: 0.25rem 0; }
    .detail-list dt         { margin-top: 0.75rem; font-size: 0.875rem; }
}

/* ========== Drawer / Off-canvas (right-side slide-out) ========== */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms ease, visibility 200ms ease;
    z-index: 1000;
}
.drawer-backdrop.is-open { opacity: 1; visibility: visible; }
[data-theme="dark"] .drawer-backdrop { background: rgba(0, 0, 0, 0.7); }

.drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(460px, 100vw);
    background: var(--bg-elevated);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 220ms cubic-bezier(.4, 0, .2, 1);
    overflow: visible;
}
.drawer-backdrop.is-open .drawer-panel { transform: translateX(0); }

.drawer-header {
    flex: 0 0 auto;
    padding: var(--space-5) var(--space-5) var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    border-bottom: 1px solid var(--border);
}
.drawer-title { margin: 0; font-size: var(--text-lg); font-weight: 600; }
.drawer-close {
    background: transparent;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    line-height: 0;
}
.drawer-close:hover { background: var(--bg-muted); color: var(--text); }

.drawer-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: var(--space-5);
}
.drawer-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    color: var(--text-subtle);
    font-size: var(--text-sm);
}

/* ========== Notifications ========== */
.notification-list { list-style: none; margin: 0; padding: 0; }
.notification-item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}
.notification-item:last-child { border-bottom: none; }
.notification-item.is-unread { background: var(--bg-muted); }
.notification-item-body { flex: 1; min-width: 0; }
/* Title row wraps so a long type badge + title never spills over the actions column. */
.notification-item-title { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-weight: 500; font-size: var(--text-sm); }
.notification-item-title a { color: var(--text); text-decoration: none; min-width: 0; }
.notification-item-title a:hover { text-decoration: underline; }
.notification-item-title .badge { font-size: 10px; }
.notification-item-text { margin: var(--space-1) 0 0 0; color: var(--text-muted); font-size: var(--text-xs); }
.notification-item-meta { margin-top: var(--space-1); color: var(--text-subtle); font-size: var(--text-xs); }
.notification-item-actions { flex-shrink: 0; }
/* Phones: let the action drop below the body instead of crowding it. */
@media (max-width: 560px) {
    .notification-item { flex-wrap: wrap; }
    .notification-item-actions { width: 100%; }
}

/* ========== Ticket activity timeline ========== */
.timeline { list-style: none; margin: 0 0 var(--space-4) 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.timeline-item { display: flex; gap: var(--space-3); align-items: flex-start; }
.timeline-avatar { flex-shrink: 0; }
.timeline-body { flex: 1; min-width: 0; }
.timeline-meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.timeline-body-text { margin: var(--space-1) 0 0 0; white-space: pre-line; }
.timeline-item.is-event .timeline-body-text { color: var(--text-muted); }

.comment-form { border-top: 1px solid var(--border); padding-top: var(--space-3); margin-top: var(--space-3); }
.comment-form-actions { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }

/* ========== Tickets: view toggle + kanban board + 2-pane detail ========== */
.board-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}
.view-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-elevated);
}
.view-toggle a {
    padding: 6px 14px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--text-sm);
    line-height: 1.4;
    transition: background-color 120ms ease, color 120ms ease;
}
.view-toggle a:hover { color: var(--text); }
.view-toggle a.is-active { background: var(--bg-muted); color: var(--text); font-weight: 500; }
.view-toggle svg { vertical-align: -2px; margin-right: 4px; }

.kanban-board {
    display: grid;
    grid-template-columns: repeat(6, minmax(260px, 1fr));
    gap: var(--space-3);
    overflow-x: auto;
    padding-bottom: var(--space-3);
}
.board-column {
    background: var(--bg-muted);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    min-height: 60vh;
    max-height: calc(100vh - 280px);
}
.board-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    border-bottom: 1px solid var(--border);
}
.board-column-header h3 {
    margin: 0;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.board-column-count {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 0 10px;
    font-size: var(--text-xs);
    color: var(--text-muted);
    height: 22px;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
.board-column-content {
    flex: 1;
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    overflow-y: auto;
    min-height: 80px;
}
.board-column.is-drop-target {
    outline: 2px dashed var(--brand-primary);
    outline-offset: -4px;
}
.board-column-overflow {
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: var(--text-xs);
}
.board-column-empty {
    padding: var(--space-3);
    color: var(--text-subtle);
    font-size: var(--text-xs);
    text-align: center;
}

.ticket-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-subtle);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    cursor: pointer;
    transition: box-shadow 120ms ease, transform 120ms ease;
    position: relative;
}
.ticket-card:hover { box-shadow: var(--shadow-sm); }
.ticket-card.is-priority-urgent { border-left-color: var(--danger); }
.ticket-card.is-priority-high   { border-left-color: var(--warning); }
.ticket-card.is-priority-medium { border-left-color: var(--brand-primary); }
.ticket-card.is-priority-low    { border-left-color: var(--text-subtle); }
.ticket-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--text-subtle);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    margin-bottom: var(--space-1);
}
.ticket-card-title {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: var(--text-sm);
    color: var(--text);
    line-height: 1.35;
    margin: 4px 0 8px 0;
    font-weight: 500;
}
.ticket-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    font-size: var(--text-xs);
}
.ticket-card-foot .badge { font-size: 10px; height: 18px; padding: 0 6px; }
.ticket-card-due { color: var(--text-subtle); }
.ticket-card-due.is-overdue { color: var(--danger); font-weight: 500; }
.ticket-card.is-draggable { cursor: grab; }
.ticket-card.is-dragging { opacity: 0.5; transform: scale(0.98); }
.ticket-card-menu { position: absolute; top: 6px; right: 6px; }

/* JIRA-style 2-pane issue detail */
.issue-breadcrumb {
    font-size: var(--text-xs);
    color: var(--text-subtle);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: var(--space-2);
    flex-wrap: wrap;
}
.issue-breadcrumb a { color: var(--text-muted); text-decoration: none; }
.issue-breadcrumb a:hover { color: var(--text); text-decoration: underline; }
.issue-breadcrumb .issue-key {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text-muted);
    font-weight: 500;
}

.issue-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: var(--space-5);
    align-items: flex-start;
}
@media (max-width: 1024px) {
    .issue-layout { grid-template-columns: 1fr; }
}
.issue-main { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.issue-sidebar { display: flex; flex-direction: column; gap: var(--space-3); position: sticky; top: 80px; }
.issue-sidebar .card-content { padding: var(--space-3); }
.issue-sidebar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.issue-sidebar-row:last-child { border-bottom: none; }
.issue-sidebar-row .issue-sidebar-label {
    color: var(--text-subtle);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
    flex-shrink: 0;
    min-width: 90px;
}
.issue-sidebar-row .issue-sidebar-value { text-align: right; min-width: 0; }
.issue-sidebar-row .issue-sidebar-value form { display: inline; }

/* Activity tabs */
.activity-tabs { padding-bottom: var(--space-2); }
.activity-tabs .tab-list { margin-bottom: var(--space-3); }
.activity-tabs .timeline-item[data-hidden="true"] { display: none; }

/* Attachment chip strip */
.attachment-strip {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    font-size: var(--text-xs);
    color: var(--text);
    text-decoration: none;
    max-width: 260px;
}
.attachment-chip:hover { background: var(--bg-muted); }
.attachment-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip-size { color: var(--text-subtle); }

/* Status pill / quick-pick popover */
.status-pill-trigger {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.status-pill-trigger .badge { cursor: pointer; }
.quick-popover .dropdown-menu { min-width: 220px; }
.quick-popover .dropdown-item { padding: 8px 10px; }
.quick-popover form { margin: 0; }
.quick-popover button {
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    padding: 0;
    color: inherit;
    font: inherit;
}

/* ========== Project key chip + inline Assignee picker ========== */
.project-code {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1;
    text-decoration: none;
}

/* Inline assignee picker (right-sidebar Assignee row) */
.assignee-picker { display: inline-flex; }
.assignee-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: inherit;
    font: inherit;
    text-align: left;
}
.assignee-trigger:hover { background: var(--bg-muted); border-color: var(--border); }
.assignee-trigger .assignee-chevron { color: var(--text-subtle); font-size: 10px; margin-left: 2px; }
.assignee-picker .dropdown-menu { min-width: 240px; max-height: 300px; overflow-y: auto; }
.assignee-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: transparent;
    border: none;
    padding: 2px 0;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.assignee-option:hover { color: var(--text); }

/* ========== Responsive: toolbars, forms, popovers ========== */

/* Keep popovers within the viewport on narrow screens. */
.datepicker-popover,
.monthpicker-popover,
.dropdown-menu {
    max-width: calc(100vw - var(--space-6));
}

/* Phones: filter toolbars and two-up form rows stack full width. */
@media (max-width: 640px) {
    /* Override the hard-coded inline max-width on filter selects across all list pages. */
    .data-table-toolbar .input-wrap,
    .data-table-filters .filter-field,
    .data-table-filters .select,
    .data-table-filters .input {
        max-width: none !important;
        flex-basis: 100%;
        width: 100%;
    }
    .data-table-toolbar { gap: 8px; }
    .data-filter-clear { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
}
