/* ===================================================================
   Portfolio Tracker — theme matched to TimeFlux (Boltin brand palette)
   =================================================================== */

:root {
  /* Brand colors */
  --tf-navy: #1A2B5F;
  --tf-blue: #1565C0;
  --tf-blue-bright: #1877F2;
  --tf-orange: #F5820A;
  --tf-orange-soft: #FCE3CB;
  --tf-teal: #00B09B;
  --tf-white: #FFFFFF;
  --tf-text: #212121;
  --tf-red: #C62828;

  /* Neutrals */
  --tf-bg: #F4F6FA;
  --tf-surface: #FFFFFF;
  --tf-border: #E1E5EE;
  --tf-muted: #6B7390;
  --tf-muted-2: #9AA1B8;

  /* Sizing */
  --tf-radius: 10px;
  --tf-radius-sm: 6px;
  --tf-shadow: 0 2px 12px rgba(26, 43, 95, 0.08);
  --tf-shadow-md: 0 4px 24px rgba(26, 43, 95, 0.10);

  --tf-header-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  font-family: 'Calibri', 'Segoe UI', Arial, sans-serif;
  background: var(--tf-bg);
  color: var(--tf-text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--tf-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  padding: 8px 11px;
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius-sm);
  background: var(--tf-white);
  color: var(--tf-text);
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--tf-blue);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.12);
}
textarea { resize: vertical; min-height: 70px; }

label {
  display: block;
  font-size: 13px;
  color: var(--tf-muted);
  margin-bottom: 4px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.muted-inline { color: var(--tf-muted); font-size: 13px; }

/* === Header === */
.tf-header {
  background: var(--tf-navy);
  color: var(--tf-white);
  height: var(--tf-header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--tf-shadow-md);
  position: sticky; top: 0; z-index: 50;
}
.tf-header-user {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: rgba(255,255,255,0.85); flex-shrink: 0;
}
.tf-header-user #logoutBtn { color: rgba(255,255,255,0.85); font-weight: 600; }
.tf-header-user #logoutBtn:hover { color: white; background: rgba(255,255,255,0.12); }

/* app-login role pills */
.tf-pill.role-admin  { background: var(--tf-navy); }
.tf-pill.role-viewer { background: var(--tf-muted); }

/* Viewer role: hide every add/edit/delete affordance across the app -- this is a UX nicety,
   not the security boundary (server.js's blockViewerWrites middleware is what actually
   enforces read-only access; this just keeps a viewer from seeing controls that would 403). */
body.role-viewer [data-add], body.role-viewer [data-edit], body.role-viewer [data-delete],
body.role-viewer [data-add-lookup], body.role-viewer [data-edit-lookup], body.role-viewer [data-delete-lookup],
body.role-viewer [data-edit-template], body.role-viewer [data-delete-template],
body.role-viewer [data-add-slab], body.role-viewer [data-save-slabs], body.role-viewer [data-remove-slab-row],
body.role-viewer [data-delete-fx], body.role-viewer [data-deactivate], body.role-viewer [data-reactivate],
body.role-viewer #newProjectBtn, body.role-viewer #editProjectBtn, body.role-viewer #copyProjectBtn,
body.role-viewer #deleteProjectBtn, body.role-viewer #newTeamBtn, body.role-viewer #newCustomerBtn,
body.role-viewer #newRateCalcBtn, body.role-viewer #newOpenPosBtn, body.role-viewer #newFxBtn {
  display: none !important;
}

.tf-logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 20px; letter-spacing: -0.01em;
  color: white;
  text-decoration: none;
  cursor: default;
}
.tf-logo:hover { text-decoration: none; }
.tf-logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  height: 30px;
}
.tf-logo-mark img { height: 100%; width: auto; display: block; }
.tf-nav { display: flex; gap: 4px; align-items: center; }
.tf-nav-hint { color: rgba(255,255,255,0.65); font-size: 13px; font-weight: 600; }

/* === Footer (orange brand strip) === */
.tf-footer {
  background: var(--tf-orange);
  color: white;
  font-size: 11px;
  padding: 6px 24px;
  text-align: center;
  letter-spacing: 0.05em;
}

