/* ── Font ─────────────────────────────────────────────────────────────────── */
/* Plus Jakarta Sans loaded via <link> in HTML */

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  height: var(--header-h);
  background: var(--panel);
  border-bottom: 2px solid var(--accent);   /* pink bottom border — brand signature */
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: .9375rem;
  font-weight: 700;
  letter-spacing: -.02em;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text);
}

/* ── Nav tabs ─────────────────────────────────────────────────────────────── */
.view-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--accent-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  margin-left: auto;
}
.view-switch button {
  padding: .3rem .9rem;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 3px);
  color: var(--muted);
  cursor: pointer;
  transition: color .12s, background .12s;
  white-space: nowrap;
  box-shadow: none;
}
.view-switch button:hover { color: var(--text); }
.view-switch button.active {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}

/* ── Theme toggle ─────────────────────────────────────────────────────────── */
.theme-toggle {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 48px; height: 26px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.theme-toggle .opt { font-size: 12px; text-align: center; z-index: 1; }
.theme-toggle .thumb {
  position: absolute;
  inset: 2px auto 2px 2px;
  width: calc(50% - 2px);
  border-radius: 999px;
  background: var(--accent);
  transition: left .2s ease;
}
[data-theme="dark"] .theme-toggle .thumb { left: calc(50%); }

/* ── Context toolbars ─────────────────────────────────────────────────────── */
.ctx-toolbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 0 1.5rem;
  height: var(--toolbar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ctx-toolbar input[type="search"] { flex: 0 1 260px; }
.ctx-actions {
  display: flex;
  align-items: center;
  gap: .25rem;
  margin-left: auto;
}

/* Hamburger — hidden on desktop */
.menu-toggle { display: none; }

/* ── Form controls ────────────────────────────────────────────────────────── */
select,
input[type="date"],
input[type="text"],
input[type="number"],
textarea,
input[type="url"],
input[type="search"] {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: .875rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .75rem;
  transition: border-color .15s, box-shadow .15s;
  line-height: 1.4;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
button {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: .8125rem;
  font-weight: 600;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .8rem;
  cursor: pointer;
  transition: background .12s, border-color .12s, box-shadow .12s;
  white-space: nowrap;
}
button:hover { border-color: var(--text); }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { background: #b81aa0; border-color: #b81aa0; }

button.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
button.danger:hover { background: #b91c1c; border-color: #b91c1c; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); border-color: var(--border); color: var(--text); }

.btn-danger-ghost { color: #dc2626; }
.btn-danger-ghost:hover { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
[data-theme="dark"] .btn-danger-ghost:hover { background: #1f0606; border-color: #7f1d1d; }

.btn-delete { background: transparent; border-color: transparent; color: var(--muted); }
.btn-delete:hover { color: #dc2626; border-color: transparent; }

.btn-sm { padding: .25rem .6rem; font-size: .75rem; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
main {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h) - var(--toolbar-h));
  overflow: hidden;
}

/* Sections that scroll */
#portfolioView,
#dateView,
#marginView {
  flex: 1;
  overflow: auto;
}

/* Board section needs special flex treatment */
#boardView {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#board {
  display: flex;
  gap: 14px;
  padding: 20px;
  overflow-x: auto;
  flex: 1;
  align-items: flex-start;
}

/* ── Columns ──────────────────────────────────────────────────────────────── */
.column {
  background: var(--col-bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border);
  border-radius: var(--radius-lg);
  min-width: 300px;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--header-h) - var(--toolbar-h) - 40px);
  box-shadow: var(--shadow);
  transition: border-top-color .2s;
}
.column:hover { border-top-color: var(--accent); }

.col-head {
  display: flex;
  gap: .4rem;
  align-items: center;
  padding: .75rem .75rem .5rem;
}

.col-title {
  font-size: .8125rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: .2rem .25rem;
  border-radius: 4px;
}
.col-title[contenteditable="true"]:focus {
  outline: 0;
  color: var(--text);
  border-bottom-color: var(--accent);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  overflow-y: auto;
  flex: 1;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .15s;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* Overdue cards */
.badge-risk {
  background: var(--risk-bg);
  border: 1px solid var(--risk-border);
  border-radius: var(--radius);
  padding: .75rem;
  box-shadow: var(--shadow);
}

/* Completed cards */
.card-done {
  opacity: 0.45;
  background: var(--bg) !important;
  border-color: var(--border) !important;
  box-shadow: none !important;
  transform: none !important;
}
.card-done strong { text-decoration: line-through; color: var(--muted); }
.card-done .done-meta { font-size: .6875rem; color: var(--muted); margin-top: .2rem; }

/* Card content */
.checkboxarea { display: flex; gap: .6rem; align-items: flex-start; }
.titleareaoncard { flex: 1; min-width: 0; }
.titleoncard { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.titleoncard a {
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  line-height: 1.4;
  display: block;
  padding: .2rem 0;
}
strong {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  display: block;
  padding: .2rem 0;
}
.notes { color: var(--muted); font-size: .8125rem; line-height: 1.5; margin-top: .35rem; }
.statusarea { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .35rem; align-items: center; }

/* ── Completed collapse ───────────────────────────────────────────────────── */
.done-section { margin-top: 6px; border-top: 1px dashed var(--border); padding-top: 4px; }
.done-toggle {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0; box-shadow: none;
  font-size: .75rem;
  color: var(--muted);
  padding: .35rem .4rem;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: .3rem;
}
.done-toggle:hover { background: var(--bg); color: var(--text); border-color: transparent; }
.done-toggle-arrow { font-size: 9px; }
.done-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.done-list[hidden] { display: none; }

/* Column footer — next step */
.column-meta { padding: 6px 10px 10px; border-top: 1px solid var(--border); }
.next-step { display: grid; gap: 3px; padding: 6px 0 2px; }
.next-step label {
  font-size: .6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.next-step-title { font-weight: 600; font-size: .8125rem; }
.next-step-sub { font-size: .75rem; color: var(--muted); }
.next-step-empty { font-size: .75rem; color: var(--muted); }

/* ── Pills & badges ───────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .15rem .55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-size: .75rem; color: var(--muted);
  text-decoration: none;
}
.pill:hover { background: var(--panel); }
.pill a { font-size: .75rem; color: var(--accent); text-decoration: none; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  border-radius: 999px;
  padding: .15rem .55rem;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: .75rem; color: var(--muted);
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.pill-kpi {
  display: inline-flex; align-items: center; gap: .3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .15rem .55rem;
  background: var(--bg);
  font-size: .75rem; color: var(--muted);
}

/* ── Overdue pill — solid red, unmissable ─────────────────────────────────── */
.pill-overdue {
  display: inline-flex; align-items: center; gap: .3rem;
  border-radius: 999px;
  padding: .2rem .65rem;
  font-size: .75rem;
  font-weight: 700;
  background: var(--overdue-bg);
  color: var(--overdue-text);
  border: none;
}

/* ── Avatar ───────────────────────────────────────────────────────────────── */
.avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--grad-avatar);
  color: #fff; font-size: 10px; font-weight: 700;
  flex: 0 0 22px;
}

/* ── Checkbox ─────────────────────────────────────────────────────────────── */
.chk {
  position: relative; display: inline-grid; place-items: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--panel);
  cursor: pointer; flex: 0 0 20px;
  transition: border-color .15s;
}
.chk input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chk .ring {
  position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid transparent;
  transform: scale(.6); opacity: 0;
  transition: all .2s ease;
}
.chk .mark { width: 9px; height: 9px; background: transparent; position: relative; }
.chk .mark::after {
  content: ''; position: absolute;
  left: 2px; top: 0; width: 3px; height: 7px;
  border: solid transparent; border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform .18s ease, border-color .18s ease;
}
.chk.checked .mark::after { border-color: var(--success); transform: rotate(45deg) scale(1); }
.chk.checked { border-color: var(--success); background: var(--success-bg); }
.chk.checked .ring { border-color: var(--success); opacity: .3; transform: scale(1); }
.chk:hover { border-color: var(--accent); }

/* ── Project title (board toolbar) ───────────────────────────────────────── */
.proj-title {
  font-size: .9375rem; font-weight: 700;
  flex: 0 1 220px; min-width: 120px;
  background: transparent; border: 0;
  border-bottom: 1px solid transparent;
  padding: .2rem .25rem; border-radius: 4px;
  color: var(--text); cursor: text;
}
.proj-title[contenteditable="true"]:focus {
  outline: 0; border-bottom-color: var(--accent);
}

/* ── Portfolio / Clients view ─────────────────────────────────────────────── */
.portfolio {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  padding: 24px;
}

.pcard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  gap: 14px;
  transition: box-shadow .2s, transform .15s;
}
.pcard:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.pcard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin: -20px -20px 0;
  padding: 14px 16px 12px;
  background: var(--accent-dim);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-left: 3px solid var(--accent);
}
.pcard-header h4 { font-size: 1.0625rem; letter-spacing: -.02em; }
.pcard-actions { display: flex; gap: .25rem; flex-shrink: 0; }

.pcard .pstats { display: flex; gap: 6px; flex-wrap: wrap; }
.pcard .next-step { padding: 0; border-top: none; }
.pcard .next-step label { margin-bottom: .15rem; }
.pcard .next-step-title { font-size: .875rem; }

.pcard-foot {
  display: flex; align-items: center; gap: .6rem;
}
.pcard-foot .progress { flex: 1; }
.pct-label { font-size: .75rem; color: var(--muted); white-space: nowrap; }

.progress {
  height: 6px;
  background: var(--accent-dim);
  border-radius: 999px;
  overflow: hidden;
  border: none;
}
.progress > i { display: block; height: 100%; background: var(--accent); width: 0%; transition: width .3s; }

.empty { opacity: .45; text-align: center; padding: 2rem; font-size: .875rem; }

/* ── Tasks / Date view ────────────────────────────────────────────────────── */
#dateView { padding: 0; overflow: auto; }

/* My work view — already has padding; just ensure consistency */
#myWorkView {
  padding: 20px;
  max-width: 820px;
}

/* All-tasks table gets a padded page wrapper like other views */
#allTasksView {
  padding: 20px;
  overflow: auto;
}
#allTasksView .table {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 700px;
}
#allTasksView .table thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
#allTasksView .table thead th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }

