:root {
  color-scheme: light;
  --ink: #152238;
  --ink-strong: #0a1220;
  --muted: #66758c;
  --muted-2: #8d99aa;
  --line: #e3e8f0;
  --line-strong: #d2d9e5;
  --canvas: #f4f6fa;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;
  --sidebar: #111827;
  --sidebar-soft: #1c2637;
  --brand: #6558d3;
  --brand-strong: #4e42b6;
  --brand-soft: #efedff;
  --teal: #159f92;
  --teal-soft: #e7f8f5;
  --danger: #c43d55;
  --danger-soft: #fff0f3;
  --warning: #b7750a;
  --warning-soft: #fff7e7;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.035);
  --shadow-md: 0 18px 48px rgba(15, 23, 42, 0.12);
  --radius-sm: 0.65rem;
  --radius: 1rem;
  --radius-lg: 1.35rem;
  --sidebar-width: 17rem;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; overflow-x: hidden; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled, input:disabled, textarea:disabled, select:disabled { cursor: not-allowed; opacity: 0.58; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(101, 88, 211, 0.22);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.15rem 1.15rem;
  color: #fff;
  background:
    radial-gradient(circle at 8% 8%, rgba(101, 88, 211, 0.34), transparent 34%),
    linear-gradient(175deg, #131d2d 0%, var(--sidebar) 70%);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.35rem;
  padding: 0.25rem 0.35rem 1.25rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 2.8rem;
  height: 2.8rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 0.9rem;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(145deg, #7d6fea, #5749c6);
  box-shadow: 0 10px 28px rgba(101, 88, 211, 0.34), inset 0 1px 0 rgba(255,255,255,0.25);
}

.brand-copy { display: flex; flex-direction: column; line-height: 1.25; }
.brand-copy strong { font-size: 1.25rem; letter-spacing: -0.025em; }
.brand-copy small { margin-top: 0.18rem; color: #aeb8ca; font-size: 0.875rem; }
.version-pill {
  margin-inline-start: auto;
  padding: 0.1rem 0.45rem;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  color: #c6c0ff;
  font-size: 0.8rem;
  font-weight: 700;
}

.main-nav { display: grid; gap: 0.45rem; margin-top: 0.8rem; }
.main-nav button {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  min-height: 4.2rem;
  padding: 0.75rem;
  color: #cbd4e2;
  text-align: right;
  border: 1px solid transparent;
  border-radius: 0.9rem;
  background: transparent;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}
.main-nav button:hover { color: #fff; background: rgba(255,255,255,0.055); }
.main-nav button.active {
  color: #fff;
  background: linear-gradient(110deg, rgba(101,88,211,0.3), rgba(101,88,211,0.12));
  border-color: rgba(151,140,255,0.18);
}
.main-nav button > span:last-child { display: flex; flex-direction: column; }
.main-nav strong { font-size: 1rem; font-weight: 700; }
.main-nav small { color: #8997ac; font-size: 0.86rem; }
.main-nav button.active small { color: #b9b3f7; }
.nav-icon {
  width: 2.15rem;
  height: 2.15rem;
  display: grid;
  place-items: center;
  border-radius: 0.7rem;
  background: rgba(255,255,255,0.065);
  font-size: 1.1rem;
}
.main-nav button.active .nav-icon { background: rgba(136,124,244,0.24); }

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: auto;
  padding: 0.85rem;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 0.9rem;
  background: rgba(255,255,255,0.045);
}
.sidebar-status > div { min-width: 0; display: flex; flex-direction: column; }
.sidebar-status strong { overflow: hidden; color: #eef2f8; font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-status small { color: #8e9bae; font-size: 0.82rem; }
.status-dot { width: 0.62rem; height: 0.62rem; flex: 0 0 auto; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 4px rgba(21,159,146,0.13); }
.status-dot.disconnected { background: #7d899a; box-shadow: 0 0 0 4px rgba(125,137,154,0.12); }
.status-dot.failed { background: #ef6f7e; box-shadow: 0 0 0 4px rgba(239,111,126,0.12); }
.local-note { margin: 0.8rem 0 0; color: #8491a5; font-size: 0.82rem; text-align: center; }

.workspace { min-width: 0; min-height: 100vh; }
.topbar {
  height: 6.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(244,246,250,0.92);
  backdrop-filter: blur(12px);
}
.topbar h1 { margin: 0.15rem 0 0; color: var(--ink-strong); font-size: clamp(1.45rem, 2vw, 1.85rem); line-height: 1.2; letter-spacing: -0.035em; }
.eyebrow, .section-label { margin: 0; color: var(--brand); font-size: 0.82rem; font-weight: 800; letter-spacing: 0.035em; }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.save-state { display: inline-flex; align-items: center; min-height: 2.35rem; padding: 0.3rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 0.88rem; }
.save-state.busy::before { content: ""; width: 0.75rem; height: 0.75rem; margin-inline-end: 0.5rem; border: 2px solid var(--line-strong); border-top-color: var(--brand); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.mobile-menu { display: none; }

.view { display: none; padding: 1.25rem 1.5rem 1.6rem; }
.view.active { display: block; }
.panel { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }

.tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.tool-card { padding: 1.25rem; }
.tool-card-heading { display: flex; align-items: center; gap: 0.85rem; }
.tool-card-heading h3 { margin: 0.1rem 0 0; color: var(--ink-strong); font-size: 1.18rem; }
.tool-symbol { width: 3rem; height: 3rem; display: grid; place-items: center; border-radius: 0.9rem; background: var(--brand-soft); color: var(--brand-strong); font-size: 1.35rem; font-weight: 800; }
.tool-state { color: var(--teal); font-size: 0.78rem; font-weight: 800; }
.tool-card > p { margin: 1rem 0; color: var(--muted); }
.tool-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; margin: 0 0 1rem; }
.tool-card dl div { padding: 0.75rem; border-radius: 0.75rem; background: var(--surface-soft); }
.tool-card dt { color: var(--muted-2); font-size: 0.76rem; font-weight: 700; }
.tool-card dd { margin: 0.2rem 0 0; font-size: 0.9rem; }
.tool-card fieldset { display: grid; gap: 0.45rem; margin: 0; padding: 0.85rem; border: 1px solid var(--line); border-radius: 0.85rem; }
.tool-card legend { padding: 0 0.4rem; color: var(--ink); font-size: 0.85rem; font-weight: 800; }
.tool-agent-grant { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.6rem; min-height: 2.3rem; }
.tool-agent-grant input { width: 1.05rem; height: 1.05rem; accent-color: var(--brand); }
.tool-agent-grant small { color: var(--muted-2); }
.invocation-panel { margin-top: 1rem; overflow: hidden; }
.invocation-list { padding: 0 1.15rem 1.15rem; }
.invocation-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.75rem; padding: 0.75rem 0; border-top: 1px solid var(--line); }
.invocation-item > div { display: flex; flex-direction: column; }
.invocation-item small { color: var(--muted); }
.invocation-item code { color: var(--muted); font-size: 0.75rem; }
.invocation-status { width: 0.65rem; height: 0.65rem; border-radius: 50%; background: var(--teal); }
.invocation-status.failed, .invocation-status.denied { background: var(--danger); }
.conversation-tool-events { display: grid; gap: 0.65rem; margin: 0.5rem 3rem; }
.tool-result-card { padding: 0.8rem; border: 1px solid #cfe9e5; border-radius: 0.85rem; background: #f3fbfa; }
.tool-result-card.failed, .tool-result-card.denied { border-color: #f1cbd2; background: var(--danger-soft); }
.tool-result-card > div { display: flex; align-items: center; gap: 0.55rem; }
.tool-result-card small { margin-inline-start: auto; color: var(--muted); }
.tool-result-icon { color: var(--teal); font-weight: 800; }
.tool-result-card pre { overflow: auto; margin: 0.55rem 0 0; color: var(--ink); font: 0.8rem/1.55 ui-monospace, Consolas, monospace; white-space: pre-wrap; }

.chat-layout {
  height: calc(100vh - 8.95rem);
  min-height: 38rem;
  display: grid;
  grid-template-columns: 16.25rem minmax(25rem, 1fr) 19rem;
  gap: 1rem;
}

.conversation-rail, .memory-rail { min-height: 0; overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 1.15rem 1.15rem 0.7rem; }
.panel-heading.compact { padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.panel-heading > div { display: flex; flex-direction: column; }
.panel-heading strong { color: var(--ink-strong); font-size: 1.02rem; }
.square-button, .icon-button {
  width: 2.45rem;
  height: 2.45rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 0.75rem;
  color: var(--brand-strong);
  background: var(--surface);
}
.square-button:hover, .icon-button:hover { border-color: #bcb5ee; background: var(--brand-soft); }

.conversation-list { height: calc(100% - 5rem); overflow: auto; padding: 0.7rem; scrollbar-width: thin; }
.conversation-item {
  width: 100%;
  display: block;
  margin: 0 0 0.35rem;
  padding: 0.8rem;
  text-align: right;
  border: 1px solid transparent;
  border-radius: 0.8rem;
  background: transparent;
}
.conversation-item:hover { background: var(--surface-soft); }
.conversation-item.active { border-color: #d8d3fa; background: var(--brand-soft); }
.conversation-item strong, .conversation-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item strong { color: var(--ink); font-size: 0.92rem; }
.conversation-item span { margin-top: 0.15rem; color: var(--muted-2); font-size: 0.82rem; }
.conversation-item small { display: block; margin-top: 0.35rem; color: var(--muted-2); font-size: 0.78rem; }

.chat-panel { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
.chat-toolbar { min-height: 5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem 1.15rem; border-bottom: 1px solid var(--line); }
.chat-tools { display: flex; align-items: center; gap: 0.5rem; }
.agent-presence { min-width: 0; display: flex; align-items: center; gap: 0.7rem; }
.agent-presence > div { min-width: 0; display: flex; flex-direction: column; }
.agent-presence strong { overflow: hidden; color: var(--ink-strong); text-overflow: ellipsis; white-space: nowrap; }
.agent-presence small { overflow: hidden; color: var(--muted); font-size: 0.84rem; text-overflow: ellipsis; white-space: nowrap; }
.agent-avatar {
  width: 2.55rem; height: 2.55rem;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 0.82rem;
  color: #fff;
  background: linear-gradient(145deg, #7467dd, #5144b8);
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(101,88,211,0.22);
}
.agent-avatar.large { width: 3.35rem; height: 3.35rem; border-radius: 1rem; font-size: 1.2rem; }
.compact-select { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.84rem; }
.compact-select select { max-width: 10rem; min-height: 2.35rem; padding: 0.35rem 0.7rem 0.35rem 2rem; border: 1px solid var(--line); border-radius: 0.7rem; color: var(--ink); background-color: var(--surface-soft); }

.messages { min-height: 0; overflow-y: auto; padding: 1.4rem clamp(1rem, 3vw, 2.6rem); scroll-behavior: smooth; scrollbar-width: thin; }
.message-row { display: flex; gap: 0.65rem; margin-bottom: 1.2rem; }
.message-row.user { justify-content: flex-start; }
.message-row.assistant { justify-content: flex-end; }
.message-bubble { max-width: min(82%, 48rem); }
.message-content { padding: 0.8rem 1rem; border-radius: 1rem; white-space: normal; overflow-wrap: anywhere; }
.message-row.user .message-content { color: #fff; background: linear-gradient(135deg, #6558d3, #5547be); border-bottom-left-radius: 0.3rem; box-shadow: 0 8px 20px rgba(101,88,211,0.14); }
.message-row.assistant .message-content { color: var(--ink); border: 1px solid var(--line); background: var(--surface-soft); border-bottom-right-radius: 0.3rem; }
.message-meta { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.3rem; color: var(--muted-2); font-size: 0.78rem; }
.message-tool-evidence { display: flex; align-items: center; gap: .35rem; width: fit-content; margin-top: .65rem; padding: .3rem .55rem; border: 1px solid #bfe7e2; border-radius: 999px; color: #0f766e; background: #f0fdfa; font-size: .76rem; }
.message-tool-evidence small { color: var(--muted); }
.message-tool-evidence.warning { border-color: #f1cbd2; color: var(--danger); background: var(--danger-soft); }
.invocation-technical-details { grid-column: 1 / -1; margin-top: .4rem; }
.invocation-technical-details summary { width: fit-content; cursor: pointer; color: var(--brand-strong); font-size: .78rem; }
.invocation-technical-details pre { max-height: 18rem; overflow: auto; padding: .65rem; border-radius: .6rem; background: var(--canvas); color: var(--ink); font: .75rem/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; }
.message-row.user .message-meta { justify-content: flex-start; }
.message-action { padding: 0; border: 0; color: var(--brand-strong); background: transparent; font-size: 0.78rem; }
.message-action:hover { text-decoration: underline; }
.typing-bubble { display: inline-flex; gap: 0.3rem; padding: 0.85rem 1rem; border: 1px solid var(--line); border-radius: 1rem 1rem 0.3rem 1rem; background: var(--surface-soft); }
.typing-bubble i { width: 0.42rem; height: 0.42rem; border-radius: 50%; background: var(--muted-2); animation: pulse 1s infinite ease-in-out; }
.typing-bubble i:nth-child(2) { animation-delay: 120ms; }
.typing-bubble i:nth-child(3) { animation-delay: 240ms; }

.agent-draft-card {
  margin: 0.6rem 0 1.25rem;
  padding: 1rem;
  border: 1px solid #d7d2f8;
  border-radius: 1rem;
  background: linear-gradient(145deg, #fbfaff, #f5f3ff);
  box-shadow: var(--shadow-sm);
}
.agent-draft-heading, .agent-draft-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.agent-draft-heading h3 { margin: 0.15rem 0 0; color: var(--ink-strong); font-size: 1.05rem; }
.draft-state { padding: 0.2rem 0.55rem; border-radius: 999px; color: var(--warning); background: var(--warning-soft); font-size: 0.78rem; font-weight: 800; }
.draft-summary { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.85rem 0; }
.draft-count { padding: 0.22rem 0.58rem; border-radius: 999px; font-size: 0.76rem; font-weight: 800; }
.draft-count.changed { color: var(--brand-strong); background: var(--brand-soft); }
.draft-count.unchanged { color: var(--muted); background: #edf0f5; }
.draft-warning { margin: 0.7rem 0; padding: 0.65rem 0.75rem; border: 1px solid #efc47d; border-radius: 0.65rem; color: #8b5b08; background: var(--warning-soft); font-size: 0.84rem; }
.draft-comparison { overflow: hidden; margin: 0.85rem 0; border: 1px solid var(--line); border-radius: 0.8rem; background: var(--surface); }
.draft-comparison-head, .draft-comparison-row { display: grid; grid-template-columns: minmax(6rem, 0.75fr) minmax(8rem, 1fr) minmax(8rem, 1fr) 4.6rem; }
.draft-comparison-head { color: var(--muted); background: var(--surface-soft); font-size: 0.72rem; font-weight: 800; }
.draft-comparison-head span, .draft-comparison-row > strong, .draft-comparison-row > div, .draft-comparison-row > .draft-change-state { padding: 0.55rem 0.65rem; border-inline-start: 1px solid var(--line); }
.draft-comparison-head span:first-child, .draft-comparison-row > strong:first-child { border-inline-start: 0; }
.draft-comparison-row { position: relative; border-top: 1px solid var(--line); color: var(--ink); font-size: 0.82rem; }
.draft-comparison-row > strong { color: var(--ink-strong); background: #fbfcfe; }
.draft-comparison-row.changed { box-shadow: inset -3px 0 0 var(--brand); }
.draft-comparison-row.changed > div:nth-of-type(2) { background: #faf9ff; }
.draft-comparison-row.unchanged { color: var(--muted); }
.draft-comparison-row.long > div { max-height: 10rem; overflow: auto; white-space: pre-wrap; }
.draft-change-state { align-self: stretch; display: grid; place-items: center; color: var(--muted); font-size: 0.73rem; font-weight: 800; text-align: center; }
.draft-comparison-row.changed .draft-change-state { color: var(--brand-strong); background: var(--brand-soft); }
.draft-comparison-row.tools { padding-bottom: 2.25rem; }
.draft-tool-delta { position: absolute; right: 0.65rem; bottom: 0.45rem; left: 0.65rem; display: flex; flex-wrap: wrap; gap: 0.35rem; padding: 0 !important; border: 0 !important; }
.draft-tool-delta span { padding: 0.12rem 0.45rem; border-radius: 999px; font-size: 0.72rem; font-weight: 750; }
.draft-tool-delta .added { color: #11736a; background: var(--teal-soft); }
.draft-tool-delta .removed { color: var(--danger); background: var(--danger-soft); }
.draft-tool-delta .kept { color: var(--muted); background: #edf0f5; }
.agent-draft-actions small { color: var(--muted); }
@keyframes pulse { 0%, 70%, 100% { opacity: 0.32; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-0.18rem); } }

.empty-state { height: 100%; min-height: 18rem; display: grid; place-items: center; text-align: center; }
.empty-state > div { max-width: 31rem; }
.empty-symbol { width: 4.5rem; height: 4.5rem; display: grid; place-items: center; margin: 0 auto 1rem; border: 1px solid #dcd7fb; border-radius: 1.4rem; color: var(--brand); background: linear-gradient(145deg, #f5f3ff, #ebe8ff); font-size: 1.8rem; }
.empty-state h2 { margin: 0; color: var(--ink-strong); font-size: 1.4rem; }
.empty-state p { margin: 0.5rem auto 1.1rem; color: var(--muted); }
.empty-steps { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.45rem; }
.empty-steps span { padding: 0.3rem 0.65rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 0.84rem; }

.composer { padding: 0.85rem 1rem 0.75rem; border-top: 1px solid var(--line); background: var(--surface); }
.composer { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 0.6rem; align-items: end; }
.composer textarea, .memory-form textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--line-strong);
  border-radius: 0.85rem;
  color: var(--ink);
  background: var(--surface-soft);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.composer textarea { min-height: 3.2rem; max-height: 9rem; padding: 0.78rem 0.9rem; }
.composer textarea:focus, .memory-form textarea:focus, .editor input:focus, .editor textarea:focus, .editor select:focus, .provider-card input:focus, .provider-card select:focus { border-color: #9d94e6; box-shadow: 0 0 0 3px rgba(101,88,211,0.1); outline: none; }
.send-button { min-width: 6.3rem; min-height: 3.2rem; display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.7rem 0.9rem; border: 0; border-radius: 0.85rem; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-strong)); font-weight: 800; box-shadow: 0 8px 18px rgba(101,88,211,0.2); }
.send-button:hover { filter: brightness(1.04); }
.send-button kbd { padding: 0.05rem 0.3rem; border: 1px solid rgba(255,255,255,0.24); border-radius: 0.35rem; color: #e7e4ff; font-family: inherit; font-size: 0.7rem; font-weight: 500; }
.composer > p { grid-column: 1 / -1; margin: -0.15rem 0 0; color: var(--muted-2); font-size: 0.78rem; }
.composer-media-actions { display: flex; gap: 0.35rem; padding-bottom: 0.35rem; }
.media-button { width: 2.65rem; height: 2.65rem; display: grid; place-items: center; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--brand-strong); background: var(--surface-soft); font-size: 1.15rem; }
.media-button:hover { border-color: #bcb5ee; background: var(--brand-soft); }
.media-button.recording { color: #fff; border-color: var(--danger); background: var(--danger); animation: pulse-recording 1.1s infinite ease-in-out; }
@keyframes pulse-recording { 50% { box-shadow: 0 0 0 6px rgba(190,48,74,0.14); } }
.media-preview { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.media-preview:empty { display: none; }
.media-draft { max-width: 100%; display: flex; align-items: center; gap: 0.55rem; padding: 0.45rem 0.55rem; border: 1px solid var(--line); border-radius: 0.75rem; background: var(--surface-soft); }
.media-draft img { width: 2.6rem; height: 2.6rem; object-fit: cover; border-radius: 0.55rem; }
.media-draft audio { max-width: min(18rem, 62vw); height: 2.3rem; }
.media-draft-info { min-width: 0; display: flex; flex-direction: column; }
.media-draft-info strong { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8rem; }
.media-draft-info small { color: var(--muted); font-size: 0.72rem; }
.media-remove { width: 1.75rem; height: 1.75rem; padding: 0; border: 0; border-radius: 50%; color: var(--danger); background: var(--danger-soft); }
.message-media { display: grid; gap: 0.45rem; margin-top: 0.45rem; }
.message-attachment { display: flex; align-items: center; gap: 0.65rem; min-width: 12rem; padding: 0.55rem 0.65rem; border: 1px solid rgba(127,136,153,0.3); border-radius: 0.75rem; color: inherit; background: rgba(255,255,255,0.16); text-decoration: none; }
.message-attachment:hover { border-color: var(--brand); }
.message-attachment img { width: min(16rem, 100%); max-height: 13rem; object-fit: contain; border-radius: 0.65rem; }
.message-attachment-details { min-width: 0; display: flex; flex-direction: column; }
.message-attachment-details strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-attachment-details small { opacity: 0.76; }
.message-media audio { width: min(22rem, 100%); }
.message-audio { display: grid; gap: 0.45rem; }
.transcript-card { display: grid; gap: 0.5rem; padding: 0.65rem; border: 1px solid rgba(127,136,153,0.3); border-radius: 0.75rem; background: rgba(255,255,255,0.18); }
.transcript-card textarea { width: 100%; min-height: 5.5rem; padding: 0.6rem 0.7rem; border: 1px solid var(--line-strong); border-radius: 0.65rem; color: var(--ink); background: var(--surface); font: inherit; line-height: 1.6; resize: vertical; }
.transcript-heading, .transcript-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.55rem; flex-wrap: wrap; }
.transcript-heading small { color: var(--muted); }
.transcript-actions button, .transcribe-button { min-height: 2.25rem; padding: 0.35rem 0.65rem; border: 1px solid var(--line-strong); border-radius: 0.65rem; color: var(--brand-strong); background: var(--surface); font: inherit; font-size: 0.78rem; font-weight: 750; }
.transcript-actions button:hover, .transcribe-button:hover { border-color: #bcb5ee; background: var(--brand-soft); }
.transcribe-button:disabled { color: var(--muted); cursor: not-allowed; opacity: 0.7; }

.panel-copy { margin: 0 1.15rem 0.8rem; color: var(--muted); font-size: 0.86rem; }
.count-badge { min-width: 1.9rem; height: 1.9rem; display: grid; place-items: center; border-radius: 999px; color: var(--brand-strong); background: var(--brand-soft); font-size: 0.82rem; font-weight: 800; }
.memory-form { padding: 0 1.1rem 1rem; border-bottom: 1px solid var(--line); }
.memory-form textarea { min-height: 4.5rem; padding: 0.65rem 0.75rem; }
.memory-form button { width: 100%; margin-top: 0.45rem; }
.memory-list { height: calc(100% - 15rem); overflow-y: auto; padding: 0.75rem; scrollbar-width: thin; }
.memory-item { padding: 0.75rem; margin-bottom: 0.55rem; border: 1px solid var(--line); border-radius: 0.8rem; background: var(--surface-soft); }
.memory-item.pinned { border-color: #d9d4fa; background: #f8f7ff; }
.memory-item p { margin: 0; color: var(--ink); font-size: 0.88rem; line-height: 1.55; overflow-wrap: anywhere; }
.memory-actions { display: flex; align-items: center; gap: 0.7rem; margin-top: 0.5rem; }
.memory-actions button { padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 0.78rem; }
.memory-actions button:hover { color: var(--brand-strong); }
.memory-actions .delete:hover { color: var(--danger); }

.section-intro { display: flex; align-items: end; justify-content: space-between; gap: 1rem; max-width: 84rem; margin: 0 auto 1.2rem; }
.section-intro h2 { margin: 0.15rem 0 0; color: var(--ink-strong); font-size: 1.65rem; letter-spacing: -0.025em; }
.section-intro p { margin: 0.35rem 0 0; color: var(--muted); }
.primary-button, .secondary-button, .danger-button {
  min-height: 2.75rem;
  padding: 0.55rem 1rem;
  border-radius: 0.78rem;
  font-weight: 750;
}
.primary-button { border: 0; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-strong)); box-shadow: 0 7px 17px rgba(101,88,211,0.18); }
.primary-button:hover { filter: brightness(1.04); }
.secondary-button { border: 1px solid var(--line-strong); color: var(--ink); background: var(--surface); }
.secondary-button:hover { border-color: #bcb5ee; color: var(--brand-strong); background: var(--brand-soft); }
.danger-button { border: 1px solid #f1bec8; color: var(--danger); background: var(--danger-soft); }
.danger-button:hover { border-color: #e694a4; }

.management-layout { max-width: 84rem; min-height: calc(100vh - 13rem); display: grid; grid-template-columns: minmax(17rem, 0.75fr) minmax(30rem, 1.65fr); gap: 1rem; margin: 0 auto; }
.entity-list { align-self: start; padding: 0.7rem; }
.agent-list-item { width: 100%; display: flex; align-items: center; gap: 0.75rem; padding: 0.8rem; margin-bottom: 0.35rem; text-align: right; border: 1px solid transparent; border-radius: 0.85rem; background: transparent; }
.agent-list-item:hover { background: var(--surface-soft); }
.agent-list-item.active { border-color: #d7d2f8; background: var(--brand-soft); }
.agent-list-item > div { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.agent-list-item strong, .agent-list-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-list-item strong { color: var(--ink); }
.agent-list-item small { color: var(--muted); font-size: 0.84rem; }
.mini-state { width: 0.55rem; height: 0.55rem; flex: 0 0 auto; border-radius: 50%; background: var(--teal); }
.mini-state.off { background: var(--muted-2); }

.editor { padding: clamp(1.1rem, 2vw, 1.6rem); }
.editor-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; }
.editor-heading h3 { margin: 0.15rem 0 0; color: var(--ink-strong); font-size: 1.35rem; }
.editor > label, .form-grid label { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; color: var(--ink); font-size: 0.9rem; font-weight: 700; }
.editor input, .editor textarea, .editor select, .provider-card input, .provider-card select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 0.78rem;
  color: var(--ink);
  background: var(--surface-soft);
}
.editor input, .editor select, .provider-card input, .provider-card select { min-height: 2.8rem; padding: 0.55rem 0.75rem; }
.editor textarea { min-height: 11rem; padding: 0.7rem 0.8rem; resize: vertical; line-height: 1.7; }
.editor label small { color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.form-grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.form-grid.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.8rem; }
.form-grid.four { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.8rem; }
.toggle-row { display: flex; flex-wrap: wrap; gap: 1.2rem; padding: 0.75rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.switch { display: inline-flex; align-items: center; gap: 0.55rem; cursor: pointer; }
.switch input { position: absolute; width: 1px !important; height: 1px; margin: 0; opacity: 0; pointer-events: none; clip-path: inset(50%); }
.switch > span { position: relative; width: 2.45rem; height: 1.42rem; flex: 0 0 auto; border-radius: 999px; background: #cbd3df; transition: background 150ms ease; }
.switch > span::after { content: ""; position: absolute; top: 0.19rem; right: 0.2rem; width: 1.04rem; height: 1.04rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.18); transition: transform 150ms ease; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(-1rem); }
.switch input:focus-visible + span { outline: 3px solid rgba(101,88,211,0.2); outline-offset: 2px; }
.switch b { font-size: 0.9rem; }
.form-actions { display: flex; gap: 0.7rem; margin-top: 1.15rem; }
.form-actions .danger-button { margin-inline-start: auto; }

.security-chip { display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0.35rem 0.8rem; border: 1px solid #bfe3dd; border-radius: 999px; color: #12766d; background: var(--teal-soft); font-size: 0.85rem; font-weight: 750; }
.settings-actions { display: flex; align-items: center; gap: 0.65rem; }
.transcription-settings { max-width: 84rem; margin: 0 auto 1rem; padding: 1.1rem 1.25rem; }
.transcription-settings .panel-heading { padding: 0 0 0.8rem; }
.transcription-settings > p { margin: 0 0 1rem; color: var(--muted); }
.transcription-settings label { display: flex; flex-direction: column; gap: 0.35rem; color: var(--ink); font-size: 0.88rem; font-weight: 700; }
.transcription-settings select { min-height: 2.8rem; padding: 0.55rem 0.75rem; border: 1px solid var(--line-strong); border-radius: 0.78rem; color: var(--ink); background: var(--surface-soft); font: inherit; }
.transcription-settings-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.25rem; }
.transcription-settings-footer .switch { flex-direction: row; }
.transcription-settings > small { display: block; margin-top: 0.7rem; color: var(--muted-2); }
.provider-grid { max-width: 84rem; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 0 auto; }
.provider-card { overflow: hidden; }
.provider-card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.3rem 1rem; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fff, #fbfbfd); }
.provider-identity { display: flex; align-items: center; gap: 0.75rem; }
.provider-icon { width: 2.7rem; height: 2.7rem; display: grid; place-items: center; border-radius: 0.85rem; color: #fff; background: linear-gradient(145deg, #26344a, #131d2d); font-size: 1rem; font-weight: 800; }
.provider-icon.protocol-ollama { background: linear-gradient(145deg, #1fa89b, #0b776e); }
.provider-icon.protocol-gemini { background: linear-gradient(145deg, #4e82ee, #7c4ddd); }
.provider-icon.protocol-anthropic { background: linear-gradient(145deg, #b06f4d, #77402b); }
.provider-identity > div { display: flex; flex-direction: column; }
.provider-identity strong { color: var(--ink-strong); font-size: 1.05rem; }
.provider-identity small { color: var(--muted); font-size: 0.83rem; }
.connection-state { padding: 0.22rem 0.58rem; border-radius: 999px; color: var(--muted); background: #edf0f5; font-size: 0.78rem; font-weight: 800; }
.connection-state.ok { color: #11736a; background: var(--teal-soft); }
.connection-state.failed { color: var(--danger); background: var(--danger-soft); }
.provider-fields { padding: 1.15rem 1.3rem 1.3rem; }
.provider-fields label { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.85rem; color: var(--ink); font-size: 0.88rem; font-weight: 700; }
.provider-fields label small { color: var(--muted); font-size: 0.79rem; font-weight: 400; }
.provider-fields .switch { flex-direction: row; }
.provider-actions { display: flex; align-items: center; gap: 0.65rem; margin-top: 1rem; }
.provider-actions small { margin-inline-start: auto; color: var(--muted-2); font-size: 0.79rem; }
.info-banner { max-width: 84rem; display: flex; align-items: flex-start; gap: 0.8rem; margin: 1rem auto 0; padding: 1rem 1.1rem; border: 1px solid #d9d4fa; border-radius: var(--radius); background: #f7f6ff; }
.info-icon { width: 1.8rem; height: 1.8rem; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--brand); font-weight: 800; }
.info-banner strong { color: var(--ink-strong); }
.info-banner p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.88rem; }
.provider-dialog { width: min(43rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; border-radius: var(--radius-lg); color: var(--ink); background: transparent; box-shadow: var(--shadow-md); }
.provider-dialog::backdrop { background: rgba(11, 20, 36, 0.58); backdrop-filter: blur(3px); }
.provider-dialog-card { max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1.35rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.provider-dialog-card > label { display: flex; flex-direction: column; gap: 0.38rem; margin-bottom: 0.9rem; font-size: 0.88rem; font-weight: 750; }
.provider-dialog-card input, .provider-dialog-card select { min-height: 2.8rem; padding: 0.55rem 0.75rem; border: 1px solid var(--line-strong); border-radius: 0.72rem; font: inherit; background: #fff; }
.provider-dialog-card label small, .template-description { color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.provider-dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.provider-dialog-heading h2 { margin: 0.15rem 0 0; color: var(--ink-strong); }
.provider-dialog-actions { display: flex; justify-content: flex-end; gap: 0.65rem; margin-top: 1.1rem; }

.empty-list { padding: 1.4rem 0.8rem; color: var(--muted); text-align: center; font-size: 0.88rem; }
.toast { position: fixed; z-index: 100; left: 1.25rem; bottom: 1.25rem; max-width: min(26rem, calc(100vw - 2.5rem)); padding: 0.78rem 1rem; border: 1px solid var(--line-strong); border-radius: 0.85rem; color: var(--ink); background: var(--surface); box-shadow: var(--shadow-md); opacity: 0; transform: translateY(0.75rem); pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: #f0b5c0; color: #9f2e43; background: #fff8f9; }
.fatal-state { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 1.5rem; background: var(--canvas); }
.fatal-state[hidden] { display: none; }
.fatal-state > div { max-width: 28rem; padding: 2rem; text-align: center; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-md); }
.fatal-state .brand-mark { margin: 0 auto; }
.fatal-state h1 { margin: 1rem 0 0.4rem; }
.fatal-state p { color: var(--muted); }
.fatal-state button { min-height: 2.7rem; padding: 0.5rem 1rem; border: 0; border-radius: 0.75rem; color: #fff; background: var(--brand); font-weight: 800; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(circle at top right, #edf8f6, var(--canvas) 48%); }
.login-screen[hidden] { display: none; }
.app-shell[hidden] { display: none; }
.login-card { width: min(28rem, 100%); display: grid; gap: 1rem; padding: 2rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-md); }
.login-card .brand-mark { margin-inline: auto; }
.login-card h1, .login-card p { margin: 0; }
.login-card > p:not(.eyebrow):not(.form-error) { color: var(--muted); }
.login-card label { display: grid; gap: .45rem; font-weight: 750; }
.login-card input { min-height: 2.8rem; padding: .65rem .8rem; border: 1px solid var(--line-strong); border-radius: .75rem; font: inherit; }
.form-error { min-height: 1.4rem; color: #9f2e43; }
.logout-button { width: 100%; margin-top: .65rem; padding: .65rem; border: 1px solid var(--line); border-radius: .75rem; color: var(--muted); background: transparent; font: inherit; font-weight: 750; cursor: pointer; }
.workspace-create-actions { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.workspace-create-actions select { min-height: 2.65rem; max-width: 13rem; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: .7rem; background: var(--surface); font: inherit; }
.workspace-chat-layout { display: grid; grid-template-columns: minmax(15rem, 20rem) minmax(0, 1fr); gap: 1rem; min-height: min(68vh, 46rem); }
.workspace-conversation-list { padding: .75rem; overflow: auto; }
.workspace-conversation-list button { width: 100%; display: grid; gap: .25rem; padding: .8rem; margin-bottom: .5rem; text-align: start; border: 1px solid transparent; border-radius: .8rem; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.workspace-conversation-list button.active { border-color: var(--line-strong); background: var(--canvas); }
.workspace-conversation-list small { color: var(--muted); }
.workspace-thread { display: grid; grid-template-rows: auto auto auto 1fr auto; min-width: 0; overflow: hidden; }
.workspace-thread .messages { min-height: 20rem; }
.voice-call-panel { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; padding: .75rem 1rem; border-block: 1px solid var(--line); background: #f3fbf9; }
.voice-call-panel[hidden] { display: none; }
.voice-call-panel > div:first-of-type { display: grid; gap: .15rem; flex: 1 1 12rem; }
.voice-call-panel small, .voice-retention { color: var(--muted); font-size: .78rem; }
.voice-call-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.voice-call-actions button { min-height: 2.35rem; padding: .45rem .75rem; }
.voice-retention { display: grid; gap: .2rem; }
.voice-retention select { min-height: 2.2rem; border: 1px solid var(--line); border-radius: .55rem; background: var(--surface); font: inherit; }
.voice-call-recording-notice { width: 100%; color: var(--danger); font-size: .82rem; font-weight: 800; }
.voice-call-history { padding-inline: 1rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.voice-call-history details { padding: .5rem 0; }
.voice-call-history summary { color: var(--muted); cursor: pointer; font-size: .82rem; font-weight: 800; }
.voice-call-history-list { display: grid; gap: .4rem; padding-top: .55rem; max-height: 11rem; overflow: auto; }
.voice-call-history-list article { display: flex; align-items: center; gap: .65rem; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: .65rem; }
.voice-call-history-list article > div { display: grid; flex: 1; }
.voice-call-history-list audio { width: min(15rem, 45vw); height: 2rem; }
.workspace-message { max-width: min(42rem, 86%); margin: .5rem; padding: .75rem .9rem; border-radius: .9rem; background: var(--canvas); }
.workspace-message.mine { margin-inline-start: auto; color: #fff; background: var(--brand); }
.workspace-message.agent { border: 1px solid var(--line-strong); background: #f3fbf9; }
.workspace-message header { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .35rem; font-size: .78rem; opacity: .78; }
.organization-admin { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 1rem; margin-bottom: 1rem; }
.organization-admin form { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.organization-admin strong { flex-basis: 100%; }
.organization-admin input, .organization-admin select { flex: 1 1 8rem; min-height: 2.55rem; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: .7rem; background: var(--surface); font: inherit; }
.workspace-permissions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: .5rem; color: var(--muted); font-size: .8rem; }
.workspace-permissions label { display: inline-flex; align-items: center; gap: .3rem; }
.knowledge-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .75rem; align-items: end; padding: 1rem; margin-bottom: 1rem; }
.knowledge-search label, .knowledge-editor label { display: grid; gap: .4rem; color: var(--muted); font-size: .85rem; font-weight: 750; }
.knowledge-search input, .knowledge-editor input, .knowledge-editor select, .knowledge-editor textarea, .knowledge-document-picker select { width: 100%; min-height: 2.65rem; padding: .55rem .7rem; border: 1px solid var(--line-strong); border-radius: .75rem; color: var(--ink); background: var(--surface); font: inherit; }
.knowledge-editor textarea { resize: vertical; }
.knowledge-search-results { display: grid; gap: .7rem; margin-bottom: 1rem; }
.knowledge-search-result { padding: 1rem; }
.knowledge-search-result header { display: flex; justify-content: space-between; gap: 1rem; }
.knowledge-search-result header span, .knowledge-search-result footer { color: var(--muted); font-size: .82rem; }
.knowledge-search-result p { white-space: pre-wrap; line-height: 1.75; }
.knowledge-layout { display: grid; grid-template-columns: minmax(17rem, .8fr) minmax(0, 1.4fr); gap: 1rem; }
.knowledge-catalog, .knowledge-editor, .knowledge-review { padding: 1rem; }
.knowledge-editor form { display: grid; gap: .8rem; }
.knowledge-item { width: 100%; display: grid; gap: .3rem; padding: .85rem; margin-bottom: .55rem; text-align: start; border: 1px solid var(--line); border-radius: .8rem; color: inherit; background: var(--surface); font: inherit; cursor: pointer; }
.knowledge-item:hover, .knowledge-item.active { border-color: var(--brand); background: #f5f4ff; }
.knowledge-item span, .knowledge-item small { color: var(--muted); }
.knowledge-review { margin-top: 1rem; }
.knowledge-version { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.knowledge-version:last-child { border-bottom: 0; }
.knowledge-version header { display: flex; justify-content: space-between; gap: 1rem; }
.knowledge-version p { max-height: 18rem; overflow: auto; white-space: pre-wrap; line-height: 1.75; }
.knowledge-version dl { display: grid; grid-template-columns: 5rem minmax(0, 1fr); gap: .35rem .7rem; color: var(--muted); font-size: .85rem; }
.knowledge-version dt { font-weight: 800; }
.knowledge-version dd { margin: 0; }
.knowledge-status { padding: .2rem .55rem; border-radius: 999px; color: var(--muted); background: var(--canvas); font-size: .78rem; }
.knowledge-status.approved { color: #116457; background: #e7f7f3; }
.knowledge-status.pending { color: #875b00; background: #fff5d8; }
.knowledge-status.rejected { color: #9f2e43; background: #fff0f3; }
.knowledge-document-picker { padding: .75rem; border: 1px dashed var(--line-strong); border-radius: .75rem; background: var(--canvas); }
.invoice-import-center { padding: 1rem; margin-bottom: 1rem; }
.sales-data-center { padding: 1rem; margin-bottom: 1rem; }
.sales-data-center form { display: grid; gap: .75rem; margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.sales-profile-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .6rem; margin-top: .8rem; }
.sales-profile-card { padding: .75rem; border: 1px solid var(--line); border-radius: .75rem; background: var(--surface-soft); }
.sales-profile-card strong, .sales-profile-card span { display: block; }
.sales-profile-card small { color: var(--muted); }
.sales-import-status { margin-top: .8rem; padding: .75rem; border-radius: .75rem; color: var(--muted); background: var(--surface-soft); }
.invoice-import-center .panel-heading p { margin: .25rem 0 0; color: var(--muted); font-size: .8rem; }
#invoice-import-form, .invoice-search { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: .7rem; align-items: end; margin-top: .8rem; }
#invoice-import-form label, .invoice-search label { display: grid; gap: .35rem; color: var(--muted); font-size: .82rem; font-weight: 750; }
#invoice-import-form select, #invoice-import-form input, .invoice-search input { min-height: 2.55rem; width: 100%; padding: .5rem .65rem; border: 1px solid var(--line-strong); border-radius: .72rem; background: var(--surface); color: var(--ink); font: inherit; }
.invoice-file-picker { grid-column: span 2; }
.invoice-file-picker small { font-weight: 500; }
.invoice-search { grid-template-columns: minmax(0, 1fr) auto; padding-top: .8rem; border-top: 1px solid var(--line); }
.invoice-import-layout { display: grid; grid-template-columns: minmax(15rem, .65fr) minmax(0, 1.35fr); gap: .8rem; margin-top: .8rem; }
.invoice-import-list, .invoice-import-detail { min-height: 8rem; padding: .75rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--surface-soft); }
.invoice-import-card { width: 100%; display: grid; gap: .3rem; padding: .7rem; margin-bottom: .5rem; text-align: start; border: 1px solid var(--line); border-radius: .72rem; background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
.invoice-import-card.active { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.invoice-import-card small, .invoice-import-card span, .invoice-progress small { color: var(--muted); }
.invoice-progress-bar { height: .45rem; overflow: hidden; border-radius: 999px; background: var(--line); }
.invoice-progress-bar i { display: block; height: 100%; background: var(--brand); }
.invoice-import-counts { display: flex; flex-wrap: wrap; gap: .45rem; margin: .7rem 0; }
.invoice-import-counts span { padding: .2rem .5rem; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: .75rem; }
.invoice-record { padding: .8rem; margin-top: .65rem; border: 1px solid var(--line); border-radius: .75rem; background: var(--surface); }
.invoice-record header { display: flex; justify-content: space-between; gap: .6rem; }
.invoice-record-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; margin-top: .65rem; }
.invoice-record-form label { display: grid; gap: .25rem; color: var(--muted); font-size: .76rem; }
.invoice-record-form input, .invoice-record-form select { min-width: 0; padding: .45rem; border: 1px solid var(--line); border-radius: .55rem; font: inherit; }
.invoice-record-form .form-actions { grid-column: 1 / -1; }
.invoice-record-warning { color: #956200; font-size: .78rem; }
.invoice-file-status { display: flex; justify-content: space-between; gap: .7rem; padding: .35rem 0; border-bottom: 1px solid var(--line); font-size: .76rem; }
.invoice-search-result { padding: .65rem; margin-top: .5rem; border: 1px solid var(--line); border-radius: .7rem; background: var(--surface-soft); }

.task-summary { display: grid; grid-template-columns: repeat(6, minmax(7rem, 1fr)); gap: 0.65rem; margin-bottom: 0.85rem; overflow-x: auto; }
.task-summary article { min-width: 7rem; padding: 0.8rem; border: 1px solid var(--line); border-radius: 0.9rem; background: var(--surface); }
.task-summary strong { display: block; font-size: 1.35rem; }
.task-summary span { color: var(--muted); font-size: 0.78rem; }
.task-layout { display: grid; grid-template-columns: minmax(18rem, 0.85fr) minmax(24rem, 1.5fr); gap: 0.8rem; margin-bottom: 0.85rem; }
.task-create, .task-detail { padding: 1rem; }
.task-create label, #task-evidence-form { display: grid; gap: 0.35rem; margin-bottom: 0.65rem; }
.task-board { display: grid; grid-template-columns: repeat(6, minmax(14rem, 1fr)); gap: 0.7rem; overflow-x: auto; padding-bottom: 0.5rem; }
.task-column { min-width: 14rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface-soft); padding: 0.65rem; }
.task-column > header { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
.task-card { width: 100%; display: grid; gap: 0.35rem; text-align: right; padding: 0.7rem; margin-bottom: 0.45rem; border: 1px solid var(--line); border-radius: 0.8rem; background: var(--surface); color: inherit; }
.task-card.active { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.task-card small { color: var(--muted); }
.task-priority { width: fit-content; border-radius: 999px; padding: 0.15rem 0.45rem; font-size: 0.68rem; background: var(--surface-soft); }
.task-priority.urgent, .task-blocker { color: var(--danger); }
.task-priority.high { color: #b86b00; }
.task-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.task-meta div { padding: 0.55rem; background: var(--surface-soft); border-radius: 0.65rem; }
.task-meta dt { color: var(--muted); font-size: 0.72rem; }.task-meta dd { margin: 0.15rem 0 0; }
.task-evidence article, .task-result, .task-blocker { margin: 0.55rem 0; padding: 0.65rem; border-inline-start: 3px solid var(--brand); background: var(--surface-soft); border-radius: 0.5rem; }
.task-evidence article span { color: var(--muted); font-size: 0.68rem; display: block; }

@media (max-width: 800px) {
  .task-layout { grid-template-columns: 1fr; }
  .workspace-chat-layout { grid-template-columns: 1fr; }
  .workspace-conversation-list { max-height: 13rem; }
  .workspace-create-actions { align-items: stretch; }
  .workspace-create-actions select, .workspace-create-actions button { max-width: none; flex: 1 1 12rem; }
  .organization-admin { grid-template-columns: 1fr; }
  .knowledge-layout, .knowledge-search { grid-template-columns: 1fr; }
  #invoice-import-form, .invoice-search, .invoice-import-layout, .invoice-record-form { grid-template-columns: 1fr; }
  .invoice-file-picker { grid-column: auto; }
}

@media (max-width: 1180px) {
  :root { --sidebar-width: 14rem; }
  .brand-copy small, .main-nav small { display: none; }
  .chat-layout { grid-template-columns: 14rem minmax(23rem,1fr) 16rem; }
  .panel-copy { display: none; }
  .memory-list { height: calc(100% - 12.2rem); }
}

@media (max-width: 960px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; right: 0; width: min(19rem, 86vw); display: none; box-shadow: var(--shadow-md); }
  .app-shell.sidebar-open .sidebar { display: flex; }
  .brand-copy small, .main-nav small { display: block; }
  .mobile-menu { display: grid; }
  .topbar { height: 5.6rem; padding-inline: 1.1rem; }
  .view { padding: 1rem; }
  .chat-layout { height: auto; min-height: calc(100vh - 7.6rem); grid-template-columns: 13rem minmax(0,1fr); grid-template-rows: minmax(36rem, calc(100vh - 7.6rem)) auto; }
  .memory-rail { grid-column: 1 / -1; min-height: 18rem; }
  .memory-list { height: auto; max-height: 20rem; }
  .management-layout, .provider-grid, .tool-grid { grid-template-columns: 1fr; }
  .management-layout { min-height: auto; }
}

@media (max-width: 680px) {
  .save-state { display: none; }
  .topbar h1 { font-size: 1.45rem; }
  .view { padding: 0.65rem; }
  .chat-layout { display: block; min-height: 0; }
  .conversation-rail { max-height: 13rem; margin-bottom: 0.65rem; }
  .conversation-list { height: 7.5rem; display: flex; gap: 0.4rem; overflow-x: auto; overflow-y: hidden; }
  .conversation-item { min-width: 12.5rem; margin: 0; }
  .chat-panel { height: calc(100vh - 20rem); min-height: 34rem; margin-bottom: 0.65rem; }
  .memory-rail { min-height: 18rem; }
  .chat-toolbar { align-items: flex-start; }
  .compact-select { align-items: flex-start; flex-direction: column; gap: 0.15rem; }
  .compact-select span { display: none; }
  .compact-select select { max-width: 8.5rem; }
  .messages { padding: 1rem 0.75rem; }
  .message-bubble { max-width: 91%; }
  .agent-draft-heading, .agent-draft-actions { align-items: stretch; flex-direction: column; }
  .draft-comparison-head { display: none; }
  .draft-comparison-row { grid-template-columns: 5.5rem minmax(0, 1fr); padding-bottom: 0.4rem; }
  .draft-comparison-row > strong { grid-row: 1 / 4; }
  .draft-comparison-row > div { border-bottom: 1px dashed var(--line); }
  .draft-comparison-row > div::before { display: block; margin-bottom: 0.15rem; color: var(--muted-2); font-size: 0.68rem; font-weight: 800; }
  .draft-comparison-row > div:nth-of-type(1)::before { content: "قبل"; }
  .draft-comparison-row > div:nth-of-type(2)::before { content: "بعد"; }
  .draft-change-state { min-height: 2rem; border-bottom: 0; }
  .draft-comparison-row.tools { padding-bottom: 5rem; }
  .composer { padding: 0.65rem; }
  .send-button { min-width: 4.8rem; }
  .send-button kbd { display: none; }
  .section-intro { align-items: flex-start; }
  .section-intro p { font-size: 0.9rem; }
  .security-chip { display: none; }
  .settings-actions { width: 100%; justify-content: space-between; }
  .form-grid.two, .form-grid.three, .form-grid.four { grid-template-columns: 1fr; gap: 0; }
  .provider-actions { flex-wrap: wrap; }
  .provider-actions small { width: 100%; margin: 0; }
  .tool-card dl { grid-template-columns: 1fr; }
  .conversation-tool-events { margin-inline: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* NSQ Stitch identity — visual layer only; application behavior and data remain unchanged. */
:root {
  --ink: #0f172a;
  --ink-strong: #082f2b;
  --muted: #475569;
  --muted-2: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --canvas: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --sidebar: #ffffff;
  --sidebar-soft: #f0fdfa;
  --brand: #0f766e;
  --brand-strong: #115e59;
  --brand-soft: #e6f4f2;
  --teal: #14b8a6;
  --teal-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.025);
  --shadow-md: 0 16px 40px rgba(15, 23, 42, 0.12);
  --radius-sm: 0.65rem;
  --radius: 0.85rem;
  --radius-lg: 1rem;
  --sidebar-width: 17.5rem;
}

body { background: var(--canvas); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline-color: rgba(15, 118, 110, 0.28);
}

.sidebar {
  color: var(--ink);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: none;
}
.brand { color: var(--ink-strong); border-bottom: 1px solid var(--line); }
.brand-mark {
  border-radius: 0.8rem;
  background: var(--brand);
  box-shadow: none;
}
.brand-copy strong { color: var(--ink-strong); }
.brand-copy small { color: var(--muted); }
.version-pill { border-color: #99f6e4; color: var(--brand-strong); background: #f0fdfa; }
.main-nav { gap: 0.25rem; margin-top: 0.9rem; overflow-y: auto; scrollbar-width: thin; }
.nav-group-label {
  display: block;
  padding: 0.65rem 0.75rem 0.35rem;
  color: var(--muted-2);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.035em;
}
.admin-nav-label { margin-top: 0.5rem; padding-top: 0.85rem; border-top: 1px solid var(--line); }
.main-nav button { min-height: 3.65rem; color: var(--muted); border-radius: 0.75rem; }
.main-nav button:hover { color: var(--brand-strong); background: #f0fdfa; }
.main-nav button.active {
  color: var(--brand-strong);
  border-color: #99f6e4;
  background: var(--brand-soft);
}
.main-nav small, .main-nav button.active small { color: var(--muted-2); }
.nav-icon { color: var(--brand-strong); background: #f1f5f9; }
.main-nav button.active .nav-icon { color: #fff; background: var(--brand); }
.sidebar-status { border-color: var(--line); background: var(--surface-soft); }
.sidebar-status strong { color: var(--ink); }
.sidebar-status small, .local-note { color: var(--muted-2); }
.logout-button { color: var(--muted); border-color: var(--line); background: var(--surface); }

.topbar { height: 5.75rem; background: rgba(248, 250, 252, 0.94); }
.eyebrow, .section-label { color: var(--brand); }
.panel { box-shadow: none; }
.primary-button, .send-button { background: var(--brand); box-shadow: none; }
.primary-button:hover, .send-button:hover { background: var(--brand-strong); filter: none; }
.secondary-button:hover, .square-button:hover, .icon-button:hover, .media-button:hover {
  color: var(--brand-strong);
  border-color: #5eead4;
  background: #f0fdfa;
}
.square-button, .icon-button, .media-button { color: var(--brand-strong); }
.count-badge { color: var(--brand-strong); background: var(--brand-soft); }
.section-intro { align-items: center; }

.chat-layout { height: calc(100vh - 8.3rem); grid-template-columns: 17rem minmax(28rem, 1fr) 18rem; gap: 0.75rem; }
.conversation-rail, .chat-panel, .memory-rail { border-radius: 0.85rem; }
.conversation-item { min-height: 4.65rem; padding: 0.75rem 0.85rem; border-radius: 0.65rem; }
.conversation-item:hover { background: #f0fdfa; }
.conversation-item.active { border-color: #99f6e4; background: var(--brand-soft); }
.conversation-item.active strong { color: var(--brand-strong); }
.chat-toolbar { min-height: 4.65rem; background: #fff; }
.agent-avatar { border-radius: 50%; background: var(--brand); box-shadow: none; }
.messages {
  background-color: #f8fafc;
  background-image: radial-gradient(circle at 1px 1px, rgba(15,118,110,0.045) 1px, transparent 0);
  background-size: 24px 24px;
}
.message-row { margin-bottom: 0.85rem; }
.message-content { padding: 0.72rem 0.9rem; border-radius: 0.95rem; line-height: 1.72; }
.message-row.user .message-content {
  color: var(--ink);
  border: 1px solid #bfe7e2;
  border-bottom-left-radius: 0.25rem;
  background: #e6f4f2;
  box-shadow: none;
}
.message-row.assistant .message-content {
  border-color: var(--line);
  border-bottom-right-radius: 0.25rem;
  background: #fff;
}
.composer { padding: 0.75rem; background: #fff; }
.composer textarea, .memory-form textarea { border-radius: 1.1rem; background: #fff; }
.composer textarea:focus, .memory-form textarea:focus, .editor input:focus, .editor textarea:focus, .editor select:focus, .provider-card input:focus, .provider-card select:focus {
  border-color: #2dd4bf;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}
.send-button { min-width: 5.4rem; border-radius: 1rem; }
.workspace-chat-layout { gap: 0.75rem; }
.workspace-conversation-list button { min-height: 4.75rem; border-radius: 0.65rem; }
.workspace-conversation-list button:hover { background: #f0fdfa; }
.workspace-conversation-list button.active { border-color: #99f6e4; background: var(--brand-soft); }
.workspace-thread { border-radius: 0.85rem; }
.workspace-message { border: 1px solid var(--line); background: #fff; }
.workspace-message.mine { color: var(--ink); border-color: #bfe7e2; background: #e6f4f2; }
.workspace-message.agent { border-color: #99f6e4; background: #f0fdfa; }
.voice-call-panel { background: #f0fdfa; }

.task-summary article, .task-column, .task-card, .knowledge-item, .provider-card, .tool-card { box-shadow: none; }
.task-card.active, .knowledge-item:hover, .knowledge-item.active { border-color: var(--brand); background: #f0fdfa; }
.provider-card-head { background: #fff; }
.provider-icon, .provider-icon.protocol-ollama, .provider-icon.protocol-gemini, .provider-icon.protocol-anthropic { background: var(--brand); }
.info-banner, .agent-draft-card { border-color: #99f6e4; background: #f0fdfa; }
.tool-symbol, .empty-symbol { color: var(--brand-strong); border-color: #99f6e4; background: #e6f4f2; }

@media (max-width: 1180px) {
  :root { --sidebar-width: 14.5rem; }
  .chat-layout { grid-template-columns: 14rem minmax(23rem, 1fr) 15rem; }
}

@media (max-width: 960px) {
  .sidebar { box-shadow: -16px 0 40px rgba(15, 23, 42, 0.16); }
  .chat-layout { grid-template-columns: 12.5rem minmax(0, 1fr); }
}

@media (max-width: 680px) {
  .topbar { height: 4.75rem; padding-inline: 0.85rem; }
  .topbar .eyebrow { display: none; }
  .view { padding: 0.5rem; }
  .section-intro { align-items: stretch; flex-direction: column; padding-inline: 0.2rem; }
  .section-intro > div:first-child { width: 100%; }
  .section-intro h2 { font-size: 1.35rem; }
  .conversation-rail { max-height: 11.5rem; }
  .conversation-list { height: 6.7rem; }
  .conversation-item { min-width: 11.75rem; min-height: 5.8rem; }
  .chat-panel { height: calc(100dvh - 17rem); min-height: 31rem; border-radius: 0.75rem; }
  .chat-toolbar { min-height: 4.2rem; padding: 0.65rem 0.75rem; }
  .chat-tools { gap: 0.35rem; }
  .messages { padding: 0.85rem 0.55rem; }
  .message-bubble { max-width: 92%; }
  .composer { gap: 0.4rem; padding: 0.55rem; }
  .composer > p { display: none; }
  .composer-media-actions { gap: 0.2rem; }
  .media-button { width: 2.55rem; height: 2.55rem; }
  .send-button { min-width: 3.15rem; width: 3.15rem; padding: 0; border-radius: 50%; }
  .send-button span { font-size: 0; }
  .send-button span::after { content: "←"; font-size: 1.15rem; }
  .workspace-chat-layout { display: block; }
  .workspace-conversation-list { max-height: 11rem; margin-bottom: 0.5rem; }
  .workspace-thread { min-height: calc(100dvh - 11rem); }
  .workspace-create-actions { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .workspace-create-actions select, .workspace-create-actions button { width: 100%; max-width: none; }
  .task-summary { grid-template-columns: repeat(6, minmax(6.5rem, 1fr)); }
}

/* Stitch structural redesign: communication-first employee UI and a separate admin center. */
.mobile-dock { display: none; }
.mobile-menu { display: none; }
.admin-home-button {
  min-height: 2.55rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid #99f6e4;
  border-radius: 0.75rem;
  color: var(--brand-strong);
  background: #f0fdfa;
  font-weight: 800;
}
.admin-home-button[hidden] { display: none; }

.communication-shell {
  max-width: 94rem;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  background: var(--surface);
}
.chat-layout {
  height: calc(100dvh - 8.4rem);
  min-height: 40rem;
  grid-template-columns: 21rem minmax(0, 1fr);
  gap: 0;
}
.conversation-rail,
.workspace-directory {
  min-width: 0;
  overflow: hidden;
  border-inline-end: 1px solid var(--line);
  background: #fff;
}
.conversation-list-heading {
  min-height: 5.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.conversation-list-heading > div { min-width: 0; display: grid; }
.conversation-list-heading strong { color: var(--ink-strong); font-size: 1.1rem; }
.conversation-list-heading small { overflow: hidden; color: var(--muted); font-size: 0.78rem; text-overflow: ellipsis; white-space: nowrap; }
.conversation-list { height: calc(100% - 5.25rem); padding: 0.45rem; }
.conversation-item {
  min-height: 5.2rem;
  display: grid;
  align-content: center;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.2rem;
  border: 0;
  border-bottom: 1px solid #f1f5f9;
  border-radius: 0.75rem;
}
.conversation-item.active { border: 0; border-bottom: 1px solid #99f6e4; box-shadow: inset -3px 0 0 var(--brand); }
.conversation-item strong { font-size: 0.98rem; }
.conversation-item span { color: var(--muted); }
.chat-panel {
  min-width: 0;
  border-radius: 0;
  background: #f8fafc;
}
.chat-toolbar {
  min-height: 5.25rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.97);
}
.chat-toolbar > div:not(.chat-tools):not(.agent-presence) { min-width: 0; display: grid; }
.chat-toolbar > div:not(.chat-tools):not(.agent-presence) strong { overflow: hidden; color: var(--ink-strong); text-overflow: ellipsis; white-space: nowrap; }
.chat-tools { margin-inline-start: auto; }
.thread-back-button {
  display: none;
  width: 2.65rem;
  height: 2.65rem;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--brand-strong);
  background: #f0fdfa;
  font-size: 1.25rem;
}
.chat-panel .messages, .workspace-thread .messages {
  padding: 1.5rem clamp(1rem, 5vw, 5rem);
}
.message-bubble { max-width: min(72%, 46rem); }
.message-content { padding: 0.8rem 1rem; }
.composer {
  padding: 0.7rem clamp(0.75rem, 2vw, 1.4rem);
  border-top-color: #e2e8f0;
}
.composer textarea { min-height: 3.05rem; }
.composer > p { margin-inline-start: 3.35rem; }

.context-dialog {
  width: min(30rem, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 2rem);
  margin: auto 0 auto auto;
  padding: 0;
  border: 0;
  border-radius: 1.15rem 0 0 1.15rem;
  color: var(--ink);
  background: transparent;
  box-shadow: var(--shadow-md);
}
.context-dialog[open] { display: grid; }
.context-dialog::backdrop { background: rgba(15, 23, 42, 0.38); backdrop-filter: blur(2px); }
.context-dialog-card { min-height: min(42rem, calc(100dvh - 2rem)); overflow-y: auto; padding: 1rem; background: #fff; }
.context-dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 0.25rem 0.25rem 1rem; border-bottom: 1px solid var(--line); }
.context-dialog-heading h2 { margin: 0.15rem 0 0; color: var(--ink-strong); font-size: 1.4rem; }
.context-section { margin-top: 0.8rem; overflow: hidden; border: 1px solid var(--line); border-radius: 0.9rem; background: #fff; }
.context-section .panel-heading { padding: 0.9rem; }
.context-section .panel-copy { display: block; margin-inline: 0.9rem; }
.context-select { display: grid; gap: 0.35rem; padding: 0.9rem; color: var(--muted); font-size: 0.82rem; font-weight: 750; }
.context-select select { min-height: 2.75rem; padding: 0.45rem 0.65rem; border: 1px solid var(--line-strong); border-radius: 0.7rem; color: var(--ink); background: #fff; font: inherit; }
.context-section > button { width: calc(100% - 1.8rem); margin: 0 0.9rem 0.7rem; }
.context-section .memory-form { padding-inline: 0.9rem; }
.context-section .memory-list { height: auto; max-height: 18rem; padding: 0.7rem 0.9rem 0.9rem; }

.workspace-chat-layout {
  height: calc(100dvh - 8.4rem);
  min-height: 40rem;
  grid-template-columns: 22rem minmax(0, 1fr);
  gap: 0;
}
.workspace-directory { display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
.workspace-create-actions {
  display: grid;
  gap: 0.45rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}
.workspace-create-actions > div { display: grid; grid-template-columns: minmax(0, 1fr) 4.25rem; gap: 0.4rem; }
.workspace-create-actions select, .workspace-create-actions button { width: 100%; max-width: none; min-height: 2.55rem; }
.workspace-conversation-list { max-height: none; padding: 0.45rem; overflow-y: auto; }
.workspace-conversation-list button {
  min-height: 5rem;
  align-content: center;
  margin-bottom: 0.2rem;
  border: 0;
  border-bottom: 1px solid #f1f5f9;
  border-radius: 0.7rem;
}
.workspace-conversation-list button.active { border: 0; border-bottom: 1px solid #99f6e4; box-shadow: inset -3px 0 0 var(--brand); }
.workspace-thread {
  min-height: 0;
  border-radius: 0;
  background: #f8fafc;
}
.workspace-thread > .chat-toolbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }
.workspace-thread .composer { background: #fff; }
.workspace-message { max-width: min(72%, 44rem); border-radius: 1rem; }
.workspace-message.mine { border-bottom-left-radius: 0.25rem; }
.workspace-message:not(.mine) { border-bottom-right-radius: 0.25rem; }

.admin-hero {
  max-width: 78rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin: 0 auto 1.25rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid #bfe7e2;
  border-radius: 1.15rem;
  background: linear-gradient(125deg, #ffffff, #ecfdf5);
}
.admin-hero h2 { margin: 0.2rem 0 0; color: var(--ink-strong); font-size: clamp(1.55rem, 3vw, 2.25rem); }
.admin-hero p { margin: 0.45rem 0 0; color: var(--muted); }
.admin-center-grid {
  max-width: 78rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 0 auto;
}
.admin-center-card {
  min-height: 8.5rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
  padding: 1.1rem;
  text-align: right;
  border: 1px solid var(--line);
  border-radius: 1rem;
  color: var(--ink);
  background: #fff;
}
.admin-center-card:hover { border-color: #5eead4; background: #f0fdfa; transform: translateY(-1px); }
.admin-center-card > span:nth-child(2) { min-width: 0; display: grid; }
.admin-center-card strong { color: var(--ink-strong); font-size: 1.05rem; }
.admin-center-card small { margin-top: 0.2rem; color: var(--muted); }
.admin-center-card b { color: var(--brand); font-size: 1.2rem; }
.admin-card-icon { width: 3rem; height: 3rem; display: grid; place-items: center; border-radius: 0.85rem; color: var(--brand-strong); background: var(--brand-soft); font-size: 1.25rem; font-weight: 800; }
.admin-mode .topbar { border-bottom-color: #bfe7e2; background: #f0fdfa; }

.view[data-view="tasks"] .task-summary,
.view[data-view="tasks"] .task-layout,
.view[data-view="tasks"] .task-board,
.view[data-view="knowledge"] > *,
.view[data-view="agents"] > *,
.view[data-view="tools"] > *,
.view[data-view="settings"] > *,
.view[data-view="team"] > * { max-width: 78rem; margin-inline: auto; }
.view[data-view="tasks"] .task-summary,
.view[data-view="tasks"] .task-layout { margin-bottom: 0.9rem; }
.task-summary article, .task-column, .task-card, .knowledge-search, .invoice-import-center,
.knowledge-catalog, .knowledge-editor, .knowledge-review, .provider-card, .tool-card,
.organization-admin, .entity-list, .editor, .invocation-panel {
  border-radius: 1rem;
}

@media (max-width: 960px) {
  .mobile-menu { display: grid; }
  .communication-shell { border-radius: 0.9rem; }
  .chat-layout { grid-template-columns: 18rem minmax(0, 1fr); grid-template-rows: none; }
  .workspace-chat-layout { grid-template-columns: 18rem minmax(0, 1fr); }
  .admin-center-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  body { padding-bottom: 4.5rem; }
  .workspace { min-height: calc(100dvh - 4.5rem); }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 12;
    height: 4.35rem;
    padding: 0.65rem 0.8rem;
    background: rgba(255, 255, 255, 0.97);
  }
  .topbar h1 { font-size: 1.3rem; }
  .mobile-dock {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    height: 4.5rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.06);
  }
  .employee-mode .mobile-dock { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mobile-dock button {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0.1rem;
    padding: 0.35rem;
    border: 0;
    color: var(--muted);
    background: transparent;
  }
  .mobile-dock button[hidden] { display: none; }
  .mobile-dock button.active { color: var(--brand-strong); background: #f0fdfa; }
  .mobile-dock span { font-size: 1.15rem; line-height: 1; }
  .mobile-dock b { font-size: 0.72rem; }
  .view { padding: 0.65rem; }
  .view[data-view="chat"], .view[data-view="workspace"] { padding: 0; }
  .communication-shell {
    height: calc(100dvh - 8.85rem);
    min-height: 0;
    border: 0;
    border-radius: 0;
  }
  .chat-layout, .workspace-chat-layout {
    display: block;
    height: calc(100dvh - 8.85rem);
    min-height: 0;
  }
  .conversation-rail, .workspace-directory { height: 100%; border: 0; }
  .conversation-list-heading { min-height: 4.75rem; padding: 0.75rem 1rem; }
  .conversation-list { height: calc(100% - 4.75rem); display: block; padding: 0.35rem; overflow: auto; }
  .conversation-item { width: 100%; min-width: 0; min-height: 5rem; margin: 0 0 0.15rem; }
  .chat-panel, .workspace-thread {
    display: none;
    height: 100%;
    min-height: 0;
    margin: 0;
  }
  .thread-open .conversation-rail,
  .thread-open .workspace-directory { display: none; }
  .thread-open .chat-panel,
  .thread-open .workspace-thread { display: grid; }
  .thread-back-button { display: grid; }
  .chat-toolbar { min-height: 4.65rem; }
  .chat-panel .messages, .workspace-thread .messages { padding: 0.85rem 0.6rem; }
  .message-bubble, .workspace-message { max-width: 88%; }
  .composer { padding: 0.5rem; }
  .composer > p { display: none; }
  .workspace-create-actions { grid-template-columns: 1fr; padding: 0.55rem; }
  .workspace-conversation-list { min-height: 0; max-height: none; padding: 0.35rem; overflow-y: auto; }
  .workspace-conversation-list button { min-height: 4.8rem; }
  .context-dialog { width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 1.15rem 1.15rem 0 0; }
  .context-dialog-card { min-height: 70dvh; max-height: 92dvh; }
  .admin-hero { align-items: flex-start; flex-direction: column; padding: 1.15rem; }
  .admin-center-grid { grid-template-columns: 1fr; }
  .admin-center-card { min-height: 6.5rem; }
  .admin-home-button { min-height: 2.35rem; padding: 0.35rem 0.6rem; font-size: 0.78rem; }
  .view[data-view="tasks"] .section-intro,
  .view[data-view="knowledge"] .section-intro,
  .view[data-view="agents"] .section-intro,
  .view[data-view="tools"] .section-intro,
  .view[data-view="settings"] .section-intro,
  .view[data-view="team"] .section-intro { margin-bottom: 0.8rem; }
}
/* مركز التكاملات — نفس لغة نسق البصرية مع فصل واضح عن إعدادات النماذج. */
.integration-layout,
.integration-operations {
  display: grid;
  grid-template-columns: minmax(16rem, .8fr) minmax(0, 2fr);
  gap: 1rem;
  align-items: start;
}

.integration-operations {
  grid-template-columns: minmax(18rem, .9fr) minmax(0, 1.4fr);
  margin-top: 1rem;
}

.integration-list-panel,
.integration-editor,
.integration-sync,
.integration-audit { min-width: 0; }

#integration-list {
  display: grid;
  gap: .55rem;
}

.integration-list-item {
  width: 100%;
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr) auto;
  gap: .75rem;
  align-items: center;
  text-align: start;
  border: 1px solid var(--line, #d8e1de);
  border-radius: 1rem;
  padding: .8rem;
  background: var(--surface, #fff);
  color: inherit;
  cursor: pointer;
}

.integration-list-item:hover,
.integration-list-item.active {
  border-color: var(--brand, #176f62);
  background: color-mix(in srgb, var(--brand, #176f62) 7%, white);
}

.integration-list-item span:nth-child(2) { min-width: 0; display: grid; gap: .15rem; }
.integration-list-item strong,
.integration-list-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.integration-list-item small { color: var(--muted, #66736f); }
.integration-list-item em { font-style: normal; }

.integration-source-mark {
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: .85rem;
  background: var(--brand, #176f62);
  color: #fff;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
}

.integration-enabled { align-self: end; min-height: 3.2rem; }
.integration-scope { border: 0; margin: 1rem 0; padding: 0; }
.integration-scope > legend { font-weight: 800; font-size: 1rem; }
.integration-scope > p { color: var(--muted, #66736f); margin: .35rem 0 .8rem; }

#integration-scope-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem;
}

.integration-scope-card {
  border: 1px solid var(--line, #d8e1de);
  border-radius: 1rem;
  padding: .75rem;
  opacity: .7;
  background: color-mix(in srgb, var(--surface, #fff) 94%, var(--brand, #176f62));
}

.integration-scope-card.selected { opacity: 1; border-color: color-mix(in srgb, var(--brand, #176f62) 55%, white); }
.integration-store-toggle { display: flex; align-items: center; gap: .5rem; margin-bottom: .55rem; direction: ltr; justify-content: flex-end; }
.integration-field-grid { display: flex; flex-wrap: wrap; gap: .35rem; }
.integration-field-grid label { display: inline-flex; align-items: center; gap: .25rem; font-size: .8rem; padding: .25rem .45rem; border-radius: 999px; background: var(--surface, #fff); border: 1px solid var(--line, #d8e1de); }
.integration-field-grid input { width: .9rem; height: .9rem; }

.integration-event {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .7rem;
  padding: .7rem 0;
  border-bottom: 1px solid var(--line, #d8e1de);
}
.integration-event:last-child { border-bottom: 0; }
.integration-event div { min-width: 0; display: grid; gap: .15rem; }
.integration-event small { color: var(--muted, #66736f); overflow-wrap: anywhere; }
.integration-event time { color: var(--muted, #66736f); font-size: .78rem; }

@media (max-width: 900px) {
  .integration-layout,
  .integration-operations { grid-template-columns: 1fr; }
  #integration-scope-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .integrations-intro .settings-actions { width: 100%; align-items: stretch; }
  .integrations-intro .settings-actions button { width: 100%; }
  .integration-list-item { grid-template-columns: 2.4rem minmax(0, 1fr); }
  .integration-list-item em { grid-column: 2; justify-self: start; }
  .integration-event { grid-template-columns: auto minmax(0, 1fr); }
  .integration-event time { grid-column: 2; }
}
