/* ============================================================
   Miteda app — component classes.
   All values reference design-system tokens (var(--*)).
   Components use these classes via className (no inline-style soup).
   ============================================================ */

/* ---- Layout spacing token ----------------------------------
   Gap between layout components (cards, columns, sections).
   Change here to re-space the whole app. */
:root { --app-gap: 8px; }

/* ---- Sidebar ------------------------------------------------ */
.sb__top { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 12px; }
.sb__brand { display: inline-flex; }
.sb__logo-full { height: 28px; display: block; }
.sb__logo-mark { height: 30px; display: none; }
.sb__toggle {
  width: 36px; height: 36px; flex: 0 0 auto; border: none; border-radius: 10px;
  background: rgba(255,255,255,0.06); color: rgba(255,254,252,0.7); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}
.sb__toggle:hover { background: rgba(255,255,255,0.12); color: #fff; }
.sb__toggle i { font-size: 20px; }
.sb__nav { display: flex; flex-direction: column; gap: 2px; }
.sb__nav button { height: auto !important; padding-top: 8px !important; padding-bottom: 8px !important; padding-left: 8px !important; padding-right: 8px !important; }
.sb__divider { height: 1px; background: rgba(255,255,255,0.08); margin: 10px 12px; }
.sb__spacer { flex: 1; }
.sb__foot { display: flex; flex-direction: column; gap: 8px; }

.sb__role { padding: 4px 8px 8px; }
.sb__role-cap {
  font-size: var(--text-small); color: rgba(255,254,252,0.45);
  letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 8px; display: block;
}
.sb__role-seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  padding: 4px; background: rgba(0,0,0,0.22); border-radius: var(--radius-pill);
}
.sb__role-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; border: none; border-radius: var(--radius-pill); cursor: pointer;
  background: transparent; color: rgba(255,254,252,0.65);
  font-family: var(--font-sans); font-size: var(--text-small); font-weight: var(--fw-medium);
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}
.sb__role-btn i { font-size: 18px; }
.sb__role-btn:hover { color: var(--text-on-forest); }
.sb__role-btn.is-active { background: var(--brand-green); color: #fff; }

.sb__chip {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: none; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05); cursor: pointer; text-align: left;
}
.sb__chip-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface-card); color: var(--brand-forest); flex: 0 0 auto;
}
.sb__chip-ic i { font-size: 20px; }
.sb__chip-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sb__chip-title {
  font-size: var(--text-body); font-weight: var(--fw-medium); color: var(--text-on-forest);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb__chip-sub {
  font-size: var(--text-small); color: rgba(255,254,252,0.55);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- Collapsed rail (desktop only) -------------------------- */
@media (min-width: 761px) {
  .app-shell.sb-collapsed .sidebar { width: 84px; flex: 0 0 84px; padding-left: 12px; padding-right: 12px; }
  .sb-collapsed .sb__top { flex-direction: column; gap: 14px; padding: 4px 0 14px; }
  .sb-collapsed .sb__logo-full { display: none; }
  .sb-collapsed .sb__logo-mark { display: block; }
  .sb-collapsed .sb__nav button { justify-content: center; align-items: center; flex-direction: column; padding: 6px 4px; gap: 3px; height: auto; min-height: 52px; width: 100%; overflow: hidden; }
  .sb-collapsed .sb__nav button > span { display: block; font-size: 10px; line-height: 1.2; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; flex: none; }
  .sb-collapsed .sb__divider { margin: 10px 8px; }
  .sb-collapsed .sb__role-cap { display: none; }
  .sb-collapsed .sb__role { padding: 4px 0 8px; }
  .sb-collapsed .sb__role-seg { grid-template-columns: 1fr; gap: 6px; background: transparent; padding: 0; }
  .sb-collapsed .sb__chip { justify-content: center; padding: 8px; gap: 0; }
  .sb-collapsed .sb__chip-tx { display: none; }
  .sb-collapsed .sb__chip > i { display: none; }
  .sb-collapsed .sb__foot > div { display: none; }
}

/* ---- Header ------------------------------------------------- */
.hdr {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 24px; border-radius: var(--radius-lg);
  background: var(--glass-card);
  backdrop-filter: var(--blur-glass); -webkit-backdrop-filter: var(--blur-glass);
  box-shadow: var(--shadow-xs); position: sticky; top: 0; z-index: 20;
}
.hdr__l { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 auto; }
.hdr__title {
  margin: 0; font-size: var(--text-display); line-height: var(--lh-display);
  font-weight: var(--fw-medium); letter-spacing: var(--tracking-tight); color: var(--ink-900);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.hdr__sub {
  margin: 0; font-size: var(--text-body); color: var(--ink-500);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hdr__r { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.hdr__io { display: flex; align-items: center; gap: 12px; }
.hdr__search { width: 264px; }
.hdr__bc { display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.hdr__bc-sep { color: var(--ink-300); font-size: var(--text-small); user-select: none; }
.hdr__bc-link { font-size: var(--text-small); color: var(--ink-400); text-decoration: none; }
.hdr__bc-link:hover { color: var(--ink-700); text-decoration: underline; }
.hdr__bc-cur { font-size: var(--text-small); color: var(--ink-500); }

/* ---- Generic panel section title --------------------------- */
.panel-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px;
  margin-bottom: var(--space-5);
}
.panel-head__tx { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
@media (max-width: 680px) {
  .panel-head { flex-direction: column; gap: 10px; }
}

/* ---- Stat tiles -------------------------------------------- */
.stat {
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 20px; border-radius: var(--radius-md);
  background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--line-100);
}
.stat__k { display: flex; align-items: center; gap: 8px; font-size: var(--text-small); color: var(--ink-500); }
.stat__k i { font-size: 16px; color: var(--ink-400); }
.stat__v { font-size: 28px; line-height: 32px; font-weight: var(--fw-medium); color: var(--ink-900); letter-spacing: var(--tracking-tight); }

/* ---- Generic list row -------------------------------------- */
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius-md);
  background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--line-100);
}
.row + .row { margin-top: 0; }
.row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row__title { font-size: var(--text-body); font-weight: var(--fw-medium); color: var(--ink-900); }
.row__meta { font-size: var(--text-small); color: var(--ink-400); }
.row__meta .dot { margin: 0 6px; }

/* ---- Soft icon tile ---------------------------------------- */
.tile {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: var(--radius-sm); background: var(--overlay-ink-04); color: var(--ink-700);
}
.tile.lg { width: 48px; height: 48px; }
.tile i { font-size: 20px; }
.tile--green { background: var(--brand-green-faint); color: var(--brand-green-strong); }
.tile--orange { background: var(--orange-soft); color: var(--orange); }

/* ---- Tabs --------------------------------------------------- */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--overlay-ink-04); border-radius: var(--radius-pill); max-width: 100%; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; white-space: nowrap; }
.tabs::-webkit-scrollbar { display: none; }
.tabs__btn {
  height: 36px; padding: 0 16px; border: none; border-radius: var(--radius-pill);
  cursor: pointer; font-family: var(--font-sans); font-size: var(--text-body);
  font-weight: var(--fw-medium); color: var(--ink-500); background: transparent;
  transition: color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard);
}
.tabs__btn.is-active { color: var(--ink-900); background: transparent; box-shadow: none; }

