/* ════════════════════════════════════════════════════════════════════════
   Mokarrar PMS — Base UI (reads only from tokens.css custom properties)
   ════════════════════════════════════════════════════════════════════════ */

/* ── Reset / base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html, body { overflow-x: clip; max-width: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    font-size: 14.5px;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-variation-settings: 'wght' 400;
    transition: background .25s var(--ease), color .25s var(--ease);
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
svg { display: inline-block; vertical-align: middle; }
.hidden { display: none !important; }

/* ── Utilities ────────────────────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.grid { display: grid; }
.grid--2 { grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid--3 { grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid--4 { grid-template-columns: repeat(4, 1fr); gap: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; }
.text-xs { font-size: 12px; } .text-soft { color: var(--text-soft); }
.text-muted { color: var(--text-muted); } .fw-medium { font-weight: 600; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font-size: 13.5px; font-weight: 600; transition: all .15s var(--ease); white-space: nowrap;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-2); }
.btn--ghost { background: transparent; border-color: var(--border-strong); color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { padding: 6px 12px; font-size: 12.5px; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); margin-bottom: 18px; overflow: hidden; }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card__title { font-size: 15px; font-weight: 700; }
.card__body { padding: 20px; }

/* ── Page head ────────────────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head__title { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.page-head__sub { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }

/* ── Stat cards ───────────────────────────────────────────────────────── */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; align-items: center; gap: 15px; }
.stat__icon { width: 44px; height: 44px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.stat__value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat__label { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: var(--radius-pill); background: var(--neutral-soft); color: var(--text-muted); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }

/* ── Forms ────────────────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
.input, .select, .textarea {
    width: 100%; padding: 10px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text); font-size: 13.5px; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background: var(--surface); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.8; }
.help { font-size: 12px; color: var(--text-soft); margin-top: 6px; line-height: 1.7; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 6px; }

/* Switch (toggle) */
.switch { position: relative; display: inline-block; width: 44px; height: 25px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: .2s var(--ease); cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 19px; height: 19px; right: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s var(--ease); box-shadow: var(--shadow-xs); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(-19px); }

/* ── Tabs ─────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 15px; border: none; background: transparent; color: var(--text-muted); font-size: 13.5px; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tab:hover { color: var(--text); background: var(--surface-3); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--border); }
table.data th { font-size: 12px; font-weight: 700; color: var(--text-soft); background: var(--surface-2); }
table.data tbody tr:hover, table.data tr:hover { background: var(--surface-2); }

/* ── Admin shell ──────────────────────────────────────────────────────── */
.admin { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-inline-end: 1px solid var(--border); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.sidebar__brand { height: var(--header-h); display: flex; align-items: center; gap: 10px; padding: 0 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; font-weight: 800; font-size: 15px; }
.sidebar__brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
.sidebar__brand small { display: block; font-size: 11px; color: var(--text-muted); font-weight: 600; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-section__title { font-size: 10.5px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: .6px; padding: 14px 12px 7px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 2px; position: relative; transition: all .14s var(--ease); }
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent); }
.nav-link.is-active::before { content: ''; position: absolute; inset-inline-start: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; border-radius: 4px; background: var(--accent); }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link__badge { margin-inline-start: auto; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.sidebar__foot { padding: 12px; border-top: 1px solid var(--border); flex-shrink: 0; }

.admin__main { display: flex; flex-direction: column; min-width: 0; }
.topbar { height: var(--header-h); background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; padding: 0 24px; position: sticky; top: 0; z-index: 50; }
.topbar__title { font-weight: 700; font-size: 15px; }
.topbar__actions { display: flex; align-items: center; gap: 7px; margin-inline-start: auto; }
.icon-btn { width: 38px; height: 38px; border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--text-muted); background: transparent; border: none; transition: all .15s var(--ease); position: relative; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .dot { position: absolute; top: 8px; inset-inline-end: 9px; width: 7px; height: 7px; background: var(--accent); border-radius: 50%; border: 1.5px solid var(--surface); }
.admin__content { padding: 26px 24px 50px; flex: 1; max-width: 1500px; width: 100%; margin-inline: auto; }
.ws-switch { display: flex; align-items: center; gap: 8px; }
.ws-switch .select { padding: 6px 10px; font-size: 12.5px; width: auto; }

.menu-toggle { display: none; }
.sidebar-overlay { display: none; }

/* ── Flash ────────────────────────────────────────────────────────────── */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.flash--success { background: var(--success-soft); color: var(--success); }
.flash--error { background: var(--danger-soft); color: var(--danger); }
.flash--info { background: var(--info-soft); color: var(--info); }
.flash--warning { background: var(--warning-soft); color: var(--warning); }

/* ── Avatars ──────────────────────────────────────────────────────────── */
.avatar, .avatar-sm { display: inline-grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; flex-shrink: 0; overflow: hidden; }
.avatar { width: 40px; height: 40px; font-size: 14px; }
.avatar-sm { width: 26px; height: 26px; font-size: 11px; }
.avatar img, .avatar-sm img { width: 100%; height: 100%; object-fit: cover; }

/* ── Toolbar / filters ────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .input, .toolbar .select { width: auto; }
.toolbar__search { position: relative; flex: 1; min-width: 200px; max-width: 380px; }
.toolbar__search .input { width: 100%; padding-inline-start: 38px; }
.toolbar__search .ico { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--text-soft); pointer-events: none; }
.toolbar .spacer { flex: 1; }

/* ── Status pills ─────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: var(--radius-pill); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--active { background: var(--success-soft); color: var(--success); }
.pill--suspended { background: var(--danger-soft); color: var(--danger); }

/* ── Table actions ────────────────────────────────────────────────────── */
.row-actions { display: flex; align-items: center; gap: 4px; justify-content: flex-start; }
.act { width: 32px; height: 32px; border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--text-muted); border: 1px solid transparent; background: transparent; }
.act:hover { background: var(--surface-3); color: var(--text); }
.act--danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ── Pagination ───────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 34px; height: 34px; padding: 0 10px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; border: 1px solid var(--border); color: var(--text-muted); }
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination .is-disabled { opacity: .45; }