/* ── Margin view ──────────────────────────────────────────────────────────── */
#marginView { padding: 0; }

/* ── Shared table styles ──────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}
.table th, .table td {
  border-bottom: 1px solid var(--border);
  padding: .75rem .875rem;
  text-align: left;
  vertical-align: top;
  font-size: .8125rem;
}
.table thead th {
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 2px solid var(--border);
}
.table tr:hover td { background: rgba(0,0,0,.025); }
[data-theme="dark"] .table tr:hover td { background: rgba(255,255,255,.03); }
.table th.sortable {
  cursor: pointer; user-select: none;
  font-size: .6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
}
.table th.sortable:hover { color: var(--text); }
.table th .sort-indicator { margin-left: .3rem; font-size: 10px; color: var(--accent); }

/* Overdue row in tasks view */
.table tr.row-overdue td { background: #fef2f2; color: #991b1b; }
[data-theme="dark"] .table tr.row-overdue td { background: #1a0505; color: #fca5a5; }

/* Margin table totals footer */
.margin-totals-row td {
  border-top: 2px solid var(--border);
  background: var(--panel);
  font-weight: 600;
  font-size: .8125rem;
  position: sticky;
  bottom: 0;
}

/* Margin % inline bar */
.margin-pct-bar {
  display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap;
}
.margin-pct-bar::before {
  content: '';
  display: inline-block;
  width: 48px; height: 5px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--pct), var(--bg) var(--pct));
  border: 1px solid var(--border);
}

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center;
  padding: 1.5rem; z-index: 200;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
}
.modal.open { display: flex; }
.modal .sheet {
  width: min(640px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.sheet header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.sheet header h3 { font-size: 1rem; letter-spacing: -.02em; }
.sheet .body {
  padding: 1.25rem 1.5rem;
  display: grid;
  gap: .75rem;
  overflow-y: auto;          /* body scrolls, footer stays visible */
  flex: 1;
}
.sheet .row {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  gap: .75rem;
}
.sheet .row label {
  font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted);
}
.sheet footer {
  display: flex; gap: .5rem; justify-content: flex-end;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;            /* footer never shrinks away */
}

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.color-swatch { width: 20px; height: 20px; border-radius: 4px; border: 1px solid var(--border); }
.dropzone { min-height: 20px; }

/* ── Scrollbars ───────────────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { height: 6px; width: 6px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); }

/* ── Board menu: hidden on desktop, bottom-sheet on mobile ───────────────── */
.board-menu {
  display: none;  /* hidden on desktop — ctx-actions shows instead */
}
.board-menu-backdrop { display: none; }

/* ════════════════════════════════════════════════════════════════════════════
   MOBILE ≤ 640px
   ════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {

  header { padding: 0 1rem; height: 48px; }
  header h1 { font-size: .875rem; }
  --header-h: 48px;

  /* Hide desktop nav tabs on mobile */
  nav#mainNav, nav.view-switch { display: none !important; }
  /* Show hamburger */
  .nav-toggle { display: inline-flex !important; align-items: center; justify-content: center; font-size: 1.25rem; padding: .25rem .5rem; }

  .ctx-toolbar { padding: 0 .75rem; gap: .35rem; }
  .ctx-actions { display: none; }   /* hidden — accessible via hamburger */
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    font-size: 1.1rem;
  }

  /* Board select — full width available */
  #projectSelect { max-width: calc(100vw - 60px); min-width: 0; flex: 1; font-size: .875rem; }
  .proj-title { font-size: .875rem; flex: 1; min-width: 60px; }

  /* Bottom sheet */
  .board-menu {
    display: flex;  /* overrides the desktop display:none — transition needs flex not none */
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 300;
    background: var(--panel);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding: 0 1.25rem 2.5rem;
    box-shadow: 0 -8px 32px rgba(0,0,0,.2);
    flex-direction: column;
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.32,.72,0,1);
    pointer-events: none;
  }
  .board-menu::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 999px;
    margin: .85rem auto .5rem;
    flex-shrink: 0;
  }
  .board-menu.open { transform: translateY(0); pointer-events: auto; }
  .board-menu button {
    display: block; width: 100%; text-align: left;
    font-size: .9375rem; font-weight: 500;
    padding: .9rem .25rem;
    border-radius: 0; border: none;
    border-bottom: 1px solid var(--border);
    background: transparent; box-shadow: none;
    color: var(--text);
  }
  .board-menu button:last-child { border-bottom: none; }

  .board-menu-backdrop {
    position: fixed; inset: 0;
    z-index: 299;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(2px);
    display: none;
  }
  .board-menu-backdrop.open { display: block; }

  /* Portfolio single column */
  .portfolio { grid-template-columns: 1fr; padding: 16px; gap: 14px; }

  /* Board scrolls horizontally */
  #board { padding: 12px; gap: 10px; }
  .column { min-width: 280px; max-width: 280px; }

  main { height: calc(100vh - 48px - var(--toolbar-h)); }
}

