/* Web-only additions: projects/sheets pages, in-page dropdown menus, sidebar sections. */
:root { --menubar-h: 0px; }

html, body { height: 100%; overflow: hidden; }
.app-shell { height: 100vh; height: 100dvh; }

/* ---- Dropdown menus ([data-menu-toggle] + .cm-menu, handled by web-bridge.js) ---- */
.cm-menu-wrap { position: relative; display: inline-flex; }
.cm-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 6000;
  min-width: 210px;
  padding: 6px 0;
  background: var(--white);
  color: var(--dark);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
  text-transform: none;
  letter-spacing: normal;
  font-size: 14px;
  font-weight: 400;
  display: block;
}
.cm-menu.hidden { display: none; }
.cm-menu-right { left: auto; right: 0; }
.cm-menu button {
  display: block;
  width: 100%;
  height: auto;
  min-width: 0;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 8px 16px;
  color: var(--dark);
  font: inherit;
  font-weight: 500;
}
.cm-menu button:hover, .cm-menu button:focus-visible { background: var(--soft-teal); outline: none; }
.cm-menu hr { margin: 5px 0; border: 0; border-top: 1px solid var(--line); }

/* App bar on the projects / sheets pages */
.cm-appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 58px;
  padding: 0 28px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.cm-appbar-brand img { height: 34px; display: block; }
.cm-appbar-btn {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--dark);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
}
.cm-appbar-btn:hover { background: var(--soft-teal); }

/* Sidebar account button (license badge) */
button.brand-license-slot { font: inherit; color: inherit; text-align: left; cursor: pointer; background: transparent; }
button.brand-license-slot:hover { background: rgba(255, 255, 255, 0.14); }

/* Toolbar export button matches the other toolbar buttons */
.toolbar .cm-menu-wrap > button { white-space: nowrap; }

/* Library panel header actions */
.panel-title-actions { display: inline-flex; align-items: center; gap: 6px; }

/* ---- Collapsible category sections (items, totals, library) --------------- */
.section-header { cursor: default; }
.section-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  text-align: left;
}
.section-toggle:hover .section-name { text-decoration: underline; }
.section-chevron { width: 10px; flex: none; font-size: 10px; }
.section-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-subtotal {
  min-width: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: var(--white);
  font-size: 11px;
  text-align: center;
}
.item-list .library-category:first-child, .library-list .library-category:first-child { margin-top: 0; }

