:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #657085;
  --line: #dde5f0;
  --accent: #1769e0;
  --accent-soft: #e8f1ff;
  --ok: #16824a;
  --warn: #a46500;
  --bad: #bb2424;
  --cyan: #168b9b;
  --violet: #7652a8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.login-overlay {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(23, 32, 51, 0.08);
}

.login-card h1 {
  margin: 8px 0 0;
  font-size: 20px;
}

.login-card label {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.login-card button {
  margin-top: 16px;
}

.login-error {
  min-height: 18px;
  color: var(--bad);
}

.sidebar {
  background: #17212b;
  color: white;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid #273442;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: #a9b4c7;
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  text-align: left;
  color: #d9e2f1;
  background: transparent;
  border: 1px solid transparent;
  padding: 11px 12px;
  border-radius: 8px;
}

.nav-item.active,
.nav-item:hover {
  background: #1f2a44;
  border-color: #334361;
}

.connection-box {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid #2a354e;
}

label {
  color: #a9b4c7;
  font-size: 12px;
}

main {
  padding: 24px 28px 36px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

h1, h2, p { margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 17px; }
.topbar p { color: var(--muted); margin-top: 6px; }

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

button.loading {
  position: relative;
  color: transparent;
}

button.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: white;
  animation: spin 0.75s linear infinite;
}

button.secondary.loading::after {
  border-color: rgba(23,105,224,0.25);
  border-top-color: var(--accent);
}

button.secondary {
  background: var(--accent-soft);
  color: var(--accent);
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}

textarea { min-height: 110px; resize: vertical; }

.view { display: none; }
.view.active { display: block; }

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 17px 18px 16px 22px;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: #8b95a7;
}

.stat-card.tone-green::before { background: var(--ok); }
.stat-card.tone-blue::before { background: var(--accent); }
.stat-card.tone-cyan::before { background: var(--cyan); }
.stat-card.tone-red::before { background: var(--bad); }
.stat-card.tone-amber::before { background: #d08a00; }
.stat-card.tone-violet::before { background: var(--violet); }
.stat-card.tone-case::before { background: #b54708; }

.case-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  margin-bottom: 14px;
}

.case-create-panel { margin-bottom: 16px; }
.case-create-panel > summary { cursor: pointer; padding: 15px 18px; font-weight: 750; }
.case-create-panel[open] > summary { border-bottom: 1px solid var(--line); }
.case-create-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 18px; }
.case-create-form > div { min-width: 0; }
.case-create-form label { display: block; margin-bottom: 6px; color: var(--muted); }
.case-create-form .span-2 { grid-column: span 2; }
.case-form-action { display: flex; align-items: end; }

.case-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(250px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 5px;
}

