:root {
  color-scheme: light;

  /* surfaces */
  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-sunken: #fbf9f7;
  --border: #e6e0db;
  --border-strong: #d6cec7;

  /* text */
  --text: #211d1f;
  --text-muted: #7a716c;
  --text-faint: #a89f99;

  /* brand — a desaturated plum, a nod to Odoo's own palette */
  --primary: #714b67;
  --primary-hover: #5c3c54;
  --primary-light: #f2e9f0;
  --primary-ring: rgba(113, 75, 103, 0.28);

  /* status */
  --success: #3f7d58;
  --success-bg: #e6f1ea;
  --warning: #a06a1f;
  --warning-bg: #faf0dd;
  --danger: #ad3d3d;
  --danger-bg: #fbebea;
  --neutral-bg: #ece7e2;

  /* scale */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(43, 27, 38, 0.06), 0 1px 1px rgba(43, 27, 38, 0.04);
  --shadow-md: 0 8px 24px -8px rgba(43, 27, 38, 0.18), 0 2px 8px -2px rgba(43, 27, 38, 0.08);
  --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* The theme-resolver script in layout.html always sets data-theme to a
   concrete "light" or "dark" before first paint (resolving "system" itself),
   so this is the only override block needed — no @media (prefers-color-scheme)
   fallback required. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #16141a;
  --surface: #201e26;
  --surface-sunken: #1a1820;
  --border: #322f3a;
  --border-strong: #423e4d;

  --text: #eeecf0;
  --text-muted: #a49eae;
  --text-faint: #746e80;

  --primary: #c9a0bc;
  --primary-hover: #d9b4cc;
  --primary-light: #3a2c37;
  --primary-ring: rgba(201, 160, 188, 0.35);

  --success: #6fbf8b;
  --success-bg: #1f3327;
  --warning: #e0a94a;
  --warning-bg: #3a2e17;
  --danger: #e0807f;
  --danger-bg: #3a2020;
  --neutral-bg: #2b2732;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 1px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.6), 0 2px 8px -2px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  background: var(--bg);
  background-image: radial-gradient(circle at 15% 0%, rgba(113, 75, 103, 0.05), transparent 45%);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 0 0 0.5rem;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { line-height: 1.55; }

a { color: var(--primary); text-decoration: none; }
code { overflow-wrap: anywhere; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- nav ---------- */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-brand a {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  color: var(--text);
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}
.nav-brand a:hover { text-decoration: none; }
.nav-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
}
/* flex-wrap (not nowrap) is the actual fix for nav overflow at "tablet
   laptop" widths (~900-1150px) — rather than re-tuning exactly which
   items live in .nav-more every time a new top-level section is added
   (a moving target that broke three times in a row as features shipped),
   letting the row wrap to a second line means there's no width at which
   this can overflow or visibly collide with the brand mark, independent
   of how many items end up here in the future. justify-content:flex-end
   keeps a short second line pinned to the right, matching the row's own
   alignment, instead of drifting to the left. */
/* min-width: 0 overrides the flex item default of min-width: auto, which
   otherwise refuses to shrink a flex item below its content's natural
   width — exactly what was silently blocking flex-wrap from ever
   kicking in above. */
.nav-links { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 0.6rem 1.15rem; min-width: 0; flex: 1 1 auto; }
.nav-links a { color: var(--text-muted); font-weight: 600; font-size: 0.89rem; transition: color 150ms ease; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active:not(.button) { color: var(--primary); }
.nav-links a.button, .nav-links a.button:hover { color: #fff; }
.nav-divider { width: 1px; height: 1.3rem; background: var(--border); }
.nav-user { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--text-muted); font-size: 0.9rem; font-weight: 500; }

.theme-switch { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.theme-switch button {
  background: var(--surface);
  color: var(--text-muted);
  border: none;
  padding: 0.3rem 0.55rem;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.theme-switch button + button { border-left: 1px solid var(--border-strong); }
.theme-switch button:hover { background: var(--surface-sunken); color: var(--text); }
.theme-switch button.active { background: var(--primary); color: #fff; }

.notif-panel { position: relative; display: flex; align-items: center; }
.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 999px;
  transition: background-color 150ms ease, color 150ms ease;
}
.notif-bell:hover { background: var(--surface-sunken); color: var(--text); }
.notif-badge {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  padding: 0.05rem 0.42rem;
  font-size: 0.68rem;
  font-weight: 700;
}
.notif-badge-bell {
  position: absolute;
  top: -1px;
  right: -1px;
  min-width: 1.05rem;
  height: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.3rem;
  box-shadow: 0 0 0 2px var(--surface);
}
.notif-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 30;
  overflow: hidden;
}
.notif-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 700;
}
.notif-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.notif-item { display: block; padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--border); font-size: 0.85rem; transition: background-color 120ms ease; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--primary-light); }
.notif-item:not(.unread):hover { background: var(--surface-sunken); }
.notif-item.unread:hover { filter: brightness(0.97); }
.notif-item a { color: var(--text); }
.notif-item a:hover { text-decoration: none; }
.notif-time { display: block; color: var(--text-faint); font-size: 0.72rem; margin-top: 0.15rem; }

