/* ============================================================
   OneIndex app shell — v3
   Clay-influenced. Brand + collapse in sidebar top; utility
   block bottom; working customers toolbar; floating assistant.
   ============================================================ */
:root {
  --accent:        #6c5ce7;
  --accent-ink:    #5646d6;
  --accent-soft:   #f1efff;
  --ink:           #14141f;
  --ink-2:         #3f4256;
  --muted:         #6b7280;
  --line:          #ececf2;
  --line-2:        #f4f4f8;
  --bg:            #ffffff;
  --surface:       #ffffff;
  --surface-2:     #fafafc;
  --danger:        #dc2626;
  --amber:         #b45309;
  --green:         #15803d;

  --topbar-h:      72px;
  --rail-w:        216px;
  --rail-w-min:    64px;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(20, 20, 31, .05);
  --shadow-md: 0 8px 24px rgba(20, 20, 31, .10);
  --shadow-lg: 0 16px 48px rgba(20, 20, 31, .18);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  padding: 14px 12px 12px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  overflow-y: auto;
  transition: width .18s ease;
}

/* ---- Brand row ---- */
.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 2px 0 18px;
}

.brand__link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  padding: 4px 6px;
  border-radius: var(--r-md);
  color: var(--ink);
}
.brand__link:hover { background: var(--surface-2); text-decoration: none; }

.brand__logo {
  position: relative;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  overflow: hidden;
}

.brand__monogram { font-size: 14px; font-weight: 700; letter-spacing: -.02em; }

.brand__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.brand__edit {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s ease;
}
.brand:hover .brand__edit,
.brand__edit:focus-visible,
.brand.is-editing .brand__edit { opacity: 1; }
.brand__edit:hover { background: var(--line-2); color: var(--ink); }

/* Collapse — Clay-style panel icon, always visible, top row */
.brand__collapse {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.brand__collapse:hover { background: var(--line-2); color: var(--ink); }

/* ---- Edit popover ---- */
.popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 80;
  width: 240px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  box-shadow: var(--shadow-md);
}

.popover__title { margin: 0 0 10px; font-size: 13px; font-weight: 650; }

.popover__label {
  display: block;
  margin: 10px 0 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #9aa0ac;
}

.popover__input {
  width: 100%;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font: inherit;
  outline: none;
}
.popover__input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.popover__logo-row { display: flex; align-items: center; gap: 8px; }

.popover__logo-preview {
  position: relative;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
}
.popover__logo-preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.popover__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-2);
}

/* ---- Nav ---- */
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item svg { flex: 0 0 auto; }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

.nav-item--soon { color: #a2a7b3; cursor: default; }
.nav-item--soon:hover { background: transparent; }

.soon {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--line-2);
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #9aa0ac;
}

.sidebar__label {
  margin: 16px 0 6px;
  padding: 0 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #9aa0ac;
}

/* Bottom utility block (Clay pattern) */
.sidebar__bottom {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ---- Collapsed ---- */
body.is-collapsed .sidebar { width: var(--rail-w-min); }
body.is-collapsed .brand { flex-direction: column; gap: 8px; }
body.is-collapsed .brand__name,
body.is-collapsed .brand__edit { display: none; }
body.is-collapsed .brand__link { padding: 4px; }
body.is-collapsed .nav-item span,
body.is-collapsed .nav-item .soon { display: none; }
body.is-collapsed .nav-item { justify-content: center; padding: 0; }
body.is-collapsed .sidebar__label { text-align: center; padding: 0; font-size: 9px; }
body.is-collapsed .topbar { left: var(--rail-w-min); }
body.is-collapsed .main { margin-left: var(--rail-w-min); }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--rail-w);
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 32px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  transition: left .18s ease;
}

.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-weight: 550;
  font-size: 13.5px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-ink); }
.btn--ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { height: 30px; padding: 0 11px; font-size: 13px; }

.icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); }
.icon-btn__dot {
  position: absolute;
  top: 7px; right: 8px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---- Account ---- */
.account { position: relative; }

.account__trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  padding: 0 6px 0 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  cursor: pointer;
}
.account__trigger:hover { background: var(--surface-2); border-color: var(--line); }

.account__meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.account__name { font-size: 12.5px; font-weight: 600; }
.account__mail { font-size: 11.5px; color: var(--muted); }

.account__avatar {
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
}

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 70;
  min-width: 190px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  box-shadow: var(--shadow-md);
}
.menu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
  font-size: 13.5px;
  cursor: pointer;
}
.menu button:hover { background: var(--surface-2); }
.menu hr { margin: 5px 0; border: 0; border-top: 1px solid var(--line); }

