/* ==========================================================================
   Tokens
   Warm paper + ink in light mode, soft charcoal in dark. One accent (jade),
   one signal (amber). Logical properties everywhere so RTL just works.
   ========================================================================== */
:root,
[data-bs-theme="light"] {
    --bg: #F4F2EC;
    --surface: #FFFFFF;
    --surface-2: #FAF9F5;
    --sunken: #ECE9E1;
    --line: #E3DFD5;
    --line-strong: #CEC8B9;
    --ink: #1C1B18;
    --ink-2: #47443D;
    --muted: #7A766B;
    --accent: #1F6F5C;
    --accent-hover: #185A4A;
    --accent-ink: #FFFFFF;
    --accent-soft: #E1EEE8;
    --signal: #D9822B;
    --danger: #C2412D;
    --ok: #3D7A4A;
    --shadow-sm: 0 1px 0 rgba(28, 27, 24, .04), 0 1px 2px rgba(28, 27, 24, .06);
    --shadow-md: 0 2px 4px rgba(28, 27, 24, .05), 0 8px 24px rgba(28, 27, 24, .08);
    --col-bg: #EDEAE2;
    --card-bg: #FFFFFF;

    --bs-body-bg: var(--bg);
    --bs-body-color: var(--ink);
    --bs-secondary-color: var(--muted);
    --bs-border-color: var(--line);
    --bs-tertiary-bg: var(--sunken);
    --bs-link-color: var(--accent);
    --bs-link-color-rgb: 31, 111, 92;
    --bs-link-hover-color: var(--accent-hover);
    --bs-focus-ring-color: rgba(31, 111, 92, .25);
    --bs-emphasis-color: var(--ink);
}

[data-bs-theme="dark"] {
    --bg: #141513;
    --surface: #1B1C1A;
    --surface-2: #20221F;
    --sunken: #101110;
    --line: #2B2D29;
    --line-strong: #3B3E38;
    --ink: #ECE9E1;
    --ink-2: #C5C1B7;
    --muted: #8F8B81;
    --accent: #4FB394;
    --accent-hover: #6CC5A8;
    --accent-ink: #0D1B16;
    --accent-soft: rgba(79, 179, 148, .13);
    --signal: #E79A4B;
    --danger: #E0634F;
    --ok: #6DB57B;
    --shadow-sm: 0 1px 0 rgba(0, 0, 0, .3);
    --shadow-md: 0 8px 28px rgba(0, 0, 0, .45);
    --col-bg: #181917;
    --card-bg: #222420;

    --bs-body-bg: var(--bg);
    --bs-body-color: var(--ink);
    --bs-secondary-color: var(--muted);
    --bs-border-color: var(--line);
    --bs-tertiary-bg: var(--sunken);
    --bs-link-color: var(--accent);
    --bs-link-color-rgb: 79, 179, 148;
    --bs-link-hover-color: var(--accent-hover);
    --bs-focus-ring-color: rgba(79, 179, 148, .3);
    --bs-emphasis-color: var(--ink);
}