/* ── Breadcrumb (board toolbar) ───────────────────────────────────────────── */
.proj-breadcrumb {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .875rem;
  min-width: 0;
}
.bc-client { color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-sep    { color: var(--muted); }
.bc-project{ font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Portfolio card client name ───────────────────────────────────────────── */
.pcard-client {
  font-size: .75rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: .1rem;
  letter-spacing: .01em;
}

/* ── Segmented control (margin toggle) ───────────────────────────────────── */
.seg-control {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}
.seg-control button {
  padding: .25rem .8rem;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .02em;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 3px);
  color: var(--muted);
  box-shadow: none;
}
.seg-control button:hover { color: var(--text); }
.seg-control button.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

/* ── Financials readout block ─────────────────────────────────────────────── */
.fin-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem 1rem;
  padding: .75rem;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: .25rem;
}
.fin-label {
  display: block;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .15rem;
}
.fin-val { font-weight: 700; font-size: .9375rem; }

/* ── Client rows (manage clients modal) ───────────────────────────────────── */
.client-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: .5rem;
  align-items: center;
}

/* ── Muted span helper ────────────────────────────────────────────────────── */
.muted { color: var(--muted); }

/* ── Add column tile ──────────────────────────────────────────────────────── */
.add-col-tile {
  min-width: 200px !important;
  max-width: 200px !important;
  display: grid !important;
  place-items: center;
  background: transparent !important;
  border: 2px dashed var(--border) !important;
  box-shadow: none !important;
  cursor: pointer;
}
.add-col-tile:hover { border-color: var(--accent) !important; }