/* ---- Chips (filters) --------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; text-align: left;
  height: 32px; padding: 0 14px; border: none; border-radius: var(--radius-pill);
  cursor: pointer; font-family: var(--font-sans); font-size: var(--text-body);
  font-weight: var(--fw-medium); color: var(--ink-700);
  background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--line-200);
  transition: all var(--dur-fast) var(--ease-standard);
}
.chip.is-active { background: var(--brand-forest); color: var(--text-on-forest); box-shadow: none; }

/* ---- Table -------------------------------------------------- */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl thead tr {
  position: sticky; top: 0; z-index: 4;
  background: var(--surface-sunken);
}
.tbl th {
  text-align: left; font-size: var(--text-small); font-weight: var(--fw-medium);
  color: var(--ink-400); padding: 10px 16px 12px; border-bottom: 1px solid var(--line-100);
}
.tbl thead th:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.tbl thead th:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.tbl td { padding: 14px 16px; font-size: var(--text-body); color: var(--ink-700); border-bottom: 1px solid var(--line-100); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background var(--dur-fast) var(--ease-standard); }
.tbl tbody tr:hover td { background: var(--surface-sunken); }
.tbl tbody tr:hover td:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.tbl tbody tr:hover td:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.tbl td.tbl__id { font-weight: var(--fw-regular); color: var(--ink-900); }

/* ---- Thread / messages ------------------------------------- */
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 12px; }
.msg__b { flex: 1; min-width: 0; }
.msg__head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.msg__who { font-size: var(--text-body); font-weight: var(--fw-medium); color: var(--ink-900); }
.msg__role { font-size: var(--text-small); color: var(--ink-400); }
.msg__time { font-size: var(--text-small); color: var(--ink-300); margin-left: auto; }
.msg__bubble {
  font-size: var(--text-body); line-height: var(--lh-body); color: var(--ink-700);
  background: var(--surface-sunken); padding: 12px 14px; border-radius: var(--radius-md);
  border-top-left-radius: 4px;
}