/* ============================================================
   MAIN
   ============================================================ */
.main {
  margin-left: var(--rail-w);
  padding: calc(var(--topbar-h) + 24px) 32px 80px;
  transition: margin-left .18s ease;
}



.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}


.card h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.card p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.panel__empty {
  padding: 46px 10px;
  margin-bottom: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}




.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 600;
}
.tag--green { background: #e9f8ef; color: var(--green); }
.tag--amber { background: #fef4e2; color: var(--amber); }
.tag--red { background: #fdecec; color: var(--danger); }

/* ---- Customers toolbar ---- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: 28px 0 12px;
}
.section-head h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.015em; }
.section-head__tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.tool-search {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  width: 220px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--muted);
}
.tool-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tool-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  color: var(--ink);
  outline: none;
}

.tool-sort {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 4px 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  font-size: 13px;
  color: var(--muted);
}
.tool-sort select {
  height: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 550;
  color: var(--ink);
  outline: none;
  cursor: pointer;
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }

.chip {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.chip:hover { background: var(--surface-2); }
.chip.is-on {
  background: var(--accent-soft);
  border-color: #d5cef9;
  color: var(--accent-ink);
}

.card--customer { padding: 16px 18px; }
.card--customer h3 { margin: 0 0 8px; font-size: 15px; font-weight: 650; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; margin: 10px 0 14px; }

.stats { display: flex; gap: 40px; margin: 0; padding-top: 12px; border-top: 1px solid var(--line-2); }
.stats dt { font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: #9aa0ac; }
.stats dd { margin: 3px 0 0; font-size: 13.5px; font-weight: 600; }
.stats .danger { color: var(--danger); }
.stats .accent { color: var(--accent-ink); }

.empty-note { padding: 40px 0; text-align: center; color: var(--muted); }

/* ============================================================
   FLOATING AI ASSISTANT
   ============================================================ */
.ai { position: fixed; right: 24px; bottom: 24px; z-index: 90; }

.ai__fab {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(108, 92, 231, .4);
  transition: transform .15s ease, background .15s ease;
}
.ai__fab:hover { background: var(--accent-ink); transform: translateY(-2px); }

.ai__panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: 340px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.ai__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.ai__close {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
}
.ai__close:hover { background: var(--line-2); color: var(--ink); }

.ai__body { padding: 14px; }
.ai__msg {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink-2);
}
.ai__hint { margin: 0; font-size: 11.5px; color: #9aa0ac; }

.ai__input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.ai__input-row input {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font: inherit;
  outline: none;
}
.ai__input-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
}

/* ============================================================
   Responsive + motion
   ============================================================ */
@media (max-width: 1100px) {
  .account__meta { display: none; }
}

@media (max-width: 820px) {
  body { --rail-w: var(--rail-w-min); }
  .brand__name, .brand__edit { display: none; }
  .brand { flex-direction: column; gap: 8px; }
  .nav-item span, .nav-item .soon { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .main { padding-left: 20px; padding-right: 20px; }
  .topbar { padding: 0 20px; }
  .ai__panel { width: calc(100vw - 48px); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   v4 additions
   ============================================================ */

/* ---- Clay collapse: hover collapsed logo reveals expand ----
   The icon replaces the tile rather than sitting on top of it, so
   there is no second rounded shape underneath to bleed at the edges. */
.brand__expand {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .13s ease;
}
body.is-collapsed .brand__collapse { display: none; }

body.is-collapsed .brand__link:hover .brand__expand,
body.is-collapsed .brand__link:focus-visible .brand__expand { opacity: 1; }

/* the tile itself becomes the button: no fill, no image, no monogram */
body.is-collapsed .brand__link:hover .brand__logo,
body.is-collapsed .brand__link:focus-visible .brand__logo {
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}
body.is-collapsed .brand__link:hover .brand__monogram,
body.is-collapsed .brand__link:hover .brand__img,
body.is-collapsed .brand__link:focus-visible .brand__monogram,
body.is-collapsed .brand__link:focus-visible .brand__img {
  visibility: hidden;
}

/* ---- View toggle (grid / list) ---- */
.view-toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.view-toggle__btn {
  width: 36px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.view-toggle__btn + .view-toggle__btn { border-left: 1px solid var(--line); }
.view-toggle__btn:hover { background: var(--surface-2); }
.view-toggle__btn.is-on { background: var(--accent-soft); color: var(--accent-ink); }

/* ---- Customer list (row) mode ---- */
.customer-container.is-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.customer-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) 1.6fr 90px 90px 110px 90px;
  gap: 14px;
  align-items: center;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-2);
  cursor: pointer;
  color: inherit;
}
.customer-row:last-child { border-bottom: 0; }
.customer-row:hover { background: var(--surface-2); text-decoration: none; }

.customer-row__name { font-weight: 600; font-size: 14px; }
.customer-row__meta { font-size: 12.5px; color: var(--muted); }
.customer-row .tags { flex-wrap: nowrap; overflow: hidden; }

/* ============================================================
   WORKSPACE DETAIL PAGE
   ============================================================ */

.back-link:hover { background: var(--surface-2); text-decoration: none; }


.processed-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border: 1px solid #bfe8cd;
  border-radius: 999px;
  background: #eefaf2;
  color: var(--green);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.processed-badge svg { flex: 0 0 auto; }

/* ---- Tabs + toolbar ---- */
.ws-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.ws-tab {
  position: relative;
  height: 38px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--muted);
  cursor: pointer;
}
.ws-tab:hover { color: var(--ink); }
.ws-tab.is-on { color: var(--accent-ink); }
.ws-tab.is-on::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.ws-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.ws-toolbar .tool-search { width: 260px; }
.ws-toolbar__spacer { flex: 1; }

.wrap-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.wrap-toggle input { display: none; }
.wrap-toggle .switch {
  position: relative;
  width: 30px;
  height: 17px;
  border-radius: 999px;
  background: var(--line);
  transition: background .15s ease;
}
.wrap-toggle .switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease;
}
.wrap-toggle input:checked + .switch { background: var(--accent); }
.wrap-toggle input:checked + .switch::after { transform: translateX(13px); }

/* Columns dropdown */
.columns-menu-wrap { position: relative; }
.columns-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 70;
  min-width: 180px;
  max-height: 300px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  box-shadow: var(--shadow-md);
}
.columns-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  font-size: 13px;
  cursor: pointer;
}
.columns-menu label:hover { background: var(--surface-2); }
.columns-menu input { accent-color: var(--accent); }