/* ── Table wrapper (full-height scroll) ───────────────────────────────────── */
.table-wrap {
  overflow: auto;
  height: 100%;
}

/* ── Mobile: desktop ctx-actions hidden, hamburger shown ─────────────────── */
@media (max-width: 640px) {
  .ctx-actions { display: none !important; }
  .menu-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    margin-left: auto;
  }
  .fin-readout { grid-template-columns: 1fr; }
  .proj-breadcrumb { font-size: .8125rem; }
}

/* ── Login screen ─────────────────────────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: min(400px, 96vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  display: grid; gap: 1.25rem; text-align: center;
}
.login-card h1 { font-size: 1.5rem; }
.login-sub { color: var(--muted); font-size: .875rem; margin-top: -.5rem; }
#loginForm { display: grid; gap: .75rem; }
#loginEmail { text-align: center; font-size: 1rem; padding: .6rem .75rem; }
#loginBtn { padding: .65rem 1rem; font-size: .9375rem; }
.login-msg { font-size: .8125rem; padding: .5rem .75rem; border-radius: var(--radius); margin-top: .25rem; }
.login-msg.success { background: var(--success-bg); color: var(--success); }
.login-msg.error   { background: #fef2f2; color: #dc2626; }

/* ── Header right cluster ─────────────────────────────────────────────────── */
.header-right { display: flex; align-items: center; gap: .5rem; margin-left: auto; flex-shrink: 0; }

/* ── User chip ────────────────────────────────────────────────────────────── */
.user-chip {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--accent);
  color: #fff; font-size: .6875rem; font-weight: 700;
  cursor: pointer; flex-shrink: 0;
  transition: opacity .15s;
  user-select: none;
}
.user-chip:hover { opacity: .85; }

/* ── Clients tab table ────────────────────────────────────────────────────── */
.client-group-header td {
  background: var(--bg);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: .9rem .875rem .4rem;
  border-bottom: 1px solid var(--border);
}
.client-project-row td:first-child { width: 24px; }
.proj-name-link {
  font-weight: 600; font-size: .875rem;
  cursor: pointer; text-decoration: none; color: var(--text);
}
.proj-name-link:hover { color: var(--accent); }