/* Project markup items look like library rows */
.project-item-row { grid-template-columns: 14px minmax(0, 1fr) auto; cursor: pointer; }
.project-item-row.active { outline: 2px solid white; background: rgba(255, 255, 255, 0.22); }
.project-item-row.item-hidden { opacity: 0.68; }
.item-hidden-tag { font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: rgba(255, 255, 255, 0.7); }
.project-item-row.row-dragging { opacity: 0.4; }
.project-item-row.drop-above { box-shadow: 0 -3px 0 #fff; }
.project-item-row.drop-below { box-shadow: 0 3px 0 #fff; }
.item-list { gap: 6px; }

/* Totals: category subtotal rows */
.total-category-row {
  border-top: 1px solid rgba(255, 255, 255, 0.24);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255, 255, 255, 0.86);
}
.total-item-row > span { padding-left: 16px; }

/* Add/Edit markup item popup: project-only options */
.library-item-project-options { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.library-item-project-options.hidden { display: none; }
.library-item-project-options select { margin-bottom: 8px; }

/* New Project / Add Sheets page choice */
.cm-choice { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.cm-choice label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--dark); cursor: pointer; }
.cm-input:disabled { background: #f1f4f4; color: var(--muted); cursor: not-allowed; }
/* ---- Projects / sheets pages (projects.js) ---------------------------------- */
body[data-view="projects"] .app-shell,
body[data-view="sheets"] .app-shell { display: none; }
.cm-view.hidden { display: none; }

.cm-view {
  height: calc(100vh - var(--menubar-h));
  height: calc(100dvh - var(--menubar-h));
  overflow-y: auto;
  background: var(--bg);
}
.cm-view-inner { max-width: 1280px; margin: 0 auto; padding: 28px 28px 60px; }
.cm-view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.cm-view-header h1 { margin: 0; color: var(--teal); font-size: 30px; }
.cm-subtle { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.cm-hint { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.cm-breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.cm-breadcrumb a { color: var(--teal); font-weight: 700; text-decoration: none; }
.cm-breadcrumb a:hover { text-decoration: underline; }

.cm-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cm-header-actions button,
.project-nav-btn {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--dark);
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 700;
}
.cm-header-actions .cm-primary { background: var(--teal); border-color: var(--teal); color: var(--white); }
.cm-header-actions button:hover { filter: brightness(0.97); }
.cm-search {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  min-width: 220px;
  background: var(--white);
}

.cm-save-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cm-save-status[data-status="saved"]::before { content: "✓ "; color: #1b7f4b; }
.cm-save-status[data-status="offline"],
.cm-save-status[data-status="error"] { color: #9a6200; }
.cm-save-status[data-status="conflict"] { color: #a33535; font-weight: 700; }

.cm-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.cm-sheet-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.cm-card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: box-shadow .15s, border-color .15s;
}
.cm-card:hover, .cm-card:focus-visible { border-color: var(--teal); box-shadow: 0 8px 22px rgba(11, 76, 146, 0.14); outline: none; }
.cm-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.cm-card-titles { min-width: 0; }
.cm-card-title { font-weight: 800; color: var(--dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-card-number { font-size: 13px; color: var(--muted); margin-top: 2px; }
.cm-card-stats { font-size: 13px; color: var(--teal); font-weight: 700; margin-top: 10px; }
.cm-sheet-card .cm-card-stats { margin-top: 3px; }
.cm-card-time { font-size: 12px; color: var(--muted); margin-top: 4px; }
.cm-more {
  flex: none;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  line-height: 1;
}
.cm-more:hover { background: var(--soft-teal); }

.cm-sheet-card { padding: 0; overflow: hidden; }
.cm-sheet-body { padding: 12px 14px 14px; }
.cm-thumb {
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef2f2;
  border-bottom: 1px solid var(--line);
}
.cm-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; }
.cm-thumb-loading { font-size: 12px; color: var(--muted); }
.cm-sheet-notes {
  margin-top: 8px;
  font-size: 12px;
  color: var(--dark);
  background: #fff8e1;
  border-radius: 8px;
  padding: 6px 8px;
  white-space: pre-wrap;
  max-height: 54px;
  overflow: hidden;
}
.cm-sheet-notes.hidden { display: none; }
.cm-dragging { opacity: 0.45; }
.cm-drop-before { box-shadow: -4px 0 0 var(--teal); }
.cm-drop-after { box-shadow: 4px 0 0 var(--teal); }

.cm-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 50px 20px;
  border: 2px dashed var(--line);
  border-radius: 18px;
  background: var(--white);
  line-height: 1.6;
}
.cm-empty strong { color: var(--dark); }

.cm-action-menu {
  position: absolute;
  z-index: 6000;
  min-width: 210px;
  padding: 6px 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
}
.cm-action-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 16px;
  color: var(--dark);
}
.cm-action-menu button:hover { background: var(--soft-teal); }
.cm-action-menu .cm-danger { color: #a33535; }

.cm-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(51, 51, 51, 0.62);
}
.cm-dialog .cm-input {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  background: var(--white);
  color: var(--dark);
  font: inherit;
}
.cm-dialog textarea.cm-input { resize: vertical; }
.cm-field-help { font-size: 12px; color: var(--muted); margin: 4px 0 12px; min-height: 4px; }
.cm-dialog-error { color: #a33535; font-size: 13px; font-weight: 700; min-height: 18px; }

.cm-busy {
  position: fixed;
  inset: 0;
  z-index: 7000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 247, 247, 0.82);
}
.cm-busy.hidden { display: none; }
.cm-busy-card {
  min-width: 280px;
  padding: 26px 30px;
  text-align: center;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
}
.cm-busy-text { margin-top: 12px; font-weight: 700; color: var(--teal); }
.cm-spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border: 4px solid var(--soft-teal);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: cm-spin 0.8s linear infinite;
}
@keyframes cm-spin { to { transform: rotate(360deg); } }
.cm-progress { height: 8px; margin-top: 14px; border-radius: 999px; background: var(--soft-teal); overflow: hidden; }
.cm-progress.hidden { display: none; }
.cm-progress div { height: 100%; width: 0; background: var(--teal); transition: width .2s; }

.project-nav-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.project-nav-btn { padding: 7px 12px; font-size: 13px; }
.sidebar .cm-save-status { color: rgba(255, 255, 255, 0.78); }
.sidebar .cm-save-status[data-status="saved"]::before { color: #9ff0c4; }
.sidebar .cm-save-status[data-status="offline"],
.sidebar .cm-save-status[data-status="error"] { color: #ffd98a; }
.sidebar .cm-save-status[data-status="conflict"] { color: #ffb4b4; }

@media (max-width: 640px) {
  .cm-view-inner { padding: 18px 16px 40px; }
  .cm-search { min-width: 0; flex: 1; }
}

/* ---- Markup library picker (opened from Markup Items) ------------------------ */
.library-picker-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(51, 51, 51, 0.55);
}
.library-picker-backdrop.hidden { display: none; }
.library-picker-card {
  width: min(980px, calc(100vw - 32px));
  height: min(820px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  padding: 20px;
  background: var(--teal);
  color: var(--white);
  border-radius: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}
.library-picker-card .panel-title { font-size: 13px; }
.library-picker-help { margin: 0 0 10px; font-size: 12px; color: rgba(255, 255, 255, 0.72); }
.library-picker-card .library-list { flex: 1; max-height: none; min-height: 120px; margin-top: 10px; }
/* Scales to large libraries: category sidebar + item grid. */
.library-picker-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 16px; }
.library-category-nav { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 2px; padding-right: 4px; border-right: 1px solid var(--rule, #D9DDE3); }
.library-category-nav button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border-radius: 8px; font-size: 13px; color: var(--ink, #15202E); }
.library-category-nav button span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-category-nav button span:last-child { font-family: var(--font-mono, monospace); font-size: 11px; color: var(--graphite, #5B6573); }
.library-category-nav button:hover { background: var(--blue-tint, #EAF1FA); }
.library-category-nav button.is-active { background: var(--navy, #002C5E); color: #fff; font-weight: 700; }
.library-category-nav button.is-active span:last-child { color: rgba(255, 255, 255, 0.75); }
.library-category-nav button:focus-visible { outline: 2px solid var(--blue, #0B4C92); outline-offset: -2px; }
.library-picker-main { min-height: 0; display: flex; flex-direction: column; }
.library-picker-card .library-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); align-content: start; gap: 6px 10px; overflow: auto; }
.library-picker-card .library-list > .library-category { grid-column: 1 / -1; }
.library-picker-card .library-list > .library-empty { grid-column: 1 / -1; padding: 16px 4px; }
@media (max-width: 700px) {
  .library-picker-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 10px; }
  .library-category-nav { flex-direction: row; overflow-x: auto; border-right: 0; padding: 0 0 4px; }
  .library-category-nav button { width: auto; flex: none; border: 1px solid var(--rule, #D9DDE3); border-radius: 999px; }
}
.library-picker-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.library-picker-actions button {
  border: 0;
  border-radius: 999px;
  padding: 9px 22px;
  background: var(--white);
  color: var(--teal);
  font-weight: 800;
}

/* ---- Sidebar project summary ------------------------------------------------- */
.project-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.project-summary-text { min-width: 0; }
.project-summary-name { font-weight: 800; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-summary-number { font-size: 12px; color: rgba(255, 255, 255, 0.72); margin-top: 2px; }
.project-summary .project-nav-btn { flex: none; }
.markup-item-buttons .secondary-btn { padding: 10px; border-radius: 999px; font-weight: 700; }

/* ---- Account Settings page ------------------------------------------------------ */
body[data-view="settings"] .app-shell { display: none; }
.cm-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  align-items: start;
}
.cm-settings-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
}
.cm-settings-card h2 { margin: 0 0 14px; font-size: 18px; color: var(--teal); }
.cm-settings-card .cm-input {
  display: block;
  width: 100%;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  background: var(--white);
  color: var(--dark);
  font: inherit;
}
.cm-settings-card .cm-input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--soft-teal); }
.cm-settings-card textarea.cm-input { resize: vertical; }
.cm-settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cm-settings-preview-card { grid-column: 1 / -1; }
.cm-settings-actions { display: flex; gap: 8px; margin: 10px 0 4px; }
.cm-settings-actions button,
.cm-color-row button {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
}
.cm-settings-actions button:first-child { background: var(--teal); border-color: var(--teal); color: var(--white); }
.cm-settings-actions .hidden { display: none; }
.cm-logo-preview {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--line);
  border-radius: 14px;
  /* Checkerboard so transparent parts of the logo are visible. */
  background-color: #fafcfc;
  background-image:
    linear-gradient(45deg, #e8eded 25%, transparent 25%),
    linear-gradient(-45deg, #e8eded 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8eded 75%),
    linear-gradient(-45deg, transparent 75%, #e8eded 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  color: var(--muted);
  font-size: 13px;
}
.cm-logo-preview img { max-width: 90%; max-height: 90px; object-fit: contain; }
.cm-color-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.cm-color-row input[type="color"] { width: 46px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: none; }
.cm-color-row .cm-input { max-width: 120px; margin-bottom: 0; font-family: Consolas, monospace; }

.cm-summary-preview {
  max-width: 640px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}
.cm-preview-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
}
.cm-preview-project { font-size: 20px; font-weight: 800; }
.cm-preview-number { font-size: 15px; font-weight: 700; margin-top: 2px; }
.cm-preview-date { font-size: 11px; margin-top: 6px; opacity: 0.9; }
.cm-preview-logo {
  min-width: 90px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  opacity: 0.85;
}
.cm-preview-logo.has-logo { padding: 6px; opacity: 1; }
.cm-preview-logo.has-logo.on-white { background: #fff; }
.cm-preview-logo img { display: block; max-width: 150px; max-height: 56px; object-fit: contain; }
.cm-preview-body { padding: 18px 22px 8px; }
.cm-preview-title { font-weight: 800; margin-bottom: 10px; }
.cm-preview-line { height: 10px; border-radius: 4px; background: #eef2f2; margin-bottom: 8px; }
.cm-preview-line.short { width: 60%; }
.cm-preview-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 22px 14px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
.cm-preview-footer span:first-child { font-weight: 700; color: var(--dark); }
@media (max-width: 640px) {
  .cm-settings-row { grid-template-columns: 1fr; }
}

/* ---- Navigation back to Projects ------------------------------------------------ */
.cm-breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 14px; }
.cm-breadcrumb .cm-back-link {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--teal);
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
}
.cm-breadcrumb .cm-back-link:hover { background: var(--soft-teal); text-decoration: none; }
.cm-crumb-sep { color: var(--muted); }
.project-nav-row { flex-wrap: wrap; }
.project-nav-buttons { display: inline-flex; gap: 6px; }
.brand-home-link { display: inline-block; border-radius: 8px; }
.brand-home-link:hover { opacity: 0.85; }

/* ---- Notes ------------------------------------------------------------------------ */
.cm-notes-card {
  margin: 0 0 16px;
  padding: 14px 16px;
  background: #fffbea;
  border: 1px solid #f2e3a6;
  border-radius: 16px;
}
.cm-notes-title { display: block; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: #7a5c00; margin-bottom: 6px; }
.cm-notes-input {
  display: block;
  width: 100%;
  min-height: 64px;
  resize: vertical;
  border: 1px solid #f2e3a6;
  border-radius: 10px;
  padding: 9px 11px;
  background: #fff;
  color: var(--dark);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
}
.cm-notes-input:focus { outline: none; border-color: #d4b23a; box-shadow: 0 0 0 3px rgba(212, 178, 58, 0.2); }

.sheet-notes-label { display: block; font-size: 12px; color: rgba(255, 255, 255, 0.78); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-notes-input {
  display: block;
  width: 100%;
  min-height: 60px;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  padding: 9px 11px;
  background: #fff8e1;
  color: var(--dark);
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
}
.sheet-notes-input:focus { outline: none; border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18); }
.sheet-notes-input:disabled { opacity: 0.6; }

/* Collapsible Sheet Notes panel title */
.panel-title-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.panel-title-toggle:hover span:not(.sheet-notes-badge) { color: var(--white); }
.sheet-notes-panel .panel-title-toggle[aria-expanded="false"] { margin-bottom: 0; }
.sheet-notes-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff1b8;
  color: #6b5200;
  font-size: 10px;
  letter-spacing: .04em;
}
.sheet-notes-badge.hidden, #sheetNotesBody.hidden { display: none; }

/* ---- Home page ----------------------------------------------------------------- */
.cm-appbar-search { flex: 1; max-width: 460px; min-width: 0; margin: 0 16px; }
.cm-appbar-actions { display: flex; align-items: center; gap: 10px; }
.cm-appbar-primary {
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  background: var(--teal);
  color: var(--white);
  font-weight: 800;
  white-space: nowrap;
}
.cm-appbar-primary:hover { filter: brightness(1.1); }
.cm-home-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.cm-home-hero h1 { margin: 0; color: var(--teal); font-size: 30px; }
.cm-quick-links { display: flex; gap: 8px; flex-wrap: wrap; }
.cm-quick-links button {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--teal);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 700;
  font-size: 13px;
}
.cm-quick-links button:hover { background: var(--soft-teal); }
.cm-home-section { margin-bottom: 30px; }
.cm-home-section.hidden { display: none; }
.cm-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cm-section-head h2 { margin: 0; font-size: 19px; color: var(--dark); }
.cm-count { margin-left: 6px; padding: 2px 9px; border-radius: 999px; background: var(--soft-teal); color: var(--teal); font-size: 12px; vertical-align: middle; }
.cm-count:empty { display: none; }
.cm-link-btn { border: 0; background: none; color: var(--teal); font-weight: 700; padding: 4px 6px; cursor: pointer; }
.cm-link-btn:hover { text-decoration: underline; }
.cm-link-btn.hidden { display: none; }
.cm-home-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.cm-empty-small { padding: 22px 16px; font-size: 14px; }
.cm-card-share { font-size: 12px; color: var(--muted); margin-top: 4px; }
.cm-card-share:empty { display: none; }
.cm-project-card.is-shared { border-left: 4px solid #7fb8b9; }
.cm-sort { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.cm-sort select { border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; background: var(--white); }

.cm-project-table { background: var(--white); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.cm-project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 100px 110px 36px;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.cm-project-row:hover, .cm-project-row:focus-visible { background: #f6fafa; outline: none; }
.cm-project-row-head { border-top: 0; cursor: default; background: #f6f8f8; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: 9px; padding-bottom: 9px; }
.cm-project-row-head:hover { background: #f6f8f8; }
#homeAllList .cm-project-row:first-child { border-top: 1px solid var(--line); }
#homeAllList .cm-empty { border: 0; border-radius: 0; }
.cm-row-title { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cm-row-cell { font-size: 13px; color: var(--muted); }
.cm-show-more { display: block; margin: 12px auto 0; border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 8px 18px; font-weight: 700; color: var(--teal); }
.cm-show-more.hidden { display: none; }
/* All Projects: sortable column headers and pager */
.cm-col-sort { all: unset; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; display: inline-flex; align-items: center; gap: 4px; width: max-content; }
.cm-col-sort:hover, .cm-col-sort.is-sorted { color: var(--ink, #15202E); }
.cm-col-sort:focus-visible { outline: 2px solid var(--blue, #0B4C92); outline-offset: 2px; border-radius: 3px; }
.cm-col-sort.is-sorted[data-dir="asc"]::after { content: "▲"; font-size: 8px; }
.cm-col-sort.is-sorted[data-dir="desc"]::after { content: "▼"; font-size: 8px; }
.cm-pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.cm-pager.hidden { display: none; }
.cm-pager-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cm-pager-info { font-size: 13px; color: var(--muted); }
.cm-pager-btn { border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 13px; color: var(--teal); cursor: pointer; }
.cm-pager-btn:disabled { opacity: .45; cursor: default; }
@media (max-width: 760px) {
  .cm-project-row { grid-template-columns: minmax(0, 1fr) 36px; }
  .cm-project-row .cm-row-cell, .cm-project-row-head .cm-row-cell { display: none; }
  .cm-appbar-search { display: none; }
}

.cm-get-started { margin-bottom: 26px; padding: 18px 20px; border-radius: 18px; background: linear-gradient(135deg, #e6f3f3, #ffffff); border: 1px solid #cfe5e5; }
.cm-get-started.hidden { display: none; }
.cm-get-started-head { display: flex; align-items: center; justify-content: space-between; }
.cm-get-started h2 { margin: 0 0 10px; font-size: 18px; color: var(--teal); }
.cm-steps { display: grid; gap: 8px; }
.cm-step {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  color: var(--dark);
  cursor: pointer;
}
.cm-step:hover { border-color: var(--teal); }
.cm-step-check { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid var(--teal); display: inline-flex; align-items: center; justify-content: center; font-weight: 900; color: var(--white); font-size: 12px; }
.cm-step.done { color: var(--muted); text-decoration: line-through; }
.cm-step.done .cm-step-check { background: var(--teal); }

/* Library opened from the home page: manage only (no project to add items to). */
body:not([data-view="workspace"]) #libraryPicker .library-picker-help { visibility: hidden; }

/* ---- Shared projects ------------------------------------------------------------ */
body.project-collaborator .owner-only { display: none !important; }
.sheet-lock-banner {
  margin: 0;
  padding: 10px 18px;
  background: #fff4d6;
  border-bottom: 1px solid #f0d98a;
  color: #6b5200;
  font-weight: 700;
  font-size: 14px;
}
.sheet-lock-banner.hidden { display: none; }
body.sheet-read-only #dotLayer,
body.sheet-read-only #measurementLayer,
body.sheet-read-only #legendLayer { pointer-events: none !important; }
body.sheet-read-only #pdfStage { cursor: grab; }
.cm-sheet-lock { margin-top: 8px; font-size: 12px; font-weight: 700; color: #8a5a00; background: #fff4d6; border-radius: 8px; padding: 5px 8px; }
.cm-sheet-lock.hidden { display: none; }
.cm-sheet-card.is-locked { border-color: #f0d98a; }

.cm-share-dialog { width: min(560px, calc(100vw - 40px)); }
.cm-share-form { display: flex; gap: 8px; margin: 8px 0 4px; }
.cm-share-form .cm-input { flex: 1; }
.cm-share-add { border: 0; border-radius: 999px; padding: 9px 18px; background: var(--teal); color: var(--white); font-weight: 800; }
.cm-share-add:disabled { opacity: 0.6; }
.cm-share-list { display: grid; gap: 6px; max-height: 260px; overflow: auto; margin-bottom: 4px; }
.cm-share-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.cm-share-email { font-weight: 700; overflow-wrap: anywhere; }
.cm-share-status { font-size: 12px; color: var(--muted); }
.cm-share-row button { border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 6px 12px; }