/* ==========================================================================
   Base
   ========================================================================== */
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14.5px;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}
[dir="rtl"] body { font-family: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif; }
.font-mono { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; letter-spacing: -.01em; }
.text-muted { color: var(--muted) !important; }
.min-w-0 { min-width: 0; }
a { text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4, h5, h6 { color: var(--ink); letter-spacing: -.01em; }
::selection { background: var(--accent-soft); }
.req { color: var(--danger); }
.eyebrow { display: block; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
[dir="rtl"] .eyebrow { letter-spacing: 0; }
.link-accent { color: var(--accent); cursor: pointer; font-weight: 500; }

/* Bootstrap surface overrides */
.form-control, .form-select, .input-group-text {
    background-color: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink);
    border-radius: 8px;
}
.form-control::placeholder { color: var(--muted); opacity: .8; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--bs-focus-ring-color); background-color: var(--surface); color: var(--ink); }
.input-group-text { background: var(--surface-2); color: var(--muted); font-size: 13px; }
.form-label { font-weight: 500; font-size: 13.5px; color: var(--ink-2); margin-bottom: .35rem; }
.form-text { color: var(--muted); font-size: 12.5px; }
.form-check-input { border-color: var(--line-strong); background-color: var(--surface); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--bs-focus-ring-color); border-color: var(--accent); }
.form-control-color { height: 38px; padding: 4px; }
.dropdown-menu {
    --bs-dropdown-bg: var(--surface);
    --bs-dropdown-border-color: var(--line);
    --bs-dropdown-link-color: var(--ink);
    --bs-dropdown-link-hover-bg: var(--sunken);
    --bs-dropdown-link-hover-color: var(--ink);
    --bs-dropdown-link-active-bg: var(--accent);
    --bs-dropdown-header-color: var(--muted);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 6px;
    font-size: 14px;
}
.dropdown-item { border-radius: 6px; padding: 6px 10px; }
.modal-content { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-md); }
.modal-header, .modal-footer { border-color: var(--line); }
.modal-backdrop.show { opacity: .35; }
.table { --bs-table-bg: transparent; --bs-table-color: var(--ink); --bs-table-border-color: var(--line); }
.table > thead th { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; border-bottom-width: 1px; }
.pagination { --bs-pagination-bg: var(--surface); --bs-pagination-border-color: var(--line); --bs-pagination-color: var(--ink); --bs-pagination-hover-bg: var(--sunken); --bs-pagination-hover-color: var(--ink); --bs-pagination-active-bg: var(--accent); --bs-pagination-active-border-color: var(--accent); --bs-pagination-disabled-bg: var(--surface-2); --bs-pagination-hover-border-color: var(--line); font-size: 13.5px; }

/* Buttons */
.btn { border-radius: 8px; font-weight: 500; font-size: 14px; padding: .45rem .9rem; }
.btn-sm { font-size: 13px; padding: .3rem .65rem; }
.btn-lg { font-size: 15.5px; padding: .65rem 1.1rem; border-radius: 10px; }
.btn-accent { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); }
.btn-accent:hover, .btn-accent:focus-visible { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-ink { background: var(--ink); color: var(--bg); border: 1px solid var(--ink); }
.btn-ink:hover { background: var(--ink-2); color: var(--bg); }
.btn-quiet { background: transparent; color: var(--ink-2); border: 1px solid transparent; }
.btn-quiet:hover { background: var(--sunken); color: var(--ink); }
.btn-quiet.border { border-color: var(--line-strong) !important; }
.btn-toggle { border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface); }
.btn-toggle:hover { background: var(--sunken); }
.btn-toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-icon {
    display: inline-grid; place-items: center;
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-2);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}
.btn-icon:hover { background: var(--sunken); color: var(--ink); text-decoration: none; }
.btn-icon-sm { width: 30px; height: 30px; font-size: 15px; }
.btn-icon-xs { width: 22px; height: 22px; font-size: 12px; border-radius: 5px; }

/* Segmented controls (language, theme, filter buttons) */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--sunken); border: 1px solid var(--line); border-radius: 9px; }
.segmented .seg {
    display: inline-flex; align-items: center; gap: 6px;
    border: 0; background: transparent; color: var(--muted);
    padding: 4px 10px; border-radius: 6px; font-size: 13px; font-weight: 500; line-height: 20px;
    cursor: pointer; white-space: nowrap;
}
.segmented .seg:hover { color: var(--ink); text-decoration: none; }
.segmented .seg.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.segmented-lg .seg { padding: 6px 12px; font-size: 13.5px; }