/* ── My work view ─────────────────────────────────────────────────────────── */
.mywork-banner {
  font-size: .875rem; color: var(--muted);
  padding: 0 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.mywork-section { margin-bottom: 1.5rem; }
.mywork-group-label {
  font-size: .6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: .5rem;
}
.mywork-group-overdue .mywork-group-label { color: var(--overdue-bg); }
.mywork-list { display: grid; gap: 2px; }
.mywork-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow .15s;
}
.mywork-row:hover { box-shadow: var(--shadow-md); }
.mywork-row-body { flex: 1; min-width: 0; }
.mywork-row-title {
  font-weight: 600; font-size: .875rem;
  cursor: pointer; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mywork-row-title:hover { color: var(--accent); }
.mywork-row-meta { font-size: .75rem; color: var(--muted); display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .15rem; }
.mywork-row-meta .sep { color: var(--border); }

/* ── "My task" card highlight ─────────────────────────────────────────────── */
.card-mine {
  border-left: 3px solid var(--accent) !important;
}

/* ── "My task" row in all-tasks table ────────────────────────────────────── */
.row-mine td { background: rgba(219,33,188,.04); }
[data-theme="dark"] .row-mine td { background: rgba(219,33,188,.08); }

/* ── Column estimated hours tag ───────────────────────────────────────────── */
.col-hours {
  font-size: .6875rem; font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .1rem .45rem;
  margin-left: auto;
}

/* ── Wide sheet (templates modal) ────────────────────────────────────────── */
.sheet-wide { width: min(900px, 96vw) !important; }

/* ── Templates modal layout ──────────────────────────────────────────────── */
.tmpl-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 420px;
  max-height: 60vh;
}
.tmpl-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: .5rem 0;
}
.tmpl-group-label {
  font-size: .6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
  padding: .6rem 1rem .3rem;
}
.tmpl-list-row {
  padding: .6rem 1rem;
  font-size: .875rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .1s;
}
.tmpl-list-row:hover { background: var(--bg); }
.tmpl-list-row.active {
  background: var(--accent-dim);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* ── Template editor pane ────────────────────────────────────────────────── */
.tmpl-editor { padding: 1rem 1.25rem; overflow-y: auto; }
.tmpl-editor-empty { color: var(--muted); font-size: .875rem; padding: 2rem; text-align: center; }
.tmpl-editor-header { display: grid; gap: .4rem; margin-bottom: 1rem; }
.tmpl-name-input {
  font-size: 1rem; font-weight: 700;
  background: transparent; border: 0;
  border-bottom: 1px dashed var(--border);
  padding: .2rem 0; color: var(--text);
}
.tmpl-name-input:focus { outline: 0; border-bottom-color: var(--accent); }
.tmpl-desc-input {
  font-size: .8125rem; background: transparent; border: 0;
  border-bottom: 1px dashed var(--border);
  padding: .15rem 0; color: var(--muted);
}
.tmpl-desc-input:focus { outline: 0; border-bottom-color: var(--accent); }
.tmpl-editor-actions { display: flex; gap: .5rem; margin-top: .25rem; }
.tmpl-builtin-note { font-size: .75rem; color: var(--muted); font-style: italic; }

/* ── Template column + task editor ──────────────────────────────────────── */
.tmpl-cols-wrap { display: grid; gap: .75rem; }
.te-col {
  background: var(--col-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .75rem;
}
.te-col-head {
  display: flex; align-items: center; gap: .4rem;
  margin-bottom: .5rem;
}
.te-col-name {
  flex: 1; font-size: .8125rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  background: transparent; border: 0;
  border-bottom: 1px dashed transparent;
  padding: .1rem .2rem; color: var(--text);
}
.te-col-name:focus { outline: 0; border-bottom-color: var(--accent); }
.te-tasks { display: grid; gap: 4px; margin-bottom: .3rem; }
.te-task {
  display: flex; align-items: center; gap: .4rem;
}
.te-task-title {
  flex: 1; font-size: .8125rem;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .3rem .5rem;
}
.te-task-hours {
  font-size: .8125rem;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .3rem .4rem;
  text-align: right;
}

/* ── Template picker preview (new project modal) ─────────────────────────── */
.tmpl-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
}
.tmpl-desc { font-size: .8125rem; color: var(--muted); margin-bottom: .5rem; }
.tmpl-preview-cols {
  display: flex; gap: .5rem; overflow-x: auto;
  padding-bottom: .25rem;
}
.tmpl-preview-col {
  min-width: 120px; flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .5rem;
}
.tmpl-preview-col-name {
  font-size: .6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: .3rem;
}
.tmpl-preview-task {
  display: flex; justify-content: space-between; align-items: center;
  gap: .3rem; padding: .15rem 0;
  font-size: .75rem; color: var(--text);
  border-bottom: 1px dashed var(--border);
}
.tmpl-preview-task:last-child { border-bottom: none; }
.tmpl-task-hrs { color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.tmpl-total-hrs { font-size: .75rem; color: var(--muted); margin-top: .4rem; text-align: right; }

/* ── Comment thread ──────────────────────────────────────────────────────── */
.comment-divider {
  display: flex; align-items: center; gap: .75rem;
  margin: 1rem 0 .75rem;
}
.comment-divider::before, .comment-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.comment-divider span { font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.comment-list {
  display: grid; gap: .75rem;
  max-height: 200px; overflow-y: auto;
  margin-bottom: .75rem;
}
.comment-empty { font-size: .8125rem; color: var(--muted); text-align: center; padding: .75rem; }
.comment-item { display: flex; gap: .6rem; align-items: flex-start; }
.comment-avatar { flex-shrink: 0; width: 28px; height: 28px; font-size: .6875rem; }
.comment-body { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: center; gap: .5rem; margin-bottom: .2rem; }
.comment-meta strong { font-size: .8125rem; }
.comment-time { font-size: .75rem; color: var(--muted); }
.comment-text { font-size: .8125rem; line-height: 1.5; color: var(--text); word-break: break-word; }

.comment-compose { display: flex; gap: .6rem; align-items: flex-start; }
.comment-input-wrap { flex: 1; display: flex; flex-direction: column; gap: .35rem; }
#m_comment_input {
  width: 100%; font-size: .8125rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .4rem .6rem; resize: none; line-height: 1.4;
  background: var(--panel); color: var(--text);
  transition: border-color .15s;
}
#m_comment_input:focus { outline: none; border-color: var(--accent); }
#m_comment_post { align-self: flex-end; }

/* ── Clients modal — make it taller and scrollable ───────────────────────── */
#clientsModal .sheet { max-height: 90vh; display: flex; flex-direction: column; }
#clientsModal .body { flex: 1; overflow-y: auto; }

@media (max-width: 640px) {
  .tmpl-layout { grid-template-columns: 1fr; }
  .tmpl-list { border-right: none; border-bottom: 1px solid var(--border); max-height: 150px; }
}

/* ── Clients tab — card per client ───────────────────────────────────────── */
#clientsTabView { overflow-y: auto; }

.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  padding: 20px;
  align-content: start;
}

.client-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.client-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--accent-dim);
  border-left: 3px solid var(--accent);
}
.client-card-title h4 {
  font-size: 1rem;
  letter-spacing: -.02em;
  margin-bottom: .35rem;
}
.client-card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.client-add-proj {
  flex-shrink: 0;
  margin-top: .1rem;
}

/* Project rows inside each client card */
.client-projects-list {
  display: flex;
  flex-direction: column;
}

.client-project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.client-project-item:last-child { border-bottom: none; }
.client-project-item:hover { background: var(--bg); }

.cpi-main { flex: 1; min-width: 0; }
.cpi-name {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .3rem;
}
.cpi-meta {
  display: flex;
  gap: .3rem;
  align-items: center;
  flex-wrap: wrap;
}
.cpi-assignees {
  display: flex;
  gap: 2px;
  margin-left: .1rem;
}

.cpi-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .25rem;
  flex-shrink: 0;
}
.cpi-progress {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.cpi-next {
  font-size: .6875rem;
  color: var(--muted);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .clients-grid {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }
  .cpi-right { display: none; } /* simplify on mobile */
}

/* ── Team hours view ─────────────────────────────────────────────────────── */
#teamView { overflow-y: auto; }

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 20px;
  align-content: start;
}

.team-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.team-card-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 14px 16px 12px;
  background: var(--col-bg);
  border-bottom: 1px solid var(--border);
}

.team-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: .75rem; font-weight: 700;
  flex-shrink: 0;
}

.team-card-info { flex: 1; min-width: 0; }

.team-name {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .2rem;
}

.team-summary {
  font-size: .75rem;
  color: var(--muted);
  display: flex;
  gap: .4rem;
  align-items: center;
}

.team-overdue-pill {
  font-size: .6875rem;
  font-weight: 600;
  color: #b91c1c;
  background: #fff1f2;
  border: 1px solid #fecaca;
  border-radius: 4px;
  padding: 1px 5px;
}

/* Hours block — est vs tracked */
.team-hours-block {
  display: grid;
  gap: .15rem;
  text-align: right;
  flex-shrink: 0;
}