.nav-more { position: relative; }
.nav-more-trigger {
  background: none;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.89rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  transition: color 150ms ease;
}
.nav-more-trigger:hover { color: var(--text); }
.nav-more-dropdown {
  position: absolute;
  left: 0;
  top: calc(100% + 0.5rem);
  min-width: 150px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0.4rem;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.nav-more-dropdown a { padding: 0.5rem 0.6rem; border-radius: var(--radius-sm); }
.nav-more-dropdown a:hover { background: var(--surface-sunken); text-decoration: none; }
.nav-more-mobile-link { display: none; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  transition: background-color 150ms ease;
}
.nav-toggle:hover { background: var(--surface-sunken); }

[x-cloak] { display: none !important; }

.nav-search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8rem;
  transition: background-color 150ms ease, color 150ms ease;
}
.nav-search-trigger:hover { background: var(--surface-sunken); color: var(--text); }
.nav-search-hint kbd {
  font-family: inherit;
  font-size: 0.72rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 0.05rem 0.32rem;
}

.search-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 22, 0.45);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10vh 1rem 1rem;
  z-index: 100;
}
.search-modal {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.search-modal-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  font-size: 1rem;
  font-family: inherit;
  background: transparent;
  color: var(--text);
}
.search-modal-input:focus { outline: none; }
.search-results { max-height: 60vh; overflow-y: auto; padding: 0.4rem; }
.search-results .empty-state { padding: 0.75rem; margin: 0; }
.search-results-list { list-style: none; margin: 0; padding: 0; }
.search-result {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}
.search-result:hover, .search-result.active { background: var(--surface-sunken); text-decoration: none; }
.search-result-kind { flex-shrink: 0; }
.search-result-text { display: flex; flex-direction: column; min-width: 0; }
.search-result-title { font-weight: 600; }
.search-result-subtitle { font-size: 0.8rem; color: var(--text-muted); }

@media (max-width: 640px) {
  .nav-search-hint { display: none; }
}

@media (max-width: 640px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .nav-links {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: 0.25rem 1.5rem 1.25rem;
  }
  .nav-links.nav-links-open { display: flex; }
  .nav-links > a:not(.button) {
    width: 100%;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
  }
  /* Discuss leads the mobile menu (highest-traffic item on a small screen)
     while staying in its usual desktop position — order is scoped to this
     media query only, DOM order (and the row-layout desktop nav) is
     untouched. */
  .nav-link-discuss { order: -1; }
  .nav-more { display: none; }
  .nav-more-mobile-link { display: block; }
  .nav-divider { display: none; }
  .nav-links .theme-switch,
  .nav-links #notif-panel,
  .nav-links .nav-user,
  .nav-links .inline-form,
  .nav-links a.button {
    margin-top: 0.85rem;
  }
}
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.inline-form { display: inline; margin: 0; }
.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition: color 150ms ease;
}
.link-button:hover { text-decoration: underline; color: var(--primary-hover); }

