:root {
  --brand: #086dfb;
  --brand-ink: #1b44a4;
  --brand-soft: #e8effb;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #18212f;
  --ink-2: #4a5566;
  --ink-3: #7a8494;
  --line: #e1e6ee;
  --danger: #c4314b;
  --danger-bg: #fdecef;
  --warn-bg: #fff6e0;
  --warn-line: #f2d48a;
  --ok: #107c41;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #4c95ff;
    --brand-ink: #9cc2ff;
    --brand-soft: #1c2a44;
    --bg: #14171c;
    --surface: #1d2128;
    --ink: #eef1f6;
    --ink-2: #c1c8d3;
    --ink-3: #8a93a1;
    --line: #2d333d;
    --danger: #ff8a9b;
    --danger-bg: #3a1f26;
    --warn-bg: #3a3220;
    --warn-line: #6b5a2c;
    --ok: #5fd08b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

[hidden] { display: none !important; }

h1 { font-size: 18px; margin: 0 0 4px; }
h2 { font-size: 13px; margin: 0; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }

.view { min-height: 100%; }
.view-center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; }
.boot-logo { width: 56px; height: 56px; }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login { max-width: 420px; margin: 0 auto; padding: 24px 16px; }
.login-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 20px; }
.login-logo { width: 44px; height: 44px; flex: none; }
.login-head p { margin: 0; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field input, .field select {
  height: 36px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit;
}
.field input:focus, .field select:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.field select option:disabled { color: var(--ink-3); }

.advanced { margin: 4px 0 12px; font-size: 13px; color: var(--ink-2); }
.advanced summary { cursor: pointer; margin-bottom: 8px; }

.error {
  margin: 0 0 12px; padding: 8px 10px; border-radius: 8px;
  background: var(--danger-bg); color: var(--danger); font-size: 13px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--ink-2); margin-top: 6px; }
.btn-block { width: 100%; }

/* ---------- Main ---------- */
.view-main { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-logo { width: 26px; height: 26px; }
.topbar-title { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; flex: 1; }
.topbar-title span { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-ink);
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }

.panel { padding: 10px 12px 0; display: flex; flex-direction: column; gap: 8px; flex: none; max-height: 48vh; overflow: auto; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 12px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.kind {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-ink);
}
.who { font-weight: 600; word-break: break-word; }
.who .addr { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.subject { color: var(--ink-2); font-size: 13px; margin-top: 2px; word-break: break-word; }

.link-btn { border: 0; background: none; color: var(--brand); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; padding: 0; }

.hits { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hit { display: flex; gap: 8px; align-items: flex-start; }
.hit-role {
  flex: none; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  background: var(--brand-soft); color: var(--brand-ink); margin-top: 1px;
}
.hit-role.owner { background: #e7f6ec; color: #107c41; }
.hit-role.customer { background: #eaf1ff; color: #1b44a4; }
.hit-role.service_provider { background: #fff2e0; color: #8a5300; }
@media (prefers-color-scheme: dark) {
  .hit-role.owner { background: #17331f; color: #7fdc9f; }
  .hit-role.customer { background: #1c2a44; color: #9cc2ff; }
  .hit-role.service_provider { background: #3a2c17; color: #f3c27a; }
}
.hit-name { font-weight: 600; }
.hit-meta { font-size: 12px; color: var(--ink-3); }
.empty { font-size: 13px; color: var(--ink-3); margin: 4px 0 0; }
.skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--line), var(--bg), var(--line)); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin: 6px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

.options { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 13px; cursor: pointer;
}
.chip:hover { border-color: var(--brand); color: var(--brand-ink); }
.chip:disabled { opacity: .5; cursor: not-allowed; }
.chip svg { width: 14px; height: 14px; }

.chat { position: relative; flex: 1; min-height: 320px; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.chat iframe { flex: 1; width: 100%; border: 0; background: var(--surface); }
.chat-state {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: var(--ink-3); text-align: center; padding: 0 24px;
}
.notice {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  margin: 8px 12px 0; padding: 8px 10px; border-radius: 8px; font-size: 13px;
  background: var(--warn-bg); border: 1px solid var(--warn-line);
}

/* Inside Outlook: chat only (no topbar/logout, no context cards and quick actions). */
.in-outlook .topbar,
.in-outlook .panel { display: none; }
.in-outlook .chat { border-top: 0; }