.team-hours-row {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  justify-content: flex-end;
}

.team-hours-label {
  font-size: .6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

.team-hours-val {
  font-size: .875rem;
  font-weight: 700;
  color: var(--text);
  min-width: 40px;
}

.team-hours-val.tracked { color: var(--accent); }

/* Capacity bar */
.team-capacity-bar {
  height: 4px;
  background: var(--accent-dim);
  margin: 0;
}

.team-capacity-fill {
  height: 100%;
  background: var(--accent);
  transition: width .4s ease;
  min-width: 2px;
}

/* Project breakdown */
.team-proj-list {
  padding: 8px 16px 10px;
  display: grid;
  gap: 2px;
}

.team-proj-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 5px 4px;
  border-bottom: 1px solid var(--border);
  font-size: .8125rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background .1s;
  margin: 0 -4px;
}
.team-proj-row:hover { background: var(--bg); }
.team-proj-row:hover .team-proj-name { color: var(--accent); }

.team-proj-row:last-child { border-bottom: none; }

.team-proj-name {
  flex: 1; min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.team-proj-client {
  color: var(--muted);
  font-size: .75rem;
}

.team-proj-right {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-shrink: 0;
}

.team-proj-tasks {
  font-size: .75rem;
  color: var(--muted);
}

.team-proj-hrs {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text);
  min-width: 32px;
  text-align: right;
}

.team-no-tasks {
  font-size: .8125rem;
  color: var(--muted);
  font-style: italic;
  padding: .5rem 0;
}

@media (max-width: 640px) {
  .team-grid { grid-template-columns: 1fr; padding: 12px; }
}

/* ── Realtime live indicator ─────────────────────────────────────────────── */
.rt-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background .3s;
}
.rt-connected {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34,197,94,.25);
}
.rt-error {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239,68,68,.25);
}
.rt-off {
  background: var(--border);
}

/* ── Toggl / Financials additions ────────────────────────────────────────── */
.fin-val-toggl { color: var(--accent); }

.fin-members {
  margin-top: .75rem;
  padding: .75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.fin-member-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem 0;
  font-size: .8125rem;
  border-bottom: 1px solid var(--border);
}
.fin-member-row:last-child { border-bottom: none; }

.fin-member-hrs {
  margin-left: auto;
  font-weight: 600;
  font-size: .8125rem;
  color: var(--accent);
}

.fin-sync-note {
  font-size: .75rem;
  color: var(--muted);
  margin-top: .5rem;
  font-style: italic;
}

/* ── Portfolio card hours burn line ─────────────────────────────────────── */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex: 1;
}
.progress-wrap .progress { flex: 1; position: relative; }

/* Estimated hours marker — a thin tick on the progress bar */
.progress-est-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--text);
  opacity: .35;
  border-radius: 1px;
  pointer-events: none;
  transform: translateX(-50%);
}