/* ── Forms extras ─────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .col-2 { grid-column: 1 / -1; }
.checkbox, .radio { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.checkbox input, .radio input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ── Empty state ──────────────────────────────────────────────────────── */
.empty-state { padding: 46px 20px; text-align: center; color: var(--text-soft); }
.empty-state svg { opacity: .5; margin-bottom: 8px; }

/* ── Auth extras ──────────────────────────────────────────────────────── */
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 13px; }
.auth-links a { color: var(--accent); font-weight: 600; }
.auth-sep { text-align: center; color: var(--text-soft); font-size: 12.5px; margin: 18px 0; position: relative; }
.otp-input { text-align: center; letter-spacing: 12px; font-size: 24px; font-weight: 700; font-family: monospace; padding-inline: 12px; }

/* ── 2FA / QR card ────────────────────────────────────────────────────── */
.qr-box { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.qr-box img { width: 190px; height: 190px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; padding: 8px; }
.secret-key { font-family: monospace; direction: ltr; background: var(--surface-3); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14px; letter-spacing: 2px; word-break: break-all; display: inline-block; }

/* ── Permission matrix ────────────────────────────────────────────────── */
.matrix-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.matrix { border-collapse: collapse; width: 100%; font-size: 13px; }
table.matrix th, table.matrix td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
table.matrix thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 2; font-weight: 700; }
table.matrix th.perm-col, table.matrix td.perm-col { text-align: right; position: sticky; inset-inline-start: 0; background: var(--surface); z-index: 1; min-width: 240px; box-shadow: 1px 0 0 var(--border); }
table.matrix tbody tr:hover td { background: var(--surface-2); }
table.matrix tbody tr:hover td.perm-col { background: var(--surface-3); }
.matrix__group td { background: var(--surface-3); font-weight: 700; text-align: right; color: var(--text); }
.matrix input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.matrix .col-super { color: var(--accent); font-weight: 700; }
.role-head { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.role-head small { font-weight: 500; color: var(--text-soft); font-size: 10.5px; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .admin { grid-template-columns: 1fr; }
    .sidebar { position: fixed; inset-inline-start: 0; top: 0; z-index: 120; transform: translateX(100%); transition: transform .25s var(--ease); width: var(--sidebar-w); }
    [dir='ltr'] .sidebar { transform: translateX(-100%); }
    .sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .menu-toggle { display: grid; }
    .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 110; display: none; }
    .sidebar-overlay.is-open { display: block; }
}
@media (max-width: 720px) {
    .grid--4 { grid-template-columns: repeat(2, 1fr); }
    .grid--3, .grid--2 { grid-template-columns: 1fr; }
}

