:root {
  --primary: #4b5563;
  --primary-hover: #374151;
  --accent: #6b7280;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --sidebar: #111827;
  --sidebar-text: #e5e7eb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); }
button { font-family: inherit; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s;
}
.btn:hover { background: var(--primary-hover); }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: #dc2626; }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(75, 85, 99, 0.12);
}
textarea { resize: vertical; min-height: 80px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

/* ---------- Login ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--surface);
  width: 100%;
  max-width: 400px;
  padding: 32px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card .sub { color: var(--muted); margin-bottom: 24px; }
.auth-lang { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.lang-btn {
  padding: 5px 12px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 20px; cursor: pointer; font-size: 13px; color: var(--muted);
}
.lang-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.msg { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.msg.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.msg.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font-size: 13px; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  flex-shrink: 0;
}
.sidebar .brand { font-size: 18px; font-weight: 700; padding: 8px 12px 18px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 10px 12px; border-radius: var(--radius); color: var(--sidebar-text);
  cursor: pointer; text-decoration: none; font-size: 14px; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); }
.nav-item.active { background: rgba(255, 255, 255, 0.16); }
.nav-badge { background: #dc2626; color: #fff; border-radius: 20px; padding: 1px 7px; font-size: 11px; }
.act-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: #dc2626; margin-left: 8px; vertical-align: middle; flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.18);
}
.act-dot[hidden] { display: none; }
.sidebar-footer { margin-top: auto; }
.sidebar-lang { display: flex; gap: 4px; padding: 8px 12px; }

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main { flex: 1; padding: 24px 28px; overflow-x: auto; }

/* Mobile top bar + drawer machinery (hidden on desktop) */
.mobile-topbar { display: none; }
.nav-backdrop { display: none; }
.hamburger {
  background: none; border: none; color: var(--sidebar-text);
  font-size: 22px; cursor: pointer; padding: 6px 10px; line-height: 1;
}
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 20px; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); cursor: pointer; transition: transform 0.1s, box-shadow 0.1s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.card .desc { color: var(--muted); font-size: 13px; margin-bottom: 12px; min-height: 18px; }
.card .stats { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.card .stats b { color: var(--text); }

/* ---------- Table ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: var(--bg); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); font-size: 13px; }

/* Dual-timezone timestamps (Moscow / Beijing).
   The whole stamp may wrap onto several lines, but each "time + zone" chunk
   stays together so it never breaks mid-value or overflows its tile. */
.dt { white-space: normal; word-break: normal; overflow-wrap: anywhere; }
.dt-part { white-space: nowrap; display: inline-block; }
.dt b { font-weight: 600; }
.tzc {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  padding: 0 5px; border-radius: 6px; background: var(--bg); color: var(--muted);
  border: 1px solid var(--border); vertical-align: middle;
}
.tzc.cn { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.st-open { background: #e0e7ff; color: #3730a3; }
.st-in_progress { background: #dbeafe; color: #1e40af; }
.st-need_info { background: #fef3c7; color: #92400e; }
.st-resolved { background: #d1fae5; color: #065f46; }
.st-closed { background: #e5e7eb; color: #374151; }
.pr-blocker, .pr-critical { color: #dc2626; font-weight: 600; }
.pr-major { color: #ea580c; }
.pr-normal { color: var(--text); }
.pr-minor, .pr-trivial { color: var(--muted); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 80; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px;
  padding: 24px; box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.modal.wide { max-width: 860px; }
.modal h3 { margin: 0 0 18px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Task detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 280px; gap: 20px; }
.detail-main { display: flex; flex-direction: column; gap: 18px; }
.detail-side .side-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.detail-side .side-block h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.03em; }
.kv { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 5px 0; font-size: 13px; }
.kv .k { color: var(--muted); flex-shrink: 0; }
.kv > span:last-child { text-align: right; min-width: 0; }
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.section h4 { margin: 0 0 12px; font-size: 15px; }
.comment { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment .head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.comment .author { font-weight: 600; }
.comment .time { color: var(--muted); font-size: 12px; }
.comment .body { white-space: pre-wrap; }
.hist-item { font-size: 13px; color: var(--muted); padding: 5px 0; }
.hist-item b { color: var(--text); }
.attach-item { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.attach-item:last-child { border-bottom: none; }

/* Inline media attachments — messenger-style cards */
.att-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.att-card {
  width: 280px; max-width: 100%;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); overflow: hidden; box-shadow: var(--shadow);
}
.att-card .att-thumb {
  display: block; width: 100%; max-height: 220px; object-fit: cover; background: #f0f1f3;
}
.att-card img.att-thumb { cursor: zoom-in; }
.att-card video.att-thumb { background: #000; height: auto; max-height: 240px; }
.att-card.doc .att-docicon { font-size: 30px; padding: 16px 14px 4px; }
.att-fallback { display: none; padding: 22px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.att-card.broken .att-thumb { display: none; }
.att-card.broken .att-fallback { display: block; }
.att-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; font-size: 12px; border-top: 1px solid var(--border);
}
.att-card.doc .att-foot { border-top: none; }
.att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { color: var(--muted); flex-shrink: 0; }
.att-dl {
  flex-shrink: 0; text-decoration: none; font-size: 15px; line-height: 1;
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--surface);
}
.att-dl:hover { background: var(--bg); }
.att-del { font-size: 13px; color: var(--muted); }
.att-del:hover { color: #dc2626; border-color: #fecaca; background: #fef2f2; }

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { display: none; }
.switch .sl {
  position: absolute; inset: 0; background: var(--border); border-radius: 24px;
  cursor: pointer; transition: background 0.2s;
}
.switch .sl:before {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch input:checked + .sl { background: var(--primary); }
.switch input:checked + .sl:before { transform: translateX(20px); }
.nav-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border);
}
.nav-toggle-row:last-of-type { border-bottom: none; }

/* ---------- Smart translator ---------- */
.tr-state {
  font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.15); color: var(--sidebar-text); flex-shrink: 0;
}
.tr-state.on { background: #16a34a; color: #fff; }
.tr-preview {
  margin-top: 8px; font-size: 13px; color: var(--muted);
  background: var(--bg); border: 1px dashed var(--border);
  padding: 8px 12px; border-radius: 8px; white-space: pre-wrap;
}

/* ---------- Avatars ---------- */
.ava {
  border-radius: 50%; object-fit: cover; flex-shrink: 0; vertical-align: middle;
  display: inline-flex; align-items: center; justify-content: center;
}
.ava-init { color: #fff; font-weight: 700; user-select: none; }
.ulab { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }

/* ---------- Chat ---------- */
.chat-wrap {
  display: flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); overflow: hidden;
  height: calc(100vh - 140px); min-height: 420px;
}
.chat-list { width: 270px; border-right: 1px solid var(--border); overflow-y: auto; flex-shrink: 0; }
.conv-item {
  display: flex; gap: 10px; align-items: center; padding: 10px 12px;
  cursor: pointer; border-bottom: 1px solid var(--border);
}
.conv-item:hover { background: var(--bg); }
.conv-item.active { background: var(--bg); box-shadow: inset 3px 0 0 var(--primary); }
.conv-info { flex: 1; min-width: 0; }
.conv-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-preview { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; gap: 10px; align-items: flex-start; }
.chat-msg .bubble {
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 8px 12px; max-width: 78%; min-width: 0;
}
.chat-msg.own .bubble { background: #eef2ff; }
.chat-msg .m-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 2px; }
.chat-msg .m-author { font-weight: 600; font-size: 13px; }
.chat-msg .m-time { font-size: 11px; color: var(--muted); }
.chat-msg .m-body { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
/* Telegram-style composer: paperclip + rounded input + round send button */
.chat-composer {
  border-top: 1px solid var(--border); padding: 8px 10px;
  display: flex; gap: 8px; align-items: flex-end; background: var(--surface);
}
.chat-composer textarea {
  flex: 1; min-height: 42px; max-height: 120px; border-radius: 21px;
  padding: 10px 14px; resize: none; line-height: 1.4;
}
.attach-btn {
  position: relative; width: 42px; height: 42px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 19px; cursor: pointer; flex-shrink: 0;
  background: var(--bg); border: 1px solid var(--border); color: var(--muted);
}
.attach-btn:hover { background: var(--border); }
.attach-btn.has-files { background: #dcfce7; border-color: #86efac; }
.attach-count {
  position: absolute; top: -4px; right: -4px; background: #dc2626; color: #fff;
  border-radius: 10px; font-size: 11px; font-weight: 700; padding: 0 5px;
  min-width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center;
}
.attach-count[hidden] { display: none; }
.send-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--primary); color: #fff; font-size: 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.send-btn:hover { background: var(--primary-hover); }
.send-btn:disabled { opacity: 0.6; }
.chat-side { width: 280px; border-left: 1px solid var(--border); overflow-y: auto; flex-shrink: 0; padding: 12px; }
.chat-side .tabs { margin-bottom: 12px; }
.chat-side .tab { padding: 7px 10px; font-size: 13px; }
.cs-item { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cs-item:last-child { border-bottom: none; }
.chat-header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.chat-header .ch-name { font-weight: 700; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: #dc2626; flex-shrink: 0; }
.sr-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.sr-item .m-time { font-size: 11px; color: var(--muted); }

/* Header buttons: back (phone) and info/side-panel toggle (narrow screens) */
.chat-back, .chat-info {
  display: none; background: none; border: none; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--text); padding: 4px 8px; border-radius: 8px;
}
.chat-back:hover, .chat-info:hover { background: var(--bg); }

/* Tablets: side panel hidden behind the ⓘ toggle */
@media (max-width: 980px) {
  .chat-side { display: none; }
  .chat-info { display: inline-flex; }
  .chat-wrap.side-open .chat-side { display: block; }
}

/* Phones: messenger flow — full-screen list, tap -> full-screen conversation */
@media (max-width: 860px) {
  /* iOS Safari auto-zooms the page when focusing a field with font-size < 16px.
     16px on form controls prevents that zoom (and the layout jump it causes). */
  input, select, textarea { font-size: 16px; }

  .chat-wrap { height: calc(100vh - 150px); min-height: 380px; }
  .chat-list { width: 100%; border-right: none; }
  .chat-main { display: none; }
  .chat-side { display: none; border-left: none; width: 100%; }
  .conv-item { padding: 13px 14px; }        /* bigger touch targets */
  .conv-name { font-size: 15px; }
  .conv-preview { font-size: 13px; }

  /* Open conversation = full-screen overlay (like a native messenger):
     only the message list scrolls, the composer is always pinned above
     the keyboard (dvh follows the visual viewport). */
  .chat-wrap.conv-open {
    position: fixed; inset: 0; z-index: 60;
    height: 100vh; height: 100dvh;
    flex-direction: column; border: none; border-radius: 0; box-shadow: none;
    min-height: 0;
  }
  .chat-wrap.conv-open .chat-list { display: none; }
  .chat-wrap.conv-open .chat-main { display: flex; flex: 1; min-height: 0; }
  .chat-wrap.conv-open .chat-back { display: inline-flex; }
  /* ⓘ panel replaces the message area but keeps the header (with the toggle) */
  .chat-wrap.conv-open.side-open .chat-main { flex: 0 0 auto; }
  .chat-wrap.conv-open.side-open .chat-msgs,
  .chat-wrap.conv-open.side-open .chat-composer { display: none; }
  .chat-wrap.conv-open.side-open .chat-side { display: block; flex: 1; overflow-y: auto; }
}

/* Comment edit/delete actions */
.c-act {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 14px; padding: 2px 4px; line-height: 1; border-radius: 6px;
}
.c-act:hover { color: var(--text); background: var(--bg); }
.c-act-del:hover { color: #dc2626; }
.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.9);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  cursor: zoom-out; padding: 24px;
}
.lightbox img { max-width: 96%; max-height: 96%; border-radius: 8px; }
.comment .att-grid { margin-top: 8px; }
.chip-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); }
.chip-check { display: flex; align-items: center; gap: 8px; }
.chip-check input { width: auto; }
.chip-check label { margin: 0; color: var(--text); }
.muted { color: var(--muted); }
.empty-state { text-align: center; color: var(--muted); padding: 48px 16px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; }
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.tab { padding: 9px 16px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); }
.tab.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.color-field { display: flex; align-items: center; gap: 10px; }
.color-field input[type=color] { width: 46px; height: 38px; padding: 2px; cursor: pointer; }
.color-field .cf-label { flex: 1; }

/* ---------- Tags ---------- */
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600;
  color: #fff; white-space: nowrap;
}
.tag-chip .x { cursor: pointer; opacity: 0.8; font-weight: 700; }
.tag-chip .x:hover { opacity: 1; }
.tag-toggle {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.tag-toggle.on { color: #fff; border-color: transparent; }
.tag-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.task-tags { display: inline-flex; gap: 4px; margin-left: 8px; vertical-align: middle; }

/* ---------- Observer highlight ---------- */
.observer-label {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fef3c7; color: #92400e; border: 1px solid #fbbf24;
  padding: 1px 8px; border-radius: 20px; font-weight: 600;
}
.observer-row { background: #fffbeb !important; }
.observer-row:hover { background: #fef3c7 !important; }
tbody tr.observer-row td:first-child { box-shadow: inset 3px 0 0 #f59e0b; }

/* ---------- Checklist ---------- */
.checklist-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.checklist-item:last-child { border-bottom: none; }
.checklist-item input[type=checkbox] { width: 18px; height: 18px; flex-shrink: 0; }
.checklist-item .ci-text { flex: 1; }
.checklist-item .ci-text.done { text-decoration: line-through; color: var(--muted); }
.checklist-item .ci-del { cursor: pointer; color: var(--muted); border: none; background: none; font-size: 16px; }
.checklist-item .ci-del:hover { color: #dc2626; }
.progress-bar { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 4px 0 12px; }
.progress-bar > span { display: block; height: 100%; background: var(--primary); transition: width 0.2s; }
.add-inline { display: flex; gap: 8px; margin-top: 10px; }
.add-inline input { flex: 1; }

/* =========================================================================
   Mobile / tablet (≤ 860px): drawer navigation + card-style tables.
   Everything keeps its original scale — content reflows into a single
   readable column instead of shrinking.
   ========================================================================= */
@media (max-width: 860px) {
  html, body { overflow-x: hidden; }

  /* ----- Navigation becomes an off-canvas drawer ----- */
  .content { width: 100%; }
  .main { padding: 16px; overflow-x: hidden; }

  .mobile-topbar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 30;
    background: var(--sidebar); color: var(--sidebar-text);
    padding: 10px 12px;
  }
  .mobile-topbar .mtb-title { font-size: 17px; font-weight: 700; }

  .sidebar {
    position: fixed; top: 0; left: 0; height: 100%; width: 82%; max-width: 300px;
    z-index: 50; transform: translateX(-100%);
    transition: transform 0.25s ease; box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }
  .layout.nav-open .sidebar { transform: translateX(0); }

  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(0, 0, 0, 0.5); opacity: 0; pointer-events: none;
    transition: opacity 0.25s;
  }
  .layout.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

  .nav-item { padding: 13px 14px; font-size: 15px; }  /* bigger touch targets */

  /* ----- Task detail: single column ----- */
  .detail-grid { grid-template-columns: 1fr; }

  /* ----- Toolbar / filters: full-width stacked controls ----- */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input, .toolbar select, .toolbar button { width: 100%; }

  /* ----- Forms: stack side-by-side fields ----- */
  .row { flex-direction: column; gap: 0; }
  .row > * { min-width: 0; }

  /* ----- Modals fill the screen comfortably ----- */
  .modal-overlay { padding: 12px; align-items: flex-start; }
  .modal, .modal.wide { max-width: 100%; padding: 18px; }

  /* ----- Tables turn into stacked cards (no horizontal squeeze) ----- */
  .panel { overflow: visible; }
  .panel table, .panel thead, .panel tbody, .panel tr, .panel td { display: block; width: 100%; }
  .panel thead { display: none; }
  .panel tr {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 12px; padding: 6px 2px;
  }
  .panel tbody tr:hover { background: var(--surface); }
  .panel td {
    border: none; padding: 8px 14px;
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    text-align: right;
  }
  .panel td::before {
    content: attr(data-label); color: var(--muted);
    font-weight: 600; font-size: 12px; text-align: left; flex-shrink: 0;
  }
  .panel td:empty { display: none; }
  .panel td[data-label=""] { justify-content: flex-end; }
  .task-tags { margin-left: 0; }
}

/* Extra-small phones */
@media (max-width: 420px) {
  .topbar h2 { font-size: 18px; }
  .grid { grid-template-columns: 1fr; }
}
