/* Kashfia PMT — styles.
   Layout uses logical properties (inline-start / inline-end) everywhere,
   so the whole UI mirrors automatically when <html dir="rtl">. */

:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --panel-2: #f8f9fc;
  --sunken: #eef0f6;
  --text: #1d2130;
  --text-2: #3b4152;
  --muted: #6b7286;
  --border: #e3e6ee;
  --border-2: #d3d8e3;
  --accent: #5b5bd6;
  --accent-2: #4646c2;
  --accent-soft: #ededfc;
  --hover: #f0f1f6;
  --danger: #d83a52;
  --ok: #00a86b;
  --warn: #e08a00;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 6px rgba(16, 24, 40, .06);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .18), 0 2px 8px rgba(16, 24, 40, .08);
  --radius: 10px;
  --radius-sm: 7px;
  --side-w: 264px;
  --font: 'Inter', 'IBM Plex Sans Arabic', system-ui, 'Segoe UI', Tahoma, sans-serif;
  --slide: 32px;
  color-scheme: light;
}
html[lang="ar"] { --font: 'IBM Plex Sans Arabic', 'Inter', system-ui, 'Segoe UI', Tahoma, sans-serif; }
html[dir="rtl"] { --slide: -32px; }

:root[data-theme="dark"] {
  --bg: #121419;
  --panel: #1b1e26;
  --panel-2: #20232c;
  --sunken: #171a21;
  --text: #e8eaf0;
  --text-2: #c6cad6;
  --muted: #9097a8;
  --border: #2b2f3a;
  --border-2: #3a3f4c;
  --accent: #8484f4;
  --accent-2: #9d9df7;
  --accent-soft: #2a2b4d;
  --hover: #262a34;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 3px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; }
[hidden] { display: none !important; }

/* user-written text: direction from the content, alignment from the interface */
.ua { unicode-bidi: plaintext; text-align: match-parent; }
/* user text: its direction comes from what is typed, its alignment from the surrounding layout */
:dir(ltr) > .ua { text-align: left; }
:dir(rtl) > .ua { text-align: right; }
bdi, .key { unicode-bidi: isolate; }

.ico { display: inline-flex; width: 16px; height: 16px; flex: none; }
.ico svg { width: 100%; height: 100%; }
html[dir="rtl"] .flip { transform: scaleX(-1); }

.spacer { flex: 1; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.count {
  font-size: 11px; font-weight: 600; color: var(--muted);
  background: var(--sunken); border-radius: 999px; padding: 0 7px; line-height: 18px; min-width: 18px; text-align: center;
}
.count:empty { display: none; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding-inline: 14px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; white-space: nowrap; background: var(--panel); color: var(--text);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(70, 70, 194, .3); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: var(--border-2); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.95); }
.btn.danger-text { color: var(--danger); border-color: transparent; }
.btn.sm { height: 30px; padding-inline: 10px; font-size: 13px; }
.btn.xs { height: 26px; padding-inline: 8px; font-size: 12px; }
.btn.lg { height: 44px; padding-inline: 22px; font-size: 15px; }
.btn:focus-visible, .icon-btn:focus-visible, .chip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.xs { width: 22px; height: 22px; border-radius: 6px; }
.icon-btn.xs .ico { width: 14px; height: 14px; }
.icon-btn.danger-hover:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.lang-btn { font-weight: 700; font-size: 14px; font-family: 'IBM Plex Sans Arabic', 'Inter', sans-serif; }

.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding-inline: 10px;
  border: 1px solid var(--border-2); border-radius: 8px; background: var(--panel); color: var(--text-2); font-size: 13px; font-weight: 500;
}
.chip-btn:hover { background: var(--hover); }
.chip-btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip-btn.sm { height: 26px; padding-inline: 8px; font-size: 12px; }
.chip-btn .avatar { width: 20px; height: 20px; font-size: 9px; }
.link-btn { background: none; border: 0; color: var(--accent); font-weight: 600; font-size: 13px; padding: 0 4px; }
.link-btn:hover { text-decoration: underline; }

.input {
  width: 100%; height: 36px; padding-inline: 11px; border: 1px solid var(--border-2); border-radius: 8px;
  background: var(--panel); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding-block: 8px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.lg { height: 44px; font-size: 16px; font-weight: 500; }
.input.sm { height: 30px; font-size: 13px; }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.plain { border: 0; background: transparent; outline: none; padding: 2px 4px; border-radius: 5px; min-width: 0; }
.plain:hover { background: var(--hover); }
.plain:focus { background: var(--panel); box-shadow: 0 0 0 2px var(--accent-soft), inset 0 0 0 1px var(--accent); }

.swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; display: inline-block; }

/* ---------- app layout ---------- */
#app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100vh; }
.boot { grid-column: 1 / -1; display: grid; place-items: center; }
.boot img { width: 56px; height: 56px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.9); opacity: .6; } }

