:root {
  /* Design tokens live in ui.css, which every page loads. */
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--surface-1);
}
* { box-sizing: border-box; }
body { margin: 0; padding: 0; background: var(--surface-1); }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

button {
  border: none; border-radius: 7px; padding: 7px 12px;
  background: var(--brand); color: var(--surface); cursor: pointer; font-size: 13px;
  font-family: inherit;
}
button.secondary { background: var(--text-2); }
button.danger { background: var(--danger); }
button.ghost-nav { background: none; color: var(--text-3); }
button.link { background: none; color: var(--brand); padding: 2px 4px; font-size: 12px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn { background: none; color: var(--muted); padding: 2px 6px; font-size: 13px; line-height: 1; }
.icon-btn:hover { color: var(--text); }

/* ---------- top nav, shared by board and clients ---------- */
.nav {
  display: flex; align-items: center; gap: 14px; padding: 10px 18px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.nav .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.02em; }
.nav .brand .dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: linear-gradient(135deg, var(--brand), var(--brand-400));
}
.nav .links { display: flex; gap: 4px; }
.nav .links a {
  text-decoration: none; color: var(--muted); font-size: 13px; padding: 7px 12px;
  border-radius: 7px; font-weight: 500;
}
.nav .links a:hover { background: var(--surface-2); color: var(--text); }
.nav .links a.active { background: var(--brand-soft); color: var(--brand-dark); }
.nav .spacer { flex: 1; }
.nav .toolbar { display: flex; align-items: center; gap: 8px; }
.nav .brand { flex-shrink: 0; white-space: nowrap; }

.nav-burger {
  display: none; background: none; color: var(--text-2); padding: 6px 8px;
  font-size: 19px; line-height: 1; border-radius: 7px; margin-left: auto;
}
.nav-burger:hover { background: var(--surface-2); }

/* ---------- mobile nav: collapse links + toolbar behind a burger ---------- */
@media (max-width: 1280px) {
  .nav { flex-wrap: wrap; row-gap: 4px; gap: 8px; padding: 10px 12px; max-height: 100dvh; overflow-y: auto; }
  .nav > button { flex-shrink: 0; }
  .nav > [data-rt-bot], .nav > [data-rt-history] { padding: 8px; font-size: 12px; }
  .nav .brand { font-size: 14px; gap: 5px; }
  .nav-burger { display: inline-flex; }
  .nav .spacer { display: none; }
  .nav .links, .nav .toolbar {
    display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 2px;
  }
  .nav .links a { padding: 10px 12px; }
  .nav .toolbar {
    flex-direction: row; flex-wrap: wrap; justify-content: flex-start;
    padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--border);
  }
  .nav.open .links, .nav.open .toolbar { display: flex; }
  .nav.open .links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav .toolbar #current-user { flex-basis: 100%; padding-bottom: 6px; }
  .row { flex-wrap: wrap; }
  .row label { min-width: min(180px, 100%); }
  input, textarea, select { font-size: 16px; }
}

.page { padding: 16px 18px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 720px) { .page { padding: 12px; } }
.status { margin-bottom: 8px; font-size: 12px; min-height: 16px; color: var(--muted); }
.status.error { color: var(--danger); }

label { display: block; font-size: 13px; color: var(--text-3); margin-bottom: 10px; }
.row { display: flex; gap: 10px; }
.row label { flex: 1; }
input, textarea, select {
  width: 100%; margin-top: 4px; border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 9px 10px; font-size: 13px; font-family: inherit; background: var(--surface-1); color: var(--text);
}
textarea { min-height: 80px; resize: vertical; }

#confirm-dialog { width: min(400px, 92vw); }
.confirm-text { margin: 0 0 16px; font-size: 13px; color: var(--text-3); line-height: 1.5; }
.confirm-text b { color: var(--text); }

#login-screen { max-width: 340px; margin: 14vh auto 0; }
#login-screen .box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}
#login-screen h1 { font-size: 20px; margin-bottom: 4px; }