/* ---------- layout ---------- */

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 2.5rem 1.75rem 4rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem 1.75rem;
}

details.card summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
details.card summary::-webkit-details-marker { display: none; }
details.card summary::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 800;
  transition: transform 150ms ease;
}
details.card[open] summary::before { content: "\2212"; }

/* ---------- auth ---------- */

.auth-shell {
  max-width: 860px;
  margin: 0 auto;
  /* Vertically centers the login/register card in the viewport instead of
     pinning it near the top like a regular content page — a gate screen
     reads better centered. min-height (not height) so a very short
     viewport still lets the card grow past it rather than clipping. */
  min-height: calc(100vh - 200px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
  align-content: center;
}
.auth-brand { padding: 1rem 0; }
.auth-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 1.4rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow-md);
}
.auth-brand h2 { font-size: 1.75rem; margin-bottom: 0.5rem; }
.auth-brand p { color: var(--text-muted); max-width: 30ch; }

.auth-card { max-width: 380px; }
.auth-card h1 { margin-top: 0; font-size: 1.3rem; }
.auth-alt { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 0; margin-top: 1rem; }

@media (max-width: 720px) {
  .auth-shell { grid-template-columns: 1fr; gap: 1.5rem; min-height: 0; margin: 2rem auto; }
  .auth-brand { text-align: center; padding: 0; }
  .auth-card { max-width: none; margin: 0 auto; }
}

/* ---------- forms ---------- */

form label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}
form input, form select, form textarea {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 0.94rem;
  color: var(--text);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
form textarea { font-family: inherit; }
form input:hover, form select:hover, form textarea:hover { border-color: var(--text-faint); }
form input:focus, form select:focus, form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
form input::placeholder { color: var(--text-faint); }

/* ---------- buttons ---------- */

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.15rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 150ms ease, transform 100ms ease, box-shadow 150ms ease;
}
button:hover, .button:hover { background: var(--primary-hover); text-decoration: none; }
button:active, .button:active { transform: translateY(1px) scale(0.99); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

button.secondary, .button.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
button.secondary:hover, .button.secondary:hover { background: var(--surface-sunken); }
button.success, .button.success { background: var(--success); }
button.danger, .button.danger { background: var(--danger); }
/* filter, not a hardcoded hex, so this reads correctly whether --success/
   --danger is the darker light-mode shade or the lighter dark-mode one */
button.success:hover, .button.success:hover,
button.danger:hover, .button.danger:hover { filter: brightness(0.92); }

/* ---------- alerts / empty states ---------- */

.alert {
  padding: 0.65rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 1.1rem;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: rgba(173, 61, 61, 0.18); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(63, 125, 88, 0.18); }

.empty-state {
  color: var(--text-muted);
  padding: 3rem 1rem;
  text-align: center;
  background: var(--surface-sunken);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: 0.94rem;
}

/* ---------- page header ---------- */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1.75rem;
}
.week-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.week-nav-range { color: var(--text-muted); font-size: 0.88rem; white-space: nowrap; }
.page-header h1 { margin: 0; }
.page-header a { font-weight: 600; }

/* Marks the boundary between a page's primary content (a task board, a
   comment thread) and its secondary, occasional-use config panels below —
   introduced so those panels can be demoted to collapsed accordions
   without the page just trailing off with no visual cue. */
.section-divider {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 2.5rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; vertical-align: middle; }
th {
  color: var(--text-faint);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 0.6rem;
}
tbody tr { transition: background-color 120ms ease; }
tbody tr:hover { background: var(--surface-sunken); }
tbody tr:last-child td { border-bottom: none; }
td:has(input[type="number"]), td:has(input[type="date"]) { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 0.85rem; }
tfoot td { border-bottom: none; border-top: 1px solid var(--border-strong); padding-top: 0.85rem; font-variant-numeric: tabular-nums; }

table form { margin: 0; }
table input, table select { padding: 0.45rem 0.55rem; font-size: 0.88rem; }
.actions-cell { white-space: nowrap; }