/* ---------- sidebar ---------- */
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-inline-end: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; }
.logo { width: 34px; height: 34px; border-radius: 9px; }
.brand-name { font-weight: 750; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 10px; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 34px; padding-inline: 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-section {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px 4px 20px; padding-inline: 20px 12px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
html[lang="ar"] .side-section { text-transform: none; letter-spacing: 0; font-size: 12px; }
.tree { flex: 1; overflow-y: auto; padding: 2px 10px 12px; }
.tree-empty { display: flex; gap: 8px; align-items: center; width: 100%; border: 1px dashed var(--border-2); background: none; border-radius: 8px; padding: 10px; color: var(--muted); }
.space-row {
  display: flex; align-items: center; gap: 6px; height: 34px; padding-inline: 6px; border-radius: 8px; cursor: pointer; user-select: none; font-weight: 600;
}
.space-row:hover { background: var(--hover); }
.space-row .chev { width: 14px; height: 14px; color: var(--muted); transition: transform .15s; }
.space.open > .space-row .chev { transform: rotate(90deg); }
.space-ico {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; font-size: 14px; flex: none;
  background: color-mix(in srgb, var(--sc) 18%, transparent);
}
.space-ico.sm { width: 20px; height: 20px; font-size: 12px; border-radius: 6px; }
.space-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hover-show { opacity: 0; transition: opacity .12s; }
.space-row:hover .hover-show, .tg-head:hover .hover-show, .field-row:hover .hover-show, .check-item:hover .hover-show,
.comment:hover .hover-show, .hover-show:focus-visible { opacity: 1; }
.pages { display: flex; flex-direction: column; gap: 1px; padding-inline-start: 18px; margin-block: 2px 6px; }
.page-row {
  display: flex; align-items: center; gap: 8px; height: 32px; padding-inline: 10px 6px; border-radius: 8px;
  color: var(--text-2); background: none; border: 0; width: 100%; text-align: start;
}
.page-row:hover { background: var(--hover); }
.page-row.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.page-row.add { color: var(--muted); font-size: 13px; }
.page-row.add .ico { width: 14px; height: 14px; }
.page-ico { font-size: 14px; width: 18px; text-align: center; }
.page-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot { display: flex; align-items: center; gap: 2px; padding: 10px; border-top: 1px solid var(--border); }
.me-btn { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; height: 38px; padding-inline: 6px; border: 0; background: none; border-radius: 8px; position: relative; }
.me-btn:hover { background: var(--hover); }
.me-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ok); }
.sync-dot.s-saving { background: var(--warn); }
.sync-dot.s-offline { background: var(--danger); animation: pulse 1s infinite; }
.sync-dot.s-local { background: #579bfc; }
.side-scrim { display: none; }
.mobile-only { display: none; }

/* ---------- main ---------- */
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.page { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.page-head { padding: 18px 24px 0; background: var(--bg); }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-emoji { font-size: 26px; width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel); flex: none; }
.page-emoji:hover { border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.title-col { display: flex; flex-direction: column; min-width: 0; flex: 0 1 auto; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.page-title {
  font-size: 22px; font-weight: 700; border: 0; background: transparent; outline: none; padding: 0 4px; margin-inline-start: -4px;
  border-radius: 6px; min-width: 120px; letter-spacing: -.01em;
  field-sizing: content; max-width: 46vw;
}
.page-title:hover { background: var(--hover); }
.page-title:focus { background: var(--panel); box-shadow: 0 0 0 2px var(--accent-soft); }
.tabs { display: inline-flex; padding: 3px; gap: 2px; background: var(--sunken); border-radius: 9px; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding-inline: 12px; border-radius: 7px; border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 13px; }
.tab:hover { color: var(--text); }
.tab.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 14px 0 12px; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 6px; height: 32px; padding-inline: 10px; border: 1px solid var(--border-2);
  border-radius: 8px; background: var(--panel); color: var(--muted); width: 240px;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { border: 0; outline: none; background: none; flex: 1; min-width: 0; color: var(--text); }

/* ---------- board ---------- */
.board {
  flex: 1; min-height: 0; display: flex; align-items: flex-start; gap: 14px;
  overflow: auto; padding: 4px 24px 24px;
}
.board-empty { color: var(--muted); padding: 30px 0; }
.column {
  flex: none; width: 296px; display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--gc) 6%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--gc) 16%, var(--border));
  border-radius: 12px;
}
.column.drop-target { box-shadow: 0 0 0 2px color-mix(in srgb, var(--gc) 50%, transparent); }
.col-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 10px 8px 12px; padding-inline: 12px 8px; cursor: grab;
  /* the whole board scrolls as one; group titles stay visible at the top while scrolling */
  position: sticky; top: -4px; z-index: 3; border-radius: 12px 12px 0 0;
  background: color-mix(in srgb, var(--gc) 6%, var(--panel-2));
}
.col-head:active { cursor: grabbing; }
.col-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gc); flex: none; }
.col-name { font-weight: 700; color: color-mix(in srgb, var(--gc) 70%, var(--text)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.col-count { font-size: 12px; color: var(--muted); font-weight: 600; background: color-mix(in srgb, var(--gc) 14%, transparent); border-radius: 999px; padding: 0 7px; }
.col-actions { margin-inline-start: auto; display: flex; gap: 2px; }
.group-name-input { font-weight: 700; border: 1px solid var(--accent); border-radius: 6px; padding: 2px 6px; outline: none; background: var(--panel); min-width: 0; flex: 1; }
.col-body { flex: none; min-height: 40px; display: flex; flex-direction: column; gap: 8px; padding: 2px 10px 6px; }
.col-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 14px 8px; }
.ph:not(:only-child) ~ .col-empty, .col-body:has(.ph) .col-empty { display: none; }
.quick-add { padding: 4px 10px 10px; }
.quick-input {
  width: 100%; height: 34px; border: 1px solid transparent; border-radius: 8px; background: transparent; padding-inline: 10px; outline: none; color: var(--text);
}
.quick-input::placeholder { color: var(--muted); }
.quick-input:hover { background: color-mix(in srgb, var(--gc) 8%, transparent); }
.quick-input:focus { background: var(--panel); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.column.collapsed { width: 52px; cursor: pointer; }
.column.collapsed .col-head { flex-direction: column; padding: 12px 0; gap: 10px; height: 260px; }
.column.collapsed .col-name { writing-mode: vertical-rl; white-space: nowrap; }
.add-col {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 44px; padding-inline: 16px;
  border: 1px dashed var(--border-2); border-radius: 12px; background: transparent; color: var(--muted); font-weight: 600;
}
.add-col:hover { background: var(--panel); color: var(--text); }

.card {
  position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  box-shadow: var(--shadow-sm); cursor: pointer; display: flex; flex-direction: column; gap: 7px;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.card:hover { border-color: var(--border-2); box-shadow: var(--shadow); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.card.dragging { opacity: .4; }
.card.is-done .card-title { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.card-top { display: flex; align-items: center; gap: 6px; min-height: 18px; }
.key { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card-title { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.meta-i { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); }
.meta-i .ico { width: 13px; height: 13px; }
.meta-i.ok { color: var(--ok); }
.ph-card { height: 54px; border-radius: 10px; border: 2px dashed var(--accent); background: var(--accent-soft); flex: none; }
.ph-col { flex: none; width: 6px; align-self: stretch; border-radius: 4px; background: var(--accent); }
.column.dragging { opacity: .4; }

.pill {
  display: inline-flex; align-items: center; height: 22px; padding-inline: 9px; border-radius: 999px;
  background: var(--pc); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.prio { display: inline-flex; align-items: center; gap: 4px; color: var(--pc); font-size: 12px; font-weight: 600; white-space: nowrap; }
.prio .ico { width: 14px; height: 14px; }
.prio.p-critical .ico svg path { fill: var(--pc); }
.due {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding-inline: 7px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--sunken); white-space: nowrap;
}
.due .ico { width: 13px; height: 13px; }
.due.soon { color: #b86e00; background: #fff2da; }
.due.today { color: #fff; background: var(--warn); }
.due.late { color: #fff; background: var(--danger); }
.due.done { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); text-decoration: line-through; }
:root[data-theme="dark"] .due.soon { color: #ffc46b; background: #3a2c12; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag {
  display: inline-flex; align-items: center; gap: 2px; height: 20px; padding-inline: 7px; border-radius: 5px; font-size: 11px; font-weight: 600;
  color: color-mix(in srgb, var(--tc) 75%, var(--text)); background: color-mix(in srgb, var(--tc) 14%, transparent);
}
.tag-x { border: 0; background: none; padding: 0 2px; color: inherit; opacity: .6; font-size: 14px; line-height: 1; }
.tag-x:hover { opacity: 1; }
.tpl-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding-inline: 6px; border-radius: 5px; max-width: 160px;
  font-size: 11px; font-weight: 600; color: color-mix(in srgb, var(--tc) 70%, var(--text)); background: color-mix(in srgb, var(--tc) 12%, transparent);
  overflow: hidden; white-space: nowrap;
}
.tpl-chip span:last-child { overflow: hidden; text-overflow: ellipsis; }

.avatars { display: inline-flex; align-items: center; }
.avatar {
  --as: 24px;
  display: inline-grid; place-items: center; width: var(--as); height: var(--as); border-radius: 50%; flex: none;
  background: var(--ac); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .02em;
  box-shadow: 0 0 0 2px var(--panel); font-family: 'Inter', 'IBM Plex Sans Arabic', sans-serif;
}
.avatars .avatar + .avatar { margin-inline-start: -6px; }
.avatar.more { background: var(--sunken); color: var(--muted); }
.avatar.empty { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--border-2); }
.avatar.empty .ico { width: 13px; height: 13px; }

/* ---------- table view ---------- */
.tview { flex: 1; min-height: 0; overflow: auto; padding: 4px 24px 40px; }
.tgroup { margin-bottom: 26px; }
.tgroup.drop-target { outline: 2px dashed var(--gc); border-radius: 8px; }
.tg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tg-toggle .chev { color: var(--gc); transition: transform .15s; }
.tgroup.collapsed .tg-toggle .chev { transform: rotate(-90deg); }
html[dir="rtl"] .tgroup.collapsed .tg-toggle .chev { transform: rotate(90deg); }
.tg-name { font-size: 16px; font-weight: 700; color: var(--gc); }
.grid-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); box-shadow: var(--shadow-sm); }
.grid { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 920px; }
.grid th {
  position: sticky; top: 0; z-index: 1; background: var(--panel-2); font-size: 12px; font-weight: 600; color: var(--muted);
  text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.grid td { border-bottom: 1px solid var(--border); padding: 0 10px; height: 42px; vertical-align: middle; }
.grid tbody tr:hover td { background: var(--panel-2); }
.grid tr.selected td { background: var(--accent-soft) !important; }
.grid tr.dragging { opacity: .4; }
.grid .c-grip { width: 30px; padding: 0; border-inline-start: 5px solid var(--gc); color: var(--muted); text-align: center; cursor: grab; }
.grid th.c-grip { border-inline-start: 5px solid var(--gc); }
.grid .c-grip .ico { opacity: 0; width: 14px; }
.grid tr:hover .c-grip .ico { opacity: 1; }
.grid .c-title { min-width: 300px; }
.t-title { display: flex; align-items: center; gap: 8px; }
.cell-input { flex: 1; min-width: 0; border: 1px solid transparent; background: transparent; border-radius: 6px; height: 30px; padding-inline: 6px; outline: none; font-weight: 500; }
.cell-input:hover { border-color: var(--border-2); }
.cell-input:focus { border-color: var(--accent); background: var(--panel); }
.open-btn {
  display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--border-2); background: var(--panel); color: var(--text-2);
  border-radius: 6px; height: 24px; padding-inline: 8px 4px; font-size: 12px; font-weight: 600; opacity: 0;
}
.open-btn .ico { width: 13px; height: 13px; }
.grid tr:hover .open-btn, .open-btn:focus-visible { opacity: 1; }
.grid td.c-status { width: 150px; white-space: nowrap; background: var(--pc) !important; color: #fff; font-weight: 600; text-align: center; cursor: pointer; font-size: 13px; border-inline: 1px solid var(--panel); }
.grid td.c-status:hover { filter: brightness(.95); }
.grid th.c-status-h { text-align: center; }
.grid .c-people, .grid .c-prio { cursor: pointer; width: 130px; }
.grid .c-people:hover, .grid .c-prio:hover { background: var(--hover) !important; }
.grid .c-date { width: 150px; }
.cell-date { border: 1px solid transparent; border-radius: 6px; background: transparent; height: 30px; padding-inline: 6px; font-size: 13px; outline: none; }
.cell-date:hover { border-color: var(--border-2); }
.cell-date.late { color: var(--danger); font-weight: 600; }
.cell-date.today, .cell-date.soon { color: var(--warn); font-weight: 600; }
.grid .c-tpl { width: 170px; }
.grid .c-prog { width: 140px; }
.grid tfoot td { border-bottom: 0; }
.grid tfoot .quick-add { padding: 4px 0; --gc: var(--accent); }
.grid .empty-row td { color: var(--muted); font-size: 13px; height: 48px; }
.ph-row td { height: 4px !important; padding: 0 !important; background: var(--accent) !important; }
.add-group-t { margin-top: 4px; }
.status-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; margin-top: 8px; max-width: 420px; }
.status-bar:empty { display: none; }
.tview .status-bar { margin-inline-start: 0; }
.progress { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; }
.bar { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ok); border-radius: 3px; transition: width .2s; }
.bar.big { width: 100%; height: 6px; margin-bottom: 6px; }

/* ---------- home ---------- */
.home, .templates-view { flex: 1; overflow-y: auto; padding: 26px 28px 40px; }
.home-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.home-head h1 { font-size: 26px; letter-spacing: -.02em; }
.home-head p { margin: 2px 0 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow-sm); }
.stat-n { font-size: 26px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-l { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat.late .stat-n { color: var(--danger); }
.stat.ok .stat-n { color: var(--ok); }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.work-sec { margin-bottom: 20px; }
.work-h { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 8px; color: var(--text-2); }
.work-h.late { color: var(--danger); }
.work-h.today { color: var(--warn); }
.work-list { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm); }
.work-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 46px; padding: 8px 14px; border: 0; background: none;
  border-bottom: 1px solid var(--border); text-align: start;
}
.work-row:last-child { border-bottom: 0; }
.work-row:hover { background: var(--panel-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.work-title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-page { white-space: nowrap; }
.empty-card { background: var(--panel); border: 1px dashed var(--border-2); border-radius: 14px; padding: 40px; text-align: center; color: var(--muted); }
.empty-emoji { font-size: 40px; margin-bottom: 8px; }
.empty-state { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px; }
.side-h { font-size: 13px; color: var(--muted); font-weight: 650; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.home-side { display: flex; flex-direction: column; gap: 12px; }
.space-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px; box-shadow: var(--shadow-sm); }
.space-card-h { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 6px; }
.space-card-page { display: flex; align-items: center; gap: 8px; padding: 7px 6px; border-radius: 7px; }
.space-card-page:hover { background: var(--hover); }
.space-card-page .status-bar { width: 70px; margin: 0; height: 6px; flex: none; }

/* ---------- popovers & menus ---------- */
.pop {
  position: fixed; z-index: 1000; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 5px; animation: pop-in .12s ease-out; max-height: 70vh; overflow-y: auto;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.menu { display: flex; flex-direction: column; min-width: 200px; }
.menu-item {
  display: flex; align-items: center; gap: 9px; height: 34px; padding-inline: 10px; border: 0; background: none; border-radius: 7px;
  text-align: start; color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.menu-item:hover { background: var(--hover); }
.menu-item .ico { color: var(--muted); }
.menu-item.on { font-weight: 650; }
.menu-item .avatar { --as: 22px; font-size: 9px; box-shadow: none; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .ico { color: var(--danger); }
.menu-label { flex: 1; }
.menu-check { color: var(--accent) !important; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.menu-h { font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: .05em; }
html[lang="ar"] .menu-h { text-transform: none; letter-spacing: 0; font-size: 12px; }
.swatches { display: grid; grid-template-columns: repeat(7, 26px); gap: 6px; padding: 6px; }
.sw { width: 26px; height: 26px; border-radius: 7px; border: 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.sw:hover { transform: scale(1.1); }
.sw.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }
.emoji-pop { padding: 4px; width: 264px; display: flex; flex-direction: column; gap: 6px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.em { border: 0; background: none; font-size: 19px; height: 32px; border-radius: 7px; }
.em:hover { background: var(--hover); }

/* ---------- modals ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 500; background: rgba(15, 18, 30, .45); display: grid; place-items: center; padding: 20px;
  animation: fade-in .15s ease-out; backdrop-filter: blur(2px);
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  width: min(520px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--panel);
  border-radius: 16px; box-shadow: var(--shadow-lg); animation: modal-in .18s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal.small { width: min(440px, 100%); }
.modal.medium { width: min(640px, 100%); }
.modal.wide { width: min(1040px, 100%); height: min(820px, calc(100vh - 40px)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px 22px; padding-inline: 22px 14px; }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 10px 22px 18px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); }
.confirm-msg { margin: 4px 0; color: var(--text-2); font-size: 15px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row.inline { flex-direction: row; align-items: center; justify-content: space-between; }
.form-label { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0; }
.emoji-btn { font-size: 22px; width: 44px; height: 44px; border: 1px solid var(--border-2); border-radius: 10px; background: var(--panel); flex: none; }
.emoji-btn:hover { background: var(--hover); }
.emoji-btn.lg { width: 48px; height: 48px; font-size: 24px; }
.color-btn { width: 32px; height: 32px; border-radius: 9px; border: 0; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); flex: none; }

.toast {
  position: fixed; inset-block-end: 24px; inset-inline-start: 50%; transform: translateX(-50%); z-index: 2000;
  background: #1d2130; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500;
  animation: modal-in .2s ease-out; transition: opacity .3s;
}
html[dir="rtl"] .toast { transform: translateX(50%); }
.toast.out { opacity: 0; }

/* ---------- new ticket dialog ---------- */
.nt { display: flex; flex-direction: column; gap: 14px; height: 100%; }
.nt-top { display: flex; gap: 12px; align-items: flex-end; }
.nt-top select { width: 200px; height: 44px; }
.nt-label { display: flex; align-items: center; justify-content: space-between; font-weight: 650; font-size: 14px; }
.nt-main { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; flex: 1; min-height: 0; }
.tpl-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; overflow-y: auto; align-content: start; padding: 2px; }
.tpl-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px; border-radius: 12px; text-align: start;
  border: 1.5px solid var(--border); background: var(--panel); min-height: 118px; transition: border-color .15s, box-shadow .15s;
}
.tpl-card:hover { border-color: color-mix(in srgb, var(--tc) 50%, var(--border)); box-shadow: var(--shadow); }
.tpl-card.on { border-color: var(--tc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc) 20%, transparent); }
.tpl-card.blank { border-style: dashed; }
.tpl-card.blank.on { border-style: solid; --tc: var(--accent) !important; }
.tpl-ico {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; font-size: 18px; flex: none;
  background: color-mix(in srgb, var(--tc, var(--accent)) 15%, transparent);
}
.tpl-ico.lg { width: 44px; height: 44px; font-size: 22px; border-radius: 11px; }
.tpl-name { font-weight: 700; }
.tpl-sum { line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tpl-preview { background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; overflow-y: auto; padding: 16px; }
.pv { display: flex; flex-direction: column; gap: 14px; }
.pv-head { display: flex; gap: 12px; align-items: flex-start; }
.pv-head h3 { font-size: 17px; }
.pv-head p { margin: 2px 0 0; }
.pv-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pv-sec h4 { font-size: 12px; color: var(--muted); font-weight: 650; margin-bottom: 6px; display: flex; align-items: center; gap: 4px; }
.pv-fields { display: flex; flex-wrap: wrap; gap: 6px; }
.pv-field { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 7px; background: var(--panel); border: 1px solid var(--border); font-size: 12px; font-weight: 500; }
.pv-field .ico { width: 13px; height: 13px; color: var(--muted); }
.pv-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.pv-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.pv-table th { background: var(--sunken); font-weight: 650; text-align: start; padding: 6px 8px; white-space: nowrap; }
.pv-table td { border-top: 1px solid var(--border); padding: 5px 8px; height: 26px; color: var(--text-2); }
.pv-table th + th, .pv-table td + td { border-inline-start: 1px solid var(--border); }
.pv-check { margin: 0; padding-inline-start: 18px; color: var(--text-2); }
.pv-hints { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; color: var(--text-2); }
.pv-hints li { display: flex; gap: 8px; align-items: flex-start; }
.pv-hints .ico { color: var(--accent); margin-top: 2px; }

/* ---------- ticket window (centered, or full screen) ---------- */
.drawer-layer { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 28px; }
.drawer-back {
  position: absolute; inset: 0; background: rgba(15, 18, 30, .35); animation: fade-in .15s;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.drawer {
  position: relative; width: min(920px, 100%); height: min(900px, calc(100vh - 56px)); background: var(--panel);
  border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; outline: none; overflow: hidden;
  transition: width .2s ease, height .2s ease, border-radius .2s ease;
}
.drawer.enter { animation: ticket-in .2s cubic-bezier(.2, .8, .2, 1); }
@keyframes ticket-in { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.drawer-layer.full { padding: 0; }
.drawer-layer.full .drawer { width: 100%; height: 100vh; border-radius: 0; border: 0; }
.drawer-layer.full .dr-body { padding-inline: max(28px, calc((100% - 1100px) / 2)); }
@media (max-width: 860px) {
  .drawer-layer { padding: 0; }
  .drawer { width: 100%; height: 100vh; border-radius: 0; border: 0; }
}
.dr-head { display: flex; align-items: center; gap: 2px; padding: 10px 12px 10px 20px; padding-inline: 20px 12px; border-bottom: 1px solid var(--border); }
.dr-crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; overflow: hidden; white-space: nowrap; }
.dr-crumbs a:hover { color: var(--text); text-decoration: underline; }
.dr-crumbs .sep { width: 12px; height: 12px; }
.dr-crumbs .key { margin-inline-start: 6px; background: var(--sunken); padding: 1px 7px; border-radius: 5px; }
.dr-body { flex: 1; overflow-y: auto; padding: 18px 28px 40px; }
.dr-title {
  width: 100%; font-size: 24px; font-weight: 700; line-height: 1.3; border: 0; outline: none; resize: none; background: none;
  padding: 4px 6px; margin-inline-start: -6px; border-radius: 8px; letter-spacing: -.01em; overflow: hidden;
}
.dr-title:hover { background: var(--hover); }
.dr-title:focus { background: var(--panel-2); box-shadow: 0 0 0 2px var(--accent-soft); }
.props { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 24px; margin: 12px 0 8px; }
.prop { display: flex; align-items: center; min-height: 38px; gap: 10px; }
.prop-l { display: flex; align-items: center; gap: 8px; width: 120px; flex: none; color: var(--muted); font-size: 13px; font-weight: 500; }
.prop-l .ico { width: 15px; height: 15px; }
.prop-v { flex: 1; min-width: 0; display: flex; align-items: center; }
.prop-btn {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 32px; padding: 3px 6px; border: 1px solid transparent; background: none;
  border-radius: 7px; text-align: start; max-width: 100%;
}
.prop-btn:hover { background: var(--hover); }
.prop-select, .prop-input {
  height: 32px; border: 1px solid transparent; background: transparent; border-radius: 7px; padding-inline: 6px; outline: none; max-width: 100%;
}
.prop-select:hover, .prop-input:hover { background: var(--hover); }
.prop-select:focus, .prop-input:focus { border-color: var(--accent); background: var(--panel); }
.prop-input.late { color: var(--danger); font-weight: 600; }
.prop-input.today, .prop-input.soon { color: var(--warn); font-weight: 600; }
.deadline-ctl { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.person-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 2px; padding-inline: 2px 8px; border-radius: 999px; background: var(--sunken); font-size: 12px; font-weight: 600; }
.person-chip .avatar { --as: 22px; box-shadow: none; font-size: 9px; }
.dr-sec { margin-top: 22px; }
.dr-sec-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--text-2); }
.dr-sec-h h3 { font-size: 14px; }
.dr-sec-h .ico { color: var(--muted); }
.dr-desc {
  width: 100%; min-height: 70px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; resize: none; outline: none;
  background: var(--panel-2); line-height: 1.55; overflow: hidden;
}
.dr-desc:focus { border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 3px var(--accent-soft); }
.dr-foot { margin-top: 30px; padding-top: 14px; border-top: 1px solid var(--border); }

/* fields */
.fields { display: flex; flex-direction: column; gap: 2px; }
.field-row { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 10px; align-items: start; padding: 3px 0; }
.field-label { display: flex; align-items: center; gap: 6px; min-height: 34px; color: var(--muted); }
.field-label .ico { width: 15px; height: 15px; flex: none; }
.field-label .plain { flex: 1; font-size: 13px; font-weight: 600; color: var(--text-2); height: 28px; }
.field-value { min-height: 34px; display: flex; align-items: center; }
.val-in {
  width: 100%; height: 34px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); padding-inline: 10px; outline: none;
}
textarea.val-in { height: auto; min-height: 34px; padding-block: 7px; resize: none; overflow: hidden; line-height: 1.45; }
.val-in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.val-in::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.check-wrap { display: inline-flex; align-items: center; min-height: 34px; }
.check-wrap input, .check-item input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.url-wrap { position: relative; display: flex; align-items: center; width: 100%; }
.url-wrap .val-in { padding-inline-end: 34px; }
.url-go { position: absolute; inset-inline-end: 8px; color: var(--accent); display: inline-flex; }
.add-btn { align-self: flex-start; margin-top: 6px; color: var(--muted); border-style: dashed; }
.add-btn:hover { color: var(--text); }

/* ticket tables (sheets) */
.tables { display: flex; flex-direction: column; gap: 14px; }
.tb-card { border: 1px solid var(--border); border-radius: 12px; background: var(--panel); overflow: hidden; }
.tb-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 12px; padding-inline: 12px 8px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.tb-head > .ico { color: var(--muted); }
.tb-name { font-weight: 700; font-size: 14px; height: 30px; min-width: 120px; flex: 0 1 260px; }
.sheet-wrap { overflow-x: auto; overflow-y: hidden; }
.sheet { border-collapse: collapse; table-layout: fixed; width: 100%; font-size: 13px; }
.sheet th {
  background: var(--panel-2); text-align: start; font-weight: 600; color: var(--text-2); padding: 0;
  border-bottom: 1px solid var(--border-2); white-space: nowrap; position: relative; overflow: hidden;
}
.sheet th + th, .sheet td + td { border-inline-start: 1px solid var(--border); }
.sheet td { padding: 0; border-bottom: 1px solid var(--border); height: var(--rh, 36px); text-align: start; vertical-align: top; overflow: hidden; }
.sheet tbody tr:hover td { background: color-mix(in srgb, var(--accent) 3%, transparent); }
.sheet tfoot td { background: var(--panel-2); font-weight: 700; border-bottom: 0; }
.th-in { display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 8px; padding-inline: 8px 4px; }
.th-ico { width: 13px !important; height: 13px !important; color: var(--muted); }
.th-name { flex: 1; font-weight: 650; height: 28px; font-size: 13px; }
.sheet .rn { width: 44px; min-width: 44px; text-align: center; color: var(--muted); font-size: 12px; position: relative; }
.sheet td.rn .rn-menu { display: none; margin: auto; }
.sheet tr:hover td.rn .rn-n { display: none; }
.sheet tr:hover td.rn .rn-menu { display: inline-flex; }
.sheet .add-col-th, .sheet .add-col-td { width: 36px; min-width: 36px; text-align: center; }
.sheet .val-in.compact {
  height: 36px; border: 0; border-radius: 0; background: transparent; box-shadow: none; padding-inline: 9px; text-align: match-parent;
}
.sheet .val-in.compact:focus { box-shadow: inset 0 0 0 2px var(--accent); background: var(--panel); }
.sheet td.t-number, .sheet th.t-number { text-align: end; }
/* Inputs keep their own text direction (dir=auto) but line up with the table / panel direction. */
td:dir(rtl) > .val-in, td:dir(rtl) .url-wrap .val-in, .field-value:dir(rtl) > .val-in { text-align: right; }
td:dir(ltr) > .val-in, td:dir(ltr) .url-wrap .val-in, .field-value:dir(ltr) > .val-in { text-align: left; }
td.t-number:dir(rtl) > .val-in { text-align: left; }
td.t-number:dir(ltr) > .val-in { text-align: right; }
.sheet .val-in.num { font-variant-numeric: tabular-nums; }
.sheet td.t-checkbox { text-align: center; }
.sheet td.t-checkbox .check-wrap { min-height: 36px; justify-content: center; width: 100%; }
.sheet .sum { display: block; padding-inline: 9px; font-variant-numeric: tabular-nums; }
.sheet select.val-in.compact { cursor: pointer; }
.tb-foot { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; }

/* checklist */
.checklist { display: flex; flex-direction: column; gap: 1px; }
.check-item { display: flex; align-items: center; gap: 10px; min-height: 34px; padding-inline: 4px; border-radius: 7px; }
.check-item:hover { background: var(--panel-2); }
.check-item .plain { flex: 1; height: 30px; }
.check-item.done .plain { color: var(--muted); text-decoration: line-through; }
.check-item.add { color: var(--muted); }
.check-item.add .ico { width: 17px; height: 15px; }

/* tags editor */
.tags-editor { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 32px; padding: 3px 6px; border-radius: 7px; cursor: text; width: 100%; }
.tags-editor:hover { background: var(--hover); }
.tag-input { flex: 1; min-width: 80px; height: 24px; font-size: 13px; }
.tag-input:hover, .tag-input:focus { background: transparent; box-shadow: none; }

/* comments */
.comments { display: flex; flex-direction: column; gap: 14px; }
.comment { display: flex; gap: 10px; align-items: flex-start; }
.comment > .avatar { --as: 30px; font-size: 11px; box-shadow: none; }
.comment-b { flex: 1; min-width: 0; }
.comment-h { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.comment-t { background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px 12px 12px 12px; padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
html[dir="rtl"] .comment-t { border-radius: 12px 4px 12px 12px; }
.comment.new textarea { resize: none; overflow: hidden; min-height: 60px; }
.comment-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }

/* ---------- templates ---------- */
.tsec { margin-bottom: 26px; }
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tcard {
  display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--panel);
  box-shadow: var(--shadow-sm); cursor: pointer; position: relative; overflow: hidden; transition: box-shadow .15s, transform .15s;
}
.tcard:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.tcard:focus-visible { outline: 2px solid var(--accent); }
.tcard-top { display: flex; align-items: center; gap: 2px; margin-bottom: 4px; }
.tcard-top .tpl-ico { --tc: inherit; }
.tcard h3 { font-size: 16px; }
.tcard p { margin: 0; min-height: 18px; }
.tcard-stats { display: flex; gap: 12px; flex-wrap: wrap; color: var(--text-2); font-size: 12px; font-weight: 500; margin-top: 4px; }
.tcard-stats span { display: inline-flex; align-items: center; gap: 4px; }
.tcard-stats .ico { width: 13px; height: 13px; color: var(--muted); }
.tcard-cols { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.tcard-cols span { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--sunken); color: var(--text-2); font-weight: 500; }
.tcard-foot { margin-top: auto; padding-top: 8px; }

.tpl-editor { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 24px; align-items: start; }
.te-meta { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; }
.te-row { display: flex; align-items: center; gap: 10px; }
.te-grid { display: flex; flex-direction: column; gap: 12px; }
.te-meta .tags-editor { border: 1px solid var(--border-2); border-radius: 8px; min-height: 36px; }
.te-content { min-width: 0; }
.te-content .dr-sec:first-of-type { margin-top: 8px; }
.te-hint { margin: 0; padding: 10px 12px; background: var(--accent-soft); color: var(--text-2); border-radius: 10px; font-size: 13px; }
.te-content .field-row { grid-template-columns: 180px minmax(0, 1fr); }

/* ---------- settings ---------- */
.settings { display: flex; flex-direction: column; gap: 22px; }
.set-sec h3 { font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 42px; border-bottom: 1px solid var(--border); }
.set-row > span { font-weight: 500; color: var(--text-2); }
.set-row .input { width: 240px; }
.seg { display: inline-flex; padding: 3px; background: var(--sunken); border-radius: 9px; gap: 2px; }
.seg button { border: 0; background: none; height: 30px; padding-inline: 14px; border-radius: 7px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.seg.big button { height: 38px; padding-inline: 22px; font-size: 15px; }
.member-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.member-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.member-row .plain { height: 32px; font-weight: 500; }
.avatar-btn { border: 0; background: none; padding: 0; border-radius: 50%; }
.avatar-btn .avatar { --as: 30px; font-size: 11px; }
.you-badge { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }
.member-add { display: flex; gap: 8px; }
.mode-note { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 12px; color: var(--text-2); }
.mode-note .sync-dot { margin-top: 6px; }
.set-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- welcome ---------- */
.welcome-modal { width: min(460px, 100%); }
.welcome { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 16px 6px 4px; }
.welcome-logo { width: 60px; height: 60px; border-radius: 16px; box-shadow: var(--shadow); }
.welcome h1 { font-size: 24px; letter-spacing: -.02em; }
.welcome p { margin: 0; }
.welcome .input, .welcome .btn { width: 100%; }
.welcome-pick { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.pick-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pick { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; padding-inline: 6px 12px; border-radius: 999px; border: 1px solid var(--border-2); background: var(--panel); font-weight: 600; }
.pick:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .home-grid { grid-template-columns: 1fr; }
  .tpl-editor { grid-template-columns: 1fr; }
  .te-meta { position: static; }
}
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: 280px; z-index: 200; box-shadow: var(--shadow-lg);
    transform: translateX(-105%); transition: transform .2s;
  }
  html[dir="rtl"] .sidebar { transform: translateX(105%); }
  #app.side-open .sidebar { transform: none; }
  #app.side-open .side-scrim { display: block; position: fixed; inset: 0; z-index: 150; background: rgba(15, 18, 30, .35); }
  .mobile-only { display: inline-flex; }
  .page-head { padding: 12px 14px 0; }
  .board, .tview { padding-inline: 14px; }
  .home, .templates-view { padding: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-title { width: 60vw; font-size: 19px; }
  .search { width: 100%; }
  .props { grid-template-columns: 1fr; }
  .field-row, .te-content .field-row { grid-template-columns: 1fr; gap: 0; }
  .dr-body { padding: 14px 16px 30px; }
  .nt-main { grid-template-columns: 1fr; }
  .tpl-preview { display: none; }
  .nt-top { flex-direction: column; align-items: stretch; }
  .nt-top select { width: 100%; }
  .work-page { display: none; }
  .modal.wide { height: calc(100vh - 20px); }
  .modal-back { padding: 10px; }
}

/* ---------- sign in & team accounts ---------- */
.auth .form-row { width: 100%; text-align: start; }
.auth .seg { margin-top: -4px; }
.auth-error {
  width: 100%; margin: 0; padding: 9px 12px; border-radius: 9px; font-size: 13px; font-weight: 500; text-align: start;
  color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent);
}
.check-line { display: flex; align-items: center; gap: 8px; width: 100%; text-align: start; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check-line input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.busy { cursor: progress; }
.acct { display: flex; align-items: center; gap: 10px; }
.acct .avatar { --as: 34px; font-size: 12px; }
.acct-t { display: flex; flex-direction: column; line-height: 1.3; }
.set-row .set-actions { flex-wrap: nowrap; }
.set-note { margin: -4px 0 8px; }
.role-badge, .nologin-badge {
  display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.role-badge { color: #b86e00; background: #fff2da; }
.role-badge .ico { width: 12px; height: 12px; }
:root[data-theme="dark"] .role-badge { color: #ffc46b; background: #3a2c12; }
.nologin-badge { color: var(--muted); background: var(--sunken); }
.member-row input:disabled { color: var(--text); background: transparent; cursor: default; }
.member-add .input[type="password"] { max-width: 190px; }
@media (max-width: 860px) {
  .member-add { flex-wrap: wrap; }
  .member-add .input[type="password"] { max-width: none; }
  .set-row { flex-wrap: wrap; padding-block: 6px; }
}
.phone-txt { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.member-add .input[type="tel"] { max-width: 170px; }
@media (max-width: 860px) { .member-add .input[type="tel"] { max-width: none; } }
.dir-btn { margin-inline-end: 4px; }

/* ---------- clean, resizable table cells ---------- */
.sheet td:focus-within { box-shadow: inset 0 0 0 2px var(--accent); background: var(--panel); }
.sheet td.rn, .sheet td.add-col-td { vertical-align: middle; }
.sheet td.rn { overflow: visible; }
.cell-in {
  display: block; width: 100%; height: 35px; border: 0; background: transparent; padding: 0 9px; outline: none; color: var(--text); font-size: 13px;
}
.cell-txt {
  display: block; width: 100%; height: calc(var(--rh, 36px) - 1px); border: 0; background: transparent; outline: none; resize: none;
  padding: 8px 9px; line-height: 19px; overflow: hidden; color: var(--text); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.cell-in.num { font-variant-numeric: tabular-nums; }
td:dir(ltr) > .cell-in.num { text-align: right; }
td:dir(rtl) > .cell-in.num { text-align: left; }
.url-wrap.cell .cell-in { padding-inline-end: 30px; }
/* empty dates stay blank; the calendar icon shows on hover */
.cell-date-in { cursor: pointer; }
.cell-date-in:invalid:not(:focus) { color: transparent; }
.cell-date-in::-webkit-calendar-picker-indicator { opacity: 0; cursor: pointer; }
.sheet tr:hover .cell-date-in::-webkit-calendar-picker-indicator, .cell-date-in:focus::-webkit-calendar-picker-indicator { opacity: .45; }

/* dropdown & person cells: a value chip, or nothing */
.cell-btn {
  display: flex; align-items: center; gap: 6px; width: 100%; height: 35px; padding: 0 8px; border: 0; background: transparent;
  text-align: start; cursor: pointer; overflow: hidden; color: var(--text); font-size: 13px;
}
.cell-btn:hover { background: var(--hover); }
.cell-btn .avatar { --as: 22px; box-shadow: none; font-size: 9px; }
.cell-person { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.opt-chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600;
  max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--oc) 18%, transparent); color: color-mix(in srgb, var(--oc) 72%, var(--text));
}
/* checkbox: invisible until hover, a filled tick when done */
.cell-check { display: grid; place-items: center; width: 100%; height: 35px; border: 0; background: transparent; cursor: pointer; }
.ck { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid transparent; color: transparent; transition: background .12s, border-color .12s; }
.ck .ico { width: 12px; height: 12px; }
.sheet tr:hover .ck, .cell-check:focus-visible .ck { border-color: var(--border-2); }
.cell-check.on .ck { background: var(--accent); border-color: var(--accent); color: #fff; }
/* header tools appear on hover */
.sheet th .th-menu { opacity: 0; transition: opacity .12s; }
.sheet th:hover .th-menu, .sheet th:focus-within .th-menu { opacity: 1; }
.th-ico { opacity: .7; }
/* resize handles */
.col-resize { position: absolute; top: 0; bottom: 0; inset-inline-end: 0; width: 8px; cursor: col-resize; z-index: 2; touch-action: none; }
.col-resize::after { content: ''; position: absolute; top: 22%; bottom: 22%; inset-inline-end: 3px; width: 2px; border-radius: 2px; background: transparent; }
.sheet th:hover .col-resize::after { background: var(--border-2); }
.col-resize:hover::after, body.resizing-col .col-resize::after { background: var(--accent) !important; }
.row-resize { position: absolute; inset-inline: 0; bottom: -4px; height: 8px; cursor: row-resize; z-index: 2; touch-action: none; }
.row-resize:hover { background: linear-gradient(transparent 3px, var(--accent) 3px, var(--accent) 5px, transparent 5px); }
body.resizing { user-select: none; }
body.resizing-col, body.resizing-col * { cursor: col-resize !important; }
body.resizing-row, body.resizing-row * { cursor: row-resize !important; }

/* ---------- Fields section: same clean cells as tables ---------- */
.field-value { min-height: 34px; align-items: flex-start; }
.field-value > .cell-in, .field-value > .cell-txt, .field-value > .cell-btn, .field-value .url-wrap .cell-in {
  height: 34px; border-radius: 7px; transition: background .12s, box-shadow .12s;
}
.field-value > .cell-txt { height: auto; min-height: 34px; padding: 7px 9px; line-height: 20px; }
.field-row:hover .field-value > .cell-in, .field-row:hover .field-value > .cell-txt,
.field-row:hover .field-value .url-wrap .cell-in, .field-row:hover .field-value > .cell-btn { background: var(--hover); }
.field-value > .cell-in:focus, .field-value > .cell-txt:focus, .field-value .url-wrap .cell-in:focus {
  background: var(--panel); box-shadow: 0 0 0 3px var(--accent-soft), inset 0 0 0 1px var(--accent);
}
.field-value > .cell-btn { width: 100%; }
.field-value > .cell-check { width: auto; height: 34px; padding: 0 8px; justify-content: start; display: flex; align-items: center; border-radius: 7px; }
.field-row:hover .ck, .field-value > .cell-check:focus-visible .ck { border-color: var(--border-2); }
.field-row:hover .cell-date-in::-webkit-calendar-picker-indicator { opacity: .45; }
/* faint "Empty" hints only while hovering or editing */
.cell-empty { color: var(--muted); opacity: 0; font-size: 13px; transition: opacity .12s; }
.field-row:hover .cell-empty, .cell-btn:focus-visible .cell-empty { opacity: .7; }
.field-value .cell-in::placeholder, .field-value .cell-txt::placeholder { color: transparent; }
.field-row:hover .field-value .cell-in::placeholder, .field-row:hover .field-value .cell-txt::placeholder,
.field-value .cell-in:focus::placeholder, .field-value .cell-txt:focus::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
/* numbers and links line up with the panel direction */
.field-value:dir(rtl) > .cell-in { text-align: right; }
.field-value:dir(ltr) > .cell-in { text-align: left; }
.field-value .url-wrap { width: 100%; }
/* empty dates in the ticket header: blank, with a faint hint on hover */
.prop-input[type="date"]:invalid:not(:focus) { color: transparent; }
.prop:hover .prop-input[type="date"]:invalid:not(:focus) { color: color-mix(in srgb, var(--muted) 60%, transparent); }
.prop-input[type="date"]::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }


/* the blank filler column at the end of every table */
.sheet .add-col-th { text-align: start; padding-inline-start: 6px; }
.sheet tbody tr:hover td.add-col-td { background: color-mix(in srgb, var(--accent) 3%, transparent); }
.sheet .add-col-th, .sheet .add-col-td { width: auto; min-width: 0; }

/* ---------- section layout controls ---------- */
.dr-sec-h .sec-tools { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.dr-sec:hover .sec-tools, .sec-tools:focus-within { opacity: 1; }
.dr-body > .dr-sec:first-of-type { margin-top: 14px; }
.dr-sec[data-sec="details"] .props { margin-top: 0; }
.add-sections {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 22px; padding: 10px 12px;
  border: 1px dashed var(--border-2); border-radius: 10px;
}
.add-sections .chip-btn .ico { width: 13px; height: 13px; }
.sec-placeholder { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); }
.te-hint-row { display: flex; align-items: flex-start; gap: 10px; }
.te-hint-row .te-hint { flex: 1; }

/* ---------- page access ---------- */
.page-lock { display: inline-flex; color: var(--muted); }
.page-lock .ico { width: 13px; height: 13px; }
.access-chip {
  display: inline-flex; align-items: center; gap: 4px; margin-inline-start: 6px; height: 20px; padding: 0 8px; border-radius: 999px;
  border: 1px solid var(--border-2); background: var(--panel); color: var(--text-2); font-size: 11px; font-weight: 600;
}
.access-chip .ico { width: 12px; height: 12px; }
.access { display: flex; flex-direction: column; gap: 14px; }
.access > p { margin: 0; }
.access-opts { display: flex; flex-direction: column; gap: 8px; }
.access-opt {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--panel);
  text-align: start; color: var(--text);
}
.access-opt > span { display: flex; flex-direction: column; gap: 2px; }
.access-opt .ico { margin-top: 2px; color: var(--muted); }
.access-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.access-opt.on .ico { color: var(--accent); }
.access-list { display: flex; flex-direction: column; gap: 2px; }
.access-list .form-label { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.access-row { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 6px; border-radius: 8px; cursor: pointer; }
.access-row:hover { background: var(--hover); }
.access-row.always { cursor: default; }
.access-row input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.access-row .avatar { --as: 28px; font-size: 11px; box-shadow: none; }

/* ---------- notifications ---------- */
.bell-btn.on { color: var(--accent); background: var(--accent-soft); }
.notify-dlg { display: flex; flex-direction: column; gap: 12px; }
.notify-block { display: flex; flex-direction: column; gap: 8px; }
.notify-block .form-label { margin-top: 6px; }
.notify-groups { display: flex; flex-direction: column; gap: 2px; }
.notify-groups .col-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gc); flex: none; }
.notify-warn { display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--text-2); font-size: 13px; }
.notify-warn .ico { color: var(--accent); }
.set-sec h3 .ico { width: 16px; height: 16px; color: var(--muted); }
.tg-ok { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 600; }
.tg-link { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 6px 0; }
.tg-link p { margin: 0; }
.tg-open { width: 100%; }
.tg-wait { animation: pulse 1.4s ease-in-out infinite; }

/* =====================================================================
   Phones & touch screens
   ===================================================================== */
.modal { min-width: 0; }
.home-grid > *, .stats > *, .work, .work-list { min-width: 0; }
body:has(.modal-back) .boot { visibility: hidden; }
.mobile-menu-only { display: none; }

@media (max-width: 860px) {
  /* iPhone zooms into any text box under 16px — keep inputs at 16px on phones */
  input, select, textarea { font-size: 16px !important; }

  .modal { max-height: calc(100dvh - 20px); }
  .modal.wide { height: calc(100dvh - 20px); }
  .drawer, .drawer-layer.full .drawer { height: 100dvh; }

  /* page header: compact */
  .page-head { padding: 10px 12px 0; }
  .page-emoji { width: 38px; height: 38px; font-size: 20px; border-radius: 10px; }
  .page-title { font-size: 18px; max-width: 58vw; }
  .title-row { gap: 6px; }
  .title-row .tabs { order: 10; }
  .title-row > .btn.primary { order: 11; margin-inline-start: auto; }
  .toolbar { gap: 6px; padding: 10px 0 8px; }
  .toolbar > .muted.small, .toolbar > .btn.ghost { display: none; } /* ticket count & "add group" (still at the end of the board) */
  .chip-btn { height: 34px; }

  /* board: each group is a full-width panel; swipe sideways one group at a time */
  .board { padding: 4px 12px 24px; gap: 10px; scroll-snap-type: x mandatory; scroll-padding-inline: 12px; }
  .column { width: min(340px, calc(100vw - 44px)); scroll-snap-align: start; }
  .column.collapsed { width: 52px; }
  .add-col { scroll-snap-align: start; }

  /* table view: keep the ticket title pinned while swiping to the other columns */
  .tview { padding-inline: 12px; }
  .grid .c-grip { position: sticky; inset-inline-start: 0; z-index: 2; background: var(--panel); }
  .grid .c-title { position: sticky; inset-inline-start: 30px; z-index: 2; background: var(--panel); min-width: 190px; max-width: 190px; }
  .grid th.c-grip, .grid th.c-title { background: var(--panel-2); z-index: 3; }
  .grid .c-title .open-btn { display: none; }

  /* home */
  .home-head h1 { font-size: 21px; }
  .work-row { padding: 8px 10px; gap: 8px; }
  .work-row .avatars .avatar:nth-child(n+3) { display: none; }

  /* ticket window */
  .dr-head { padding-inline: 10px 6px; gap: 0; }
  .dr-crumbs { font-size: 12px; }
  .dr-crumbs > .space-ico, .dr-crumbs > bdi, .dr-crumbs > .sep { display: none; }
  .desktop-only { display: none !important; }
  .mobile-menu-only { display: inline-flex; }
  .dr-title { font-size: 20px; }
  .prop-l { width: 104px; }

  /* dialogs */
  .tpl-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tpl-card { min-height: 0; padding: 10px; }
  .tpl-card .tpl-sum { display: none; }
  .set-row .set-actions { flex-wrap: wrap; justify-content: flex-start; }
  .set-row .input { width: 100%; }
  .acct { width: 100%; }
  .modal-body { padding: 8px 14px 14px; }
  .modal-head { padding-inline: 16px 10px; }
  .modal-foot { padding: 12px 14px; }
}

/* touch screens have no hover: show the buttons that otherwise appear on mouse-over */
@media (hover: none) {
  .hover-show, .dr-sec-h .sec-tools, .sheet th .th-menu { opacity: 1 !important; }
  .grid .c-grip .ico { opacity: .6; }
  .open-btn { opacity: 1; }
  .sheet td.rn .rn-n { display: none; }
  .sheet td.rn .rn-menu { display: inline-flex; }
  .ck { border-color: var(--border-2); }
  .cell-empty { opacity: .5; }
  .field-value .cell-in::placeholder, .field-value .cell-txt::placeholder { color: color-mix(in srgb, var(--muted) 60%, transparent); }
  .cell-date-in::-webkit-calendar-picker-indicator { opacity: .4; }
  .col-resize::after { background: var(--border-2); }
}

/* date inputs: draw the calendar icon for the current theme (dark mode = light icon) */
:root[data-theme="dark"] input[type="date"] { color-scheme: dark; }
:root[data-theme="light"] input[type="date"] { color-scheme: light; }

/* tags picker */
.tags-editor { cursor: pointer; }
.tags-editor .tag-plus { width: 14px; height: 14px; color: var(--muted); opacity: .7; }
.tag-add { font-size: 13px; }
.tag-pop { display: flex; flex-direction: column; gap: 6px; width: 250px; padding: 2px; }
.tag-menu { min-width: 0; max-height: 280px; overflow-y: auto; }
.tag-empty { text-transform: none; letter-spacing: 0; font-weight: 500; }
.color-btn.sm { width: 22px; height: 22px; border-radius: 6px; }
.tag-mgr { display: flex; flex-direction: column; gap: 10px; }
.tag-mgr > p { margin: 0; }

/* done groups */
.done-mark { display: inline-flex; color: var(--ok); }
.done-mark .ico { width: 14px; height: 14px; }

/* ---------- framed property sheets: Details, Fields, Checklist ---------- */
:root { --line: var(--border); }
:root[data-theme="dark"] { --line: var(--border-2); }
/* the 1px gaps of a grid over a line-colored background draw the lines between cells */
.props, .fields-grid {
  display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.props { grid-template-columns: 1fr 1fr; margin: 0; }
.prop, .field-row { background: var(--panel); }
.prop { min-height: 42px; padding: 0 10px 0 0; padding-inline: 0 8px; gap: 0; align-items: stretch; }
.prop:last-child:nth-child(odd) { grid-column: 1 / -1; } /* an odd last cell spans the row instead of leaving a gap */
.prop-l {
  align-self: stretch; padding-inline: 12px 10px; margin-inline-end: 8px;
  border-inline-end: 1px solid var(--line); background: var(--panel-2);
}
.prop-v { align-self: center; padding-block: 4px; }
.fields-grid .field-row { padding: 0; gap: 0; align-items: stretch; grid-template-columns: 200px minmax(0, 1fr); }
.fields-grid .field-label { padding-inline: 10px 6px; border-inline-end: 1px solid var(--line); background: var(--panel-2); min-height: 42px; }
.fields-grid .field-value { padding: 4px 6px; align-items: center; min-height: 42px; }
.fields .add-btn { margin-top: 10px; }
.te-content .fields-grid .field-row { grid-template-columns: 170px minmax(0, 1fr); }
.checklist { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; gap: 0; }
.checklist .check-item { border-radius: 0; min-height: 38px; }
.checklist .check-item + .check-item { border-top: 1px solid var(--line); }
.checklist .bar.big { margin: 4px 0 8px; }
@media (max-width: 860px) {
  .props { grid-template-columns: 1fr; }
  .fields-grid .field-row, .te-content .fields-grid .field-row { grid-template-columns: 1fr; }
  .fields-grid .field-label { border-inline-end: 0; border-bottom: 1px solid var(--line); min-height: 36px; }
  .prop-l { width: 110px; }
}
.fields-grid { grid-template-columns: minmax(0, 1fr); }
.props { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.fields-grid .field-row > *, .prop > * { min-width: 0; }
@media (max-width: 860px) { .props { grid-template-columns: minmax(0, 1fr); } }

/* ---------- named, repeatable sections ---------- */
.sec-title {
  font-size: 14px; font-weight: 650; color: var(--text-2); height: 28px; padding: 0 6px; margin-inline-start: -2px;
  min-width: 70px; max-width: 70%; field-sizing: content;
}
.sec-title::placeholder { color: var(--text-2); opacity: 1; }
.sec-title:hover { background: var(--hover); }
.sec-title:focus::placeholder { color: var(--muted); }
.add-section-btn { margin-top: 18px; }

/* ---------- comments panel on the right of the ticket ---------- */
.dr-main { flex: 1; min-height: 0; display: flex; }
.dr-main > .dr-body { flex: 1; min-width: 0; }
.drawer.has-side { width: min(1240px, 100%); }
.dr-side {
  flex: none; width: 360px; display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--line); background: var(--panel-2);
}
html[dir="rtl"] .dr-side { order: -1; } /* right side in Arabic too (there the right is the start) */
.dr-side-h { display: flex; align-items: center; gap: 6px; padding: 12px 12px 10px 14px; padding-inline: 14px 8px; border-bottom: 1px solid var(--line); color: var(--text-2); }
.dr-side-h .ico { color: var(--muted); }
.dr-side-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 0; display: flex; flex-direction: column; }
.dr-side-body .comments { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.dr-side .comment.new { position: sticky; bottom: 0; margin-top: auto; padding: 10px 0 14px; background: var(--panel-2); border-top: 1px solid var(--line); }
.dr-side .comment-t { background: var(--panel); }
.cm-toggle { position: relative; }
.cm-toggle.on { color: var(--accent); background: var(--accent-soft); }
.cm-count {
  position: absolute; top: 1px; inset-inline-end: 0; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
}
@media (max-width: 1100px) { .dr-side { width: 300px; } }

/* ---------- comment images & voice messages ---------- */
.comment-b > * + * { margin-top: 6px; }
.cm-images { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-img { padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--sunken); cursor: zoom-in; }
.cm-img img { display: block; max-width: 220px; max-height: 180px; object-fit: cover; }
.cm-audio { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); max-width: 100%; }
.cm-audio .ico { color: var(--accent); flex: none; }
.cm-audio audio { height: 32px; min-width: 0; flex: 1; max-width: 260px; }
.cm-pending { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-chip { position: relative; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); overflow: hidden; min-height: 44px; }
.cm-chip img { display: block; width: 56px; height: 56px; object-fit: cover; }
.cm-chip-audio { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px 0 10px; padding-inline: 10px 30px; font-size: 13px; font-weight: 600; }
.cm-chip-audio .ico { color: var(--accent); }
.cm-chip-x { position: absolute; top: 2px; inset-inline-end: 2px; background: rgba(0, 0, 0, .55) !important; color: #fff !important; border-radius: 50%; }
.cm-chip.busy { opacity: .7; }
.cm-spin { position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.cm-tools { display: inline-flex; gap: 2px; }
.comment-actions { gap: 8px; }
.comment-actions .cm-hint { flex: 1; text-align: end; }
.rec-bar { display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 8px 12px; border: 1px solid var(--danger); border-radius: 10px; background: color-mix(in srgb, var(--danger) 8%, var(--panel)); font-weight: 600; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s ease-in-out infinite; }
.rec-time { font-variant-numeric: tabular-nums; }
.rec-on { color: var(--danger) !important; }
.comment.new.drop .comment-b { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 10px; }
.modal.lightbox { width: auto; max-width: 96vw; background: transparent; box-shadow: none; }
.modal.lightbox .modal-body { padding: 0; overflow: auto; }
.lightbox-img { display: block; max-width: 94vw; max-height: 90vh; border-radius: 10px; cursor: zoom-out; }

/* ---------- single-table sections ---------- */
.tb-card.single { border-radius: 12px; }

/* ---------- voice player ---------- */
.vp { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; padding-inline: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); max-width: 300px; min-width: 200px; }
.vp-btn { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; cursor: pointer; }
.vp-btn .ico { width: 14px; height: 14px; }
.vp-bars { flex: 1; display: flex; align-items: center; gap: 2px; height: 28px; cursor: pointer; min-width: 0; }
.vp-bars span { flex: 1; min-width: 2px; border-radius: 2px; background: color-mix(in srgb, var(--muted) 55%, transparent); transition: background .1s; }
.vp-bars span.on { background: var(--accent); }
.vp-time { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 32px; text-align: center; }
.cm-chip .vp { border: 0; min-width: 210px; padding-inline-end: 30px; }

/* ---------- recording bar ---------- */
.rec-bar { display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-height: 0; padding: 10px 12px; }
.rec-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rec-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 26px; min-width: 0; overflow: hidden; }
.rec-wave span { flex: 1; min-width: 2px; border-radius: 2px; background: var(--danger); transition: height .1s; }
.rec-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }

/* ---------- comments panel: list scrolls, the comment box stays below it ---------- */
.dr-side-body { padding: 0; overflow: hidden; }
.dr-side-body .comments { height: 100%; display: flex; flex-direction: column; gap: 0; }
.dr-side .cm-list { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.dr-side .comment.new { position: static; margin: 0; padding: 10px 14px 14px; border-top: 1px solid var(--line); background: var(--panel-2); flex: none; max-height: 60%; overflow-y: auto; }
.comments:not(.dr-side .comments) .cm-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }

/* ---------- @mentions ---------- */
.mention { color: var(--accent); font-weight: 600; background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 6px; padding: 0 3px; unicode-bidi: isolate; }
.mention.me { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.mention-list { display: flex; flex-direction: column; gap: 2px; padding: 4px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); max-height: 220px; overflow-y: auto; box-shadow: 0 6px 20px rgb(0 0 0 / .18); }
.mention-list[hidden] { display: none; }
.mention-h { padding: 4px 8px 2px; }
.mention-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.mention-item .avatar { width: 24px; height: 24px; font-size: 11px; }
.mention-item:hover, .mention-item.on { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.cm-at { font-weight: 700; font-size: 15px; }

.dr-side .cm-hint { visibility: hidden; } /* narrow panel: the hint is on the Send button's tooltip */
