/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --brand:       #2563eb;
  --brand-dark:  #1d4ed8;
  --brand-light: #eff6ff;
  --sidebar-w:   240px;
  --sidebar-bg:  #0f172a;
  --bg:          #f1f5f9;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --text:        #0f172a;
  --text-2:      #475569;
  --text-3:      #94a3b8;
  --radius:      10px;
  --shadow:      0 2px 12px rgba(0,0,0,.07);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.12);
}
body { font-family: 'Plus Jakarta Sans', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
button { cursor: pointer; }
img { max-width: 100%; }

/* ── Layout ───────────────────────────────────────────────── */
.app-layout  { display: flex; min-height: 100vh; }
.main-wrap   { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-content{ flex: 1; padding: 24px; max-width: 1400px; width: 100%; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); display: flex;
  flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.sidebar-brand {
  padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar-brand-sub { color: rgba(255,255,255,.35); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: rgba(255,255,255,.55); font-weight: 500; transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 10px;
}
.staff-pill {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.staff-info { flex: 1; min-width: 0; }
.staff-name { color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.staff-role { color: rgba(255,255,255,.4); font-size: 11px; }
.logout-btn { color: rgba(255,255,255,.4); font-size: 18px; padding: 4px; }
.logout-btn:hover { color: #fff; text-decoration: none; }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px; display: flex; align-items: center;
  gap: 16px; position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-weight: 700; font-size: 16px; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ── Flash messages ───────────────────────────────────────── */
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-radius: var(--radius); margin: 16px 24px 0;
  font-weight: 500; font-size: 13.5px;
}
.flash-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.flash-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.flash-close   { background: none; border: none; font-size: 18px; line-height: 1; color: inherit; opacity: .6; }
.flash-close:hover { opacity: 1; }

/* ── Cards ────────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 20px; }
.card-sm { padding: 14px 18px; }
.card-title { font-weight: 700; font-size: 15px; margin-bottom: 14px; color: var(--text); }

/* ── Stats grid ───────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; display: flex; align-items: center; gap: 14px;
}
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-val  { font-size: 26px; font-weight: 800; line-height: 1; color: var(--text); }
.stat-lbl  { font-size: 12px; color: var(--text-3); margin-top: 2px; font-weight: 500; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px;
  border-radius: 7px; font-weight: 600; border: none; transition: all .15s;
  font-size: 13.5px; white-space: nowrap;
}
.btn-primary  { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn-secondary{ background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-danger   { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; text-decoration: none; color: #b91c1c; }
.btn-success  { background: #dcfce7; color: #15803d; }
.btn-success:hover { background: #bbf7d0; text-decoration: none; color: #15803d; }
.btn-sm       { padding: 5px 11px; font-size: 12.5px; border-radius: 6px; }
.btn-icon     { padding: 6px 8px; }
.btn-ghost    { background: transparent; color: var(--text-2); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--bg); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th { background: #f8fafc; padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); border-bottom: 1px solid var(--border); }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-2); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* ── Badges ───────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 100px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-amber  { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-gray   { background: #f1f5f9; color: #64748b; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-teal   { background: #ccfbf1; color: #0f766e; }

/* ── Forms ────────────────────────────────────────────────── */
.form-row   { display: grid; gap: 16px; margin-bottom: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
label       { font-weight: 600; font-size: 12.5px; color: var(--text); }
.form-control {
  border: 1.5px solid var(--border); border-radius: 7px; padding: 8px 12px;
  background: #fff; color: var(--text); width: 100%; transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11.5px; color: var(--text-3); }

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5);
  z-index: 1000; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 14px; width: 100%;
  max-width: 560px; box-shadow: var(--shadow-lg); overflow: hidden;
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal-lg { max-width: 780px; }
.modal-hd {
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-hd h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-3); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-ft   { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Priority dot ─────────────────────────────────────────── */
.prio-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ── Category tag ─────────────────────────────────────────── */
.cat-tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; color: #fff; }

/* ── Progress bar ─────────────────────────────────────────── */
.progress-wrap { background: var(--border); border-radius: 100px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 100px; background: var(--brand); transition: width .4s; }

/* ── Task groups (My Tasks) ───────────────────────────────── */
.task-group { margin-bottom: 24px; }
.task-group-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px;
  margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
}
.task-group-title .tg-count {
  background: var(--bg); color: var(--text-3); border-radius: 100px;
  padding: 1px 8px; font-size: 11px;
}
.task-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 8px; display: flex; align-items: flex-start;
  gap: 12px; transition: box-shadow .15s;
}
.task-card:hover { box-shadow: var(--shadow); }
.task-card-left  { flex: 1; min-width: 0; }
.task-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.task-title      { font-weight: 600; color: var(--text); font-size: 14px; margin-bottom: 4px; }
.task-meta       { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--text-3); }
.project-chip    { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 11.5px; font-weight: 600; }

/* ── Phase accordion ──────────────────────────────────────── */
.phase-block { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.phase-header {
  padding: 14px 18px; background: #f8fafc; display: flex; align-items: center;
  gap: 10px; cursor: pointer; user-select: none;
}
.phase-header:hover { background: #f1f5f9; }
.phase-header-title { flex: 1; font-weight: 700; font-size: 15px; }
.phase-header-meta  { display: flex; align-items: center; gap: 10px; }
.phase-body { padding: 0; display: none; }
.phase-body.open { display: block; }
.phase-chevron { transition: transform .2s; color: var(--text-3); }
.phase-chevron.open { transform: rotate(180deg); }

/* ── Task rows in phase ───────────────────────────────────── */
.task-row {
  display: grid; grid-template-columns: 28px 1fr 130px 120px 120px 90px 90px;
  gap: 8px; align-items: center; padding: 10px 18px;
  border-top: 1px solid var(--border); font-size: 13px;
}
.task-row:hover { background: #fafbfc; }
.task-row-hd    { background: #f8fafc; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); }
.task-row-hd:hover { background: #f8fafc; }

/* ── Comments ─────────────────────────────────────────────── */
.comment-list { display: flex; flex-direction: column; gap: 14px; }
.comment-item { display: flex; gap: 10px; }
.comment-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.comment-bubble { background: var(--bg); border-radius: 10px; padding: 10px 14px; flex: 1; }
.comment-bubble.internal { background: #fef3c7; border: 1px solid #fde68a; }
.comment-bubble.client-comment { background: #eff6ff; }
.comment-meta { font-size: 11.5px; color: var(--text-3); margin-bottom: 4px; }
.comment-text { font-size: 13.5px; color: var(--text); }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-3); }
.empty-state svg { opacity: .3; margin-bottom: 12px; }
.empty-state p   { font-size: 14px; }

/* ── Page sections ────────────────────────────────────────── */
.section { margin-bottom: 28px; }
.section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px;
  color: var(--text-3); margin-bottom: 14px; display: flex; align-items: center;
  justify-content: space-between;
}

/* ── Two-column layout ────────────────────────────────────── */
.two-col     { display: grid; grid-template-columns: 1fr 360px; gap: 24px; align-items: start; }
.three-col   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Detail page header ───────────────────────────────────── */
.detail-header {
  background: var(--sidebar-bg); border-radius: var(--radius); padding: 24px 28px;
  color: #fff; margin-bottom: 24px; display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px;
}
.detail-title   { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.detail-meta    { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: rgba(255,255,255,.6); align-items: center; }
.detail-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* ── Service type colors ──────────────────────────────────── */
.svc-SEO       { background: #dbeafe; color: #1d4ed8; }
.svc-ads       { background: #fee2e2; color: #b91c1c; }
.svc-combo     { background: #ede9fe; color: #6d28d9; }
.svc-web       { background: #ccfbf1; color: #0f766e; }

/* ── Login page ───────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; background: var(--sidebar-bg); display: flex;
  align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 440px;
  padding: 40px; box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand img { height: 40px; }
.login-brand h1 { font-size: 20px; font-weight: 800; color: var(--text); margin-top: 12px; }
.login-brand p  { font-size: 13px; color: var(--text-3); margin-top: 4px; }

/* Login layout mode (desktop vs touch) — chosen before sign-in */
.login-ui-mode { margin: 0 0 18px; padding: 0; border: 0; }
.login-ui-legend { font-size: 12px; font-weight: 700; color: var(--text-2); margin-bottom: 10px; padding: 0; }
.login-ui-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) {
  .login-ui-options { grid-template-columns: 1fr; }
}
.login-ui-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
  transition: border-color .15s, background .15s;
  margin: 0;
}
.login-ui-option:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-light);
}
.login-ui-option input { flex-shrink: 0; margin-top: 3px; }
.login-ui-opt-title { font-weight: 700; font-size: 13px; color: var(--text); display: block; }
.login-ui-opt-desc { font-size: 11px; color: var(--text-3); line-height: 1.45; margin-top: 4px; display: block; }

/* ── Portal (client) ──────────────────────────────────────── */
.portal-body   { background: #f8fafc; min-height: 100vh; }
.portal-header { background: var(--sidebar-bg); color: #fff; padding: 0; }
.portal-hero   { max-width: 900px; margin: 0 auto; padding: 28px 24px; display: flex; align-items: center; gap: 20px; }
.portal-content { max-width: 900px; margin: 0 auto; padding: 28px 24px; }

.portal-phase { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; background: #fff; }
.portal-phase-hd { padding: 16px 20px; background: #f8fafc; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.portal-phase-hd:hover { background: #f1f5f9; }
.portal-task { display: flex; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); align-items: flex-start; }
.portal-task-status { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px; }
.portal-task-body { flex: 1; }
.portal-task-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.portal-task-meta  { font-size: 12px; color: var(--text-3); }
.portal-task-actions { display: flex; gap: 6px; }

/* ── Report styles ────────────────────────────────────────── */
.report-page { max-width: 860px; margin: 0 auto; }
.report-header { background: var(--sidebar-bg); color: #fff; border-radius: var(--radius) var(--radius) 0 0; padding: 28px 36px; }
.report-body   { background: #fff; padding: 32px 36px; border: 1px solid var(--border); border-top: none; }
.report-section { margin-bottom: 28px; }
.report-section-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--text-3); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.report-task-item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.report-task-check { color: #10b981; font-size: 15px; flex-shrink: 0; margin-top: 1px; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-item { padding: 9px 16px; font-weight: 600; font-size: 13.5px; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab-item:hover  { color: var(--text); }
.tab-item.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Filters bar ──────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; align-items: center; }
.filters .form-control { width: auto; }

/* ── Template cards ───────────────────────────────────────── */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.template-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; transition: box-shadow .15s; cursor: pointer;
}
.template-card:hover { box-shadow: var(--shadow); border-color: var(--brand); }
.template-card-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.template-card-desc  { font-size: 13px; color: var(--text-3); margin-bottom: 14px; }
.template-card-meta  { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Utilities ────────────────────────────────────────────── */
.text-muted  { color: var(--text-3); }
.text-small  { font-size: 12.5px; }
.fw-bold     { font-weight: 700; }
.fw-600      { font-weight: 600; }
.d-flex      { display: flex; }
.align-center{ align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.mb-0        { margin-bottom: 0; }
.mb-12       { margin-bottom: 12px; }
.mb-20       { margin-bottom: 20px; }
.mt-16       { margin-top: 16px; }
.overdue-badge { color: #ef4444; font-weight: 700; font-size: 11.5px; }


/* ── Personal tasks (responsive) ──────────────────────────── */
.personal-tasks-page {
  max-width: min(960px, 100%);
  margin: 0 auto;
}
.pt-intro-card { margin-bottom: 16px; }
.pt-summary {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
}
.pt-summary-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.pt-summary-date {
  font-size: clamp(1.125rem, 4vw + 0.75rem, 1.375rem);
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
}
.pt-summary-desc {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
  max-width: 42rem;
}
.pt-summary-progress {
  flex-shrink: 0;
  text-align: right;
  line-height: 1;
}
.pt-summary-progress-num { font-size: 26px; font-weight: 800; color: var(--brand); }
.pt-summary-progress-of { opacity: 0.45; font-weight: 600; }
.pt-summary-progress-lbl {
  margin-top: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 700;
}
.pt-actions {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.pt-action-btn {
  justify-content: center;
  text-align: center;
  padding: 10px 8px;
  font-size: 13px;
  white-space: normal;
  line-height: 1.25;
}
.pt-panel { margin-bottom: 16px !important; }
.pt-panel[hidden] { display: none !important; }
.pt-date-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.pt-date-form .form-control { flex: 1 1 220px; min-width: 0; }
.pt-stack-form { display: flex; flex-direction: column; gap: 14px; }
.pt-paste-help {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
}
.pt-kbd {
  font-size: 11px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  font-family: inherit;
}

/* "Tidy with AI" control under the paste box */
.pt-ai-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.pt-ai-btn {
  white-space: nowrap;
}
.pt-ai-btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}
.pt-ai-status {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-3);
}
.pt-ai-status.is-error {
  color: #b91c1c;
}
body.portal-ui-touch .pt-ai-btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
}

/* Share-link panel */
.pt-share-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: stretch;
  margin-bottom: 6px;
}
.pt-share-row .form-control {
  flex: 1 1 260px;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: #f8fafc;
}
.pt-share-row .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.pt-share-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
}
.pt-share-actions form {
  margin: 0;
}
body.portal-ui-touch .pt-share-row .btn,
body.portal-ui-touch .pt-share-actions .btn {
  min-height: 44px;
}
.pt-task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pt-tasks-board > .card-title {
  margin-bottom: 4px;
  padding-bottom: 14px;
  border-bottom: 1px solid #eef2f7;
}

.pt-task-row {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color .15s ease, box-shadow .18s ease;
}

.pt-task-row:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
}

.pt-task-row--done {
  background: linear-gradient(105deg, #f8fafc 0%, #ffffff 54%);
}

.pt-task-top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 14px;
  align-items: flex-start;
}

.pt-task-lead {
  flex-shrink: 0;
}

.pt-toggle-form {
  margin: 0;
}

.pt-check-line {
  display: flex;
  align-items: center;
  gap: 11px;
}

.pt-checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--brand);
  flex-shrink: 0;
}

.pt-status-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.pt-status-pill--open {
  background: #e2e8f0;
  color: #475569;
}

.pt-status-pill--done {
  background: #dcfce7;
  color: #166534;
}

.pt-status-pill--followup {
  background: #fef3c7;
  color: #92400e;
}

.pt-status-pill--addedby {
  background: #ede9fe;
  color: #5b21b6;
  max-width: 16ch;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pt-task-main {
  flex: 1 1 min(0, 100%);
  min-width: 0;
}

.pt-task-title {
  display: block;
  cursor: pointer;
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.55;
  color: var(--text);
}

.pt-task-row--done .pt-task-title {
  color: var(--text-3);
  text-decoration: line-through;
  font-weight: 500;
}

.pt-task-notes {
  margin-top: 10px;
  padding: 11px 14px;
  background: rgba(239, 246, 255, 0.92);
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: 9px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--text-2);
}

.pt-task-row--done .pt-task-notes {
  opacity: 0.78;
  color: var(--text-3);
}

.pt-task-aside {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
  align-self: center;
  position: relative;
}

.pt-delete-form {
  margin: 0;
  display: inline-flex;
}

.pt-delete-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  font-size: 16px;
  line-height: 1;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Edit lives in the action column (same row as delete on desktop) */
.pt-task-aside .pt-edit-details {
  margin: 0;
  padding: 0;
  border: none;
  width: auto;
  position: relative;
}

.pt-edit-summary {
  cursor: pointer;
  list-style: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  user-select: none;
  line-height: 1.2;
  transition: background .12s ease, border-color .12s ease;
}

.pt-edit-summary:hover {
  background: #e8eef5;
  border-color: #cbd5e1;
}

.pt-edit-details[open] > .pt-edit-summary {
  background: #eff6ff;
  border-color: rgba(37, 99, 235, 0.35);
  color: var(--brand);
}

.pt-edit-summary::-webkit-details-marker {
  display: none;
}

.pt-edit-summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.pt-edit-summary::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  opacity: 0.75;
  transition: transform 0.15s ease;
  transform: translateY(0.5px);
}

.pt-edit-details[open] > .pt-edit-summary::before {
  transform: rotate(90deg) translate(2px, -1px);
}

/* Edit panel: flows below triggers by default (touch / stacked layouts) */
.pt-edit-panel {
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
}

.pt-edit-panel form {
  display: flex;
  flex-direction: column;
  gap: 11px;
  max-width: 640px;
}

.pt-edit-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.pt-edit-label--mt {
  margin-top: 2px;
}

/* "Follow-up task" toggle inside the Edit panel */
.pt-edit-checkline {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.pt-edit-checkline input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

/* "Hold" button — defers a task to the next day and tags it Follow-up */
.pt-hold-form {
  margin: 0;
  display: inline-flex;
}
.pt-hold-btn {
  white-space: nowrap;
  line-height: 1.2;
  padding: 7px 14px;
  border-radius: 7px;
}

/* Subtle marker on rows tagged Follow-up */
.pt-task-row--followup {
  background: linear-gradient(105deg, #fffbeb 0%, #ffffff 60%);
}
.pt-task-row--done.pt-task-row--followup {
  background: linear-gradient(105deg, #f8fafc 0%, #ffffff 54%);
}

.pt-empty-hint {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-3);
  font-size: 14px;
  line-height: 1.6;
}
.pt-layout-switch {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-3);
}
.pt-layout-switch a {
  font-weight: 600;
}

/* Desktop layout preference: wider canvas, horizontal toolbar */
body.portal-ui-desktop .personal-tasks-page {
  max-width: min(1080px, 100%);
}
body.portal-ui-desktop .pt-intro-card {
  padding: 22px 26px;
}
body.portal-ui-desktop .pt-summary {
  align-items: center;
  gap: 28px;
}
body.portal-ui-desktop .pt-summary-desc {
  max-width: 52rem;
}
body.portal-ui-desktop .pt-actions {
  margin-top: 20px;
  gap: 12px;
}
body.portal-ui-desktop .pt-action-btn {
  white-space: nowrap;
  padding: 10px 20px;
  min-height: 42px;
  font-size: 13.5px;
  line-height: 1.2;
}
body.portal-ui-desktop .pt-task-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px 20px;
  align-items: center;
}
body.portal-ui-desktop .pt-task-aside {
  margin-left: 0;
  justify-self: end;
  align-self: center;
  flex-wrap: nowrap;
}
/* Keep each task on a single line — long titles truncate with an ellipsis
   (full text stays available via the title="" tooltip and the Edit panel). */
body.portal-ui-desktop .pt-task-title {
  font-size: 15px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.portal-ui-desktop .pt-delete-btn {
  min-width: 36px;
  min-height: 34px;
  font-size: 14px;
  padding: 0 8px;
}
body.portal-ui-desktop .pt-checkbox {
  width: 19px;
  height: 19px;
}
body.portal-ui-desktop .pt-edit-panel form {
  max-width: none;
}
body.portal-ui-desktop .pt-task-row {
  padding: 16px 20px;
}

/* Wide desktop + desktop UI mode: pop the edit form out so the row stays compact */
@media (min-width: 641px) {
  /* Title and work-notes share the one row; notes show as a muted "· …" tail
     and truncate before the title does. Full text is on hover (title="") and
     fully editable in the Edit panel. */
  body.portal-ui-desktop .pt-task-main {
    display: flex;
    align-items: baseline;
    min-width: 0;
  }
  body.portal-ui-desktop .pt-task-title {
    flex: 0 1 auto;
    min-width: 3ch;
  }
  body.portal-ui-desktop .pt-task-notes {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-3);
  }
  body.portal-ui-desktop .pt-task-notes::before {
    content: '·';
    margin: 0 0.55em;
    opacity: 0.5;
    font-weight: 700;
  }

  body.portal-ui-desktop .pt-task-row:has(.pt-edit-details[open]) {
    z-index: 8;
  }
  body.portal-ui-desktop .pt-edit-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    width: min(440px, 78vw);
    margin-top: 0;
    padding: 18px;
    padding-top: 18px;
    border-top: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
    z-index: 10;
  }
}

/* Touch layout preference — app-like primary actions strip (also works on tablets) */
body.portal-ui-touch .personal-tasks-page {
  -webkit-tap-highlight-color: rgba(37, 99, 235, 0.12);
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}

body.portal-ui-touch .personal-tasks-page > .pt-intro-card {
  border-radius: 18px;
  border: none;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.09);
}

body.portal-ui-touch .personal-tasks-page > .card.pt-panel {
  border-radius: 18px;
  border: none;
  box-shadow: 0 6px 28px rgba(15, 23, 42, 0.08);
}

body.portal-ui-touch .pt-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding: 6px 0 14px;
  margin-inline: -2px;
  scrollbar-width: none;
}

body.portal-ui-touch .pt-actions::-webkit-scrollbar {
  display: none;
  height: 0;
}

body.portal-ui-touch .pt-action-btn {
  flex: 0 0 auto;
  scroll-snap-align: start;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

body.portal-ui-touch .pt-action-btn.btn-secondary {
  background: rgba(255, 255, 255, 0.88);
}

body.portal-ui-touch .personal-tasks-page textarea.form-control,
body.portal-ui-touch .personal-tasks-page input.form-control,
body.portal-ui-touch .personal-tasks-page input[type="date"] {
  font-size: 16px;
}

body.portal-ui-touch .pt-summary {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

body.portal-ui-touch .pt-summary-progress {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  margin-top: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  align-self: flex-start;
}

body.portal-ui-touch .pt-summary-progress-lbl {
  flex-basis: auto;
  margin-top: 0;
  padding-left: 6px;
  font-size: 10px;
  letter-spacing: 0.06em;
  opacity: 0.92;
}

body.portal-ui-touch .pt-summary-progress-num {
  font-size: 24px;
}

body.portal-ui-touch .pt-summary-desc {
  line-height: 1.52;
}

body.portal-ui-touch .pt-task-row {
  border-radius: 16px;
  border: none;
  box-shadow: 0 2px 14px rgba(15, 23, 42, 0.07);
}

body.portal-ui-touch .pt-task-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px 12px;
  align-items: start;
}

body.portal-ui-touch .pt-task-aside {
  margin-left: 0;
  align-self: start;
}

body.portal-ui-touch .pt-task-title {
  font-size: 15px;
  line-height: 1.42;
}

body.portal-ui-touch .pt-edit-summary {
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 11px;
}

body.portal-ui-touch .pt-hold-btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 11px;
}

body.portal-ui-touch .personal-tasks-page .pt-tasks-board.card {
  background: transparent;
  border: none;
  box-shadow: none;
}

body.portal-ui-touch .personal-tasks-page .pt-tasks-board > .card-title {
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom-color: transparent;
}

body.portal-ui-touch .pt-task-list {
  gap: 10px;
}

/* Tablets in touch preference: bring the board back as a surfaced card */
@media (min-width: 641px) {
  body.portal-ui-touch .personal-tasks-page .pt-tasks-board.card {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 6px 28px rgba(15, 23, 42, 0.08);
    border-radius: 16px !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
    padding-top: 8px !important;
  }

  body.portal-ui-touch .personal-tasks-page .pt-tasks-board > .card-title {
    position: static;
    margin: 0 0 12px !important;
    padding: 6px 0 12px !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border-bottom: 1px solid #eef2f7;
    letter-spacing: normal;
    font-size: 15px;
    font-weight: 700;
    text-transform: none;
    color: var(--text);
  }
}

@media (max-width: 640px) {
  .personal-tasks-page {
    max-width: 100%;
    margin: 0;
    padding-bottom: calc(36px + env(safe-area-inset-bottom, 0px));
    background:
      radial-gradient(1200px 400px at 50% -8%, rgba(37, 99, 235, 0.08), transparent 55%),
      linear-gradient(180deg, #e7ecf8 0%, var(--bg) 38%);
  }

  /* Intro + panels read as layered cards */
  .personal-tasks-page > .pt-intro-card {
    padding: 16px;
    margin-bottom: 14px !important;
    border: none;
    border-radius: 20px;
    box-shadow: 0 10px 42px rgba(15, 23, 42, 0.1);
  }

  .personal-tasks-page .pt-panel.card {
    border-radius: 18px !important;
    border: none;
    padding: 16px !important;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.09);
  }

  .personal-tasks-page .card-title {
    font-size: 16px;
  }

  .personal-tasks-page .pt-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding: 4px 0 12px;
    margin-inline: -2px;
    scrollbar-width: none;
  }

  .personal-tasks-page .pt-actions::-webkit-scrollbar {
    display: none;
    height: 0;
  }

  .personal-tasks-page .pt-action-btn {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 48px;
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.22;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  }

  .personal-tasks-page .pt-action-btn.btn-secondary {
    background: rgba(255, 255, 255, 0.92);
  }

  .personal-tasks-page .pt-summary-progress {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    flex-wrap: wrap;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    align-self: flex-start;
    margin-top: 0 !important;
  }

  .personal-tasks-page .pt-summary-progress-lbl {
    flex-basis: auto !important;
    margin-top: 0 !important;
    padding-left: 6px;
  }

  .personal-tasks-page .pt-summary {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .personal-tasks-page .pt-summary-date {
    font-size: clamp(1.375rem, 5vw + 0.85rem, 1.625rem);
  }

  .personal-tasks-page .pt-summary-desc {
    margin-top: 8px;
    font-size: 13px;
  }

  .personal-tasks-page textarea.form-control,
  .personal-tasks-page input.form-control,
  .personal-tasks-page input[type="date"] {
    font-size: 16px;
    border-radius: 12px;
  }

  .personal-tasks-page .pt-stack-form button.btn-primary {
    width: 100%;
    justify-content: center;
    border-radius: 12px;
    min-height: 48px;
    font-size: 15px;
  }

  /* Task board: detached list floating on tinted canvas */
  .personal-tasks-page .pt-tasks-board.card {
    background: transparent;
    border: none;
    box-shadow: none;
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-bottom: 0 !important;
  }

  .personal-tasks-page .pt-tasks-board > .card-title {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: 0 0 10px !important;
    padding: 10px max(12px, env(safe-area-inset-left))
             12px max(12px, env(safe-area-inset-right));
    padding-bottom: 12px !important;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-2);
    background: rgba(241, 245, 251, 0.85);
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.75);
    border-radius: 0 !important;
  }

  /* One compact row per task — checkbox · title · actions */
  .personal-tasks-page .pt-task-list {
    gap: 10px;
  }

  .personal-tasks-page .pt-task-row {
    border: none !important;
    border-radius: 16px !important;
    padding: 12px 14px !important;
    box-shadow: 0 2px 16px rgba(15, 23, 42, 0.08);
    transition: transform 0.12s ease, box-shadow 0.15s ease;
  }

  .personal-tasks-page .pt-task-row--done {
    opacity: 0.92;
  }

  .personal-tasks-page .pt-task-row:active {
    transform: scale(0.992);
    box-shadow: 0 1px 10px rgba(15, 23, 42, 0.06);
  }

  .personal-tasks-page .pt-task-top {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px 12px;
    align-items: start;
  }

  .personal-tasks-page .pt-task-main {
    min-width: 0;
    padding-top: 1px;
  }

  .personal-tasks-page .pt-task-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.38;
    padding-top: 1px;
  }

  .personal-tasks-page .pt-task-notes {
    margin-top: 10px;
    border-radius: 12px;
    font-size: 13px;
    padding: 10px 12px;
  }

  .personal-tasks-page .pt-task-aside {
    margin-left: 0;
    gap: 6px;
    align-self: start;
    flex-shrink: 0;
  }

  .personal-tasks-page .pt-check-line {
    gap: 8px;
  }

  .personal-tasks-page .pt-status-pill {
    padding: 3px 8px;
    font-size: 10px;
    letter-spacing: 0.07em;
  }

  .personal-tasks-page .pt-edit-summary {
    min-height: 44px;
    padding-left: 12px;
    padding-right: 14px;
    border-radius: 11px;
  }

  .personal-tasks-page .pt-delete-btn {
    border-radius: 11px !important;
  }

  body.portal-ui-desktop .pt-task-top {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px 12px;
    align-items: start;
  }

  body.portal-ui-desktop .pt-task-aside {
    justify-self: end;
    width: auto;
    align-self: start;
    margin-left: 0;
  }
}

@media (pointer: coarse) {
  .personal-tasks-page .pt-checkbox {
    width: 23px;
    height: 23px;
  }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .two-col { grid-template-columns: 1fr; }
  .task-row { grid-template-columns: 24px 1fr 100px 80px; }
  .task-row > *:nth-child(n+4) { display: none; }
  .task-row > *:nth-child(4)   { display: flex; }
  .main-content {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
}

/* ── Page loader overlay ──────────────────────────────────── */
#page-loader {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(255,255,255,.88);
  align-items: center; justify-content: center;
  flex-direction: column; gap: 14px;
  backdrop-filter: blur(2px);
}
#page-loader .pl-spinner {
  width: 44px; height: 44px;
  border: 4px solid #e2e8f0;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
#page-loader .pl-text {
  color: var(--text-2); font-size: 14px; font-weight: 600;
}
#page-loader .pl-sub {
  color: var(--text-3); font-size: 12px; margin-top: -8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { padding: 0; }
  .report-page { max-width: 100%; }
}