.case-column { min-width: 250px; border-top: 3px solid #9aa4b2; }
.case-column[data-case-status="planning"] { border-color: #1769e0; }
.case-column[data-case-status="working"] { border-color: #d08a00; }
.case-column[data-case-status="done"] { border-color: var(--ok); }
.case-column-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; }
.case-column-header h3 { margin: 0; font-size: 14px; }
.case-column-header span { color: var(--muted); font-size: 12px; }
.case-column-list { display: grid; align-content: start; gap: 9px; min-height: 160px; }
.case-card {
  width: 100%;
  min-height: 190px;
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 13px;
  text-align: left;
  color: var(--text);
  background: white;
  border: 1px solid var(--line);
  border-left: 4px solid #8b95a7;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.case-card:hover, .case-card.selected { border-color: var(--accent); box-shadow: 0 3px 12px rgba(23, 105, 224, 0.12); }
.case-card.priority-high { border-left-color: #d08a00; }
.case-card.priority-urgent { border-left-color: var(--bad); }
.case-card.priority-low { border-left-color: var(--ok); }
.case-card-top { display: flex; justify-content: space-between; gap: 10px; }
.case-card-top strong, .case-card p, .case-card small, .case-card dd { overflow-wrap: anywhere; }
.case-card-top span { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.case-card p { color: var(--muted); font-size: 13px; line-height: 1.45; }
.case-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.case-tags span { padding: 3px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.case-card dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.case-card dl div { min-width: 0; }
.case-card dt { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.case-card dd { margin: 2px 0 0; font-size: 12px; }
.case-card small { color: var(--muted); line-height: 1.4; }
.case-card small b { color: var(--text); }
.case-empty { padding: 18px 10px; color: var(--muted); text-align: center; font-size: 13px; border: 1px dashed var(--line); border-radius: 8px; }

.case-detail-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(340px, .95fr); gap: 16px; align-items: start; }
.case-detail-form, .case-activity-panel { padding: 18px; }
.case-detail-form { display: grid; gap: 9px; }
.case-detail-form label { color: var(--muted); }
.case-detail-form textarea { min-height: 78px; }
.case-detail-form.is-empty input, .case-detail-form.is-empty textarea, .case-detail-form.is-empty select, .case-detail-form.is-empty button,
.case-activity-form.is-empty input, .case-activity-form.is-empty textarea, .case-activity-form.is-empty button { opacity: .55; pointer-events: none; }
.case-activities { display: grid; gap: 10px; max-height: 760px; overflow: auto; margin: 14px 0; }
.case-activity { border-left: 3px solid var(--accent); padding: 10px 12px; background: #f7f9fc; }
.case-activity header { display: flex; justify-content: space-between; gap: 12px; }
.case-activity time, .case-activity-actor { color: var(--muted); font-size: 11px; }
.case-activity p { margin-top: 8px; line-height: 1.45; overflow-wrap: anywhere; }
.case-activity pre { max-height: 180px; overflow: auto; margin: 9px 0 0; padding: 9px; border-radius: 6px; background: #101828; color: #e7edf7; white-space: pre-wrap; overflow-wrap: anywhere; }
.case-activity-form { display: grid; gap: 9px; padding-top: 14px; border-top: 1px solid var(--line); }
.case-activity-form textarea { min-height: 78px; }

.stat-card span, .stat-card small {
  display: block;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 26px;
}

.panel {
  padding: 18px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.8fr) minmax(280px, 0.8fr);
  gap: 16px;
  align-items: stretch;
}

.dashboard-grid .wide { grid-column: span 2; }
.chart-panel, .operations-panel { min-height: 265px; }
.bar-chart {
  height: 200px;
  display: grid;
  grid-template-columns: repeat(6, minmax(54px, 1fr));
  gap: 14px;
  align-items: end;
  padding: 8px 4px 0;
}
.bar-column { height: 100%; display: grid; grid-template-rows: 20px 1fr 32px; gap: 5px; text-align: center; min-width: 0; }
.bar-value { font-weight: 800; font-size: 13px; }
.bar-track { height: 100%; display: flex; align-items: end; justify-content: center; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to top, transparent 0, transparent 39px, #edf1f6 40px); }
.bar-fill { width: min(42px, 70%); min-height: 2px; background: var(--accent); border-radius: 4px 4px 0 0; transition: height 0.3s ease; }
.bar-fill.green { background: var(--ok); }
.bar-fill.cyan { background: var(--cyan); }
.bar-fill.amber { background: #d08a00; }
.bar-fill.red { background: var(--bad); }
.bar-fill.violet { background: var(--violet); }
.bar-label { color: var(--muted); font-size: 11px; line-height: 1.2; overflow-wrap: anywhere; }
.donut-layout { min-height: 198px; display: grid; grid-template-columns: 145px 1fr; gap: 22px; align-items: center; }
.donut-chart { position: relative; width: 145px; height: 145px; border-radius: 50%; display: grid; place-content: center; text-align: center; }
.donut-chart::after { content: ""; position: absolute; inset: 24px; border-radius: 50%; background: white; }
.donut-chart strong, .donut-chart span { position: relative; z-index: 1; display: block; }
.donut-chart strong { font-size: 27px; }
.donut-chart span { color: var(--muted); font-size: 11px; }
.chart-legend { display: grid; gap: 9px; }
.chart-legend div { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; font-size: 12px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 2px; }
.metric-list { margin: 0; display: grid; }
.metric-list div { padding: 13px 0; border-bottom: 1px solid var(--line); }
.metric-list div:last-child { border: 0; }
.metric-list dt { color: var(--muted); font-size: 12px; }
.metric-list dd { margin: 4px 0 0; font-weight: 800; overflow-wrap: anywhere; }
.status-dot-label::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--ok); }
.compact-list { display: grid; }
.compact-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.compact-row:last-child { border: 0; }
.compact-row strong, .compact-row span { display: block; }
.compact-row span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.compact-capabilities { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.file-toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(180px, 240px) minmax(180px, 300px) auto; gap: 10px; align-items: center; margin-bottom: 16px; }
.file-browser { display: grid; grid-template-columns: minmax(340px, 0.75fr) minmax(520px, 1.4fr); gap: 16px; align-items: stretch; }
.file-tree-panel, .file-preview-panel { min-height: 680px; }
.file-list { display: grid; align-content: start; max-height: 610px; overflow: auto; border-top: 1px solid var(--line); }
.file-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 10px 8px; color: var(--text); text-align: left; background: transparent; border-bottom: 1px solid var(--line); border-radius: 0; font-weight: 400; }
.file-row:hover, .file-row.selected { background: #eef5ff; }
.file-kind { display: grid; place-items: center; min-height: 30px; color: var(--accent); background: var(--accent-soft); border-radius: 4px; font-size: 10px; font-weight: 900; }
.file-name { min-width: 0; }
.file-name strong, .file-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.file-size { color: var(--muted); font-size: 11px; white-space: nowrap; }
.file-preview-empty { min-height: 560px; display: grid; place-items: center; padding: 28px; color: var(--muted); text-align: center; border: 1px dashed var(--line); }
.file-text-preview { min-height: 560px; max-height: 610px; overflow: auto; margin: 0; padding: 18px; white-space: pre-wrap; overflow-wrap: anywhere; background: #101827; color: #d9e7ff; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.file-media-preview { min-height: 560px; display: grid; place-items: center; overflow: auto; background: #eef2f7; }
.file-media-preview img { max-width: 100%; max-height: 590px; object-fit: contain; }
.file-media-preview iframe { width: 100%; height: 590px; border: 0; background: white; }
.button-link { display: inline-flex; align-items: center; min-height: 36px; padding: 8px 12px; border-radius: 8px; background: var(--accent); color: white; font-weight: 800; text-decoration: none; font-size: 13px; }
.hidden { display: none !important; }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-heading > button { flex: 0 0 auto; white-space: nowrap; }
.section-heading h2 { font-size: 22px; }
.section-heading p { margin-top: 5px; color: var(--muted); }
.knowledge-grid { display: grid; grid-template-columns: minmax(280px, 0.7fr) minmax(280px, 0.7fr) minmax(440px, 1.3fr); gap: 16px; align-items: start; }
select[multiple] { min-height: 176px; }
.knowledge-search-panel { min-height: 100%; }
.inline-search-form { display: grid; grid-template-columns: minmax(180px, 0.7fr) minmax(240px, 1.3fr) auto; gap: 8px; }
.knowledge-results { display: grid; gap: 9px; margin-top: 14px; max-height: 520px; overflow: auto; }
.knowledge-result { padding: 12px; border: 1px solid var(--line); border-left: 4px solid var(--cyan); background: #fbfcff; }
.knowledge-result p { margin: 8px 0; max-height: 150px; overflow: auto; white-space: pre-wrap; color: #364155; font-size: 13px; line-height: 1.45; }
.knowledge-result a, .knowledge-card a { color: var(--accent); font-size: 12px; font-weight: 800; }
.score { color: var(--ok); font-weight: 900; }
.knowledge-library-panel { margin-top: 16px; }
.knowledge-source-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.knowledge-card { padding: 13px; border: 1px solid var(--line); border-top: 4px solid var(--cyan); background: #fff; }
.knowledge-card strong, .knowledge-card span { display: block; }
.knowledge-card .item-head span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.knowledge-card p { margin: 9px 0; color: var(--muted); font-size: 12px; }
.knowledge-assignees { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.knowledge-assignees span { padding: 4px 6px; border-radius: 4px; background: #e9f6f7; color: #126c78; font-size: 10px; font-weight: 800; }
.knowledge-assignees em { color: var(--muted); font-size: 11px; }
.compact-empty { min-height: 140px; grid-column: 1 / -1; }

.social-compose-grid { display: grid; grid-template-columns: minmax(420px, 1.2fr) minmax(300px, 0.65fr); gap: 16px; align-items: start; }
.social-caption { min-height: 72px; }
.social-board-panel { margin-top: 16px; }
.social-board { display: grid; grid-template-columns: repeat(3, minmax(280px, 1fr)); gap: 14px; }
.social-card { display: flex; flex-direction: column; min-height: 310px; border: 1px solid var(--line); background: white; box-shadow: 0 2px 7px rgba(16,24,40,0.06); }
.social-card header, .social-card footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; }
.social-card header { border-bottom: 1px solid var(--line); }
.social-card header strong { margin-left: 7px; font-size: 13px; }
.platform-label { display: inline-flex; padding: 4px 6px; border-radius: 4px; color: white; background: #596579; font-size: 10px; font-weight: 900; text-transform: uppercase; }
.platform-label.instagram { background: #bd2f68; }
.platform-label.x { background: #111; }
.platform-label.tiktok { background: #117e86; }
.social-media { aspect-ratio: 16 / 9; overflow: hidden; background: #edf1f6; }
.social-media img { width: 100%; height: 100%; object-fit: cover; }
.social-copy { flex: 1; padding: 14px; }
.social-copy h3 { margin: 0 0 8px; font-size: 16px; }
.social-copy p { white-space: pre-wrap; color: #364155; line-height: 1.45; }
.hashtags { margin-top: 10px; color: var(--accent); font-size: 12px; font-weight: 800; }
.social-card footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.social-actions { display: flex; gap: 6px; }
.social-actions button { padding: 7px 9px; }
.social-error { padding: 9px 12px; color: var(--bad); background: #fff0f0; font-size: 11px; }

.employee-work-board { margin-top: 18px; }
.work-board-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.work-board-grid h3 { margin: 0 0 10px; font-size: 14px; }
.work-list { display: grid; gap: 8px; max-height: 520px; overflow: auto; }

.automation-toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(220px, 320px) auto auto auto auto; gap: 10px; align-items: center; margin-bottom: 14px; }
.automation-layout { display: grid; grid-template-columns: 220px minmax(560px, 1fr) 300px; gap: 14px; align-items: stretch; }
.node-palette, .node-inspector { padding: 14px; }
.node-palette-list { display: grid; gap: 8px; }
.palette-node { width: 100%; min-height: 58px; text-align: left; background: #f7f9fc; color: var(--text); border: 1px solid var(--line); padding: 9px 10px; }
.palette-node:hover { border-color: var(--accent); background: var(--accent-soft); }
.palette-node strong, .palette-node small { display: block; }
.palette-node small { margin-top: 4px; color: var(--muted); font-weight: 500; line-height: 1.35; }
.workflow-surface { min-width: 0; padding: 14px; }
.workflow-meta { display: grid; grid-template-columns: 1fr 130px auto; gap: 8px; align-items: center; }
.workflow-description { min-height: 56px; margin-top: 8px; }
.workflow-canvas { position: relative; height: 620px; margin-top: 10px; overflow: auto; border: 1px solid #cfd8e6; border-radius: 8px; background-color: #f8fafc; background-image: linear-gradient(#e8edf5 1px, transparent 1px), linear-gradient(90deg, #e8edf5 1px, transparent 1px); background-size: 24px 24px; }
.workflow-edges, .workflow-nodes { position: absolute; inset: 0; width: 1600px; height: 1000px; }
.workflow-edges { pointer-events: none; overflow: visible; }
.workflow-edge { stroke: #55708f; stroke-width: 2.5; fill: none; }
.workflow-edge.preview { stroke: var(--accent); stroke-dasharray: 6 4; }
.workflow-node { position: absolute; width: 220px; min-height: 104px; border: 1px solid #c9d4e3; border-left: 5px solid #55708f; border-radius: 8px; background: white; box-shadow: 0 5px 16px rgba(28, 39, 60, 0.1); user-select: none; }
.workflow-node[data-category="trigger"] { border-left-color: #15805d; }
.workflow-node[data-category="ai"] { border-left-color: #1769e0; }
.workflow-node[data-category="mail"] { border-left-color: #b26200; }
.workflow-node[data-category="document"] { border-left-color: #7c4d9e; }
.workflow-node.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.workflow-node-header { padding: 10px 12px 7px; cursor: grab; font-size: 13px; font-weight: 800; }
.workflow-node-header:active { cursor: grabbing; }
.workflow-node-type { padding: 0 12px 11px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.node-port { position: absolute; top: 42px; width: 16px; height: 16px; padding: 0; border: 3px solid white; border-radius: 50%; background: #55708f; box-shadow: 0 0 0 1px #55708f; }
.node-port.input { left: -10px; }
.node-port.output { right: -10px; }
.workflow-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.workflow-empty.hidden { display: none; }
.node-inspector h3, .schedule-editor h3 { margin: 0 0 10px; font-size: 14px; }
.inspector-fields, .schedule-editor, #scheduleFields { display: grid; gap: 8px; }
.schedule-editor { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.compact-button { padding: 7px 9px; }
button.danger { background: #fce9e9; color: var(--bad); }
.automation-bottom { display: grid; grid-template-columns: minmax(360px, 0.9fr) minmax(520px, 1.4fr); gap: 14px; margin-top: 14px; }
.run-list, .external-mailbox-list { display: grid; gap: 8px; max-height: 300px; overflow: auto; }
.run-item, .external-mailbox-item { border-bottom: 1px solid var(--line); padding: 9px 0; }
.run-item:last-child, .external-mailbox-item:last-child { border-bottom: 0; }
.external-mailbox-form { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 8px; margin-top: 14px; }
.external-mailbox-form button { grid-column: span 2; }

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(380px, 1.4fr);
  gap: 18px;
}

.employee-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(300px, 0.8fr) minmax(440px, 1.35fr);
  gap: 18px;
  align-items: start;
}

.employee-interview {
  grid-column: 1 / -1;
}

.employee-interview.is-empty textarea,
.employee-interview.is-empty button,
.employee-interview.is-empty .interview-side {
  opacity: 0.62;
  pointer-events: none;
}

.interview-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(420px, 1fr);
  gap: 16px;
  align-items: start;
}

.interview-chat {
  display: grid;
  gap: 12px;
}

.interview-messages {
  min-height: 320px;
  max-height: 520px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.interview-bubble {
  max-width: 88%;
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  white-space: pre-wrap;
  line-height: 1.45;
}

.interview-bubble.user {
  justify-self: end;
  background: var(--accent-soft);
}

.interview-bubble.assistant {
  justify-self: start;
}

.interview-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.interview-form textarea {
  min-height: 88px;
}

.harness-chat-panel {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 62vh;
  gap: 12px;
}

.harness-chat-messages {
  min-height: 420px;
  max-height: calc(100vh - 280px);
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.harness-chat-row {
  display: flex;
}

.harness-chat-row.mine {
  justify-content: flex-end;
}

.harness-chat-row.theirs {
  justify-content: flex-start;
}

.harness-chat-bubble {
  max-width: min(720px, 88%);
  display: grid;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  white-space: pre-wrap;
  line-height: 1.45;
}

.harness-chat-bubble.mine {
  background: #e8f7ef;
  border-color: #b7e0c7;
}

.harness-chat-bubble.theirs {
  background: #eef4ff;
  border-color: #c5d4f5;
}

.harness-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.harness-chat-form textarea {
  min-height: 72px;
  resize: vertical;
}

.chat-toolbar-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.chat-toolbar-controls select {
  min-width: 220px;
}

.cli-chat-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(420px, 1.4fr);
  gap: 16px;
  align-items: start;
}

.cli-session-panel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.cli-session-panel input {
  width: 100%;
}

.cli-session-item {
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: white;
}

.cli-session-item.active {
  border-color: var(--accent, #2f6fed);
  background: #eef4ff;
}

.ops-layout {
  display: grid;
  grid-template-columns: minmax(340px, 1.1fr) minmax(360px, 1fr);
  gap: 16px;
  align-items: start;
}

.office-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

.office-stage {
  overflow: hidden;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(90, 140, 255, 0.18), transparent 55%),
    radial-gradient(ellipse at 90% 100%, rgba(255, 180, 90, 0.12), transparent 50%),
    #121826;
  border: 1px solid #243049;
}

.office-topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: #d7e0ff;
}

.office-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.office-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #c5d0ef;
}

.office-legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

#officeCanvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  cursor: grab;
  touch-action: none;
  background: #0f1424;
  image-rendering: pixelated;
}

.office-credit {
  margin-top: 8px;
  color: #9aa8c7;
}

.office-credit a { color: #9ec1ff; }

.office-side {
  min-height: 320px;
}

.office-help {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 8px;
  color: var(--muted, #5b657a);
  font-size: 13px;
}

@media (max-width: 980px) {
  .office-layout {
    grid-template-columns: 1fr;
  }
}

.ops-employee-grid {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 280px);
  overflow: auto;
  padding-right: 4px;
}

.ops-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 10px;
}

.ops-card.state-stuck,
.ops-card.state-error {
  border-color: #e2a3a3;
  background: #fff7f7;
}

.ops-card.state-working {
  border-color: #9fc0ef;
  background: #f5f9ff;
}

.ops-card.state-waiting {
  border-color: #e2c48a;
  background: #fffbf2;
}

.ops-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.ops-card-grid {
  display: grid;
  gap: 8px;
}

.ops-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.ops-item strong {
  display: block;
  font-size: 13px;
}

.ops-blockers,
.ops-blocker {
  color: #8a1f1f;
}

.ops-blocker {
  font-size: 12px;
  margin-top: 4px;
}

.ops-blocker-row {
  display: grid;
  gap: 6px;
}

.ops-nudge-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  margin-top: 8px;
}

.ops-nudge-form textarea {
  min-height: 54px;
  resize: vertical;
}

.ops-timeline {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 280px);
  overflow: auto;
  padding-right: 4px;
}

.ops-timeline-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.ops-timeline-row.phase-ahead {
  border-left: 3px solid #d4a017;
}

.ops-timeline-row.phase-active {
  border-left: 3px solid #2f6fed;
}

.ops-timeline-row.phase-done {
  border-left: 3px solid #6f9f7a;
}

.ops-timeline-time {
  display: grid;
  gap: 6px;
  align-content: start;
}

.ops-timeline-time strong {
  font-size: 12px;
}

.pill.ops-state {
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .ops-layout,
  .ops-timeline-row {
    grid-template-columns: 1fr;
  }
}

#harnessKeyStatus {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.interview-side {
  display: grid;
  gap: 10px;
}

.interview-side h3 {
  margin: 0;
  font-size: 14px;
}

.mail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.75fr) minmax(330px, 1fr) minmax(460px, 1.45fr);
  gap: 18px;
  align-items: start;
}

.mailbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.mailbox-toolbar select {
  max-width: 420px;
}

.form-panel {
  display: grid;
  gap: 11px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
}

.form-note {
  color: var(--muted);
  font-size: 13px;
}

.capability-list, .employee-list, .message-list, .job-list {
  display: grid;
  gap: 10px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

button.item {
  width: 100%;
  color: var(--text);
  text-align: left;
  font-weight: 400;
}

.employee-item,
.message-item {
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.employee-item:hover,
.employee-item.selected,
.message-item:hover,
.message-item.selected {
  border-color: var(--accent);
  background: #f4f8ff;
  box-shadow: 0 0 0 2px rgba(23, 105, 224, 0.08);
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.item-title { font-weight: 800; }
.item-meta { color: var(--muted); font-size: 13px; }
.message-body {
  white-space: pre-wrap;
  line-height: 1.45;
}

.mail-preview {
  margin: 7px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.mailbox-empty {
  min-height: 280px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.mail-detail-content {
  display: grid;
  gap: 14px;
}

.mail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mail-actions {
  display: flex;
  justify-content: flex-end;
}

.mail-header h3 {
  margin: 0;
  font-size: 20px;
}

.mail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.mail-meta div {
  min-width: 0;
}

.mail-meta dt {
  color: var(--muted);
  font-size: 12px;
}

.mail-meta dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.mail-raw summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 800;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.attachment-link {
  display: inline-grid;
  gap: 2px;
  min-width: 150px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.attachment-link small {
  color: var(--muted);
  font-weight: 600;
}

.attachment-link.disabled {
  color: var(--muted);
  pointer-events: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.pill.ok { background: #e6f6ee; color: var(--ok); }
.pill.warn { background: #fff4db; color: var(--warn); }
.pill.bad { background: #ffe9e9; color: var(--bad); }

.json-box {
  min-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  padding: 14px;
  border-radius: 8px;
  background: #0e1628;
  color: #d9e7ff;
}

.json-box.compact {
  min-height: 180px;
  max-height: 360px;
  font-size: 12px;
}

.employee-editor.is-empty input,
.employee-editor.is-empty textarea,
.employee-editor.is-empty select,
.employee-editor.is-empty button[type="submit"] {
  opacity: 0.62;
  pointer-events: none;
}

.markdown-editor {
  min-height: 260px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.json-editor {
  min-height: 120px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.media-preview {
  display: grid;
  gap: 12px;
}

.media-preview img {
  width: min(100%, 420px);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(244, 247, 251, 0.72);
  backdrop-filter: blur(2px);
  z-index: 20;
}

.loading-overlay.show {
  display: grid;
}

.loader-card {
  min-width: 260px;
  display: grid;
  justify-items: center;
  gap: 9px;
  padding: 22px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  box-shadow: 0 18px 50px rgba(16, 24, 40, 0.18);
}

.loader-card span {
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 3px solid #d9e6f8;
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  width: min(420px, calc(100vw - 36px));
  display: grid;
  gap: 9px;
  pointer-events: none;
}

.toast {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: white;
  opacity: 0;
  transform: translateY(10px);
  transition: 0.18s ease;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .24);
  border-left: 4px solid #6b7280;
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast strong { font-size: 13px; }
.toast span { grid-column: 1; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.toast button { grid-column: 2; grid-row: 1 / span 2; align-self: start; padding: 0; min-width: 24px; background: transparent; color: #cbd5e1; font-size: 20px; line-height: 1; }
.toast-success { border-left-color: #32b36c; }
.toast-working { border-left-color: #4da3ff; }
.toast-error { border-left-color: #ff6b6b; background: #3a171a; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .status-grid, .two-column, .employee-layout, .mail-layout, .form-row, .interview-grid, .interview-form, .work-board-grid, .automation-toolbar, .automation-layout, .automation-bottom, .external-mailbox-form, .dashboard-grid, .file-toolbar, .file-browser, .knowledge-grid, .knowledge-source-grid, .inline-search-form, .social-compose-grid, .social-board { grid-template-columns: 1fr; }
  .dashboard-grid .wide { grid-column: auto; }
  .compact-capabilities { grid-template-columns: 1fr; }
  .bar-chart { overflow-x: auto; grid-template-columns: repeat(6, minmax(76px, 1fr)); }
  .workflow-canvas { height: 520px; }
  .external-mailbox-form button { grid-column: auto; }
  .mailbox-toolbar { align-items: stretch; flex-direction: column; }
  .mailbox-toolbar select { max-width: none; }
  .topbar { flex-direction: column; }
  .case-toolbar, .case-create-form, .case-detail-layout { grid-template-columns: 1fr; }
  .case-create-form .span-2 { grid-column: auto; }
  .case-board { grid-template-columns: repeat(4, minmax(270px, 1fr)); }
}