/* ---------- assignee chip, shared by board and calendar cards ---------- */
.assignee { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-2); min-width: 0; }
.assignee-dot {
  width: 15px; height: 15px; border-radius: 50%; background: var(--brand-soft-2); color: var(--brand-dark);
  font-size: 8px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.assignee-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { font-size: 12px; color: #c2ccd9; padding: 2px; }

/* Searchable selects: shared across filters, forms and dynamically added fields. */
select.search-select-native {
  position: absolute !important; width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: 0 !important; border: 0 !important;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap; pointer-events: none;
}
button.search-select {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-width: 0; margin-top: 4px; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; line-height: 18px; text-align: left;
  box-shadow: 0 1px 2px rgb(15 23 42 / 3%);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
button.search-select:hover:not(:disabled) { border-color: var(--brand-focus); background: #fafaff; }
button.search-select:focus-visible, button.search-select[aria-expanded=true] {
  outline: none; border-color: var(--brand-400); box-shadow: 0 0 0 3px rgb(99 102 241 / 13%);
}
button.search-select.active { background: var(--brand-soft); border-color: var(--brand-focus); color: var(--brand-dark); }
button.search-select[aria-invalid=true] { border-color: var(--danger-500); }
button.search-select:disabled { background: var(--surface-2); opacity: .6; }
button.search-select[hidden] { display: none; }
.search-select__caption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-select__chevron {
  flex: 0 0 7px; width: 7px; height: 7px; margin: -3px 2px 0 0;
  border: solid var(--faint); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
  transition: transform .15s;
}
[aria-expanded=true] > .search-select__chevron { transform: translateY(3px) rotate(225deg); border-color: var(--brand); }
.search-select__panel {
  position: fixed; inset: auto; margin: 0; padding: 0; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); color: var(--text); overflow: hidden;
  box-shadow: 0 16px 40px -8px rgb(15 23 42 / 20%), 0 3px 8px rgb(15 23 42 / 5%);
  font: 13px/1.4 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
.search-select__panel:popover-open { display: flex; flex-direction: column; }
.search-select__panel--fallback { display: flex; flex-direction: column; z-index: 10000; }
.search-select__search-box { padding: 10px; border-bottom: 1px solid var(--surface-2); flex-shrink: 0; }
.search-select__search-box::before {
  content: ''; position: absolute; left: 23px; top: 23px; width: 9px; height: 9px;
  border: 1.5px solid var(--faint); border-radius: 50%; pointer-events: none;
}
.search-select__search-box::after {
  content: ''; position: absolute; left: 32px; top: 33px; width: 5px;
  border-top: 1.5px solid var(--faint); transform: rotate(45deg); pointer-events: none;
}
.search-select__panel .search-select__search {
  width: 100%; min-width: 0; margin: 0; padding: 9px 10px 9px 32px;
  border: 1px solid var(--border); border-radius: 7px; background: var(--surface-1);
  font: inherit; color: var(--text); outline: none;
}
.search-select__panel .search-select__search:focus { border-color: var(--brand-focus); }
.search-select__search::placeholder { color: var(--faint); }
.search-select__list { overflow-y: auto; overscroll-behavior: contain; padding: 5px; min-height: 0; scrollbar-width: thin; }
.search-select__option {
  position: relative; padding: 9px 32px 9px 10px; border-radius: 7px;
  cursor: pointer; overflow-wrap: anywhere;
}
.search-select__option.is-highlighted { background: var(--surface-2); }
.search-select__option[aria-selected=true] { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.search-select__option[aria-selected=true]::after { content: '✓'; position: absolute; right: 11px; color: var(--brand); }
.search-select__option[aria-disabled=true] { opacity: .4; cursor: not-allowed; }
.search-select__group { padding: 9px 10px 4px; font-size: 11px; font-weight: 600; color: var(--faint); }
.search-select__empty { padding: 24px 16px; text-align: center; color: var(--faint); }
@media (max-width: 600px) { .search-select__option { padding-top: 12px; padding-bottom: 12px; } }
@media (prefers-reduced-motion: reduce) { button.search-select, .search-select__chevron { transition: none; } }

/* Section actions live with the local controls, leaving navigation compact. */
.section-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.section-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.nav .logout-button { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 8px; border-radius: 8px; flex-shrink: 0; }
.nav .logout-button:hover { background: var(--surface-2); }
.nav .logout-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (max-width: 720px) { .section-actions { flex-wrap: wrap; max-width: 100%; } }

.entity-tab-list { display:flex; gap:6px; overflow-x:auto; border-bottom:1px solid var(--border); padding:4px 0 10px; margin:12px 0 18px; scrollbar-width:thin; }
.entity-tab-list > button { flex:none; white-space:nowrap; background:var(--surface-2); color:var(--text-3); padding:9px 12px; border-radius:8px; font-size:13px; }
.entity-tab-list > button[aria-selected="true"] { background:var(--brand-soft); color:var(--brand-dark); }
.entity-tab-list > button:focus-visible { outline:2px solid var(--brand); outline-offset:2px; }
.entity-tab-panel[hidden] { display:none !important; }
.entity-tab-panel { min-width:0; }