/* === Layout === */
.tf-page { display: flex; flex-direction: column; min-height: 100vh; }
.tf-main { flex: 1; padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
.tf-page-title { font-size: 24px; font-weight: 700; color: var(--tf-navy); margin: 0 0 4px; }
.tf-page-subtitle { color: var(--tf-muted); margin: 0; font-size: 14px; }

.tf-card {
  background: var(--tf-surface);
  border-radius: var(--tf-radius);
  padding: 20px;
  box-shadow: var(--tf-shadow);
  margin-bottom: 16px;
}
.tf-card-title { font-size: 16px; font-weight: 700; color: var(--tf-navy); margin: 0 0 14px; }

/* === Buttons === */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  font-size: 14px; font-weight: 600;
  border-radius: var(--tf-radius-sm);
  background: var(--tf-blue); color: white;
  transition: filter .12s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn.btn-orange { background: var(--tf-orange); }
.btn.btn-teal   { background: var(--tf-teal); }
.btn.btn-navy   { background: var(--tf-navy); }
.btn.btn-ghost  { background: transparent; color: var(--tf-blue); border: 1px solid var(--tf-blue); }
.btn.btn-ghost:hover { background: rgba(21,101,192,0.08); }
.btn.btn-danger { background: var(--tf-red); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn--icon { background: transparent; border: none; color: var(--tf-muted-2); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 4px; }
.btn--icon:hover { color: var(--tf-red); background: rgba(198,40,40,0.08); }

/* === Pills (status / priority / severity) === */
.tf-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: white;
  background: var(--tf-muted);
  white-space: nowrap;
}
.tf-pill.pri-low      { background: #6B7390; }
.tf-pill.pri-medium   { background: #1565C0; }
.tf-pill.pri-high     { background: #F5820A; }
.tf-pill.pri-critical { background: #C62828; }

/* project status */
.tf-pill.ps-on-track  { background: var(--tf-teal); }
.tf-pill.ps-at-risk   { background: var(--tf-orange); }
.tf-pill.ps-off-track { background: var(--tf-red); }
.tf-pill.ps-on-hold   { background: var(--tf-muted); }
.tf-pill.ps-completed { background: var(--tf-navy); }

/* task status */
.tf-pill.ts-todo        { background: var(--tf-muted); }
.tf-pill.ts-in-progress { background: var(--tf-orange); }
.tf-pill.ts-blocked     { background: var(--tf-red); }
.tf-pill.ts-done        { background: var(--tf-teal); }

/* milestone status */
.tf-pill.ms-pending     { background: var(--tf-muted); }
.tf-pill.ms-in-progress { background: var(--tf-blue); }
.tf-pill.ms-completed   { background: var(--tf-teal); }
.tf-pill.ms-hold        { background: var(--tf-orange); }
.tf-pill.ms-abandoned   { background: var(--tf-red); }

/* risk status */
.tf-pill.rs-open      { background: var(--tf-red); }
.tf-pill.rs-mitigated { background: var(--tf-orange); }
.tf-pill.rs-closed    { background: var(--tf-muted); }

/* monthly allocation grid (over/under per member per month) */
.tf-pill.util-ok    { background: var(--tf-teal); }
.tf-pill.util-warn  { background: var(--tf-orange); }
.tf-pill.util-over  { background: var(--tf-red); }
.tf-pill.util-zero  { background: var(--tf-border); color: var(--tf-muted); }

/* === Tables === */
.tf-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--tf-surface);
  border-radius: var(--tf-radius);
  overflow: hidden;
  box-shadow: var(--tf-shadow);
  margin-bottom: 8px;
}
.tf-table thead th {
  background: var(--tf-blue);
  color: white;
  text-align: left;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
}
.tf-table tbody td {
  padding: 12px 14px;
  border-top: 1px solid var(--tf-border);
  font-size: 14px;
  vertical-align: middle;
}
.tf-table tbody tr:hover { background: rgba(21,101,192,0.04); }
.tf-table tbody tr.clickable { cursor: pointer; }

/* === Forms / filters === */
.tf-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  background: var(--tf-surface);
  padding: 14px;
  border-radius: var(--tf-radius);
  box-shadow: var(--tf-shadow);
  margin-bottom: 16px;
  align-items: end;
}
.tf-filters .field { display: flex; flex-direction: column; }

.field { display: flex; flex-direction: column; gap: 2px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* === Multi-select filter widget (2026-08-28) === */
.msel { position: relative; }
.msel__btn {
  width: 100%; text-align: left; background: var(--tf-white);
  border: 1px solid var(--tf-border); border-radius: var(--tf-radius-sm);
  padding: 8px 11px; font-size: 15px; color: var(--tf-text);
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
}
.msel__btn-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msel__btn:after { content: '▾'; font-size: 11px; color: var(--tf-muted); flex: none; }
.msel__btn.is-open { border-color: var(--tf-blue); }
.msel__panel {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 220px; max-width: 320px;
  background: var(--tf-white); border: 1px solid var(--tf-border); border-radius: var(--tf-radius);
  box-shadow: var(--tf-shadow-md); z-index: 40; padding: 8px 0;
}
.msel__actions { display: flex; gap: 12px; padding: 0 12px 8px; border-bottom: 1px solid var(--tf-border); margin-bottom: 4px; }
.msel__actions button { background: none; color: var(--tf-blue); font-size: 13px; padding: 2px 0; }
.msel__actions button:hover { text-decoration: underline; }
.msel__list { max-height: 220px; overflow-y: auto; }
.msel__opt { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; font-size: 14px; margin: 0; }
.msel__opt:hover { background: var(--tf-bg); }
.msel__opt input { margin: 0; padding: 0; width: auto; flex: none; }
.msel__empty { padding: 10px 12px; color: var(--tf-muted); font-size: 13px; }

/* === KPI tiles === */
.tf-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.tf-kpi {
  background: var(--tf-surface);
  border-left: 4px solid var(--tf-blue);
  border-radius: var(--tf-radius);
  padding: 14px 18px;
  box-shadow: var(--tf-shadow);
}
.tf-kpi .label { font-size: 12px; color: var(--tf-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.tf-kpi .value { font-size: 30px; font-weight: 800; color: var(--tf-navy); margin-top: 2px; }
.tf-kpi.orange { border-left-color: var(--tf-orange); }
.tf-kpi.orange .value { color: var(--tf-orange); }
.tf-kpi.teal   { border-left-color: var(--tf-teal); }
.tf-kpi.teal .value { color: var(--tf-teal); }
.tf-kpi.navy   { border-left-color: var(--tf-navy); }
.tf-kpi.red    { border-left-color: var(--tf-red); }
.tf-kpi.red .value { color: var(--tf-red); }

/* === List panels (dashboard: milestones / risks / tasks) === */
.tf-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .tf-grid-3 { grid-template-columns: 1fr; } }
.tf-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .tf-grid-2 { grid-template-columns: 1fr; } }

/* === Monthly Revenue report chart (2026-08-28) === */
.tf-chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; margin-bottom: 6px; }
.tf-chart-legend span.swatch { width: 10px; height: 10px; display: inline-block; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.tf-chart-empty { padding: 30px 0; text-align: center; color: var(--tf-muted); font-size: 14px; }
.tf-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.tf-list-item {
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--tf-radius-sm);
  background: var(--tf-bg);
  border-left: 3px solid var(--tf-blue);
}
.tf-list-item .item-title { font-weight: 700; color: var(--tf-navy); }
.tf-list-item .item-meta { color: var(--tf-muted); font-size: 12px; margin-top: 2px; }
.tf-list-empty { color: var(--tf-muted); font-size: 13px; padding: 6px 0; }

/* === Progress bar === */
.progress { display: flex; align-items: center; gap: 8px; }
.progress__track { flex: 1; height: 6px; border-radius: 4px; background: var(--tf-border); overflow: hidden; min-width: 60px; }
.progress__fill { height: 100%; background: var(--tf-blue); border-radius: 4px; }
.progress__label { font-size: 12px; color: var(--tf-muted); min-width: 30px; text-align: right; }

/* === Detail view === */
.detail-name { font-size: 20px; color: var(--tf-navy); margin: 0; }
.detail-meta { display: flex; gap: 28px; margin-top: 14px; flex-wrap: wrap; }
.detail-meta > div { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.detail-meta label { margin: 0; }

/* === Tabs === */
.tf-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--tf-border); margin-bottom: 14px; }
.tf-tab {
  background: transparent; border: none; border-bottom: 3px solid transparent;
  padding: 10px 14px; font-size: 14px; font-weight: 700; color: var(--tf-muted); cursor: pointer;
}
.tf-tab.is-active { color: var(--tf-blue); border-bottom-color: var(--tf-blue); }
.tab-panel[hidden] { display: none; }

/* === Modal === */
.tf-modal-overlay {
  position: fixed; inset: 0; background: rgba(26,43,95,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.tf-modal-overlay[hidden] { display: none; }
.tf-modal {
  background: var(--tf-surface); border-radius: 14px; width: 100%; max-width: 480px;
  max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 14px 48px rgba(0,0,0,0.25);
}
.tf-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--tf-border); }
.tf-modal-header h3 { margin: 0; font-size: 16px; color: var(--tf-navy); }
.tf-modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.tf-modal-footer { padding: 14px 18px; border-top: 1px solid var(--tf-border); display: flex; justify-content: flex-end; gap: 8px; }

/* === Toast === */
.tf-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--tf-navy); color: white;
  padding: 10px 18px; border-radius: var(--tf-radius-sm); font-size: 13px; z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.tf-toast[hidden] { display: none; }