/* ---- Data table ---- */
.ws-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.ws-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 13px;
}
.ws-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #9aa0ac;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.ws-table th .sort-arrow { margin-left: 4px; color: var(--accent-ink); }
.ws-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: top;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ws-table.is-wrapped td { white-space: normal; }
.ws-table tbody tr { cursor: pointer; }
.ws-table tbody tr:hover { background: #fbfbfe; }
.ws-table tr:last-child td { border-bottom: 0; }

.ws-table .cell-alias { color: var(--accent-ink); font-weight: 600; }
.ws-table .cell-file { color: var(--accent-ink); font-size: 12.5px; }

.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 650;
}
.type-badge--msa { background: #eef2ff; color: #4338ca; }
.type-badge--sow { background: #ecfdf3; color: var(--green); }
.type-badge--amd { background: #fef4e2; color: var(--amber); }

.yn--no { color: var(--muted); }
.yn--yes { color: var(--ink); font-weight: 550; }

.ws-count { margin: 10px 2px 0; font-size: 12.5px; color: var(--muted); }

/* ---- Detail drawer ---- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 94;
  background: rgba(20, 20, 31, .25);
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  width: 420px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
.drawer[hidden],
.drawer-backdrop[hidden] { display: none; }
.drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.drawer__title { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.015em; }
.drawer__file { margin: 4px 0 0; font-size: 12px; color: var(--accent-ink); word-break: break-all; }
.drawer__close {
  flex: 0 0 28px;
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.drawer__close:hover { background: var(--line-2); color: var(--ink); }
.drawer__body { flex: 1; overflow-y: auto; padding: 16px 20px 24px; }

.drawer__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  margin: 0 0 18px;
}
.drawer__grid div { min-width: 0; }
.drawer__grid dt {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #9aa0ac;
}
.drawer__grid dd { margin: 3px 0 0; font-size: 13.5px; font-weight: 550; overflow-wrap: anywhere; }

.drawer__section-title {
  margin: 0 0 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #9aa0ac;
}
.drawer__text {
  margin: 0 0 18px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink-2);
}

/* ============================================================
   v5: emulate production workspace table + improvements
   ============================================================ */

/* Selection + grip column (sticky) */
.ws-table th.col-sel,
.ws-table td.col-sel {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 58px;
  min-width: 58px;
  max-width: 58px;
  padding: 11px 8px 11px 12px;
  background: #fff;
  white-space: nowrap;
}
.ws-table th.col-sel { z-index: 4; background: var(--surface-2); cursor: default; }
.ws-table tbody tr:hover td.col-sel { background: #fbfbfe; }

.ws-table td.col-sel .grip {
  margin-left: 6px;
  color: #c6c9d2;
  font-size: 12px;
  letter-spacing: 1px;
  cursor: grab;
  user-select: none;
}
.ws-table tbody tr:hover td.col-sel .grip { color: #9aa0ac; }

.row-check {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}

/* Sticky alias column, sits right after the selection column */
.ws-table th.col-alias,
.ws-table td.col-alias {
  position: sticky;
  left: 58px;
  z-index: 3;
  min-width: 170px;
  background: #fff;
  border-right: 1px solid var(--line-2);
}
.ws-table th.col-alias { z-index: 4; background: var(--surface-2); }
.ws-table tbody tr:hover td.col-alias { background: #fbfbfe; }

/* File column mirrors production: violet, wrapping filename */
.ws-table .cell-file {
  min-width: 200px;
  max-width: 230px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

/* Payment terms get room to wrap like production */
.ws-table .cell-pay { min-width: 170px; max-width: 190px; }

/* Slack notify hint icon */
.notify-hint {
  display: inline-block;
  margin-left: 5px;
  color: #b6bac4;
  cursor: help;
}

/* Trailing per-row action */
.ws-table th.col-action,
.ws-table td.col-action { width: 44px; min-width: 44px; text-align: center; cursor: default; }
.row-action {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: transparent;           /* revealed on row hover */
  cursor: pointer;
}
.ws-table tbody tr:hover .row-action { color: var(--muted); }
.row-action:hover { background: var(--line-2); color: var(--ink) !important; }

/* Selected row tint */
.ws-table tbody tr.is-selected td { background: #f7f5ff; }
.ws-table tbody tr.is-selected td.col-sel,
.ws-table tbody tr.is-selected td.col-alias { background: #f7f5ff; }


/* ============================================================
   v6: sidebar slide animation
   Labels fade+slide instead of popping; rail eases with a
   standard material curve. display:none is replaced by
   opacity/width so the motion is continuous.
   ============================================================ */
:root { --rail-ease: .24s cubic-bezier(.4, 0, .2, 1); }

.sidebar,
.topbar,
.main { transition: width var(--rail-ease), left var(--rail-ease), margin-left var(--rail-ease); }

/* Nav labels: animate instead of vanishing */
.nav-item span,
.nav-item .soon,
.brand__name {
  transition: opacity .16s ease, transform .2s cubic-bezier(.4, 0, .2, 1);
}

body.is-collapsed .nav-item span,
body.is-collapsed .nav-item .soon,
body.is-collapsed .brand__name {
  display: inline-block;    /* override earlier display:none; width:0 needs a box */
  opacity: 0;
  transform: translateX(-6px);
  width: 0;
  overflow: hidden;
  pointer-events: none;
}
body.is-collapsed .brand__name { display: inline-block; }

/* Keep collapsed rows centered despite the zero-width labels */
body.is-collapsed .nav-item { gap: 0; }
body.is-collapsed .brand__link { gap: 0; }

/* Section label crossfades to a tiny centered mark */
.sidebar__label { transition: opacity .16s ease; }

/* ============================================================
   v7: breadcrumbs, page header, dashboards
   ============================================================ */

/* ---- Breadcrumbs in the navbar (Clay pattern) ---- */
.crumbs {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  font-size: 15px;
}

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  max-width: 300px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .12s ease, color .12s ease;
}
.crumb svg { flex: 0 0 auto; }
.crumb > span { overflow: hidden; text-overflow: ellipsis; }

a.crumb:hover,
.crumb--button:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
a.crumb:active { background: var(--line-2); }

/* the page you are on reads as the anchor of the trail */
.crumb--current {
  color: var(--ink);
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.crumb-sep {
  flex: 0 0 auto;
  color: #d3d5de;
  font-weight: 400;
  user-select: none;
}

/* workspace switcher crumb */
.crumb--button.is-open { background: var(--accent-soft); color: var(--accent-ink); }
.crumb__chev { transition: transform .15s ease; }
.crumb--button.is-open .crumb__chev { transform: rotate(180deg); }

/* narrow screens: keep Home and the current page, drop what is between */
@media (max-width: 860px) {
  .crumbs a.crumb { display: none; }
  .crumbs .crumb-sep { display: none; }
}

/* ---- Page header (title lives in the page, not the navbar) ---- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head__left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head__title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.025em; }
.page-head__sub { font-size: 12.5px; color: var(--muted); }
.page-head__actions { display: flex; align-items: center; gap: 8px; }

/* ---- Board filters ---- */
.board-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* ---- Tile grid ---- */
.board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.tile {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.tile__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line-2);
}
.tile__title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile__sub {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile__actions { display: flex; gap: 2px; }
.tile__actions .icon-btn { opacity: 0; transition: opacity .13s ease; }
.tile:hover .tile__actions .icon-btn,
.tile:focus-within .tile__actions .icon-btn,
.tile__actions .icon-btn.is-on { opacity: 1; }   /* pinned stays visible */

.icon-btn--sm { width: 28px; height: 28px; }

.tile__body { overflow-y: auto; }

/* ---- Rate / dates tables inside tiles ---- */
.rate-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rate-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #9aa0ac;
  white-space: nowrap;
}
.rate-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
.rate-table tbody tr { cursor: pointer; }
.rate-table tbody tr:hover { background: #fbfbfe; }
.rate-table tr:last-child td { border-bottom: 0; }

.rate-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.rate-key { font-weight: 600; white-space: normal; min-width: 150px; }
.rate-unit { color: var(--muted); font-size: 12px; }

/* Metric emphasis: avg is the headline, min/max are context */
.rate-table td.metric-avg { font-weight: 650; color: var(--ink); }
.rate-table td.metric-min { color: var(--green); }
.rate-table td.metric-max { color: var(--danger); }
.rate-table td.metric-spread { color: var(--amber); }

.rate-table--drill tbody tr { cursor: default; }
.rate-table--drill tr.is-high td { background: #fdf3f3; }
.rate-table--drill tr.is-low td { background: #f2fbf5; }

.unit-warning {
  margin: 8px 0 0;
  padding: 9px 11px;
  border: 1px solid #fbe2bd;
  border-radius: var(--r-sm);
  background: #fef8ec;
  font-size: 12px;
  color: var(--amber);
}

/* ---- Severity dots + timeline ---- */
.sev-dot {
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: 1px;
}
.sev--red   { background: var(--danger); }
.sev--amber { background: #f59e0b; }
.sev--green { background: #22c55e; }
.sev--past  { background: #9aa0ac; }
.danger-text { color: var(--danger); font-weight: 600; }

.timeline { padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; }
.timeline__row {
  display: grid;
  grid-template-columns: minmax(120px, 1.1fr) 2fr 52px;
  gap: 12px;
  align-items: center;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 12.5px;
}
.timeline__row:hover { background: var(--surface-2); }
.timeline__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline__track {
  position: relative;
  height: 5px;
  border-radius: 999px;
  background: var(--line-2);
}
.timeline__pip {
  position: absolute;
  top: -3px;
  width: 11px; height: 11px;
  margin-left: -5px;
  border: 2px solid #fff;
  border-radius: 50%;
}
.timeline__date { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 96;
  background: rgba(20, 20, 31, .28);
}
.modal-backdrop[hidden], .modal[hidden] { display: none; }

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 97;
  transform: translate(-50%, -50%);
  width: 420px;
  max-width: 92vw;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 13px;
  border-bottom: 1px solid var(--line);
}
.modal__title { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.015em; }
.modal__body { flex: 1; overflow-y: auto; padding: 16px 18px 20px; }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.field-label {
  display: block;
  margin: 14px 0 5px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #9aa0ac;
}
.modal__body > .field-label:first-child { margin-top: 0; }

select.popover__input { height: 34px; }

.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.seg__btn {
  flex: 1;
  height: 34px;
  border: 0;
  background: #fff;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-2);
  cursor: pointer;
}
.seg__btn + .seg__btn { border-left: 1px solid var(--line); }
.seg__btn.is-on { background: var(--accent-soft); color: var(--accent-ink); }

.check-row { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.check-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}
.check-row input { accent-color: var(--accent); }

.drawer__hint { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

/* ---- Home preview tiles ---- */
.preview-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
}

@media (max-width: 1000px) {
  .board { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   v8: collapsed rail alignment + label icon
   ============================================================ */

/* The horizontal scrollbar came from zero-width labels still
   carrying padding/margin. Kill the box entirely when collapsed,
   and never allow sideways scroll in the rail. */
.sidebar { overflow-x: hidden; }

body.is-collapsed .nav-item span,
body.is-collapsed .nav-item .soon,
body.is-collapsed .brand__name {
  padding: 0;
  margin: 0;
  border: 0;
  flex: 0 0 0;
}

/* Uniform 40px hit target, centered, top block and bottom block alike */
body.is-collapsed .sidebar { padding-left: 12px; padding-right: 12px; }
body.is-collapsed .nav-item {
  width: 40px;
  margin: 0 auto;
  padding: 0;
  justify-content: center;
}
body.is-collapsed .brand { margin-bottom: 14px; }
body.is-collapsed .brand__link { width: 40px; margin: 0 auto; justify-content: center; }
body.is-collapsed .sidebar__bottom { align-items: center; }

/* Premium-features label: text expanded, sparkle icon collapsed */
.sidebar__label { display: flex; align-items: center; }
.sidebar__label-icon { display: none; color: #b9bdc7; }
body.is-collapsed .sidebar__label {
  justify-content: center;
  padding: 0;
  margin: 14px auto 6px;
  width: 40px;
}
body.is-collapsed .sidebar__label-text { display: none; }
body.is-collapsed .sidebar__label-icon { display: block; }

/* ============================================================
   v8: workspace switcher in the breadcrumb
   ============================================================ */
.crumb-menu-wrap { position: relative; }

.crumb--button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}
.crumb--button:hover { background: var(--surface-2); }
.crumb--button svg { color: #9aa0ac; }

.switcher {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 75;
  width: 260px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  box-shadow: var(--shadow-md);
}
.switcher[hidden] { display: none; }

.switcher__search {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  margin-bottom: 4px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--muted);
}
.switcher__search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  outline: none;
}

.switcher__list { max-height: 260px; overflow-y: auto; }

.switcher__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: left;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
}
.switcher__item:hover { background: var(--surface-2); text-decoration: none; }
.switcher__item.is-current { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.switcher__meta { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.switcher__item.is-current .switcher__meta { color: var(--accent-ink); }
.switcher__empty { padding: 14px 10px; text-align: center; font-size: 12.5px; color: var(--muted); }
.switcher__foot {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--line-2);
}

/* ============================================================
   v9: exclusions (pivot-style row/item removal)
   ============================================================ */
.rate-table th.col-x,
.rate-table td.col-x {
  width: 30px;
  min-width: 30px;
  padding-left: 8px;
  padding-right: 0;
}

.row-x {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: transparent;          /* revealed on row hover */
  cursor: pointer;
  transition: color .1s ease, background .1s ease;
}
.rate-table tbody tr:hover .row-x { color: #b6bac4; }
.row-x:hover { background: #fdecec; color: var(--danger) !important; }

/* Chips: the exclusion must always be visible on the tile */
.tile__chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-2);
  background: #fffaf2;
}
.tile__chips--drawer {
  padding: 0;
  border: 0;
  background: transparent;
  margin-top: 4px;
}

.tile__chips-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--amber);
}

.excl-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 210px;
  padding: 2px 4px 2px 9px;
  border: 1px solid #f0dcc0;
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
}
.excl-chip--item { border-style: dashed; }
.excl-chip button {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.excl-chip button:hover { background: var(--line-2); color: var(--ink); }

.chip-clear {
  margin-left: auto;
  border: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-ink);
  cursor: pointer;
}
.chip-clear:hover { text-decoration: underline; }

.sub-excl { color: var(--amber); font-weight: 600; }

/* ============================================================
   v10: rate matrix (services x periods)
   Structure follows a worked rate sheet: labels frozen on the
   left, historical periods, then live negotiation columns.
   ============================================================ */
.matrix-scroll { overflow-x: auto; }

.matrix-table { min-width: 100%; }

.matrix-table th.matrix-rowhead,
.matrix-table td.matrix-rowhead {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 190px;
  background: #fff;
  border-right: 1px solid var(--line);
  white-space: normal;
}
.matrix-table th.matrix-rowhead { z-index: 3; background: var(--surface-2); }
.matrix-table tbody tr:hover td.matrix-rowhead { background: #fbfbfe; }

.matrix-table td.matrix-rowhead { font-weight: 600; line-height: 1.35; }
.matrix-unit {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.matrix-table th, .matrix-table td { padding-left: 12px; padding-right: 12px; }
.matrix-table td.num { font-variant-numeric: tabular-nums; }

/* the period in force today */
.matrix-table th.is-current,
.matrix-table td.is-current { background: #eef4ff; }
.matrix-table tbody tr:hover td.is-current { background: #e6eeff; }
.matrix-table th.is-current { color: var(--accent-ink); }

.col-note {
  display: block;
  margin-top: 1px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: none;
  color: var(--accent-ink);
}

.cell-empty { color: #ccced6; }

.delta { font-weight: 650; }
.delta--down { color: var(--green); }
.delta--up { color: var(--danger); }
.delta--flat { color: var(--muted); }

.matrix-table--drill { font-size: 12.5px; }
.matrix-table--drill td.num { white-space: nowrap; }


/* ============================================================
   v12: layout edit mode + present mode
   Six-column grid; tiles span 2 / 3 / 4 / 6.
   ============================================================ */
.board { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tile { position: relative; }
.tile__body { overflow-y: auto; }


/* ---- read mode: handles hidden, nothing draggable ---- */
.rz { display: none; }

/* ---- edit mode ---- */
body.is-editing-layout .board {
  padding: 12px;
  margin: -12px;
  border-radius: var(--r-lg);
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(16.666% - 1px), var(--line-2) calc(16.666% - 1px) 16.666%);
}
body.is-editing-layout .tile { cursor: move; user-select: none; }
body.is-editing-layout .tile__body { pointer-events: none; }   /* content is inert while editing */
body.is-editing-layout .tile__actions .icon-btn { opacity: 1; }
body.is-editing-layout .tile.is-selected { outline: 2px solid var(--accent); outline-offset: -1px; }

body.is-editing-layout .rz {
  display: block;
  position: absolute;
  z-index: 4;
}
/* edges */
.rz--n { top: -3px; left: 14px; right: 14px; height: 7px; cursor: ns-resize; }
.rz--s { bottom: -3px; left: 14px; right: 14px; height: 7px; cursor: ns-resize; }
.rz--e { right: -3px; top: 14px; bottom: 14px; width: 7px; cursor: ew-resize; }
.rz--w { left: -3px; top: 14px; bottom: 14px; width: 7px; cursor: ew-resize; }
/* corners */
.rz--ne, .rz--nw, .rz--se, .rz--sw { width: 14px; height: 14px; }
.rz--ne { top: -4px; right: -4px; cursor: nesw-resize; }
.rz--nw { top: -4px; left: -4px; cursor: nwse-resize; }
.rz--se { bottom: -4px; right: -4px; cursor: nwse-resize; }
.rz--sw { bottom: -4px; left: -4px; cursor: nesw-resize; }

/* visible grips, ThoughtSpot-style pills on edges and squares on corners */
body.is-editing-layout .tile:hover .rz::after,
body.is-editing-layout .tile.is-selected .rz::after {
  content: "";
  position: absolute;
  background: #fff;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
}
.rz--n::after, .rz--s::after { left: 50%; margin-left: -13px; width: 26px; height: 5px; top: 1px; }
.rz--s::after { top: auto; bottom: 1px; }
.rz--e::after, .rz--w::after { top: 50%; margin-top: -13px; width: 5px; height: 26px; left: 1px; }
.rz--e::after { left: auto; right: 1px; }
.rz--ne::after, .rz--nw::after, .rz--se::after, .rz--sw::after {
  width: 9px; height: 9px; border-radius: 2px;
}
.rz--ne::after { top: 4px; right: 4px; }
.rz--nw::after { top: 4px; left: 4px; }
.rz--se::after { bottom: 4px; right: 4px; }
.rz--sw::after { bottom: 4px; left: 4px; }


.tile.is-resizing { outline: 2px solid var(--accent); outline-offset: -1px; }


/* ============================================================
   Present mode
   ============================================================ */
.present {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: #f6f6fa;
}
.present[hidden] { display: none; }
body.is-presenting { overflow: hidden; }

.present__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.present__brand { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 650; }
.present__logo {
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
}
.present__logo img { width: 100%; height: 100%; object-fit: cover; }

.present__counter { font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.present__bar-actions { display: flex; gap: 6px; }

.present__btn {
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--ink-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.present__btn:hover { background: var(--surface-2); }

.present__stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 28px 32px;
  overflow: hidden;
}

.slide {
  width: min(1180px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.slide__head { padding: 22px 26px 16px; border-bottom: 1px solid var(--line-2); }
.slide__title { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.025em; }
.slide__sub { margin: 5px 0 0; font-size: 13px; color: var(--muted); }
.slide__body { flex: 1; overflow: auto; }
.slide .rate-table { font-size: 14px; }
.slide .rate-table th { padding-top: 12px; padding-bottom: 12px; }
.slide .rate-table td { padding-top: 13px; padding-bottom: 13px; }
.slide .row-x, .slide .col-x { display: none; }

.present__foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 14px 24px 20px;
}
.present__nav {
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink-2);
  cursor: pointer;
}
.present__nav:hover:not(:disabled) { background: #fff; border-color: var(--accent); color: var(--accent-ink); }
.present__nav:disabled { opacity: .35; cursor: default; }

.present__dots { display: flex; gap: 7px; }
.present__dot {
  width: 8px; height: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #d3d5de;
  cursor: pointer;
}
.present__dot.is-on { background: var(--accent); transform: scale(1.25); }

@media (max-width: 1000px) {
  .board { grid-template-columns: minmax(0, 1fr); }
  .tile { grid-column: 1 / -1 !important; }
  body.is-editing-layout .board { background: none; }
}

/* ============================================================
   v13: mode clarity + live reorder
   ============================================================ */

/* THE bug behind both action bars showing at once: [hidden] is the
   weakest display rule, so display:flex silently overrode it. */
.page-head__actions[hidden],
.edit-banner[hidden] { display: none; }

.board-menu-wrap { position: relative; }

/* ---- edit-mode banner: unmissable, and it says how to leave ---- */
.edit-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid #d5cef9;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  font-size: 13px;
  color: var(--accent-ink);
}
.edit-banner__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

.edit-banner__hint { color: var(--ink-2); }
.edit-banner__reset {
  margin-left: auto;
  border: 0;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-ink);
  cursor: pointer;
}
.edit-banner__reset:hover { text-decoration: underline; }

/* the page itself signals the mode, not just a button label */
body.is-editing-layout .page-head__title::after {
  content: "Editing";
  margin-left: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  vertical-align: 4px;
}

/* ---- dragging ---- */
.tile.is-dragging {
  opacity: .5;
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}
.tile.is-dragging .tile__head,
.tile.is-dragging .tile__body { visibility: hidden; }

body.is-editing-layout .board { min-height: 200px; }

/* ============================================================
   v14: tile type icons + pinned tiles on home
   ============================================================ */
.tile__icon {
  flex: 0 0 22px;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
}
.tile__icon--rate   { background: var(--accent-soft); color: var(--accent-ink); }
.tile__icon--matrix { background: #e8f1ff; color: #2563c9; }
.tile__icon--dates  { background: #eefaf2; color: var(--green); }

.slide__title .tile__icon { flex-basis: 30px; width: 30px; height: 30px; border-radius: 8px; }
.slide__title .tile__icon svg { width: 18px; height: 18px; }

.icon-btn.is-on { color: var(--accent-ink); background: var(--accent-soft); }

/* ---- Home: pinned tiles ---- */
.pinned-board { margin-bottom: 26px; }

.pinned-board__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.pinned-board__title { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.015em; }

.pinned-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}
.pinned-tile { display: flex; flex-direction: column; }
.pinned-tile__head { flex: 0 0 auto; }
@media (max-width: 900px) {
  .pinned-grid { grid-template-columns: minmax(0, 1fr); }
}

.pinned-tile {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: inherit;
  overflow: hidden;
}
.pinned-tile:hover { border-color: #ddd9f7; text-decoration: none; }

.pinned-tile__head { padding: 14px 16px 11px; border-bottom: 1px solid var(--line-2); }
.pinned-tile__title { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.pinned-tile__sub { margin: 3px 0 0; font-size: 12px; color: var(--muted); }

.pinned-tile__body { height: 280px; overflow-y: auto; }
.pinned-tile__body .rate-table th { position: sticky; top: 0; z-index: 1; }
.pinned-tile__body .tile__chips { display: none; }

.pinned-empty {
  padding: 30px 10px;
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Present mode: chips report what's excluded but can't be edited there */
.slide .tile__chips button { display: none; }
.slide .tile__chips { border-radius: 0; }

/* ============================================================
   v15: title rows align on one axis
   Icon, title and pin were each nudged with vertical-align
   hacks. One flex row centres all three properly instead.
   ============================================================ */
.slide__title {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

/* the title text itself truncates, the icon and pin never shrink */
.slide__title > span:not(.tile__icon) { min-width: 0; }
.slide__sub { margin-left: 41px; }

.tile__headtext { flex: 1; min-width: 0; }
.tile__actions { flex: 0 0 auto; }

/* both pin affordances share the same violet, so they read as one state */
.tile__actions .icon-btn.is-on {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* ============================================================
   v16: large icon treatment on pinned tiles
   Matches the original panel headers — 34px rounded tile, icon
   centred against the whole two-line text block.
   ============================================================ */
.tile__icon--lg {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 9px;
}
.tile__icon--lg svg { width: 17px; height: 17px; }

.pinned-tile__head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line-2);
}

.pinned-tile__text { flex: 1; min-width: 0; }

.pinned-tile__title {
  display: block;
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-tile__sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-tile__head .preview-link {
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--accent-ink);
}
.pinned-tile:hover .preview-link { text-decoration: underline; }