/* Avatars */
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; object-fit: cover; background: var(--sunken); color: var(--muted); font-weight: 600; overflow: hidden; vertical-align: middle; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar-xl { width: 64px; height: 64px; font-size: 22px; }
.avatar-initials { background: hsl(var(--hue) 45% 88%); color: hsl(var(--hue) 45% 28%); letter-spacing: .02em; }
[data-bs-theme="dark"] .avatar-initials { background: hsl(var(--hue) 30% 26%); color: hsl(var(--hue) 50% 82%); }
.avatar-empty { border: 1px dashed var(--line-strong); background: transparent; }
.avatar-more { background: var(--sunken); color: var(--ink-2); font-size: 10px; }
.avatar-stack { display: flex; }
.avatar-stack > * { margin-inline-start: -6px; box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack > *:first-child { margin-inline-start: 0; }
.avatar-btn { border: 0; background: none; padding: 0; border-radius: 50%; }
.avatar-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Small UI atoms */
.project-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--dot); flex: none; }
.badge-soft { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--sunken); color: var(--ink-2); border: 1px solid var(--line); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); border-color: transparent; }
.status-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 10px 2px 8px; border-radius: 6px;
    font-size: 12.5px; font-weight: 500;
    color: var(--ink);
    background: color-mix(in srgb, var(--chip) 14%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--chip) 30%, transparent);
    white-space: nowrap;
}
.status-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--chip); }
.status-chip-lg { font-size: 13.5px; padding: 5px 12px 5px 10px; cursor: pointer; }
.status-chip-lg:disabled { cursor: default; opacity: 1; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.status-dot.on { color: var(--ink-2); }
.status-dot.on::before { background: var(--ok); }

/* Priority as signal bars */
.prio { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.prio .bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.prio .bars span { width: 3px; border-radius: 1px; background: var(--line-strong); }
.prio .bars span:nth-child(1) { height: 4px; }
.prio .bars span:nth-child(2) { height: 7px; }
.prio .bars span:nth-child(3) { height: 10px; }
.prio .bars span:nth-child(4) { height: 12px; }
.prio-lowest .bars span.on, .prio-low .bars span.on { background: var(--muted); }
.prio-medium .bars span.on { background: var(--signal); }
.prio-high .bars span.on { background: var(--danger); }
.prio-critical { color: var(--danger); font-weight: 600; }
.prio-critical i { font-size: 13px; }

.due { color: var(--muted); }
.due.overdue { color: var(--danger); font-weight: 500; }

/* ==========================================================================
   App shell
   ========================================================================== */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 252px; flex: none;
    background: var(--surface-2);
    border-inline-end: 1px solid var(--line);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
@media (max-width: 991.98px) {
    .sidebar { position: fixed; height: 100%; }
}
@media (min-width: 992px) {
    .sidebar.offcanvas-lg { visibility: visible !important; transform: none !important; background: var(--surface-2) !important; }
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 14px; }
.brand-link { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; font-size: 16px; min-width: 0; }
.brand-link:hover { text-decoration: none; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; }
.brand-mark {
    width: 30px; height: 30px; flex: none; border-radius: 8px;
    display: inline-grid; place-items: center;
    background: var(--ink); color: var(--bg);
    font-weight: 700; font-size: 15px; text-transform: uppercase;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.nav-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 18px 10px 6px; font-weight: 500; }
[dir="rtl"] .nav-label { letter-spacing: 0; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; border-radius: 7px;
    color: var(--ink-2); font-size: 14px; font-weight: 500;
}
.nav-item i { font-size: 16px; color: var(--muted); }
.nav-item:hover { background: var(--sunken); color: var(--ink); text-decoration: none; }
.nav-item.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); }
.nav-item.active i { color: var(--accent); }
.nav-project { font-weight: 400; }
.nav-key { margin-inline-start: auto; font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--muted); }
.sidebar-me { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--ink); font-size: 13.5px; }
.sidebar-me:hover { background: var(--sunken); text-decoration: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: 12px;
    height: 60px; padding: 0 24px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.2) blur(8px);
    border-bottom: 1px solid var(--line);
}
.topbar-title { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; flex: 1; overflow: hidden; white-space: nowrap; }
.crumb { color: var(--muted); }
.crumb-sep { font-size: 10px; color: var(--line-strong); }
[dir="rtl"] .crumb-sep { transform: scaleX(-1); }
.crumb-current { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
@media (max-width: 575.98px) {
    .topbar { padding: 0 12px; gap: 6px; }
    #themeSwitch .seg { padding: 4px 7px; }
}

.notif-badge {
    position: absolute; top: 3px; inset-inline-end: 2px;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 99px; background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 600; line-height: 16px; text-align: center;
    box-shadow: 0 0 0 2px var(--bg);
}
.notif-menu { width: 360px; max-width: calc(100vw - 24px); padding: 0; overflow: hidden; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 10px 14px; color: var(--ink); font-size: 13.5px; border-bottom: 1px solid var(--line); }
.notif-item:hover { background: var(--sunken); text-decoration: none; }
.notif-item.unread { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.notif-item.unread .notif-icon { color: var(--accent); }
.notif-icon { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--sunken); color: var(--muted); }
.notif-excerpt { color: var(--ink-2); }
.notif-foot { display: block; text-align: center; padding: 10px; font-size: 13px; font-weight: 500; }
.notif-page .notif-item:last-child { border-bottom: 0; }

.content { padding: 28px 32px 48px; flex: 1; min-width: 0; }
.content-board { padding: 20px 0 0; display: flex; flex-direction: column; }
@media (max-width: 767.98px) { .content { padding: 20px 16px 40px; } }

.flash { margin-bottom: 18px; padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 500; border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.flash-error { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.content-board .flash { margin: 0 24px 14px; }

.toast-stack { position: fixed; bottom: 20px; inset-inline-end: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast-note {
    min-width: 240px; max-width: 380px;
    padding: 10px 14px; border-radius: 10px;
    background: var(--ink); color: var(--bg);
    box-shadow: var(--shadow-md); font-size: 13.5px;
    display: flex; gap: 10px; align-items: flex-start;
    animation: toast-in .18s ease-out;
}
.toast-note.is-error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ==========================================================================
   Page furniture
   ========================================================================== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 600; margin: 0; letter-spacing: -.02em; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; }
.panel-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 18px; align-items: start; }
.panel-span { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 18px; }
.field-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.field-box legend { float: none; width: auto; font-size: 13.5px; font-weight: 600; padding: 0 6px; margin: 0 0 0 -6px; }
.empty { text-align: center; padding: 64px 20px; border: 1px dashed var(--line-strong); border-radius: 14px; background: var(--surface-2); }
.empty > i { font-size: 30px; color: var(--muted); display: block; margin-bottom: 10px; }
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.table-card .table td, .table-card .table th { padding: 12px 16px; }
.table-card .table tr:last-child td { border-bottom: 0; }

.search-field { position: relative; }
.search-field > i { position: absolute; top: 50%; inset-inline-start: 10px; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.search-field .form-control { padding-inline-start: 30px; min-width: 220px; }

.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-fields { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-fields .form-select { width: auto; min-width: 150px; }
@media (max-width: 767.98px) {
    .filter-bar .segmented { width: 100%; overflow-x: auto; }
    .filter-fields, .filter-fields > * { width: 100%; }
    .search-field .form-control { min-width: 0; }
}

/* Stats */
.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 22px; overflow: hidden; }
.stat { padding: 16px 20px; color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.stat + .stat { border-inline-start: 1px solid var(--line); }
a.stat:hover { background: var(--surface-2); text-decoration: none; }
.stat-num { font-size: 28px; font-weight: 600; font-family: "IBM Plex Mono", monospace; letter-spacing: -.03em; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); }
@media (max-width: 575.98px) { .stat { padding: 12px; } .stat-num { font-size: 22px; } .stat-label { font-size: 12px; } }

/* My work rows */
.ticket-list { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.ticket-row {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) 150px 90px 110px 32px 56px;
    align-items: center; gap: 14px;
    width: 100%; padding: 12px 16px;
    border: 0; border-bottom: 1px solid var(--line);
    background: transparent; color: var(--ink); text-align: start;
    font-size: 14px;
}
.ticket-row:last-child { border-bottom: 0; }
.ticket-row:hover { background: var(--surface-2); }
.ticket-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tr-key { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.tr-title { min-width: 0; font-weight: 500; }
.tr-sub { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.tr-sub .project-dot { margin-inline-end: -6px; }
.tr-time { font-size: 12px; color: var(--muted); }
.tr-updated { font-size: 12px; color: var(--muted); text-align: end; }
@media (max-width: 991.98px) {
    .ticket-row { grid-template-columns: 92px minmax(0, 1fr) auto 32px; }
    .tr-prio, .tr-time, .tr-updated { display: none; }
}
@media (max-width: 575.98px) {
    .ticket-row { grid-template-columns: minmax(0, 1fr) 28px; gap: 6px 10px; }
    .tr-key { grid-column: 1; font-size: 12px; }
    .tr-title { grid-column: 1; }
    .tr-status { grid-column: 1; }
    .tr-assignee { grid-row: 1; grid-column: 2; }
}

/* Projects */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.project-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s; }
.project-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.project-card.is-archived { opacity: .7; }
.project-cover { display: grid; place-items: center; aspect-ratio: 16 / 7; background: color-mix(in srgb, var(--project) 16%, var(--surface-2)); border-bottom: 1px solid var(--line); overflow: hidden; }
.project-cover img { width: 100%; height: 100%; object-fit: cover; }
.project-cover-key { font-family: "IBM Plex Mono", monospace; font-size: 34px; font-weight: 500; color: var(--project); letter-spacing: .04em; }
.project-cover:hover { text-decoration: none; }
.project-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.project-name { font-size: 16px; font-weight: 600; margin: 0; }
.project-name a { color: var(--ink); }
.project-desc { font-size: 13.5px; color: var(--ink-2); margin: 0; }
.project-foot { margin-top: auto; padding-top: 8px; display: flex; align-items: center; justify-content: space-between; }

.team-strip { display: flex; gap: 28px; flex-wrap: wrap; padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 16px; }
.team-slot { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }

/* Image fields */
.image-field { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.image-field-stack { grid-template-columns: 1fr; }
.image-preview { width: 72px; height: 72px; border-radius: 12px; display: grid; place-items: center; overflow: hidden; background: var(--sunken); border: 1px solid var(--line); color: var(--muted); font-size: 24px; }
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-preview-round { border-radius: 50%; }
.image-preview-wide { width: 100%; height: auto; aspect-ratio: 16 / 7; background: color-mix(in srgb, var(--project, #8A8578) 14%, var(--surface-2)); color: var(--project, var(--muted)); font-size: 26px; }
.image-field:has(.image-preview-wide):not(.image-field-stack) { grid-template-columns: 1fr; }
.avatar-initials-lg { width: 100%; height: 100%; display: grid; place-items: center; background: hsl(var(--hue) 45% 88%); color: hsl(var(--hue) 45% 28%); font-weight: 600; }

.member-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; max-height: 360px; overflow-y: auto; padding: 2px; }
.member-option { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; font-size: 13.5px; }
.member-option:hover { background: var(--surface-2); }
.member-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.member-option input { accent-color: var(--accent); }

.role-pick { display: grid; gap: 8px; }
.role-option { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.role-option input { margin-top: 4px; accent-color: var(--accent); }
.role-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* Roles & permissions */
.under-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); list-style: none; padding: 0; }
.under-tabs button, .tp-tabs button { border: 0; background: none; padding: 8px 0; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.under-tabs button.active, .tp-tabs button.active { color: var(--ink); border-bottom-color: var(--ink); }
.split { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 767.98px) { .split { grid-template-columns: 1fr; } }
.list-nav { display: flex; flex-direction: column; gap: 4px; }
.list-nav-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 9px; color: var(--ink); border: 1px solid transparent; }
.list-nav-item:hover { background: var(--surface); text-decoration: none; }
.list-nav-item.active { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-sm); }
.new-role { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.perm-columns { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px 24px; }
.perm-group { margin-bottom: 6px; }
.perm-group-name { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
.perm-code { display: block; font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--muted); }
.via-role { font-size: 11px; color: var(--accent); margin-inline-start: 4px; }
.locked-note { display: flex; gap: 14px; align-items: flex-start; }
.locked-note > i { font-size: 26px; color: var(--accent); }

/* Column management */
.column-list { display: flex; flex-direction: column; gap: 8px; }
.column-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.column-row.sortable-ghost { opacity: .4; }
.column-row-main { flex: 1; min-width: 0; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 18px; }
.col-tick { width: 4px; align-self: stretch; border-radius: 4px; background: var(--col); flex: none; }
.rule-line { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.rule-line i { margin-inline-end: 3px; }

/* ==========================================================================
   Board
   ========================================================================== */
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 0 24px 16px; }
.board-cover { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex: none; border: 1px solid var(--line); }
.board-cover-key { display: grid; place-items: center; background: color-mix(in srgb, var(--project) 18%, var(--surface)); color: var(--project); font-family: "IBM Plex Mono", monospace; font-size: 14px; font-weight: 500; }
.board-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.board {
    flex: 1;
    display: flex; gap: 12px; align-items: flex-start;
    overflow-x: auto; overflow-y: hidden;
    padding: 4px 24px 24px;
    min-height: calc(100vh - 60px - 104px);
    scroll-padding-inline: 24px;
}
.board-col {
    width: 292px; flex: none;
    background: var(--col-bg);
    border-radius: 12px;
    display: flex; flex-direction: column;
    max-height: calc(100vh - 60px - 120px);
    border: 1px solid var(--line);
    border-top: 3px solid var(--col);
}
.board-col.is-collapsed { width: 46px; }
.board-col.is-collapsed .col-body, .board-col.is-collapsed .col-flags, .board-col.is-collapsed .col-add, .board-col.is-collapsed .col-tick { display: none; }
.board-col.is-collapsed .col-head { flex-direction: column; padding: 10px 0; gap: 10px; }
.board-col.is-collapsed .col-name { writing-mode: vertical-rl; white-space: nowrap; }
.board-col.is-collapsed .col-collapse i { transform: rotate(-90deg); }
[dir="rtl"] .board-col.is-collapsed .col-collapse i { transform: rotate(90deg); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 8px 8px; }
.col-head .col-tick { width: 8px; height: 8px; border-radius: 50%; align-self: center; }
.col-name { font-size: 13.5px; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-count { font-size: 12px; color: var(--muted); background: var(--surface); border-radius: 99px; padding: 0 7px; border: 1px solid var(--line); }
.col-flags { display: flex; gap: 6px; color: var(--muted); font-size: 12px; margin-inline-start: auto; }
.col-collapse, .col-add { border: 0; background: none; color: var(--muted); width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; padding: 0; }
.col-collapse:hover, .col-add:hover { background: var(--surface); color: var(--ink); }
.col-collapse i { transition: transform .15s; font-size: 12px; }
.col-body { flex: 1; overflow-y: auto; padding: 4px 8px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.col-empty { display: none; padding: 18px 8px; text-align: center; font-size: 12.5px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 9px; }
.col-body:not(:has(.card-ticket)) .col-empty { display: block; }
.board.is-dragging .board-col { opacity: .45; transition: opacity .12s; }
.board.is-dragging .board-col.is-target, .board.is-dragging .board-col.is-origin { opacity: 1; }
.board.is-dragging .board-col.is-target { box-shadow: 0 0 0 2px var(--accent); }
.board.is-dragging .col-empty { display: none !important; }

.card-ticket {
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 10px 12px;
    box-shadow: var(--shadow-sm);
    cursor: grab;
    transition: border-color .12s, box-shadow .12s;
}
.card-ticket:hover { border-color: var(--line-strong); }
.card-ticket:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.card-ticket.is-locked { cursor: pointer; }
.card-ticket.is-done .ct-title { color: var(--muted); }
.card-ticket.sortable-ghost { opacity: .35; }
.card-ticket.sortable-chosen { box-shadow: var(--shadow-md); }
.card-ticket.is-flash { animation: card-flash 1.2s ease-out; }
@keyframes card-flash { from { box-shadow: 0 0 0 3px var(--accent); } }
.ct-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.ct-key { font-size: 11.5px; color: var(--muted); display: inline-flex; gap: 5px; align-items: center; }
.ct-title { font-size: 14px; font-weight: 500; line-height: 1.4; margin: 0 0 8px; color: var(--ink); overflow-wrap: anywhere; }
.ct-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.ct-meta i { font-size: 11px; }
.ct-branch { max-width: 110px; font-family: "IBM Plex Mono", monospace; font-size: 11px; }

/* ==========================================================================
   Ticket panel
   ========================================================================== */
.ticket-panel.offcanvas-end { --bs-offcanvas-width: min(760px, 100vw); background: var(--surface); border-inline-start: 1px solid var(--line); }
[dir="rtl"] .ticket-panel.offcanvas-end { border-inline-start: 1px solid var(--line); }
.ticket-page .tp { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; max-width: 980px; margin: 0 auto; }
.tp-head { padding: 18px 24px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 3; }
.ticket-page .tp-head { position: static; border-radius: 14px 14px 0 0; }
.tp-head-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tp-key { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.tp-key a { color: var(--muted); }
.tp-title { font-size: 21px; font-weight: 600; line-height: 1.3; margin: 8px 0 12px; overflow-wrap: anywhere; }
.tp-status { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tp-body { padding: 18px 24px 40px; }
.tp-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 16px; }
.fact { background: var(--surface-2); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fact-wide { grid-column: span 2; }
.fact-label { font-size: 11.5px; color: var(--muted); }
.fact-value { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 575.98px) {
    .tp-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tp-head, .tp-body { padding-inline: 16px; }
}
.tp-edit { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 16px; }
.tp-edit summary { padding: 10px 14px; cursor: pointer; font-weight: 500; font-size: 13.5px; color: var(--ink-2); list-style: none; }
.tp-edit summary::-webkit-details-marker { display: none; }
.tp-edit[open] summary { border-bottom: 1px solid var(--line); }
.tp-edit-form { padding: 14px; }
.tp-section { padding: 16px 0; border-top: 1px solid var(--line); }
.tp-section:first-of-type { border-top: 0; }
.tp-section-title { font-size: 13.5px; font-weight: 600; margin-bottom: 10px; display: flex; gap: 8px; align-items: center; }
.tp-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; border: 1px dashed var(--line-strong); border-radius: 10px; }
.tp-tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); list-style: none; padding: 0; margin: 0; }
.tp-tabs button { font-size: 13.5px; }
.tp-tabs .font-mono { color: var(--muted); font-size: 11.5px; margin-inline-start: 3px; }

.prose { font-size: 14.5px; line-height: 1.65; color: var(--ink); overflow-wrap: anywhere; }
.prose p:last-child { margin-bottom: 0; }
.prose pre, .prose code { font-family: "IBM Plex Mono", monospace; font-size: 13px; background: var(--sunken); border-radius: 6px; }
.prose code { padding: 1px 5px; }
.prose pre { padding: 10px 12px; overflow-x: auto; }
.prose img { max-width: 100%; border-radius: 8px; }
.prose ul, .prose ol { padding-inline-start: 1.3rem; }
.mention { color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 3px; font-weight: 500; }

.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.attach { position: relative; }
.attach-thumb { display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); background: var(--sunken); }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-file { flex-direction: column; color: var(--muted); font-size: 22px; gap: 2px; }
.attach-file span { font-size: 11px; font-family: "IBM Plex Mono", monospace; }
.attach-name { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.attach-remove { position: absolute; top: 4px; inset-inline-end: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; display: none; place-items: center; padding: 0; }
.attach:hover .attach-remove, .attach:focus-within .attach-remove { display: grid; }

.composer { position: relative; margin-bottom: 18px; }
.composer-box { border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--bs-focus-ring-color); }
.composer-box.is-drop { border-style: dashed; border-color: var(--accent); background: var(--accent-soft); }
.composer-input { width: 100%; border: 0; background: transparent; resize: vertical; padding: 12px 14px 4px; color: var(--ink); font-size: 14px; min-height: 76px; }
.composer-input:focus { outline: none; }
.composer-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 8px; }
.mention-menu { position: absolute; z-index: 10; inset-inline-start: 12px; top: 100%; margin-top: -8px; width: 260px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-md); padding: 4px; max-height: 240px; overflow-y: auto; }
.mention-option { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; padding: 6px 8px; border-radius: 6px; color: var(--ink); text-align: start; font-size: 13.5px; }
.mention-option.active, .mention-option:hover { background: var(--sunken); }

.drop-previews { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 12px; }
.drop-previews:empty { display: none; }
.drop-preview { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--sunken); display: grid; place-items: center; font-size: 10px; color: var(--muted); text-align: center; margin-top: 8px; }
.drop-preview img { width: 100%; height: 100%; object-fit: cover; }
.drop-preview button { position: absolute; top: 2px; inset-inline-end: 2px; width: 18px; height: 18px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; display: grid; place-items: center; padding: 0; }
.dropzone { border: 1px dashed var(--line-strong); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); font-size: 13.5px; background: var(--surface-2); }
.dropzone > i { font-size: 22px; display: block; margin-bottom: 4px; }
.dropzone.is-drop { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone .drop-previews { justify-content: center; }

.comment-list { display: flex; flex-direction: column; gap: 18px; }
.comment { display: flex; gap: 12px; }
.comment-main { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 13.5px; }
.comment-images { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.comment-images img { max-height: 160px; max-width: 240px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; }

.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; top: 6px; bottom: 6px; inset-inline-start: 13px; width: 1px; background: var(--line); }
.timeline-item { position: relative; display: flex; gap: 12px; padding-bottom: 14px; font-size: 13.5px; }
.timeline-icon { width: 27px; height: 27px; flex: none; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); font-size: 12px; position: relative; }
.timeline-body { flex: 1; min-width: 0; padding-top: 3px; }
.timeline-body em { font-style: normal; font-weight: 500; }
.change-list { margin: 4px 0 0; padding-inline-start: 1rem; color: var(--ink-2); font-size: 13px; }

.time-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.time-summary > div { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; gap: 2px; }
.time-summary strong { font-size: 17px; }
@media (max-width: 575.98px) { .time-summary { grid-template-columns: repeat(2, 1fr); } }
.time-table { font-size: 13px; }
.kind-tag { font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.kind-tag.kind-estimate { background: var(--sunken); color: var(--ink-2); }

.move-handoff { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 3000; background: rgba(10, 10, 9, .86); display: grid; place-items: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }

/* ==========================================================================
   Sign-in
   ========================================================================== */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
@media (max-width: 899.98px) { .auth { grid-template-columns: 1fr; } .auth-art { display: none !important; } }
.auth-art { position: relative; background: var(--ink) center / cover no-repeat; overflow: hidden; display: flex; align-items: flex-end; }
[data-bs-theme="dark"] .auth-art { background-color: #0C0D0C; }
.auth-art-pattern { position: absolute; inset: 0; display: flex; gap: 14px; padding: 12% 8% 0; transform: rotate(-4deg) scale(1.08); transform-origin: top left; opacity: .9; }
.art-col { flex: 1; display: flex; flex-direction: column; gap: 10px; transform: translateY(calc(var(--i) * 18px)); }
.art-col-name { color: rgba(244, 242, 236, .55); font-size: 12px; font-family: "IBM Plex Mono", monospace; padding-bottom: 6px; border-bottom: 2px solid rgba(244, 242, 236, .14); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.art-card { height: 70px; border-radius: 9px; background: rgba(244, 242, 236, .07); border: 1px solid rgba(244, 242, 236, .1); }
.art-col:nth-child(3) .art-card:first-of-type { background: rgba(79, 179, 148, .35); border-color: rgba(79, 179, 148, .5); }
.auth-art-caption { position: relative; padding: 40px 48px; color: #F4F2EC; font-size: 22px; font-weight: 500; line-height: 1.35; max-width: 480px; background: linear-gradient(to top, rgba(0, 0, 0, .45), transparent); width: 100%; }
.auth-form-wrap { display: flex; flex-direction: column; padding: 28px clamp(20px, 6vw, 72px); background: var(--bg); }
.auth-top { display: flex; align-items: center; justify-content: space-between; }
.auth-form { margin: auto 0; width: 100%; max-width: 400px; align-self: center; padding: 40px 0; }
.auth-title { font-size: 30px; font-weight: 600; letter-spacing: -.02em; margin-bottom: 6px; }

/* Print/reduced motion */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