/* ---- Composer ---------------------------------------------- */
.composer { display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.composer input {
  flex: 1; height: 44px; padding: 0 14px; border: none; border-radius: var(--radius-sm);
  background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--line-200);
  font-family: var(--font-sans); font-size: var(--text-body); color: var(--ink-900); outline: none;
}
.composer input:focus { box-shadow: inset 0 0 0 1.5px var(--focus-ring); }

/* ---- Modal -------------------------------------------------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: 80; background: rgba(3,3,2,0.45);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade var(--dur-base) var(--ease-standard);
}
.modal {
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  background: var(--surface-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 24px;
  animation: pop var(--dur-base) var(--ease-out);
}
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label { font-size: var(--text-body); font-weight: var(--fw-medium); color: var(--ink-700); }
.field input, .field select, .field textarea {
  height: 44px; padding: 0 14px; border: none; border-radius: var(--radius-sm);
  background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--line-200);
  font-family: var(--font-sans); font-size: var(--text-body); color: var(--ink-900); outline: none;
}
.field textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: var(--lh-body); }
.field input:focus, .field select:focus, .field textarea:focus { box-shadow: inset 0 0 0 1.5px var(--focus-ring); }
.field--compact { margin-bottom: 0; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---- Misc helpers ------------------------------------------ */
.muted { color: var(--ink-500); }
.dot { color: var(--ink-300); }
.right { margin-left: auto; }
.stack-sm { display: flex; flex-direction: column; gap: 12px; }
.rowflex { display: flex; align-items: center; gap: 12px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.gap-0 { gap: 0; } .gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-14 { gap: 14px; } .gap-16 { gap: 16px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ---- Filter pills (ghost outline toggle style) ----------- */
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border: none; border-radius: var(--radius-pill);
  box-shadow: inset 0 0 0 1.5px var(--line-200);
  background: transparent; color: var(--ink-600);
  font-family: var(--font-sans); font-size: var(--text-small);
  font-weight: var(--fw-regular); cursor: pointer;
  transition: box-shadow 120ms, background 120ms, color 120ms;
}
.filter-pill.is-active {
  box-shadow: inset 0 0 0 1.5px var(--brand-green);
  background: var(--brand-green-soft, rgba(34,197,94,0.12));
  color: var(--brand-green);
  font-weight: var(--fw-medium);
}

/* ---- Tabs animated pill ---------------------------------- */
.tabs__pill {
  position: absolute; top: 4px; left: 4px;
  height: calc(100% - 8px);
  background: var(--surface-white);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-xs);
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1), width 0.22s cubic-bezier(0.4,0,0.2,1);
}

/* ---- PanelHead description ------------------------------- */
.panel-head__desc {
  font-size: var(--text-body); color: var(--ink-400);
  margin: 4px 0 0; line-height: 1.5;
}

/* ---- Stat accent variant --------------------------------- */
.stat__v--accent { color: var(--brand-green-strong); }

/* ---- Header icon buttons (bell, chat) -------------------- */
.hdr__icon-btn {
  position: relative;
  width: 36px; height: 36px; flex-shrink: 0;
  border: none; border-radius: var(--radius-md);
  background: var(--overlay-ink-04); color: var(--ink-500);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.hdr__icon-btn:hover { background: var(--overlay-ink-08); color: var(--ink-900); }
.hdr__icon-btn i { font-size: 20px; }
.hdr__icon-btn__dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--orange); border: 1.5px solid var(--surface-card);
}