/* Wide data tables (task list, timesheets, approvals) get this wrapper so
   THEY scroll horizontally on medium widths — never the whole page. On
   phones the table itself switches to a stacked-card layout instead (see
   below), so the scroll wrapper is mostly a tablet-width safety net. */
.table-scroll { overflow-x: auto; }

@media (max-width: 640px) {
  .responsive-table thead { display: none; }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
  }
  .responsive-table td {
    border-bottom: none;
    padding: 0.35rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }
  .responsive-table td[data-label]::before {
    content: attr(data-label);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-faint);
  }
  .responsive-table tfoot td { text-align: left; padding: 0.2rem 0; }
  .responsive-table td[data-label="Actions"] {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
  }
  .responsive-table td[data-label="Actions"] > * { flex: none; }
}

/* ---------- customer portal ---------- */
/* Deliberately its own class, not .nav-links: that class is display:none
   by default under 640px, only ever revealed by the internal app's
   hamburger-toggle JS, which the portal's minimal nav doesn't have (and
   doesn't need — it's only ever two items). */
.portal-nav-actions { display: flex; align-items: center; gap: 0.9rem; }

/* ---------- dashboard ---------- */

.dashboard-kpi-card { display: flex; flex-direction: column; gap: 0.3rem; }
.dashboard-kpi-label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.dashboard-kpi-value { font-size: 2.1rem; font-weight: 800; line-height: 1.2; }
.dashboard-kpi-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.dashboard-kpi-list li { display: flex; flex-direction: column; font-size: 0.88rem; }
.dashboard-kpi-meta { color: var(--text-muted); font-size: 0.78rem; }
.dashboard-kpi-empty { color: var(--text-muted); font-size: 0.88rem; margin: 0.5rem 0 0; }
.dashboard-kpi-viewall { display: inline-block; margin-top: 0.75rem; font-size: 0.85rem; font-weight: 600; }

/* ---------- deep-linked row highlight (e.g. arriving from global search) ---------- */

tr:target { animation: target-row-flash 2s ease-out; }
@keyframes target-row-flash {
  from { background: var(--primary-light); }
  to { background: transparent; }
}

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--neutral-bg);
  color: var(--text-muted);
}
.badge-submitted { background: var(--warning-bg); color: var(--warning); }
.badge-approved { background: var(--success-bg); color: var(--success); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }

.sla-status { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.1rem; }

/* ---------- approvals ---------- */

.approval-actions { white-space: nowrap; }
.approval-actions .success { margin-bottom: 0.4rem; }
.approval-reject-form { display: inline-flex; gap: 0.4rem; margin: 0; }
.approval-reject-form input { width: 10rem; }

@media (max-width: 640px) {
  .approval-actions { white-space: normal; display: flex; flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .approval-reject-form { width: 100%; }
  .approval-reject-form input { width: auto; flex: 1; }
}

/* ---------- members ---------- */

.member-list { list-style: none; margin: 0 0 0.75rem; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.member-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  padding: 0.35rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: background-color 120ms ease;
}
/* Modifier for rows that pack in more than a name + one action (e.g. task
   templates: name, meta, an inline use-form, and a delete button) — plain
   .member-row has no wrap since its other uses (Members, Subtasks) never
   need it, and forcing wrap there is unnecessary churn to what's already
   confirmed working. */
.member-row-wrap { flex-wrap: wrap; }
.member-row-wrap form { flex-wrap: wrap; }
.member-row:hover { background: var(--surface-sunken); }
.member-row .link-button { margin-left: auto; font-size: 0.82rem; }
.member-add-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.member-add-form select { margin-top: 0; max-width: 220px; }
.member-add-form button { flex-shrink: 0; white-space: nowrap; }

/* ---------- projects ---------- */

.list-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.project-card {
  display: block;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}
.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  text-decoration: none;
}
.project-card h3 { margin: 0 0 0.4rem; color: var(--text); }
.project-card p { color: var(--text-muted); font-size: 0.86rem; margin: 0; }