.tf-toast.error { background: var(--tf-red); }

/* === Utility === */
.tf-empty { text-align: center; padding: 36px; color: var(--tf-muted); font-size: 14px; }
.tf-flex { display: flex; gap: 10px; align-items: center; }
.tf-flex.between { justify-content: space-between; }
.tf-flex.wrap { flex-wrap: wrap; }

/* === Top-level nav (main app sections) === */
.tf-mainnav { display: flex; gap: 4px; }
.tf-mainnav a {
  color: rgba(255,255,255,0.75);
  padding: 8px 14px;
  border-radius: var(--tf-radius-sm);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.tf-mainnav a:hover { background: rgba(255,255,255,0.10); color: white; text-decoration: none; }
.tf-mainnav a.is-active { background: rgba(255,255,255,0.16); color: white; }

.view-section[hidden] { display: none; }

/* === Sub tabs (within a page, e.g. Masters, Project Detail) === */
.tf-subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--tf-border); margin-bottom: 14px; flex-wrap: wrap; }
.tf-subtab {
  background: transparent; border: none; border-bottom: 3px solid transparent;
  padding: 9px 12px; font-size: 13px; font-weight: 700; color: var(--tf-muted); cursor: pointer;
}
.tf-subtab.is-active { color: var(--tf-blue); border-bottom-color: var(--tf-blue); }
.subtab-panel[hidden] { display: none; }