/* Header profile avatar + dropdown */
.hdr__profile { position: relative; flex-shrink: 0; }
.hdr__avatar-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent;
  padding: 0; cursor: pointer; background: none;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s;
}
.hdr__avatar-btn:hover,
.hdr__avatar-btn.is-open { border-color: var(--brand, var(--ink-300)); }
.hdr__avatar-fallback {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--overlay-ink-08); color: var(--ink-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.hdr__profile-drop {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 220px;
  background: var(--surface-sidebar, #1a1a1a);
  border: 1px solid rgba(255,254,252,0.1);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  z-index: 200;
  overflow: hidden;
}
.hdr__profile-drop__header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255,254,252,0.08);
  display: flex; flex-direction: column; gap: 2px;
}
.hdr__profile-drop__name {
  font-size: 13px; font-weight: 600; color: rgba(255,254,252,0.9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hdr__profile-drop__sub {
  font-size: 11px; color: rgba(255,254,252,0.45);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---- DSSelect custom dropdown ---------------------------- */
.ds-select__trigger {
  display: flex; align-items: center; justify-content: space-between;
  height: 36px; padding: 0 10px; width: 100%; cursor: pointer;
  border: none; border-radius: var(--radius-sm);
  background: var(--surface-card);
  box-shadow: inset 0 0 0 1px var(--line-200);
  font-family: var(--font-sans); font-size: var(--text-body); color: var(--ink-900);
  outline: none; box-sizing: border-box; gap: 6px;
  transition: box-shadow 120ms;
}
.ds-select__trigger.is-open { box-shadow: inset 0 0 0 1px var(--line-300); }
.ds-select__label {
  flex: 1; text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ds-select__trigger i { font-size: 14px; color: var(--ink-400); flex-shrink: 0; }
.ds-select__dropdown {
  position: fixed; z-index: 9999;
  background: var(--surface-card); border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12); border: 1px solid var(--line-200);
  padding: 4px; display: flex; flex-direction: column;
}
.ds-select__option {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border: none; border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--font-sans); font-size: var(--text-body); font-weight: var(--fw-regular);
  color: var(--ink-900); cursor: pointer; width: 100%; text-align: left;
  transition: background 100ms;
}
.ds-select__option:hover { background: var(--overlay-ink-04); }
.ds-select__option.is-active { background: var(--overlay-ink-04); font-weight: var(--fw-medium); }
.ds-select__check { font-size: 14px; color: var(--brand-green); }

/* ---- HeaderSearch --------------------------------------- */
.hdr-search {
  position: relative; flex-shrink: 0; width: 36px; height: 36px;
}
.hdr-search__icon-btn {
  position: absolute; top: 0; right: 0;
  width: 36px; height: 36px; border: none;
  border-radius: var(--radius-md); background: var(--overlay-ink-04);
  color: var(--ink-500); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.hdr-search__icon-btn:hover { background: var(--overlay-ink-08); color: var(--ink-900); }
.hdr-search__icon-btn i { font-size: 20px; }
.hdr-search__bar {
  position: absolute; top: 0; right: 0;
  display: flex; align-items: center; gap: 8px;
  height: 36px; background: var(--overlay-ink-04);
  border-radius: var(--radius-md); padding: 0 10px;
  overflow: hidden;
}
.hdr-search__bar i { font-size: 16px; color: var(--ink-400); flex-shrink: 0; }
.hdr-search__input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: var(--text-body); font-family: var(--font-sans); color: var(--ink-900);
  min-width: 0;
}
.hdr-search__clear {
  background: none; border: none; cursor: pointer; padding: 2px;
  color: var(--ink-400); display: flex; align-items: center; flex-shrink: 0;
}
.hdr-search__clear i { font-size: 14px; }
.hdr-search__results {
  position: absolute; top: calc(100% + 6px); right: 0; width: 360px;
  background: var(--surface-card); border: 1px solid var(--line-200);
  border-radius: var(--radius-lg); box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  z-index: 9999; overflow: hidden;
}
.hdr-search__result-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 14px; border: none;
  background: none; cursor: pointer; text-align: left;
}
.hdr-search__result-row:hover { background: var(--overlay-ink-04); }
.hdr-search__result-row + .hdr-search__result-row { border-top: 1px solid var(--line-100); }
.hdr-search__result-icon {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: var(--overlay-ink-04); display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.hdr-search__result-icon i { font-size: 16px; color: var(--ink-600); }
.hdr-search__result-body { flex: 1; min-width: 0; }
.hdr-search__result-title {
  display: block; font-size: var(--text-body); color: var(--ink-900);
  font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hdr-search__result-sub {
  display: block; font-size: var(--text-small); color: var(--ink-400);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hdr-search__result-role { font-size: 11px; color: var(--ink-300); flex-shrink: 0; }
.hdr-search__empty {
  padding: 14px; text-align: center;
  font-size: var(--text-body); color: var(--ink-400);
}

/* ---- Page content wrapper -------------------------------- */
/* .content is the top-level page div inside Shell's .main.
   .stack / .grid-* set display; this just handles flex sizing. */
.content { flex: 1; min-width: 0; min-height: 0; }

/* ---- Scroll-reveal animation marker ---------------------- */
/* Elements with this class are excluded from the page-enter
   GSAP animation (.content > *:not(.scroll-reveal)) */
.scroll-reveal {}