#gantt { margin: 1.75rem 0; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }

/* frappe-gantt palette overrides — loaded after its stylesheet so these win */
.gantt .bar { fill: var(--primary-light); }
.gantt .bar-progress { fill: var(--primary); }
.gantt .bar-invalid { fill: var(--neutral-bg); }
.gantt .bar-label { fill: var(--text); font-family: var(--font-sans); font-weight: 600; }
.gantt .bar-label.big { fill: var(--text); }
.gantt .arrow { stroke: var(--text-faint); }
.gantt .today-highlight { fill: var(--primary); opacity: 0.08; }
.gantt .grid-header { fill: var(--surface-sunken); stroke: var(--border); }
.gantt .grid-background { fill: var(--surface); }
.gantt .tick { stroke: var(--border); }
.gantt .tick.thick { stroke: var(--border-strong); }
.gantt-container .lower-text, .gantt-container .upper-text { fill: var(--text-muted); font-family: var(--font-sans); }

/* ---------- view tabs ---------- */

.view-tabs { display: flex; gap: 0.3rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.view-tabs a {
  padding: 0.55rem 0.9rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 150ms ease, border-color 150ms ease;
}
.view-tabs a:hover { color: var(--text); text-decoration: none; }
.view-tabs a.active { color: var(--primary); border-color: var(--primary); }

/* ---------- kanban board ---------- */

.kanban-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }
/* CRM's stage count is dynamic (user-managed), unlike tasks' fixed 3
   columns, so it can't use a hardcoded repeat(3,...) + one media-query
   override — auto-fill naturally reflows to fewer columns per row as the
   viewport narrows, all the way to a single column, with no media query
   needed. Same idiom .list-grid already uses for the project cards grid. */
.kanban-board-fluid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; align-items: start; }
.kanban-column {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  min-height: 120px;
}
.kanban-column h4 {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.kanban-count {
  background: var(--neutral-bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.72rem;
}
.kanban-cards { display: flex; flex-direction: column; gap: 0.6rem; min-height: 40px; border-radius: var(--radius-sm); transition: background-color 120ms ease; }
.kanban-cards.drag-over { background: var(--primary-light); outline: 2px dashed var(--primary); outline-offset: 4px; }

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 150ms ease, transform 150ms ease, opacity 150ms ease;
}
.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.4rem; }
.kanban-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.76rem; color: var(--text-muted); }
.kanban-assignee.unassigned { color: var(--text-faint); font-style: italic; }
.kanban-dates { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kanban-progress { margin-top: 0.55rem; height: 4px; border-radius: 999px; background: var(--neutral-bg); overflow: hidden; }
.kanban-progress-fill { height: 100%; background: var(--primary); border-radius: 999px; }

@media (max-width: 860px) {
  .kanban-board { grid-template-columns: 1fr; }
}

.task-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 0.9rem; font-size: 0.9rem; color: var(--text-muted); }
.task-summary > * + * { position: relative; padding-left: 0.9rem; }
.task-summary > * + *::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 0.9em;
  background: var(--border);
}

.attachment-list { list-style: none; margin: 0; padding: 0; }
.attachment-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: background-color 120ms ease;
}
.attachment-row:last-child { border-bottom: none; }
.attachment-row:hover { background: var(--surface-sunken); }
.attachment-row a { font-weight: 600; }
.attachment-meta { color: var(--text-muted); font-size: 0.8rem; white-space: nowrap; }

/* ---------- activities ---------- */

/* flex + wrap from the start (not a fixed grid needing a separate mobile
   fallback) — rows just reflow onto multiple lines on a narrow viewport. */
