/* ============================================================
   MGMKurdish — Admin panel stylesheet
   ============================================================ */

@font-face { font-family: 'Bahij Helvetica Neue'; src: url('/fonts/BahijHelveticaNeue-Light.ttf') format('truetype'); font-weight: 300; font-display: swap; }
@font-face { font-family: 'Bahij Helvetica Neue'; src: url('/fonts/BahijHelveticaNeue-Roman.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Bahij Helvetica Neue'; src: url('/fonts/BahijHelveticaNeue-Bold.ttf')  format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --primary:      #074a47;
  --primary-dark: #052426;
  --primary-soft: #0a6b66;
  --accent:       #b6e2df;

  --bg:        #052426;
  --panel:     #0a3a37;
  --panel-2:   #07302d;
  --text:      #e9f5f3;
  --muted:     #8fb4b1;
  --border:    rgba(255,255,255,.08);
  --border-2:  rgba(255,255,255,.12);
  --danger:    #e65d6e;
  --ok:        #4cd1a6;
  --shadow:    0 6px 20px rgba(0,0,0,.25);

  --sidebar-w: 260px;
  --topbar-h:  60px;
  --radius:    12px;
}
[data-theme="light"] {
  --bg:       #f3f7f6;
  --panel:    #e3efed;
  --panel-2:  #d3e6e2;
  --text:     #052426;
  --muted:    #5b7572;
  --border:   rgba(0,0,0,.08);
  --border-2: rgba(0,0,0,.12);
  --shadow:   0 6px 20px rgba(0,0,0,.06);
}
/* Use a darker accent inside the main content area only, so headings/role
   rows stay readable on the pale tinted panels. The sidebar keeps its bright accent. */
[data-theme="light"] main,
[data-theme="light"] .content,
[data-theme="light"] .card { --accent: #074a47; }

/* Light mode: brand-green sidebar + light-green tinted panels */
[data-theme="light"] .sidebar {
  background: var(--primary);
  color: #fff;
  border-inline-end-color: rgba(0,0,0,.1);
}
[data-theme="light"] .sidebar nav a,
[data-theme="light"] .sidebar nav summary { color: #fff; }
[data-theme="light"] .sidebar nav a:hover,
[data-theme="light"] .sidebar nav summary:hover { background: rgba(255,255,255,.08); }
[data-theme="light"] .sidebar nav a.active,
[data-theme="light"] .sidebar nav details > summary.active,
[data-theme="light"] .sidebar nav details > a.active { background: var(--primary-dark); color: #fff; }
[data-theme="light"] .sidebar nav details[open] > summary { background: rgba(255,255,255,.06); }
[data-theme="light"] .sidebar nav details[open] { background: rgba(255,255,255,.04); }
[data-theme="light"] .sidebar .brand { border-bottom-color: rgba(255,255,255,.18); }
[data-theme="light"] .sidebar .brand .name { color: #fff; }
[data-theme="light"] .sidebar .brand .name b { color: var(--accent); }
[data-theme="light"] .sidebar nav .ico { color: var(--accent); }
[data-theme="light"] .sidebar .brand .logo-light { display: none; }
[data-theme="light"] .sidebar .brand .logo-dark  { display: inline-block; }

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; min-height: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: 'Bahij Helvetica Neue', 'Helvetica Neue', Arial, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ============ Layout ============================================== */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
/* CSS Grid + dir=rtl automatically reverses column order, so DO NOT override. */

main {
  display: flex;
  flex-direction: column;
  min-width: 0;          /* prevent grid blowout */
  overflow-x: hidden;
  grid-column: 2 / 3;
}

/* ============ Sidebar ============================================= */

.sidebar {
  background: var(--panel-2);
  border-inline-end: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  width: var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  z-index: 20;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.sidebar .brand img { height: 36px; width: 36px; object-fit: contain; }
.sidebar .brand .logo-light { display: none; }
[data-theme="light"] .sidebar .brand .logo-dark { display: none; }
[data-theme="light"] .sidebar .brand .logo-light { display: inline-block; }
.sidebar .brand .name { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.sidebar .brand .name b { color: var(--accent); font-weight: 700; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a,
.sidebar nav summary {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 14px;
  white-space: nowrap;
}
.sidebar nav a:hover,
.sidebar nav summary:hover { background: rgba(255,255,255,.05); }
.sidebar nav a.active { background: var(--primary); }
.sidebar nav details > summary::-webkit-details-marker,
.sidebar nav details > summary::marker { display: none; content: ''; }
.sidebar nav details[open] > summary { background: rgba(255,255,255,.04); }
.sidebar nav details > a {
  padding-inline-start: 42px;
  font-size: 13px;
  opacity: .85;
}
.sidebar nav .ico {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.sidebar nav .ico svg { width: 18px; height: 18px; stroke-width: 1.6; }
.sidebar nav .label { flex: 1; }

/* ============ Topbar ============================================== */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  height: var(--topbar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar .page-title {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .actions {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.topbar .me {
  font-size: 12px;
  color: var(--muted);
  padding: 0 6px;
  white-space: nowrap;
}
.topbar .me b { color: var(--text); font-weight: 600; }

.icon-btn {
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255,255,255,.06); border-color: var(--border-2); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.6; }

.lang-pills { display: inline-flex; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-pills a {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  border-inline-end: 1px solid var(--border);
}
.lang-pills a:last-child { border-inline-end: 0; }
.lang-pills a:hover { background: rgba(255,255,255,.05); color: var(--text); }
.lang-pills a.active { background: var(--primary); color: #fff; }

/* ============ Content ============================================= */

.content {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.alerts { display: grid; gap: 10px; padding: 0 18px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 700; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat .num { font-size: 26px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.stat .label { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ============ Forms / Buttons ===================================== */

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); }

.input, select, textarea {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
[data-theme="light"] .input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  background: rgba(255,255,255,.55);
  border-color: rgba(255,255,255,.7);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 1px 2px rgba(7,74,71,.04);
}
[data-theme="light"] .input::placeholder,
[data-theme="light"] textarea::placeholder { color: rgba(7,74,71,.45); }

/* Native <option> dropdown is rendered by the OS, not the page —
   force a readable solid background per theme so options aren't invisible. */
select option {
  background: #0f1d22;
  color: #e7eef0;
}
[data-theme="light"] select option {
  background: #ffffff;
  color: #0a2a28;
}
select optgroup {
  background: #0f1d22;
  color: #e7eef0;
  font-weight: 600;
}
[data-theme="light"] select optgroup {
  background: #f3f7f7;
  color: #0a2a28;
}

textarea { resize: vertical; min-height: 60px; }
.input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(10,107,102,.25);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  width: auto;
}
.btn:hover { background: var(--primary-soft); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: rgba(255,255,255,.05); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #d24858; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 12px;
}
.chip:hover { background: rgba(255,255,255,.05); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ============ Tables ============================================== */

.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: start;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(255,255,255,.03); }

/* ============ Alerts ============================================= */

.alert { padding: 10px 14px; border-radius: 10px; font-size: 13px; }
.alert.ok  { background: rgba(76,209,166,.12); border: 1px solid var(--ok); color: var(--ok); }
.alert.err { background: rgba(230,93,110,.12); border: 1px solid var(--danger); color: var(--danger); }

/* ============ Misc ================================================ */

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.inline { display: inline; }
.pill {
  padding: 2px 10px; border-radius: 999px; background: var(--panel-2);
  font-size: 11px; color: var(--muted);
}

/* ============ FAQ grid ============================================ */

.faq-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.faq-card {
  background: var(--panel-2);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.faq-card .cover { aspect-ratio: 16/10; background: rgba(0,0,0,.3) center/cover; }
.faq-card .body { padding: 12px; }
.faq-card .q { font-weight: 700; margin-bottom: 6px; font-size: 14px; }
.faq-card .a { color: var(--muted); font-size: 13px; }

/* ============ Chat ================================================ */

.chat {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  height: calc(100vh - var(--topbar-h) - 36px);
}
.chat .rooms { background: var(--panel); border-radius: var(--radius); padding: 8px; overflow: auto; }
.chat .rooms a { display: block; padding: 9px 12px; border-radius: 8px; font-size: 13px; }
.chat .rooms a.active, .chat .rooms a:hover { background: rgba(255,255,255,.05); }
.chat .room { background: var(--panel); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; }
.chat .messages { flex: 1; padding: 14px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.chat .msg { max-width: 70%; padding: 8px 12px; border-radius: 14px; background: var(--panel-2); }
.chat .msg.me { align-self: flex-end; background: var(--primary); }
.chat .msg .who { font-size: 11px; opacity: .7; margin-bottom: 2px; }
.chat .msg .when { font-size: 10px; opacity: .6; margin-top: 2px; }
.chat .composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.chat .composer .input { flex: 1; }

/* New chat layout (members + room + composer) */
.chat-side { background: var(--panel); border-radius: var(--radius); padding: 10px; overflow: auto; }
.chat-side-title { margin: 4px 6px 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.chat-peer { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; }
.chat-peer:hover { background: rgba(255,255,255,.04); }
.chat-peer.active { background: var(--primary); color: #fff; }
.chat-peer-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.chat-peer-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chat-peer-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-peer-last { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-peer.active .chat-peer-last { color: rgba(255,255,255,.75); }
.chat-room { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: 10px; font-size: 13px; gap: 8px; }
.chat-room:hover { background: rgba(255,255,255,.05); }
.chat-room.active { background: var(--primary); color: #fff; }
.chat-room-count { font-size: 11px; opacity: .7; background: rgba(0,0,0,.25); padding: 2px 8px; border-radius: 999px; }
.chat-members { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.chat-members-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 0 6px 6px; }
.chat-member { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 13px; }
.chat-member:hover { background: rgba(255,255,255,.04); }
.chat-member-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.chat-member-name { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-member-role { font-size: 11px; color: var(--muted); }

.chat-main { background: var(--panel); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.chat-header { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.chat-header-name { font-weight: 700; font-size: 15px; }
.chat-header-sub  { font-size: 12px; color: var(--muted); margin-top: 2px; }

.chat .msg .text  { white-space: pre-wrap; word-break: break-word; }
.chat .msg .msg-img { max-width: 240px; border-radius: 10px; margin-top: 4px; display: block; }
.chat .msg audio  { max-width: 240px; margin-top: 4px; display: block; }

.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); align-items: center; }
.composer .icon-btn { flex-shrink: 0; }
.composer .icon-btn.rec { background: var(--danger); color: #fff; animation: rec-pulse 1s ease-in-out infinite; }
@keyframes rec-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(230,93,110,.6); } 50% { box-shadow: 0 0 0 10px rgba(230,93,110,0); } }
.chat-input { flex: 1; min-width: 0; }
.btn-send { flex-shrink: 0; }
.composer-preview { padding: 6px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); background: var(--panel-2); }

/* Settings sidebar: highlight summary when section active */
.sidebar nav details[open] > summary,
.sidebar nav details.open > summary { background: rgba(255,255,255,.04); }
.sidebar nav details[open] { background: rgba(255,255,255,.02); border-radius: 10px; }
.sidebar nav details > summary.active { background: var(--primary); color: #fff; }
.sidebar nav details > a.active { background: var(--primary); color: #fff; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 999; padding: 20px; backdrop-filter: blur(4px); }
.modal[hidden] { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; width: min(640px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }

/* Notifications */
.notif { position: relative; }
.notif-btn { position: relative; }
.notif-dot {
    position: absolute; top: -4px; inset-inline-end: -4px;
    min-width: 18px; height: 18px; padding: 0 5px;
    background: var(--danger); color: #fff;
    border-radius: 999px;
    font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg);
}
.notif-panel {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-end: 0;
    width: min(360px, 90vw);
    max-height: 70vh;
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 200;
    padding: 8px;
}
.notif-panel[hidden] { display: none; }
.notif-section + .notif-section { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.notif-section-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 6px 10px 8px; font-weight: 600; }
.notif-item {
    display: flex; gap: 8px; align-items: flex-start;
    padding: 9px 10px; border-radius: 8px;
}
.notif-item:hover { background: rgba(255,255,255,.04); }
.notif-link { display: flex; gap: 10px; align-items: flex-start; flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.notif-x {
    flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
    border: 1px solid var(--border); background: transparent; color: var(--muted);
    cursor: pointer; display: grid; place-items: center; font-size: 14px; line-height: 1;
    transition: background .15s, color .15s, border-color .15s;
}
.notif-x:hover { background: #ef4444; color: #fff; border-color: #ef4444; }
.notif-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.notif-head-title { font-weight: 700; font-size: 13px; }
.notif-clear-all {
    background: transparent; border: 1px solid var(--border); color: var(--muted);
    padding: 4px 10px; border-radius: 999px; cursor: pointer; font-size: 11px;
    transition: background .15s, color .15s, border-color .15s;
}
.notif-clear-all:hover { background: #ef4444; color: #fff; border-color: #ef4444; }
.notif-icon { flex-shrink: 0; width: 28px; height: 28px; border-radius: 8px; background: var(--panel-2); display: grid; place-items: center; color: var(--accent); }
.notif-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.notif-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.notif-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-sub { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-empty { padding: 10px; color: var(--muted); font-size: 12px; text-align: center; }
.notif-see-all {
    display: block; text-align: center;
    padding: 8px 10px; margin-top: 6px;
    font-size: 12px; font-weight: 600;
    color: var(--accent); text-decoration: none;
    border-radius: 8px;
}
.notif-see-all:hover { background: rgba(255,255,255,.05); }

/* Mobile: center notification panel on the viewport instead of anchoring under the bell */
@media (max-width: 640px) {
    .notif { position: static; }
    .notif-panel {
        position: fixed;
        top: 64px;
        inset-inline-start: 50%;
        inset-inline-end: auto;
        transform: translateX(-50%);
        width: calc(100vw - 24px);
        max-width: 420px;
        max-height: calc(100vh - 84px);
    }
    [dir="rtl"] .notif-panel { transform: translateX(50%); }
}

/* ============ QR ================================================== */

.qr-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.qr-card {
  background: var(--panel); padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--border); text-align: center;
}
.qr-card img {
  width: 160px; height: 160px; object-fit: contain;
  background: #fff; border-radius: 10px; padding: 6px;
  margin: 0 auto;
}
.qr-card .name { font-weight: 700; margin: 6px 0 2px; }
.qr-card .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* ============ Hamburger / mobile sidebar ========================== */

.sidebar-backdrop { display: none; }
.hamburger { display: none; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  main { grid-column: 1 / 2; }

  /* Off-canvas sidebar */
  .sidebar {
    position: fixed;
    top: 0; bottom: 0;
    inset-inline-start: 0;
    width: 75vw;
    max-width: 320px;
    height: 100vh;
    max-height: 100vh;
    z-index: 1001;
    border-inline-end: 1px solid var(--border);
    border-bottom: none;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow);
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .layout.sidebar-open .sidebar { transform: translateX(0); }

  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .layout.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .hamburger { display: inline-flex; }

  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  /* Reset inline grid-column spans (used for desktop layout) so fields stack cleanly on mobile */
  .grid.cols-2 > [style*="grid-column"],
  .grid.cols-3 > [style*="grid-column"],
  .grid.cols-4 > [style*="grid-column"] { grid-column: 1 / -1 !important; }
  .topbar .me { display: none; }
  .chat { grid-template-columns: 1fr; height: auto; }
  .field label { white-space: normal; line-height: 1.35; }
  .field label > span { display: inline-block; }
  .role-dropdown .rd-menu { left: 0; right: 0; }
  /* iOS Safari: prevent auto-zoom on focus when input font-size < 16px */
  input, select, textarea, .input { font-size: 16px; }
}

/* ============ Print =============================================== */

@media print {
  .sidebar, .topbar, .actions, .btn, form button { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ============ Sidebar profile dropdown ============================ */
.sidebar { display: flex; flex-direction: column; }
/* Scroll the entire sidebar as one — keep nav, lang switcher, and logout in the same scroll flow. */
.sidebar nav { flex: 0 0 auto; overflow: visible; }

/* Themed scrollbar for the sidebar (replaces ugly default white/grey). */
.sidebar { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.18);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--primary); background-clip: padding-box; }
[data-theme="light"] .sidebar { scrollbar-color: rgba(0,0,0,.25) transparent; }
[data-theme="light"] .sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,.25); background-clip: padding-box; }
[data-theme="light"] .sidebar::-webkit-scrollbar-thumb:hover { background: var(--primary); background-clip: padding-box; }
.profile-card { position: relative; padding: .5rem .75rem; border-bottom: 1px solid var(--border, rgba(255,255,255,.08)); margin-bottom: .25rem; }
.profile-btn { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .65rem; background: transparent; border: 1px solid transparent; border-radius: 10px; color: inherit; cursor: pointer; text-align: start; }
.profile-btn:hover { background: rgba(255,255,255,.06); border-color: var(--border, rgba(255,255,255,.1)); }
[data-theme="light"] .profile-btn:hover { background: rgba(0,0,0,.04); }
.profile-avatar { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 50%; overflow: hidden; background: rgba(255,255,255,.1); display: inline-flex; align-items: center; justify-content: center; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar svg { width: 20px; height: 20px; opacity: .8; }
.profile-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.profile-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-branch { font-size: .72rem; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-chev { width: 14px; height: 14px; opacity: .6; flex-shrink: 0; }
.profile-menu { position: absolute; inset-inline-start: .75rem; inset-inline-end: .75rem; top: calc(100% - .25rem); background: var(--card, #1b1f2a); border: 1px solid var(--border, rgba(255,255,255,.1)); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.35); z-index: 30; padding: .3rem; }
[data-theme="light"] .profile-menu { background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.profile-menu form { margin: 0; }
.profile-menu-item { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .55rem .65rem; background: transparent; border: 0; color: inherit; cursor: pointer; border-radius: 8px; text-align: start; text-decoration: none; font: inherit; }
.profile-menu-item svg { width: 16px; height: 16px; }
.profile-menu-item:hover { background: rgba(255,255,255,.07); }
[data-theme="light"] .profile-menu-item:hover { background: rgba(0,0,0,.05); }
.profile-menu-item.danger { color: #ff6b6b; }

/* ============ Sidebar footer language dropdown =================== */
.sidebar-foot { padding: .5rem .75rem; border-top: 1px solid var(--border, rgba(255,255,255,.08)); position: relative; }
.lang-select { position: relative; }
.lang-btn { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .5rem .65rem; background: transparent; border: 1px solid var(--border, rgba(255,255,255,.1)); border-radius: 10px; color: inherit; cursor: pointer; font: inherit; }
.lang-btn:hover { background: rgba(255,255,255,.05); }
[data-theme="light"] .lang-btn:hover { background: rgba(0,0,0,.04); }
.lang-btn svg { width: 16px; height: 16px; }
.lang-btn span { flex: 1; text-align: start; }
.lang-chev { opacity: .6; }
.lang-menu { position: absolute; inset-inline-start: 0; inset-inline-end: 0; bottom: calc(100% + .25rem); background: var(--card, #1b1f2a); border: 1px solid var(--border, rgba(255,255,255,.1)); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.35); padding: .3rem; z-index: 30; }
[data-theme="light"] .lang-menu { background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.lang-menu a { display: block; padding: .5rem .65rem; border-radius: 8px; color: inherit; text-decoration: none; }
.lang-menu a:hover { background: rgba(255,255,255,.07); }
[data-theme="light"] .lang-menu a:hover { background: rgba(0,0,0,.05); }
.lang-menu a.active { background: var(--accent, #2b6cf6); color: #fff; }

/* Sidebar logout button (below language switcher). */
.sidebar-logout-form { margin-top: .5rem; }
.sidebar-logout-btn {
    display: flex; align-items: center; gap: .5rem; width: 100%;
    padding: .5rem .65rem;
    background: transparent;
    border: 1px solid rgba(255, 80, 80, .35);
    border-radius: 10px;
    color: #ff6b6b;
    cursor: pointer; font: inherit;
    transition: background .12s, border-color .12s;
}
.sidebar-logout-btn:hover { background: rgba(255, 80, 80, .12); border-color: rgba(255, 80, 80, .6); }
.sidebar-logout-btn svg { width: 16px; height: 16px; }
.sidebar-logout-btn span { flex: 1; text-align: start; }
[data-theme="light"] .sidebar-logout-btn { color: #c0392b; border-color: rgba(192, 57, 43, .35); }
[data-theme="light"] .sidebar-logout-btn:hover { background: rgba(192, 57, 43, .08); border-color: rgba(192, 57, 43, .6); }

/* Privacy button in sidebar foot — neutral (not destructive). */
.sidebar-privacy-btn {
    margin-bottom: .5rem;
    color: var(--text, #e7eef0);
    border-color: var(--border, rgba(255,255,255,.14));
}
.sidebar-privacy-btn:hover {
    background: rgba(255,255,255,.06);
    border-color: rgba(255,255,255,.28);
}
[data-theme="light"] .sidebar-privacy-btn {
    color: #1f2937;
    border-color: rgba(0,0,0,.14);
}
[data-theme="light"] .sidebar-privacy-btn:hover {
    background: rgba(0,0,0,.04);
    border-color: rgba(0,0,0,.28);
}

/* ============ Staff grid cards =================================== */
.staff-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.staff-card { display: flex; flex-direction: column; align-items: center; padding: 1.1rem .8rem; background: var(--card, #1b1f2a); border: 1px solid var(--border, rgba(255,255,255,.08)); border-radius: 14px; color: inherit; text-decoration: none; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; text-align: center; }
[data-theme="light"] .staff-card { background: #fff; }
.staff-card:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(0,0,0,.18); border-color: var(--accent, #2b6cf6); }
.staff-card .avatar { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; background: rgba(255,255,255,.08); display: inline-flex; align-items: center; justify-content: center; margin-bottom: .55rem; font-weight: 700; font-size: 1.4rem; color: #fff; }
.staff-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.staff-card .name { font-weight: 600; margin-bottom: .15rem; }
.staff-card .meta { font-size: .78rem; opacity: .75; }
.staff-card .badges { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: center; margin-top: .45rem; }
.staff-card .dot-on { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #2ecc71; margin-inline-end: .3rem; }
.staff-card .dot-off { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #888; margin-inline-end: .3rem; }
.avatar-initials { width: 100%; height: 100%; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #2b6cf6, #6f3df6); color: #fff; font-weight: 700; }

/* ============ Role chips (multi-role picker) ====================== */
.role-chips { display: flex; flex-wrap: wrap; gap: .35rem; padding: .4rem 0; }
.role-chips .chip { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .6rem; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); cursor: pointer; font-size: .8rem; user-select: none; transition: background .12s, border-color .12s; }
.role-chips .chip:hover { background: rgba(255,255,255,.1); }
.role-chips .chip input { accent-color: var(--primary, #0f8b87); margin: 0; }
.role-chips .chip:has(input:checked) { background: rgba(15,139,135,.22); border-color: var(--primary, #0f8b87); }
[data-theme="light"] .role-chips .chip { background: #f3f8f7; border-color: rgba(7,74,71,.16); }
[data-theme="light"] .role-chips .chip:hover { background: #e9efee; }
[data-theme="light"] .role-chips .chip:has(input:checked) { background: rgba(7,74,71,.12); border-color: var(--primary, #0f8b87); }

/* ============ Role dropdown (multi-role picker as dropdown) ======== */
.role-dropdown { position: relative; }
.role-dropdown > summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    padding: .65rem .9rem; min-height: 42px;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 10px; color: inherit; font-size: .9rem;
    user-select: none; transition: border-color .12s, background .12s;
}
.role-dropdown > summary::-webkit-details-marker { display: none; }
.role-dropdown > summary:hover { background: rgba(255,255,255,.06); }
.role-dropdown[open] > summary { border-color: var(--primary, #0f8b87); background: rgba(15,139,135,.08); }
.role-dropdown .rd-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .9; }
.role-dropdown .rd-caret { transition: transform .15s; opacity: .65; font-size: .85rem; }
.role-dropdown[open] .rd-caret { transform: rotate(180deg); opacity: 1; }
.role-dropdown .rd-menu {
    position: absolute; inset-inline-start: 0; inset-inline-end: 0; top: calc(100% + 6px);
    z-index: 30;
    max-height: 320px; overflow: auto;
    background: var(--card, #1b1f2a);
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.45);
    padding: .5rem;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .35rem;
}
.role-dropdown .rd-item {
    display: flex; align-items: center; gap: .55rem;
    padding: .5rem .7rem; border-radius: 8px;
    cursor: pointer; font-size: .85rem;
    background: rgba(255,255,255,.03);
    border: 1px solid transparent;
    transition: background .12s, border-color .12s;
}
.role-dropdown .rd-item:hover { background: rgba(255,255,255,.08); }
.role-dropdown .rd-item input { accent-color: var(--primary, #0f8b87); margin: 0; flex: 0 0 auto; }
.role-dropdown .rd-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-dropdown .rd-item:has(input:checked) {
    background: rgba(15,139,135,.22);
    border-color: var(--primary, #0f8b87);
    color: #fff;
}
[data-theme="light"] .role-dropdown > summary { background: #f3f8f7; border-color: rgba(7,74,71,.16); }
[data-theme="light"] .role-dropdown > summary:hover { background: #eaf2f1; }
[data-theme="light"] .role-dropdown[open] > summary { background: rgba(7,74,71,.08); }
[data-theme="light"] .role-dropdown .rd-menu { background: #fff; border-color: rgba(7,74,71,.18); }
[data-theme="light"] .role-dropdown .rd-item { background: #f7faf9; }
[data-theme="light"] .role-dropdown .rd-item:hover { background: #ebf2f1; }
[data-theme="light"] .role-dropdown .rd-item:has(input:checked) { background: rgba(7,74,71,.12); color: #062e2c; }
@media (max-width: 640px) {
    .role-dropdown .rd-menu { grid-template-columns: 1fr 1fr; }
}

/* ============ Staff detail page =================================== */
.staff-header { display: flex; align-items: center; gap: 1rem; padding: 1rem; flex-wrap: wrap; }
.staff-header .avatar { width: 90px; height: 90px; border-radius: 50%; overflow: hidden; background: rgba(255,255,255,.08); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.staff-header .avatar img { width: 100%; height: 100%; object-fit: cover; }
.staff-header h2 { margin: 0; word-break: break-word; }
.staff-header .meta { font-size: .85rem; opacity: .75; margin-top: .25rem; word-break: break-word; }
@media (max-width: 640px) {
    .staff-header { gap: .6rem; padding: .75rem; }
    .staff-header .avatar { width: 64px; height: 64px; }
    .staff-header h2 { font-size: 1.05rem; }
    .staff-header .meta { font-size: .78rem; }
    .staff-header > a.btn { margin-inline-start: auto; }
}

/* ============ Attendance enhancements ============================= */
.att-badge { display: inline-block; padding: .12rem .45rem; border-radius: 8px; font-size: .72rem; background: rgba(43,108,246,.18); color: #5b8cff; }
.att-badge.extra { background: rgba(255,165,0,.18); color: #ffb84d; }
.att-badge.break { background: rgba(46,204,113,.18); color: #2ecc71; }
.btn-mini { padding: .25rem .5rem; font-size: .75rem; border-radius: 6px; }

/* ============ Print refinement ==================================== */
@media print {
  @page { size: A4; margin: 12mm 10mm; }
  html, body { background: #fff !important; color: #000 !important; }
  .topbar, .actions, .btn, .filters, .lang-select, .profile-card,
  .sidebar, .sidebar-backdrop, .sidebar-foot, .no-print { display: none !important; }
  .layout { display: block !important; grid-template-columns: 1fr !important; }
  main, .content, .card { margin: 0 !important; padding: 0 !important; background: #fff !important; box-shadow: none !important; border: 0 !important; color: #000 !important; }
  .alerts { display: none !important; }
  h1, h2, h3 { color: #000 !important; margin: 4px 0 8px !important; }
  table { width: 100% !important; border-collapse: collapse !important; font-size: 10.5pt !important; color: #000 !important; background: #fff !important; }
  table th, table td { border: 1px solid #444 !important; padding: 5px 7px !important; vertical-align: middle !important; background: #fff !important; color: #000 !important; }
  table thead th { background: #eee !important; font-weight: 700 !important; }
  table tr { page-break-inside: avoid; }
  .att-badge, .att-badge.extra, .att-badge.break { background: transparent !important; color: #000 !important; border: 1px solid #888 !important; }
  .print-only { display: block !important; }
  .print-header { display: flex !important; justify-content: space-between; align-items: center; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 10px; }
  .print-header h1 { font-size: 14pt !important; margin: 0 !important; }
  .print-header .meta { font-size: 9pt; color: #333; }
  a { color: #000 !important; text-decoration: none !important; }
}
.print-only { display: none; }

/* ============ Topbar language + notif dropdown =================== */
.topbar-lang { position: relative; }
.topbar-menu { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; background: var(--card, #1b1f2a); border: 1px solid var(--border, rgba(255,255,255,.1)); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.35); padding: .35rem; min-width: 150px; z-index: 50; }
[data-theme="light"] .topbar-menu { background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.12); }
.topbar-menu a { display: block; padding: .55rem .7rem; border-radius: 8px; color: inherit; text-decoration: none; }
.topbar-menu a:hover { background: rgba(255,255,255,.07); }
[data-theme="light"] .topbar-menu a:hover { background: rgba(0,0,0,.05); }
.topbar-menu a.active { background: var(--accent, #2b6cf6); color: #fff; }

/* ============ Toasts ============================================== */
.toast-host { position: fixed; top: 70px; inset-inline-end: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; pointer-events: none; }
.toast { display: inline-flex; align-items: center; gap: .55rem; padding: .7rem 1rem; background: var(--card, #1b1f2a); color: inherit; border: 1px solid var(--border, rgba(255,255,255,.1)); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.35); transform: translateX(20px); opacity: 0; transition: transform .25s ease, opacity .25s ease; min-width: 220px; max-width: 340px; }
[data-theme="light"] .toast { background: #fff; box-shadow: 0 12px 32px rgba(0,0,0,.15); }
.toast.show { transform: translateX(0); opacity: 1; }
[dir="rtl"] .toast { transform: translateX(-20px); }
[dir="rtl"] .toast.show { transform: translateX(0); }
.toast svg { flex-shrink: 0; color: var(--accent, #2b6cf6); }

/* Force dropdown menus to honor the hidden attribute even if a flex parent
   tries to inherit display values. */
.topbar-menu[hidden],
.profile-menu[hidden],
.lang-menu[hidden] { display: none !important; }

/* ============ Task feed (Twitter/Facebook style) ================== */
.task-feed { display: flex; flex-direction: column; gap: 14px; }
/* Responsive grid for tasks */
.grid-feed {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 1150px) {
  .grid-feed { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1400px) {
  .grid-feed { grid-template-columns: 1fr 1fr 1fr; }
}
.grid-feed > .task-post,
.grid-feed > .card { min-width: 0; }

/* Range filter popover */
.range-popover { position: relative; display: inline-block; }
.range-popover > summary {
    list-style: none; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 8px;
    background: var(--panel-2); color: inherit;
    border: 1px solid var(--border); font-size: 13px;
    white-space: nowrap;
}
.range-popover > summary::-webkit-details-marker { display: none; }
.range-popover > summary::marker { content: ''; }
.range-popover > summary:hover { background: rgba(255,255,255,.05); }
.range-popover .range-panel {
    position: absolute; z-index: 60;
    top: calc(100% + 6px);
    inset-inline-start: 0;
    min-width: 240px;
    padding: 10px;
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.35);
    display: flex; flex-direction: column; gap: 8px;
}
.range-popover .range-panel label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.range-popover .range-panel input[type="date"] { font: inherit; padding: 6px 8px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); color: inherit; }

.task-post { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.task-post .tp-head { display: flex; gap: 10px; align-items: center; }
.task-post .tp-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--accent, #2b6cf6); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px; flex-shrink: 0; text-transform: uppercase;
}
.task-post .tp-avatar-sm { width: 30px; height: 30px; font-size: 13px; }
.task-post .tp-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.task-post .tp-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.task-post .tp-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.task-post .tp-arrow { color: var(--muted); }
.task-post .tp-to { color: var(--muted); }
.task-post .tp-sub { display: flex; gap: 6px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.task-post .tp-title { margin: 0; font-size: 16px; font-weight: 700; min-width: 0; }
.task-post .tp-title a { color: inherit; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 1150px) {
    .task-post .tp-title a { white-space: normal; overflow: visible; text-overflow: clip; }
}
.task-post .tp-body { white-space: pre-wrap; margin: 0; line-height: 1.55; }
.task-post .tp-body-wrap { display: flex; flex-direction: column; gap: 4px; }
.task-post .tp-body.is-clampable.is-clamped {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
}
.task-post .tp-see-more {
    align-self: flex-start;
    background: transparent; border: 0; padding: 0;
    color: #fb923c; font-weight: 800; cursor: pointer; font: inherit; font-size: 13px;
    font-weight: 800;
    text-shadow: 0 0 1px rgba(0,0,0,.25);
}
[data-theme="light"] .task-post .tp-see-more {
    color: #ea580c;
    text-shadow: none;
}
[data-theme="light"] .task-post .tp-see-more:hover { color: #c2410c; }
.task-post .tp-see-more:hover { text-decoration: underline; }
.task-post .tp-chips { display: flex; gap: 6px; flex-wrap: wrap; }

.task-post .tp-media {
    display: grid; gap: 4px; border-radius: 12px; overflow: hidden;
    border: 1px solid var(--border); background: rgba(0,0,0,.2);
    width: 100%;
}
.task-post .tp-media-1 { grid-template-columns: 1fr; }
.task-post .tp-media-2 { grid-template-columns: 1fr 1fr; }
.task-post .tp-media-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.task-post .tp-media-3 .tp-media-cell:first-child { grid-row: span 2; }
.task-post .tp-media-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.task-post .tp-media-cell {
    position: relative; display: block; aspect-ratio: 1/1; overflow: hidden;
    max-height: 260px; cursor: zoom-in;
}
.task-post .tp-media-1 .tp-media-cell { aspect-ratio: auto; width: 100%; max-height: 360px; }
.task-post .tp-media-1 .tp-media-cell img { width: 100%; height: 100%; max-height: 360px; object-fit: cover; display: block; }
.task-post .tp-media-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.task-post .tp-media-more {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.55); color: #fff; font-size: 22px; font-weight: 700;
}

.task-post .tp-audio { width: 100%; margin: 0; }
.task-post .tp-files { display: flex; gap: 6px; flex-wrap: wrap; }

.task-post .tp-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--border); padding-top: 10px; }
.task-post .tp-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
    background: transparent; color: inherit; cursor: pointer; font: inherit; font-size: 13px;
    text-decoration: none;
}
.task-post .tp-btn:hover { background: rgba(255,255,255,.06); }
[data-theme="light"] .task-post .tp-btn:hover { background: rgba(0,0,0,.05); }
.task-post .tp-btn-primary { background: var(--accent, #2b6cf6); color: #fff; border-color: transparent; }
.task-post .tp-btn-success { background: #16a34a; color: #fff; border-color: transparent; }
.task-post .tp-btn-danger  { background: #dc2626; color: #fff; border-color: transparent; }
.task-post .tp-btn-danger-ghost { color: #dc2626; }
.task-post .tp-btn-ghost { color: var(--muted); }

/* Inline dropdown menu (uses <details>/<summary>). Works for both card and show page. */
.tp-menu { position: relative; display: inline-block; }
.tp-menu > summary { list-style: none; cursor: pointer; }
.tp-menu > summary::-webkit-details-marker { display: none; }
.tp-menu > summary::marker { content: ''; }
.tp-menu-list {
    position: absolute; z-index: 50; top: calc(100% + 4px); inset-inline-end: 0;
    min-width: 180px; padding: 6px;
    background: var(--bg, #111); border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    display: flex; flex-direction: column; gap: 2px;
}
[data-theme="light"] .tp-menu-list { background: #fff; }
.tp-menu-item {
    display: block; width: 100%; text-align: start;
    padding: 8px 12px; border-radius: 8px; border: 0; background: transparent;
    color: inherit; cursor: pointer; font: inherit; font-size: 13px;
}
.tp-menu-item:hover { background: rgba(255,255,255,.06); }
[data-theme="light"] .tp-menu-item:hover { background: rgba(0,0,0,.05); }
.tp-menu-item-danger { color: #dc2626; }

.task-post .tp-replies { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.task-post .tp-reply { display: flex; gap: 8px; }
.task-post .tp-reply[hidden] { display: none; }
.task-post .tp-reply-body { flex: 1; min-width: 0; background: rgba(255,255,255,.04); border-radius: 12px; padding: 8px 12px; }
[data-theme="light"] .task-post .tp-reply-body { background: rgba(0,0,0,.04); }
.task-post .tp-reply-head { display: flex; gap: 8px; align-items: center; }
.task-post .tp-reply-head small { color: var(--muted); font-size: 11px; }
.task-post .tp-reply-body p { margin: 4px 0; white-space: pre-wrap; }

.task-post .tp-reply-form { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.task-post .tp-reply-form textarea { resize: vertical; }

@media (max-width: 640px) {
    .task-post { padding: 12px; }
    .task-post .tp-title { font-size: 15px; }
    .task-post .tp-media { border-radius: 10px; margin-inline: -12px; border-inline: 0; max-width: none; }
    .task-post .tp-media-cell { max-height: 200px; }
    .task-post .tp-media-1 .tp-media-cell { aspect-ratio: 4/3; max-height: 240px; }
}

/* Twitter-style reply thread (vertical connecting line) */
.task-post .tp-thread {
    position: relative;
    display: flex; flex-direction: column; gap: 12px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}
.task-post .tp-thread::before {
    content: "";
    position: absolute;
    top: 22px; bottom: 22px;
    inset-inline-start: 26px;
    width: 2px;
    background: var(--border);
    border-radius: 2px;
    pointer-events: none;
}
.task-post .tp-thread .tp-reply { position: relative; z-index: 1; }
.task-post .tp-thread .tp-avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.task-post .tp-reply-form-row .input { width: 100%; }
.task-post .tp-meta-count {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px; color: var(--muted); font-size: 13px;
}

/* Reply edit / delete icon buttons */
.task-post .tp-reply-actions .tp-btn-icon {
    padding: 4px; min-width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid transparent; border-radius: 8px;
}
.task-post .tp-reply-actions .tp-btn-icon:hover {
    background: rgba(255,255,255,.06); border-color: var(--border);
}
[data-theme="light"] .task-post .tp-reply-actions .tp-btn-icon:hover { background: rgba(0,0,0,.06); }
.task-post .tp-reply-actions .tp-btn-icon svg.ic { width: 14px; height: 14px; margin: 0; }
.task-post .tp-reply-edit-form textarea { width: 100%; }

/* Replies collapse toggle */
.task-post .tp-replies-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    margin-inline-start: 36px;
    background: transparent; border: 0; padding: 4px 6px;
    color: #f59e0b; cursor: pointer; font-size: 13px; font-weight: 700;
}
.task-post .tp-replies-toggle:hover { color: #fbbf24; text-decoration: underline; }
.task-post .tp-replies-toggle .tp-replies-toggle-caret {
    display: inline-block; transition: transform .2s;
}
.task-post .tp-thread[data-collapsed="0"] .tp-replies-toggle .tp-replies-toggle-caret {
    transform: rotate(180deg);
}

/* Mobile: tighter reply controls so attach + mic + open + count + send all fit on one line */
@media (max-width: 640px) {
    .task-post .tp-reply-controls .tp-btn { padding: 5px 8px; font-size: 12px; gap: 4px; }
    .task-post .tp-reply-controls .tp-attach-label { display: none; }
    .task-post .tp-reply-controls .tp-meta-count { padding: 4px 6px; font-size: 12px; gap: 3px; }
    .task-post .tp-reply-controls svg.ic { width: 14px; height: 14px; margin-inline-end: 0; }
    .task-post .tp-actions .tp-btn { padding: 5px 10px; font-size: 12px; }
}

/* Task counts panel (bottom of feed) */
.task-bottom-bar {
    position: fixed;
    bottom: 0;
    inset-inline-start: var(--sidebar-w);
    inset-inline-end: 0;
    background: var(--panel);
    border-top: 1px solid var(--border);
    padding: 6px 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 30;
    box-shadow: 0 -2px 10px rgba(0,0,0,.2);
}
.task-archive-btn { padding: 5px 12px; font-size: 13px; }
.task-archive-btn .ic { width: 14px; height: 14px; }
.task-counts { display: flex; gap: 18px; padding: 0; border: 0; background: transparent; box-shadow: none; margin: 0; }
.task-count-item { display: flex; align-items: baseline; gap: 6px; }
.task-count-num { font-size: 17px; font-weight: 800; line-height: 1; }
.task-count-label { color: var(--muted); font-size: 12px; margin: 0; }
@media (max-width: 980px) {
    .task-bottom-bar { inset-inline-start: 0; }
}

/* Thin divider between sidebar submenu items */
.sidebar nav details > a + a {
    border-top: 1px solid rgba(255,255,255,.06);
}
[data-theme="light"] .sidebar nav details > a + a {
    border-top: 1px solid rgba(0,0,0,.08);
}

/* Inline icon helper (matches text size, aligns with button labels) */
svg.ic { width: 16px; height: 16px; vertical-align: -3px; flex-shrink: 0; stroke: currentColor; fill: none; }
.tp-btn svg.ic, .btn svg.ic, .chip svg.ic { margin-inline-end: 4px; }

/* Slim input variant used in the tasks toolbar */
.input.input-sm {
    height: 36px; padding: 6px 10px; font-size: 14px; line-height: 1.2;
    min-width: 0;
}

/* Tasks toolbar (top of /tasks page) */
.card.task-toolbar { padding: 12px 14px; overflow: visible; }
.task-toolbar .tt-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
}
.task-toolbar .tt-title { margin: 0; font-size: 16px; font-weight: 700; }
.task-toolbar .tt-form { display: flex; align-items: center; gap: 8px; margin: 0; flex-wrap: wrap; }
.task-toolbar .tt-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.task-toolbar .tt-form .input { max-width: 180px; }
.task-toolbar .tt-add { height: 36px; display: inline-flex; align-items: center; gap: 4px; }

@media (max-width: 640px) {
    .task-toolbar .tt-row {
        display: flex; flex-direction: column; align-items: stretch; gap: 8px;
    }
    .task-toolbar .tt-title { font-size: 15px; text-align: start; }
    .task-toolbar .tt-form {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px; width: 100%;
    }
    .task-toolbar .tt-form .input,
    .task-toolbar .tt-form select.input {
        width: 100% !important; max-width: 100% !important; min-width: 0 !important;
    }
    .task-toolbar .tt-form .range-popover {
        grid-column: 1 / -1; width: 100%; position: relative;
    }
    .task-toolbar .tt-form .range-popover > summary {
        width: 100%; justify-content: center;
    }
    .task-toolbar .tt-form > .btn { grid-column: 1 / -1; justify-content: center; }
    .task-toolbar .tt-add {
        width: 100%; justify-content: center;
    }
}

/* Inline link references inside task details / replies */
.task-link {
    display: inline-flex; align-items: center; gap: 6px;
    max-width: 100%;
    padding: 2px 10px;
    margin: 1px 2px;
    border-radius: 999px;
    background: rgba(37,99,235,.12);
    color: #60a5fa;
    border: 1px solid rgba(37,99,235,.35);
    text-decoration: none;
    font-size: 13px;
    vertical-align: middle;
    word-break: break-all;
    transition: background .15s, color .15s;
}
.task-link:hover { background: rgba(37,99,235,.22); color: #93c5fd; text-decoration: none; }
.task-link svg.ic { width: 14px; height: 14px; }
[data-theme="light"] .task-link {
    background: rgba(37,99,235,.08);
    color: #2563eb;
    border-color: rgba(37,99,235,.3);
}
[data-theme="light"] .task-link:hover { background: rgba(37,99,235,.16); color: #1d4ed8; }

/* Drag-drop / paste attachment zone for task form. */
.tp-dropzone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 14px;
    background: rgba(255,255,255,.02);
    transition: border-color .15s ease, background .15s ease;
    cursor: pointer;
}
[data-theme="light"] .tp-dropzone { background: rgba(0,0,0,.02); }
.tp-dropzone:hover { border-color: var(--accent, #2b6cf6); }
.tp-dropzone.is-drag {
    border-color: var(--accent, #2b6cf6);
    background: rgba(43,108,246,.08);
}
.tp-dropzone.is-pasted { animation: tpFlash .5s ease; }
@keyframes tpFlash { 0% { background: rgba(43,108,246,.25); } 100% { background: rgba(255,255,255,.02); } }
.tp-dropzone-input {
    width: 100%;
    margin-bottom: 8px;
}
.tp-dropzone-hint {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
    text-align: center;
    pointer-events: none;
}
.tp-dropzone-previews {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-top: 6px;
}
.tp-dropzone-previews:empty { display: none; }
.tp-dz-item {
    position: relative;
    width: 88px; height: 88px;
    border-radius: 8px; overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg, #111);
    display: flex; align-items: center; justify-content: center;
}
.tp-dz-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tp-dz-file {
    font-size: 11px; padding: 6px; text-align: center;
    word-break: break-word; line-height: 1.3;
}
.tp-dz-remove {
    position: absolute; top: 2px; inset-inline-end: 2px;
    width: 22px; height: 22px; border-radius: 50%;
    border: 0; background: rgba(0,0,0,.65); color: #fff;
    cursor: pointer; font-size: 12px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.tp-dz-remove:hover { background: #dc2626; }

/* Sidebar pending-task indicator on brand links. */
.sidebar nav a.has-pending { position: relative; }
.sidebar nav a .nav-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 999px; margin-inline-start: auto;
    background: #f59e0b; color: #111; font-size: 11px; font-weight: 800;
    box-shadow: 0 0 0 2px rgba(245,158,11,.25);
    line-height: 1;
}
.sidebar nav a.has-pending > span:first-child { flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 6px; }

/* Sidebar nav sub-list: keep nested indentation but scroll with the whole sidebar (not internally). */
.sidebar nav details > .nav-sublist { display: flex; flex-direction: column; }
.sidebar nav details > .nav-sublist a { padding-inline-start: 16px; }

/* Leave space for the fixed bottom bar on task index. */
main:has(.task-bottom-bar) { padding-bottom: 64px; }
body:has(.task-bottom-bar) { padding-bottom: 0; }
.task-feed:has(+ .task-bottom-bar) { margin-bottom: 12px; }

/* ============================================================
   Task reply — live voice recorder UI (browser MediaRecorder)
   ============================================================ */
.tp-recbar{
    display:flex; align-items:center; gap:8px;
    margin-top:6px; padding:6px 10px;
    background:rgba(239,68,68,.10);
    border:1px solid rgba(239,68,68,.35);
    border-radius:999px;
}
.tp-recbar[hidden]{ display:none !important; }
[data-theme="light"] .tp-recbar{
    background:#fef2f2;
    border-color:#fecaca;
}
.tp-rec-dot{
    width:10px; height:10px; border-radius:50%;
    background:#ef4444; flex:0 0 auto;
    animation:tpRecPulse 1.1s ease-in-out infinite;
}
form.is-paused .tp-rec-dot{ animation:none; opacity:.45; }
@keyframes tpRecPulse{
    0%,100%{ transform:scale(1);   opacity:1;   box-shadow:0 0 0 0 rgba(239,68,68,.6); }
    50%    { transform:scale(1.18); opacity:.85; box-shadow:0 0 0 6px rgba(239,68,68,0); }
}
.tp-rec-time{
    font-variant-numeric: tabular-nums;
    font-weight:700; font-size:14px;
    min-width:42px;
}
.tp-rec-btn{
    display:inline-flex; align-items:center; justify-content:center;
    width:34px; height:34px; padding:0;
    border:1px solid transparent; border-radius:50%;
    background:transparent; color:inherit; cursor:pointer;
    transition: background .12s ease, color .12s ease;
}
.tp-rec-btn:hover{ background:rgba(255,255,255,.08); }
[data-theme="light"] .tp-rec-btn:hover{ background:rgba(0,0,0,.06); }
.tp-rec-btn svg{ width:18px; height:18px; }
.tp-rec-btn.tp-rec-cancel{ color:#ef4444; }
.tp-rec-btn.tp-rec-send{ color:#22c55e; }
.tp-rec-btn.tp-rec-send:hover{ background:rgba(34,197,94,.15); }
.tp-rec-btn.tp-rec-cancel:hover{ background:rgba(239,68,68,.15); }

/* Pause/Play icon toggle */
form[data-reply-form]            .tp-rec-btn[data-rec-pause] .ic-play  { display:none; }
form[data-reply-form].is-paused  .tp-rec-btn[data-rec-pause] .ic-pause { display:none; }
form[data-reply-form].is-paused  .tp-rec-btn[data-rec-pause] .ic-play  { display:inline-block; }

/* Voice clip chip shown after recording */
.tp-voice-chip{
    display:inline-flex; align-items:center; gap:6px;
    margin-top:6px; padding:4px 10px 4px 8px;
    background:rgba(34,197,94,.12);
    border:1px solid rgba(34,197,94,.35);
    border-radius:999px;
    font-size:12px; color:inherit;
}
.tp-voice-chip[hidden]{ display:none !important; }
[data-theme="light"] .tp-voice-chip{
    background:#ecfdf5; border-color:#a7f3d0;
}
.tp-voice-chip svg{ width:14px; height:14px; }
.tp-voice-chip-x{
    background:transparent; border:0; cursor:pointer;
    color:#ef4444; font-size:16px; line-height:1;
    padding:0 2px; margin-inline-start:2px;
}
.tp-voice-chip-x:hover{ opacity:.8; }