/* ── Notification bell + dropdown ─────────────────────────────────────── */
.notif { position: relative; }
.notif__badge { position: absolute; top: 4px; inset-inline-end: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 1.5px solid var(--surface); }
.notif__panel { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; width: 340px; max-width: 90vw; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 200; overflow: hidden; animation: pop .16s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.notif__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13.5px; }
.notif__markall { border: none; background: none; color: var(--accent); font-size: 11.5px; font-weight: 600; cursor: pointer; }
.notif__list { max-height: 380px; overflow-y: auto; }
.notif__item { display: block; padding: 12px 14px; border-bottom: 1px solid var(--border); transition: background .12s; }
.notif__item:hover { background: var(--surface-2); }
.notif__item.is-unread { background: var(--accent-soft); }
.notif__item.is-unread:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.notif__item-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.notif__item-body { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.notif__item-time { font-size: 11px; color: var(--text-soft); margin-top: 4px; }
.notif__empty { padding: 34px 14px; text-align: center; color: var(--text-soft); font-size: 13px; }

/* ── Toasts ───────────────────────────────────────────────────────────── */
.toast-wrap { position: fixed; bottom: 22px; inset-inline-start: 22px; z-index: 400; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.toast { display: flex; gap: 11px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-inline-start: 3px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 13px 15px; opacity: 0; transform: translateX(-16px); transition: opacity .3s var(--ease), transform .3s var(--ease); }
[dir='rtl'] .toast { transform: translateX(16px); }
.toast.is-in { opacity: 1; transform: translateX(0); }
.toast__icon { font-size: 18px; line-height: 1; }
.toast__title { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.toast__body { font-size: 12px; color: var(--text-muted); line-height: 1.6; }

/* ── Projects ─────────────────────────────────────────────────────────── */
.proj-key { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 6px; color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .5px; direction: ltr; }
.proj-card { transition: border-color .15s, transform .15s; }
.proj-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.progress { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.proj-tabs { margin-top: -6px; }
.col-edit { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.col-edit__form { display: flex; align-items: center; gap: 10px; flex: 1; flex-wrap: wrap; }

/* ── Board toolbar / segments ─────────────────────────────────────────── */
.board-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; }
.seg__btn { padding: 5px 11px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.seg__btn.is-active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-xs); }

/* ── Kanban board ─────────────────────────────────────────────────────── */
.board-scroll { overflow-x: auto; padding-bottom: 8px; }
.board { min-width: min-content; }
.swimlane { margin-bottom: 14px; }
.swimlane__head { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); padding: 6px 4px; position: sticky; inset-inline-start: 0; }
.board__cols { display: flex; gap: 12px; align-items: flex-start; }
.bcol { flex: 0 0 288px; width: 288px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 240px); }
.bcol.is-blocked { outline: 2px dashed var(--danger); outline-offset: 1px; }
.bcol__head { display: flex; align-items: center; justify-content: space-between; padding: 11px 13px; border-top: 3px solid var(--border-strong); border-radius: var(--radius) var(--radius) 0 0; font-weight: 700; font-size: 13px; }
.bcol__count { font-size: 11.5px; font-weight: 700; color: var(--text-soft); background: var(--surface-3); padding: 2px 8px; border-radius: 999px; }
.bcol__count.is-over { background: var(--danger-soft); color: var(--danger); }
.bcol__body { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 9px; min-height: 80px; }

/* Task card */
.tcard { background: var(--surface); border: 1px solid var(--border); border-inline-start: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 11px 12px; cursor: grab; box-shadow: var(--shadow-xs); transition: box-shadow .15s, transform .05s; position: relative; }
.tcard:hover { box-shadow: var(--shadow-sm); }
.tcard.dragging { opacity: .5; cursor: grabbing; }
.tcard__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.tcard__key { font-size: 11px; font-weight: 700; color: var(--text-soft); direction: ltr; }
.tcard__prio { width: 9px; height: 9px; border-radius: 50%; }
.tcard__title { font-size: 13px; font-weight: 500; line-height: 1.6; margin-bottom: 8px; }
.tcard__dod { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.tcard__dod-bar { flex: 1; height: 5px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.tcard__dod-bar > span { display: block; height: 100%; background: var(--success); }
.tcard__dod-num { font-size: 10.5px; color: var(--text-soft); }
.tcard__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tcard__meta { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--text-muted); background: var(--surface-3); padding: 2px 7px; border-radius: 6px; }
.chip--danger { background: var(--danger-soft); color: var(--danger); }
.tcard__avatars { display: flex; }
.tcard__avatars .avatar-sm { margin-inline-start: -6px; border: 2px solid var(--surface); }
.tcard__avatars .avatar-sm:first-child { margin-inline-start: 0; }
.tcard__sla { position: absolute; bottom: 0; inset-inline: 0; height: 3px; background: var(--surface-3); border-radius: 0 0 var(--radius-sm) var(--radius-sm); overflow: hidden; }
.tcard__sla > span { display: block; height: 100%; }
.tcard__sla--green > span { background: var(--success); }
.tcard__sla--yellow > span { background: var(--warning); }
.tcard__sla--red > span { background: var(--danger); }
.tcard__sla--breached { background: var(--danger); }
.tcard__sla--breached > span { background: var(--danger); width: 100% !important; }

/* ── Backlog (Scrum) ──────────────────────────────────────────────────── */
.backlog-task { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 8px; cursor: grab; }
.backlog-task.dragging { opacity: .5; }
.backlog-zone { min-height: 60px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 8px; transition: border-color .15s, background .15s; }
.backlog-zone.drop-over { border-color: var(--accent); background: var(--accent-soft); }
.sprint-card { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.sprint-card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); flex-wrap: wrap; }

/* ── Calendar ─────────────────────────────────────────────────────────── */
.cal { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal__dow { padding: 10px; text-align: center; font-size: 12px; font-weight: 700; color: var(--text-muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal__cell { min-height: 108px; border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; position: relative; }
.cal__cell.is-empty { background: var(--surface-2); }
.cal__cell.is-today { background: var(--accent-soft); }
.cal__day { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 5px; }
.cal__task { display: block; font-size: 11px; padding: 3px 6px; border-radius: 5px; margin-bottom: 3px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Dependency graph ─────────────────────────────────────────────────── */
#depGraph { width: 100%; height: 600px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
#depGraph svg { width: 100%; height: 100%; }
.gnode rect { fill: var(--surface-2); stroke: var(--border-strong); rx: 8; }
.gnode.done rect { fill: var(--success-soft); stroke: var(--success); }
.gnode text { font-family: var(--font); font-size: 11px; fill: var(--text); }
.gnode__key { font-weight: 700; }
.gedge { stroke: var(--text-soft); stroke-width: 1.6; fill: none; }
.gedge--blocks { stroke: var(--danger); }
.gedge--relates_to { stroke-dasharray: 4 3; }

/* ── Task detail ──────────────────────────────────────────────────────── */
.task-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.dod-item { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.dod-item input { width: 16px; height: 16px; accent-color: var(--success); }
.dod-item.done label { text-decoration: line-through; color: var(--text-soft); }
.sla-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.sla-bar > span { display: block; height: 100%; }
.subtree { list-style: none; padding-inline-start: 16px; border-inline-start: 1px solid var(--border); margin-inline-start: 4px; }
.subtree li { padding: 4px 0; }
.meta-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.meta-row__k { color: var(--text-muted); }
@media (max-width: 900px) { .task-layout { grid-template-columns: 1fr; } }

/* ── Dynamic form (record forms / preview) ────────────────────────────── */
.dynform { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.dynfield { grid-column: 1 / -1; }
.dynfield--half { grid-column: span 1; }
@media (max-width: 640px) { .dynform { grid-template-columns: 1fr; } .dynfield--half { grid-column: 1 / -1; } }

/* ── Form Builder (split-screen designer) ─────────────────────────────── */
.builder { display: grid; grid-template-columns: 220px 1fr 300px; gap: 16px; align-items: start; }
.builder__palette, .builder__props { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; position: sticky; top: 84px; }
.builder__ptitle { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .4px; }
.palette-item { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; font-weight: 600; margin-bottom: 7px; cursor: grab; color: var(--text-muted); transition: border-color .12s, color .12s; }
.palette-item:hover { border-color: var(--accent); color: var(--accent); }
.builder__canvas { min-height: 400px; background: var(--surface-2); border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.fb-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-soft); gap: 8px; min-height: 300px; }
.fb-field { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.fb-field:hover { border-color: var(--border-strong); }
.fb-field.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.fb-field__bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fb-field__label { font-size: 13.5px; font-weight: 600; }
.fb-field__meta { display: flex; align-items: center; gap: 5px; }
.fb-field__meta .act { width: 24px; height: 24px; font-size: 13px; }
.fb-field__prev { font-size: 11.5px; color: var(--text-soft); margin-top: 4px; direction: ltr; text-align: right; }
.fb-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 980px) { .builder { grid-template-columns: 1fr; } .builder__palette, .builder__props { position: static; } .builder__palette { display: flex; flex-wrap: wrap; gap: 7px; } .palette-item { margin-bottom: 0; } }

/* ── Workflow designer ────────────────────────────────────────────────── */
.wf { display: grid; grid-template-columns: 1fr 280px; gap: 16px; align-items: start; }
.wf__canvas { min-height: 420px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; position: relative; }
.wf__panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; position: sticky; top: 84px; min-height: 200px; }
.wf-edge { stroke: var(--accent); stroke-width: 2; fill: none; }
.wf-edge.is-sel { stroke-width: 3.5; }
.wf-node text { user-select: none; }
@media (max-width: 900px) { .wf { grid-template-columns: 1fr; } .wf__panel { position: static; } }

/* ── Automation rows ──────────────────────────────────────────────────── */
.auto-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 0; border-bottom: 1px solid var(--border); }
.auto-row .select, .auto-row .input { width: auto; min-width: 130px; }
.auto-val, .auto-params { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.auto-params .input { flex: 1; }

/* ── Resource workload heatmap ────────────────────────────────────────── */
table.heat { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.heat th, table.heat td { padding: 8px 6px; text-align: center; border: 1px solid var(--border); }
table.heat thead th { background: var(--surface-2); font-weight: 700; color: var(--text-muted); font-size: 11.5px; }
table.heat .heat__u { text-align: right; min-width: 180px; position: sticky; inset-inline-start: 0; background: var(--surface); }
table.heat .heat__c { color: var(--text-soft); white-space: nowrap; }
.heat-cell { font-weight: 700; }
.heat-cell__h { font-size: 13px; }
.heat-cell__p { font-size: 10px; font-weight: 500; opacity: .8; }
.heat--green { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.heat--yellow { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var(--warning); }
.heat--red { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.heat--idle { color: var(--text-soft); }
.heat-key { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.heat-key.heat--green { background: var(--success); }
.heat-key.heat--yellow { background: var(--warning); }
.heat-key.heat--red { background: var(--danger); }
.heat-key.heat--idle { background: var(--surface-3); border: 1px solid var(--border); }

/* ── Risk matrix ──────────────────────────────────────────────────────── */
table.risk-matrix { border-collapse: collapse; width: 100%; }
table.risk-matrix th, table.risk-matrix td { border: 1px solid var(--border); padding: 6px; text-align: center; }
table.risk-matrix thead th { background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--text-muted); }
.rm-corner { background: var(--surface-2); font-size: 11px !important; }
.rm-row { background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--text-muted); white-space: nowrap; }
.rm-cell { vertical-align: top; min-width: 96px; height: 70px; }
.rm-exp { font-weight: 800; font-size: 13px; }
.rm-chip { display: block; font-size: 10.5px; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; margin-top: 3px; color: var(--text); }
.rm-more { font-size: 10px; color: var(--text-soft); margin-top: 2px; }

/* ── Markdown rendering ───────────────────────────────────────────────── */
.markdown { line-height: 1.9; font-size: 14px; }
.markdown h1 { font-size: 22px; font-weight: 800; margin: 12px 0 8px; }
.markdown h2 { font-size: 18px; font-weight: 700; margin: 12px 0 6px; }
.markdown h3 { font-size: 15.5px; font-weight: 700; margin: 10px 0 5px; }
.markdown p { margin: 6px 0; }
.markdown ul, .markdown ol { padding-inline-start: 22px; margin: 6px 0; }
.markdown li { margin: 3px 0; }
.markdown code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; direction: ltr; }
.markdown pre { background: var(--surface-3); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; direction: ltr; }
.markdown pre code { background: none; padding: 0; }
.markdown blockquote { border-inline-start: 3px solid var(--accent); padding-inline-start: 12px; color: var(--text-muted); margin: 8px 0; }
.markdown a { color: var(--accent); }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* ── Wiki ─────────────────────────────────────────────────────────────── */
.wiki { display: grid; grid-template-columns: 250px 1fr; gap: 18px; align-items: start; }
.wiki__tree { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow-y: auto; }
.wtree__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.wtree { padding: 8px; }
.wtree__link { display: flex; align-items: center; gap: 7px; padding: 6px 8px; border-radius: var(--radius-sm); font-size: 13px; color: var(--text-muted); }
.wtree__link:hover { background: var(--surface-3); color: var(--text); }
.wtree__link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.wtree__link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiki__main { min-width: 0; }
.wiki__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.wiki__title { font-size: 26px; font-weight: 800; border: none; background: none; outline: none; flex: 1; color: var(--text); font-family: inherit; }
.wiki__editor { }
.wblock { display: flex; align-items: flex-start; gap: 6px; padding: 2px 0; position: relative; }
.wblock__type { width: auto; min-width: 96px; padding: 4px 8px; font-size: 11.5px; border: 1px solid transparent; background: transparent; color: var(--text-soft); border-radius: 6px; flex-shrink: 0; opacity: 0; transition: opacity .12s; }
.wblock:hover .wblock__type { opacity: 1; border-color: var(--border); }
.wblock__content { flex: 1; padding: 4px 6px; border-radius: 6px; outline: none; line-height: 1.8; min-height: 1.6em; }
.wblock__content:focus { background: var(--surface-2); }
.wblock__content[data-ph]:empty::before { content: attr(data-ph); color: var(--text-soft); }
.wblock--h1 .wblock__content { font-size: 24px; font-weight: 800; }
.wblock--h2 .wblock__content { font-size: 19px; font-weight: 700; }
.wblock--h3 .wblock__content { font-size: 16px; font-weight: 700; }
.wblock--quote .wblock__content { border-inline-start: 3px solid var(--accent); color: var(--text-muted); background: var(--surface-2); }
.wblock--code .wblock__content { font-family: monospace; background: var(--surface-3); direction: ltr; font-size: 13px; white-space: pre-wrap; }
.wblock--bullet .wblock__content, .wblock--numbered .wblock__content { white-space: pre-wrap; }
.wblock__hr { flex: 1; padding: 10px 0; }
.wblock__hr hr { border: none; border-top: 1px solid var(--border-strong); }
.wblock__del { opacity: 0; border: none; background: none; color: var(--text-soft); cursor: pointer; padding: 4px 6px; flex-shrink: 0; }
.wblock:hover .wblock__del { opacity: 1; }
@media (max-width: 820px) { .wiki { grid-template-columns: 1fr; } .wiki__tree { position: static; max-height: none; } }

/* ── Diff ─────────────────────────────────────────────────────────────── */
.diff-view { font-size: 13.5px; line-height: 1.9; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.diff-line { padding: 3px 12px; display: flex; gap: 8px; }
.diff-sign { width: 14px; color: var(--text-soft); flex-shrink: 0; text-align: center; }
.diff--add { background: var(--success-soft); }
.diff--del { background: var(--danger-soft); text-decoration: line-through; color: var(--text-muted); }
.diff-key { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.diff-key.diff--add { background: var(--success); }
.diff-key.diff--del { background: var(--danger); }