/* Hours burn text line */
.hours-burn {
  font-size: .6875rem;
  font-weight: 500;
  margin-top: .2rem;
}
.hours-burn.ok   { color: var(--muted); }
.hours-burn.warn { color: #b45309; }
.hours-burn.over { color: #b91c1c; font-weight: 700; }
[data-theme="dark"] .hours-burn.warn { color: #fbbf24; }
[data-theme="dark"] .hours-burn.over { color: #fca5a5; }

/* ── Prominent project select (board toolbar) ────────────────────────────── */
.project-select-prominent {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .75rem;
  max-width: 280px;
  min-width: 160px;
  cursor: pointer;
  flex-shrink: 1;
}
.project-select-prominent:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(219,33,188,.15);
}
.project-select-prominent optgroup {
  font-size: .8125rem;
  font-weight: 700;
  color: var(--muted);
}
.project-select-prominent option {
  font-weight: 500;
  font-size: .875rem;
}

/* Mobile — full width, visible above the bottom sheet */
@media (max-width: 640px) {
  .project-select-prominent {
    max-width: calc(100vw - 100px);
    min-width: 0;
    flex: 1;
    font-size: .875rem;
  }
  /* Hide desktop ctx-actions on mobile board toolbar,
     show only select + hamburger */
  #ctxBoard .ctx-actions { display: none; }
  #ctxBoard .menu-toggle { display: inline-flex !important; }
}

/* ══════════════════════════════════════════════════ DASHBOARD ──── */
#dashboardView { overflow-y: auto; }

.dashboard {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 16px;
}

/* ── Greeting ─────────────────────────────────────────────────────────────── */
.dash-greeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 18px 22px;
  background: linear-gradient(135deg, #fbeaf5 0%, #f5e6f2 100%);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg);
}
[data-theme="dark"] .dash-greeting {
  background: linear-gradient(135deg, #2a1024 0%, #1c1a17 100%);
}
.dash-greeting h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: .2rem;
  color: var(--text);
  letter-spacing: -.03em;
}
.dash-greeting p {
  font-size: .875rem;
  color: var(--muted);
  margin: 0;
}

/* ── Good news banner ─────────────────────────────────────────────────────── */
.dash-good-news {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.dash-good-news-item {
  flex: 1;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem .9rem;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text);
}

/* ── KPI strip ────────────────────────────────────────────────────────────── */
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.dash-kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  text-align: center;
}
.dash-kpi-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: .25rem;
}
.dash-kpi-label {
  font-size: .6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.dash-kpi-danger .dash-kpi-val { color: #b91c1c; }
[data-theme="dark"] .dash-kpi-danger .dash-kpi-val { color: #fca5a5; }

/* ── Two-column grid ──────────────────────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.dash-col { display: grid; gap: 16px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.dash-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.dash-card-title {
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--col-bg);
}
.dash-empty {
  padding: 1.25rem 16px;
  font-size: .8125rem;
  color: var(--muted);
  font-style: italic;
}
.dash-section-sub {
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 8px 16px 4px;
}
.dash-more-link {
  font-size: .75rem;
  color: var(--accent);
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 500;
}
.dash-more-link:hover { text-decoration: underline; }

/* ── My tasks rows ────────────────────────────────────────────────────────── */
.dash-task-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.dash-task-row:last-of-type { border-bottom: none; }
.dash-task-row:hover { background: var(--bg); }
.dash-task-main { flex: 1; min-width: 0; }
.dash-task-title {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-task-meta { font-size: .75rem; color: var(--muted); margin-top: 1px; }
.dash-task-overdue .dash-task-title { color: #b91c1c; }
[data-theme="dark"] .dash-task-overdue .dash-task-title { color: #fca5a5; }
.dash-overdue-tag {
  font-size: .75rem; font-weight: 600; color: #b91c1c;
  background: #fff1f2; border: 1px solid #fecaca;
  border-radius: 4px; padding: 1px 6px; white-space: nowrap;
}
.dash-today-tag {
  font-size: .75rem; font-weight: 600; color: var(--accent);
  background: var(--accent-dim); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px; white-space: nowrap;
}
.dash-date-tag {
  font-size: .75rem; color: var(--muted);
  white-space: nowrap;
}
.dash-task-week .dash-task-title { color: var(--muted); font-weight: 500; }

/* ── Team pulse rows ──────────────────────────────────────────────────────── */
.dash-team-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.dash-team-row:last-child { border-bottom: none; }
.dash-team-row:hover { background: var(--bg); }
.dash-team-info { flex: 1; min-width: 0; }
.dash-team-name { font-size: .875rem; font-weight: 600; color: var(--text); }
.dash-team-meta { font-size: .75rem; color: var(--muted); }
.dash-team-ok { font-size: .75rem; color: #16a34a; font-weight: 600; }

/* ── At risk rows ─────────────────────────────────────────────────────────── */
.dash-risk-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.dash-risk-row:last-child { border-bottom: none; }
.dash-risk-row:hover { background: var(--bg); }
.dash-risk-info { flex: 1; min-width: 0; }
.dash-risk-name { font-size: .875rem; font-weight: 600; color: var(--text); }
.dash-risk-client { color: var(--muted); font-weight: 400; }
.dash-risk-flags { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .2rem; }
.dash-risk-arrow { color: var(--muted); font-size: .875rem; }
.dash-burn-tag {
  font-size: .6875rem; font-weight: 600;
  border-radius: 4px; padding: 1px 5px;
  border: 1px solid;
}
.dash-burn-tag.warn { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.dash-burn-tag.over { color: #b91c1c; background: #fff1f2; border-color: #fecaca; }

/* ── Revenue rows ─────────────────────────────────────────────────────────── */
.dash-revenue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: .8125rem;
}
.dash-revenue-row:last-child { border-bottom: none; }
.dash-revenue-client { font-weight: 600; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-revenue-right { display: flex; gap: .5rem; align-items: center; flex-shrink: 0; }
.dash-revenue-price { font-weight: 700; color: var(--text); }
.dash-revenue-margin { font-size: .75rem; color: var(--muted); }
.dash-revenue-total {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: .8125rem;
  font-weight: 700;
  background: var(--bg);
  border-top: 2px solid var(--border);
  color: var(--text);
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .dashboard { padding: 12px; gap: 12px; }
  .dash-kpis { grid-template-columns: repeat(3, 1fr); }
  .dash-kpis .dash-kpi:nth-child(4),
  .dash-kpis .dash-kpi:nth-child(5) { grid-column: span 1; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-kpi-val { font-size: 1.25rem; }
}

/* ── Board toolbar burn indicator ────────────────────────────────────────── */
.board-burn-indicator {
  font-size: .75rem;
  font-weight: 600;
  padding: .25rem .6rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  white-space: nowrap;
  flex-shrink: 0;
}
.board-burn-indicator:empty { display: none; }
.board-burn-indicator.ok   { color: var(--muted); background: var(--bg); }
.board-burn-indicator.warn { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.board-burn-indicator.over { color: #b91c1c; background: #fff1f2; border-color: #fecaca; font-weight: 700; }
[data-theme="dark"] .board-burn-indicator.warn { color: #fbbf24; background: #1c1400; border-color: #854d0e; }
[data-theme="dark"] .board-burn-indicator.over { color: #fca5a5; background: #1a0505; border-color: #7f1d1d; }

/* ── Column header tracked/estimated hours ───────────────────────────────── */
.col-hours.warn { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.col-hours.over { color: #b91c1c; background: #fff1f2; border-color: #fecaca; font-weight: 700; }
[data-theme="dark"] .col-hours.warn { color: #fbbf24; background: #1c1400; border-color: #854d0e; }
[data-theme="dark"] .col-hours.over { color: #fca5a5; background: #1a0505; border-color: #7f1d1d; }

@media (max-width: 640px) {
  .board-burn-indicator { display: none; }
}

/* ── Nav toggle (hamburger) — hidden on desktop, shown on mobile ─────────── */
@media (min-width: 641px) { .nav-toggle { display: none; } }

/* ── Mobile nav drawer ───────────────────────────────────────────────────── */
.nav-drawer {
  display: none; /* desktop */
}
.nav-backdrop {
  display: none;
}

@media (max-width: 640px) {
  .nav-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 75vw; max-width: 280px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 24px rgba(0,0,0,.2);
    z-index: 400;
    padding: 1rem 0 2rem;
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.32,.72,0,1);
    pointer-events: none;
  }
  .nav-drawer.open {
    transform: translateX(0);
    pointer-events: auto;
  }
  .nav-drawer::before {
    content: '2S Projects 🔥';
    display: block;
    font-size: .875rem;
    font-weight: 700;
    padding: .5rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: .5rem;
    color: var(--text);
  }
  .nav-drawer-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1.25rem;
    font-size: .9375rem;
    font-weight: 500;
    color: var(--text);
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    text-align: left;
    cursor: pointer;
    transition: background .1s;
    border-left: 3px solid transparent;
  }
  .nav-drawer-item:hover { background: var(--bg); }
  .nav-drawer-item.active {
    background: var(--accent-dim);
    border-left-color: var(--accent);
    color: var(--accent);
    font-weight: 700;
  }
  .nav-backdrop {
    display: none;
    position: fixed; inset: 0;
    z-index: 399;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(2px);
  }
  .nav-backdrop.open { display: block; }

  /* seg-controls always visible on mobile — remove ctx-actions hiding for them */
  .ctx-toolbar .seg-control { display: inline-flex !important; }

  /* Projects toolbar — + New project button compact on mobile */
  #ctxClients #addProject {
    display: inline-flex !important;
    margin-left: auto;
    font-size: .75rem;
    padding: .3rem .6rem;
    white-space: nowrap;
    flex-shrink: 0;
  }
  /* Projects toolbar — hide search and sort on mobile, just show add button */
  #ctxClients #pvSearch { max-width: 90px; font-size: .8125rem; }
  #ctxClients #pvSort { font-size: .75rem; max-width: 90px; }

  /* Clients toolbar — manage button hidden on mobile, keep search */
  #ctxClientsTab .ctx-actions { display: none; }
}

@media (max-width: 640px) {
  .modal {
    padding: .5rem;
    align-items: flex-end;  /* sheet slides up from bottom on mobile */
  }
  .modal .sheet {
    width: 100vw;
    max-width: 100vw;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin: 0;
  }
  .sheet .body { padding: 1rem; }
  .sheet .row {
    grid-template-columns: 100px 1fr;
    gap: .5rem;
  }
  .sheet footer { padding: .75rem 1rem; }
  /* Wide sheet (templates) full width on mobile */
  .sheet-wide { width: 100vw !important; }
}

/* ── User dropdown ───────────────────────────────────────────────────────── */
.user-menu-wrap {
  position: relative;
  flex-shrink: 0;
}
.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 200;
  overflow: hidden;
}
.user-dropdown.open { display: block; }
.user-dropdown-name {
  font-size: .875rem;
  font-weight: 700;
  color: var(--text);
  padding: .85rem 1rem .15rem;
}
.user-dropdown-email {
  font-size: .75rem;
  color: var(--muted);
  padding: 0 1rem .75rem;
}
.user-dropdown-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}
.user-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: .75rem 1rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
  transition: background .1s;
}
.user-dropdown-item:hover { background: var(--bg); }

/* ── Hamburger — bigger and bolder ──────────────────────────────────────── */
.nav-toggle {
  font-size: 1.5rem !important;
  font-weight: 900 !important;
  padding: .25rem .5rem !important;
  line-height: 1;
}

/* ── Tasks view — fix horizontal overflow on mobile ─────────────────────── */
@media (max-width: 640px) {
  #dateView { overflow-x: hidden; max-width: 100vw; }
  .table-wrap { overflow-x: auto; max-width: calc(100vw - 24px); }
  .mywork-row { flex-wrap: wrap; }
  .mywork-row-meta { flex-wrap: wrap; }
  .mywork-row .badge { flex-shrink: 0; }
  #myWorkGroups { max-width: 100vw; overflow-x: hidden; }
  .mywork-banner { white-space: normal; }
  /* Team grid single column already handled, but ensure no overflow */
  .team-card { max-width: calc(100vw - 24px); }
}

/* ── Financials hours comparison ─────────────────────────────────────────── */
.fin-hours-compare {
  display: grid;
  gap: .6rem;
  padding: .85rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.fin-section-label {
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .15rem;
}
.fin-hours-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: .6rem;
}
.fin-hours-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
}
.fin-hours-bar-wrap {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.fin-hours-bar-track {
  flex: 1;
  height: 10px;
  background: var(--border-light, #e2e8f0);
  border-radius: 999px;
  overflow: hidden;
}
.fin-hours-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .4s ease;
  min-width: 2px;
}
.fin-hours-val {
  font-size: .8125rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  min-width: 60px;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.fin-burn-note {
  font-size: .6875rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}
.fin-burn-note.warn { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.fin-burn-note.over { color: #b91c1c; background: #fff1f2; border-color: #fecaca; }

/* ── Finances tab pipeline summary strip ─────────────────────────────────── */
#marginSummary { padding: 12px 12px 0; }
.fin-summary-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.fin-summary-kpi {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  min-width: 90px;
}
.fin-summary-val {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
}
.fin-summary-label {
  font-size: .6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

/* ── Finances table hours cell colours ───────────────────────────────────── */
.fin-val-over { color: #b91c1c; font-weight: 700; }
.fin-val-warn { color: #b45309; font-weight: 700; }

@media (max-width: 640px) {
  .fin-summary-strip { gap: 8px; }
  .fin-summary-kpi { min-width: 70px; }
  .fin-summary-val { font-size: .9375rem; }
}

/* ── Prevent iOS auto-zoom on input focus ────────────────────────────────── */
/* iOS Safari zooms in when an input's font-size is below 16px.
   This sets all inputs to at least 16px on mobile so zoom never triggers. */
@media (max-width: 640px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}