/* === Multi-select chips (technologies etc.) === */
.chip-select { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid var(--tf-border); border-radius: var(--tf-radius-sm); background: var(--tf-white); }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--tf-bg); border: 1px solid var(--tf-border);
  border-radius: 999px; padding: 3px 10px 3px 12px; font-size: 12px; font-weight: 600; color: var(--tf-text);
  cursor: pointer; user-select: none;
}
.chip.is-selected { background: var(--tf-blue); border-color: var(--tf-blue); color: white; }
.chip .x { font-size: 11px; opacity: 0.7; }

/* === Slab editor table === */
.slab-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.slab-table th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--tf-muted); padding: 6px 8px; }
.slab-table td { padding: 4px 8px; }
.slab-table input { padding: 6px 8px; font-size: 13px; }

/* === Small stat row (used in resourcing / financial dashboards) === */
.stat-row { display: flex; gap: 24px; flex-wrap: wrap; margin: 10px 0 4px; }
.stat-row .stat { display: flex; flex-direction: column; }
.stat-row .stat .n { font-size: 22px; font-weight: 800; color: var(--tf-navy); }
.stat-row .stat .l { font-size: 11px; text-transform: uppercase; color: var(--tf-muted); font-weight: 700; letter-spacing: 0.04em; }

/* === Bar meter (utilization) === */
.meter { height: 8px; border-radius: 4px; background: var(--tf-border); overflow: hidden; min-width: 100px; }
.meter > div { height: 100%; }
.meter.ok > div { background: var(--tf-teal); }
.meter.warn > div { background: var(--tf-orange); }
.meter.over > div { background: var(--tf-red); }

/* === Section intro (page title + subtitle + action) === */
.section-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

/* === Mobile === */
@media (max-width: 720px) {
  .tf-header { padding: 0 14px; height: 54px; }
  .tf-logo { font-size: 17px; }
  .tf-main { padding: 14px; }
  .field-row { grid-template-columns: 1fr; }
  .tf-table thead { display: none; }
  .tf-table tbody td { display: block; border-top: none; padding: 4px 14px; }
  .tf-table tbody td::before { content: attr(data-label); display: inline-block; width: 110px; font-weight: 700; color: var(--tf-muted); font-size: 12px; text-transform: uppercase; }
  .tf-table tbody tr { display: block; border-top: 1px solid var(--tf-border); padding: 12px 0; }
}