.activity-list { list-style: none; margin: 0 0 0.9rem; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.activity-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  padding: 0.55rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.activity-row.activity-overdue { border-color: var(--danger); background: var(--danger-bg); }
.activity-note { flex: 1 1 160px; min-width: 0; }
.activity-no-note { color: var(--text-faint); font-style: italic; }
.activity-due { color: var(--text-muted); font-size: 0.82rem; white-space: nowrap; }
.activity-overdue .activity-due { color: var(--danger); font-weight: 600; }
.activity-assignee { color: var(--text-muted); font-size: 0.82rem; white-space: nowrap; }
.activity-done-label { color: var(--success); font-size: 0.82rem; font-weight: 600; }
.activity-row .link-button { font-size: 0.82rem; white-space: nowrap; }
.activity-context-link { flex: 1 1 200px; min-width: 0; font-weight: 600; }

.activity-add-form { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.activity-add-form select, .activity-add-form input[type="date"] { margin-top: 0; width: auto; max-width: 160px; }
.activity-add-form input[type="text"] { margin-top: 0; flex: 1 1 160px; min-width: 0; }
.activity-add-form button { flex-shrink: 0; white-space: nowrap; }

/* ---------- wiki ---------- */

.wiki-content { line-height: 1.65; }
.wiki-content h1, .wiki-content h2, .wiki-content h3 { margin: 1.3rem 0 0.6rem; }
.wiki-content h1:first-child, .wiki-content h2:first-child, .wiki-content h3:first-child { margin-top: 0; }
.wiki-content p { margin: 0 0 0.9rem; }
.wiki-content ul { margin: 0 0 0.9rem; padding-left: 1.4rem; }
.wiki-content li { margin-bottom: 0.3rem; }
.wiki-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
}
.wiki-content a.wiki-link { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }

/* ---------- invoicing ---------- */

.invoice-sheet { padding: 1.5rem; }
.invoice-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }

/* The print button just calls window.print() — no PDF library needed,
   since every browser's own "Print > Save as PDF" already covers that.
   These rules only need to strip the chrome (nav, actions, theme
   background) so what prints looks like an actual invoice document. */
@media print {
  .no-print, .nav { display: none !important; }
  body { background: #fff; color: #000; }
  .container { max-width: none; padding: 0; margin: 0; }
  .invoice-sheet { border: none; box-shadow: none; padding: 0; }
  .card { border: none; box-shadow: none; background: transparent; }
}

/* ---------- reports ---------- */

.bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 60px;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.15rem;
  font-size: 0.88rem;
  transition: background-color 120ms ease;
}
.bar-row:hover { background: var(--surface-sunken); }
.bar-row:hover .bar-fill { filter: brightness(1.1); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 480px) {
  .bar-row { grid-template-columns: 78px 1fr 44px; gap: 0.5rem; }
  .bar-value { font-size: 0.8rem; }
}
.bar-track { height: 10px; background: var(--neutral-bg); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: filter 150ms ease; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); color: var(--text-muted); }

/* ---------- calendar ---------- */

.calendar-legend { display: flex; gap: 1.25rem; margin-bottom: 1rem; font-size: 0.82rem; color: var(--text-muted); }
.calendar-legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.calendar-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.calendar-dot-task { background: var(--primary); }
.calendar-dot-milestone { background: var(--warning); }
.calendar-dot-timesheet { background: var(--success); }
.calendar-event-task { background: var(--primary-light); color: var(--primary); }
.calendar-event-milestone { background: var(--warning-bg); color: var(--warning); }
.calendar-event-timesheet { background: var(--success-bg); color: var(--success); }

/* Month grid — the default, tablet/desktop view. */
.calendar-grid {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.calendar-weekday-row, .calendar-week-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekday-row {
  background: var(--surface-sunken);
  color: var(--text-faint);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.calendar-weekday-row > div { padding: 0.6rem; text-align: center; }
.calendar-week-row:not(:last-child) { border-bottom: 1px solid var(--border); }
.calendar-day {
  min-height: 118px;
  padding: 0.5rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.calendar-day:last-child { border-right: none; }
.calendar-day-outside { background: var(--surface-sunken); }
.calendar-day-outside .calendar-day-number { color: var(--text-faint); }
.calendar-day-number {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}
.calendar-day-today .calendar-day-number { background: var(--primary); color: #fff; }
.calendar-day-events { display: flex; flex-direction: column; gap: 0.22rem; min-width: 0; }
.calendar-event {
  display: block;
  font-size: 0.72rem;
  padding: 0.18rem 0.4rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  transition: filter 120ms ease;
}
.calendar-event:hover { filter: brightness(0.95); text-decoration: none; }

/* Agenda list — mobile only. A 7-column grid has no room to be legible on a
   phone, so narrow viewports get a day-by-day list instead of a shrunken
   (or horizontally-scrolling) grid — the same "don't force horizontal
   scroll on something meant to be glanced at" call made everywhere else
   mobile-responsive in this app. */
.calendar-agenda { display: none; }
.calendar-agenda-day {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.6rem;
  background: var(--surface);
}
.calendar-agenda-day-today { border-color: var(--primary); }
.calendar-agenda-date {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.55rem;
}
.calendar-agenda-events { display: flex; flex-direction: column; gap: 0.35rem; }
.calendar-agenda-events .calendar-event { white-space: normal; overflow: visible; text-overflow: clip; }

@media (max-width: 640px) {
  .calendar-grid { display: none; }
  .calendar-agenda { display: block; }
}

/* ---------- chat ---------- */

.chat-layout { display: grid; grid-template-columns: 230px 1fr; gap: 1.5rem; height: calc(100vh - 190px); min-height: 420px; }
.chat-channels {
  border-right: 1px solid var(--border);
  padding-right: 1rem;
  overflow-y: auto;
}
.chat-channels h3 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); margin: 1.1rem 0 0.5rem; }
.chat-channels h3:first-child { margin-top: 0; }
.chat-channels a {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 120ms ease;
}
.chat-channels a:hover, .chat-channels a.active { background: var(--primary-light); text-decoration: none; }
.chat-channels a.active { color: var(--primary); font-weight: 700; }

.chat-main { display: flex; flex-direction: column; min-height: 0; }
.chat-main h2 { flex-shrink: 0; }
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chat-message { margin-bottom: 0.9rem; }
.chat-message:last-child { margin-bottom: 0; }
.chat-message .meta { font-size: 0.74rem; color: var(--text-faint); margin-bottom: 0.2rem; }
.chat-message .author { font-weight: 700; color: var(--primary); }
.chat-message .body {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.92rem;
  max-width: 42rem;
  line-height: 1.45;
}

.chat-attachment-image {
  display: block;
  margin-top: 0.35rem;
  max-width: 260px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.chat-attachment-image img { display: block; width: 100%; height: auto; }
.chat-attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.35rem;
  padding: 0.55rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.chat-attachment-file:hover { background: var(--primary-light); text-decoration: none; }
.chat-attachment-file svg { flex-shrink: 0; color: var(--text-muted); }
.chat-attachment-meta { display: flex; flex-direction: column; line-height: 1.3; }
.chat-attachment-name { font-size: 0.88rem; font-weight: 600; }
.chat-attachment-size { font-size: 0.74rem; color: var(--text-muted); }

.chat-form { display: flex; align-items: center; gap: 0.3rem; padding-top: 0.9rem; flex-shrink: 0; }
.chat-form input { flex: 1; margin: 0 0.3rem; }

.chat-icon-btn {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 999px;
  transition: background-color 150ms ease, color 150ms ease;
}
.chat-icon-btn:hover { background: var(--surface-sunken); color: var(--text); }

.chat-send-btn {
  width: 2.4rem;
  height: 2.4rem;
  flex-shrink: 0;
  padding: 0;
  border-radius: 999px;
}

.emoji-picker-wrap { position: relative; }
.emoji-dropdown {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 0;
  width: 260px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0.5rem;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.1rem;
  z-index: 30;
}
.emoji-dropdown button {
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.4rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.emoji-dropdown button:hover { background: var(--surface-sunken); }

@media (max-width: 780px) {
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-channels { border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 1rem; }
}

/* ---------- htmx loading feel ---------- */

.htmx-request, .htmx-request * { cursor: progress; }
button.htmx-request { opacity: 0.7; }
