/* Client portal: app bar + sidebar + toolbar + work area ("operate mode"), the dashboard
   widgets, and the signed-out auth layout. Depends on the theme's tokens and the core
   plugin's form styles. */

.tfm-portal { --p-bg: #F2F4F0; --p-card: #FFFFFF; --p-line: #E3E6E0; --p-radius: 12px; --p-shadow: 0 1px 2px rgba(26,54,48,.04), 0 10px 28px -18px rgba(26,54,48,.22); --p-appbar: 64px; background: var(--p-bg); min-height: 100vh; }
.tfm-portal h1, .tfm-portal h2, .tfm-portal h3 { text-wrap: balance; }
.tfm-portal table, .tfm-portal .tfm-kpi__value, .tfm-portal .tfm-stat__value, .tfm-portal .tfm-balance__amount, .tfm-portal .tfm-donut__center, .tfm-portal .tfm-bars__value { font-variant-numeric: tabular-nums lining-nums; }

/* ---------- App bar ---------- */
.tfm-app { min-height: 100vh; display: flex; flex-direction: column; }
.tfm-appbar { position: sticky; top: 0; z-index: 70; display: flex; align-items: center; gap: .75rem; height: var(--p-appbar); padding: 0 1rem 0 0; background: var(--tfm-green); color: var(--tfm-cream); }
.tfm-appbar__brand { display: inline-flex; align-items: center; gap: .7rem; height: 100%; width: 260px; padding: 0 1.25rem; color: var(--tfm-cream); text-decoration: none; font-family: var(--tfm-serif); font-size: 1.3rem; font-weight: 500; letter-spacing: -.01em; background: var(--tfm-green-dark); flex: none; }
.tfm-appbar__brand .tfm-mark { width: 26px; height: 26px; filter: brightness(1.35); }
.tfm-appbar__menu { background: none; border: 0; color: var(--tfm-cream); width: 44px; height: 44px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.tfm-appbar__menu:hover { background: rgba(255,255,255,.1); }
.tfm-appbar__menu .tfm-icon, .tfm-iconbtn .tfm-icon { width: 22px; height: 22px; flex: none; }
.tfm-appbar__tag { font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tfm-sage); }
.tfm-appbar__actions { margin-left: auto; display: flex; align-items: center; gap: .35rem; }
.tfm-iconbtn { position: relative; width: 40px; height: 40px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--tfm-cream); background: rgba(255,255,255,.08); text-decoration: none; transition: background .15s ease; }
.tfm-iconbtn:hover { background: rgba(255,255,255,.16); color: var(--tfm-cream); }
.tfm-iconbtn.has-dot::after { content: ""; position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: #E8B04B; box-shadow: 0 0 0 2px var(--tfm-green); }
.tfm-iconbtn--ghost { background: none; color: var(--tfm-muted); width: 34px; height: 34px; }
.tfm-iconbtn--ghost:hover { background: var(--p-bg); color: var(--tfm-green-dark); }
.tfm-usermenu { position: relative; margin-left: .5rem; }
.tfm-usermenu > summary { list-style: none; display: flex; align-items: center; gap: .7rem; padding: .3rem .5rem .3rem .3rem; border-radius: 10px; cursor: pointer; }
.tfm-usermenu > summary::-webkit-details-marker { display: none; }
.tfm-usermenu > summary:hover, .tfm-usermenu[open] > summary { background: rgba(255,255,255,.1); }
.tfm-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--tfm-sage); color: var(--tfm-green-dark); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .9rem; letter-spacing: .02em; flex: none; }
.tfm-usermenu__text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; max-width: 220px; }
.tfm-usermenu__text strong { font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tfm-usermenu__text small { font-size: .78rem; color: var(--tfm-sage); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tfm-usermenu__chev { width: 18px; height: 18px; opacity: .8; transition: transform .15s ease; }
.tfm-usermenu[open] .tfm-usermenu__chev { transform: rotate(180deg); }
.tfm-usermenu__panel { position: absolute; right: 0; top: calc(100% + 8px); width: 260px; background: var(--p-card); color: var(--tfm-charcoal); border-radius: var(--p-radius); box-shadow: 0 18px 40px -16px rgba(26,54,48,.35), 0 0 0 1px var(--p-line); padding: .5rem; z-index: 80; }
.tfm-usermenu__who { padding: .6rem .75rem .75rem; border-bottom: 1px solid var(--p-line); margin-bottom: .35rem; display: flex; flex-direction: column; line-height: 1.3; }
.tfm-usermenu__who strong { color: var(--tfm-green-dark); }
.tfm-usermenu__who small { color: var(--tfm-muted); font-size: .8rem; }
.tfm-usermenu__panel a, .tfm-usermenu__panel button { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .6rem .75rem; border: 0; background: none; border-radius: 8px; color: var(--tfm-charcoal); font: inherit; font-size: .95rem; text-decoration: none; text-align: left; cursor: pointer; }
.tfm-usermenu__panel a:hover, .tfm-usermenu__panel button:hover { background: var(--p-bg); color: var(--tfm-green-dark); }
.tfm-usermenu__panel form { margin: .35rem 0 0; padding-top: .35rem; border-top: 1px solid var(--p-line); }
.tfm-usermenu__panel .tfm-icon { color: var(--tfm-green); }

/* ---------- Sidebar ---------- */
.tfm-app__row { display: grid; grid-template-columns: 260px minmax(0, 1fr); flex: 1; }
.tfm-side { position: sticky; top: var(--p-appbar); height: calc(100vh - var(--p-appbar)); display: flex; flex-direction: column; background: var(--p-card); border-right: 1px solid var(--p-line); padding: .9rem .75rem; overflow-y: auto; }
.tfm-side__nav { display: flex; flex-direction: column; gap: .2rem; }
.tfm-side__item { display: flex; align-items: center; gap: .85rem; min-height: 46px; padding: .55rem .85rem; border-radius: 10px; color: var(--tfm-charcoal); text-decoration: none; font-weight: 500; font-size: .98rem; cursor: pointer; list-style: none; transition: background .15s ease, color .15s ease; }
.tfm-side__item::-webkit-details-marker { display: none; }
.tfm-side__item .tfm-icon { width: 21px; height: 21px; flex: none; color: var(--tfm-muted); }
.tfm-side__item:hover { background: var(--p-bg); color: var(--tfm-green-dark); }
.tfm-side__item:hover .tfm-icon { color: var(--tfm-green); }
.tfm-side__item.is-active { background: var(--tfm-sage-light); color: var(--tfm-green-dark); box-shadow: inset 3px 0 0 var(--tfm-green); }
.tfm-side__item.is-active .tfm-icon { color: var(--tfm-green); }
.tfm-side__label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tfm-side__chev { width: 16px; height: 16px; color: #A3AAA6; transition: transform .15s ease; }
.tfm-side__group[open] > summary .tfm-side__chev { transform: rotate(90deg); }
.tfm-side__sub { list-style: none; margin: .15rem 0 .35rem; padding: 0 0 0 2.35rem; display: flex; flex-direction: column; gap: .1rem; }
.tfm-side__sub a { display: block; padding: .5rem .85rem; border-radius: 8px; color: var(--tfm-muted); text-decoration: none; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tfm-side__sub a:hover { background: var(--p-bg); color: var(--tfm-green-dark); }
.tfm-side__sub a[aria-current="page"] { background: var(--tfm-sage-light); color: var(--tfm-green-dark); font-weight: 600; }
.tfm-side__nav .tfm-pill { margin-left: auto; }
.tfm-side__card { margin-top: auto; padding: 1.1rem 1rem 1rem; border-radius: var(--p-radius); background: linear-gradient(180deg, #F6F8F5 0%, #EDF2EE 100%); text-align: center; }
.tfm-side__art { width: 100%; height: auto; margin-bottom: .25rem; }
.tfm-side__card p { margin: 0 0 .75rem; font-size: .92rem; color: var(--tfm-green-dark); font-weight: 500; }
.tfm-side__card .tfm-btn { width: 100%; justify-content: center; }
.tfm-side__mail { display: block; margin-top: .6rem; font-size: .8rem; color: var(--tfm-muted); text-decoration: none; word-break: break-all; }
.tfm-side__mail:hover { text-decoration: underline; }
.tfm-side__scrim { display: none; }

/* Rail mode (desktop toggle): icons only. */
@media (min-width: 961px) {
	.tfm-app.is-rail .tfm-app__row { grid-template-columns: 76px minmax(0, 1fr); }
	.tfm-app.is-rail .tfm-appbar__brand { width: 76px; padding: 0; justify-content: center; }
	.tfm-app.is-rail .tfm-appbar__name, .tfm-app.is-rail .tfm-side__label, .tfm-app.is-rail .tfm-side__chev, .tfm-app.is-rail .tfm-side__sub, .tfm-app.is-rail .tfm-side__card, .tfm-app.is-rail .tfm-side__nav .tfm-pill { display: none; }
	.tfm-app.is-rail .tfm-side { padding: .9rem .6rem; }
	.tfm-app.is-rail .tfm-side__item { justify-content: center; padding: .6rem; }
}

/* ---------- Toolbar + main ---------- */
.tfm-app__body { display: flex; flex-direction: column; min-width: 0; }
.tfm-toolbar { display: flex; align-items: center; gap: 1.25rem; min-height: 68px; padding: .75rem clamp(1rem, 3vw, 2rem); background: var(--p-card); border-bottom: 1px solid var(--p-line); }
.tfm-toolbar__title { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.tfm-toolbar__title h1 { font-family: var(--tfm-sans); font-size: 1.35rem; font-weight: 600; letter-spacing: -.01em; margin: 0; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--tfm-green-dark); }
.tfm-toolbar__crumb { font-size: .9rem; color: var(--tfm-muted); text-decoration: none; white-space: nowrap; }
.tfm-toolbar__crumb:hover { text-decoration: underline; }
.tfm-toolbar__crumb::after { content: "/"; margin-left: .75rem; opacity: .5; }
.tfm-toolbar__hint { margin: 0; padding-left: 1.25rem; border-left: 1px solid var(--p-line); font-size: .92rem; color: var(--tfm-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tfm-toolbar__hint span { color: var(--tfm-green-dark); font-weight: 500; }
.tfm-toolbar__actions { margin-left: auto; display: flex; gap: .5rem; }
.tfm-app__main { flex: 1; width: 100%; max-width: 1480px; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2rem) 3rem; display: flex; flex-direction: column; gap: 1.25rem; }
.tfm-app__main > * { margin: 0; }
.tfm-app__footer { padding: 1rem clamp(1rem, 3vw, 2rem) 1.5rem; font-size: .85rem; color: var(--tfm-muted); }
.tfm-app__footer p { margin: 0; }
.tfm-app__footer a { color: inherit; }

@media (max-width: 960px) {
	.tfm-appbar { padding-right: .5rem; }
	.tfm-appbar__brand { width: auto; flex: 1; min-width: 0; background: none; padding: 0 .5rem; font-size: 1.1rem; }
	.tfm-appbar__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.tfm-appbar__actions { flex: none; gap: .25rem; }
	.tfm-usermenu { margin-left: .15rem; }
	.tfm-usermenu > summary { padding: .2rem; }
	.tfm-appbar__tag { display: none; }
	.tfm-appbar__menu { order: -1; margin-left: .25rem; }
	.tfm-usermenu__text, .tfm-usermenu__chev { display: none; }
	.tfm-app__row { grid-template-columns: minmax(0, 1fr); }
	.tfm-side { position: fixed; top: var(--p-appbar); bottom: 0; left: 0; width: min(300px, 86vw); height: auto; z-index: 60; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--tfm-shadow); }
	.tfm-app.is-nav-open .tfm-side { transform: none; }
	.tfm-side__scrim { display: block; position: fixed; inset: var(--p-appbar) 0 0 0; z-index: 55; background: rgba(26,54,48,.45); }
	.tfm-side__scrim[hidden] { display: none; }
	.tfm-toolbar { flex-wrap: wrap; gap: .5rem 1rem; }
	.tfm-toolbar__hint { display: none; }
	.tfm-toolbar__actions .tfm-btn { display: none; }
}

/* ---------- Common ---------- */
.tfm-notice { padding: .9rem 1.1rem; border-radius: 10px; font-size: .95rem; border: 1px solid; }
.tfm-notice--success { background: #E4EBE6; border-color: #B7C7BF; color: #1A3630; }
.tfm-notice--info { background: var(--p-card); border-color: var(--p-line); color: #343A39; }
.tfm-notice--error { background: var(--tfm-rose-bg); border-color: #E3B7B1; color: var(--tfm-rose); }
.tfm-notice--compact { padding: .5rem .9rem; font-size: .85rem; }
.tfm-badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; letter-spacing: .02em; background: #E9E6DF; color: #5B6462; white-space: nowrap; }
.tfm-badge--sent, .tfm-badge--active, .tfm-badge--partial, .tfm-badge--proposed { background: var(--tfm-sage-light); color: var(--tfm-green-dark); }
.tfm-badge--approved, .tfm-badge--paid, .tfm-badge--complete { background: var(--tfm-green); color: var(--tfm-cream); }
.tfm-badge--declined, .tfm-badge--void, .tfm-badge--expired { background: var(--tfm-rose-bg); color: var(--tfm-rose); }
.tfm-badge--on_hold { background: var(--tfm-amber-bg); color: var(--tfm-amber); }
.tfm-tag { display: inline-block; font-size: .72rem; padding: .1rem .45rem; border-radius: 3px; background: #E9E6DF; color: #5B6462; vertical-align: middle; }
.tfm-card { background: var(--p-card); border-radius: var(--p-radius); border-color: var(--p-line); }
.tfm-empty { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.4rem; color: var(--tfm-muted); font-size: .95rem; }
.tfm-empty p { margin: 0; }
.tfm-empty .tfm-icon { color: var(--tfm-green); flex: none; }
.tfm-empty--card { background: var(--p-card); border: 1px dashed var(--p-line); border-radius: var(--p-radius); }
.tfm-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 1.4rem; height: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: var(--tfm-green); color: var(--tfm-cream); font-size: .75rem; font-weight: 600; line-height: 1; }
.tfm-strong { font-weight: 600; color: var(--tfm-green-dark); }
.tfm-grid { display: grid; gap: 1.25rem; align-items: stretch; }
.tfm-grid--wide-narrow { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .tfm-grid--wide-narrow { grid-template-columns: minmax(0, 1fr); } }

/* ---------- KPI boxes ---------- */
.tfm-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem; }
.tfm-kpi { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.3rem 1.4rem; background: var(--p-card); border: 1px solid var(--p-line); border-radius: var(--p-radius); text-decoration: none; color: inherit; transition: box-shadow .15s ease, transform .15s ease; }
.tfm-kpi:hover { box-shadow: var(--p-shadow); transform: translateY(-1px); }
.tfm-kpi__text { display: flex; flex-direction: column; min-width: 0; gap: .1rem; }
.tfm-kpi__value { font-size: 1.85rem; font-weight: 600; line-height: 1.1; color: var(--tfm-green-dark); letter-spacing: -.02em; }
.tfm-kpi__label { font-size: .92rem; color: var(--tfm-charcoal); font-weight: 500; }
.tfm-kpi__sub { font-size: .8rem; color: var(--tfm-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tfm-kpi__icon { width: 54px; height: 54px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--tfm-sage-light); color: var(--tfm-green); }
.tfm-kpi__icon .tfm-icon { width: 24px; height: 24px; }
.tfm-kpi--overdue .tfm-kpi__value, .tfm-kpi--overdue .tfm-kpi__sub { color: var(--tfm-amber); }
.tfm-kpi--overdue .tfm-kpi__icon { background: var(--tfm-amber-bg); color: var(--tfm-amber); }
.tfm-kpis--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tfm-kpis--3 .tfm-kpi { flex-direction: column; align-items: flex-start; gap: .25rem; }
@media (max-width: 1100px) { .tfm-kpis, .tfm-kpis--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .tfm-kpis, .tfm-kpis--3 { grid-template-columns: 1fr; } }

/* ---------- Panels ---------- */
.tfm-panel { background: var(--p-card); border: 1px solid var(--p-line); border-radius: var(--p-radius); display: flex; flex-direction: column; min-width: 0; }
.tfm-panel__head { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.4rem; border-bottom: 1px solid var(--p-line); }
.tfm-panel__head h2 { font-family: var(--tfm-sans); font-size: 1.05rem; font-weight: 600; letter-spacing: 0; margin: 0; color: var(--tfm-green-dark); }
.tfm-panel__head > :last-child:not(h2) { margin-left: auto; }
.tfm-panel__meta { font-size: .82rem; color: var(--tfm-muted); }
.tfm-panel__head--bare { padding: 0 0 .75rem; border: 0; }
.tfm-panel__head--bare h2 { font-family: var(--tfm-serif); font-size: 1.5rem; font-weight: 500; }
.tfm-panel__body { padding: 1.25rem 1.4rem 1.4rem; flex: 1; }
.tfm-panel__foot { margin: 1rem 0 0; font-size: .85rem; color: var(--tfm-muted); text-align: center; }
.tfm-minilist { list-style: none; margin: 1.25rem 0 0; padding: 1rem 0 0; border-top: 1px solid var(--p-line); display: flex; flex-direction: column; gap: .15rem; }
.tfm-minilist a { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: .75rem; padding: .5rem .5rem; margin: 0 -.5rem; border-radius: 8px; text-decoration: none; color: inherit; font-size: .92rem; }
.tfm-minilist a:hover { background: var(--p-bg); }
.tfm-minilist strong { display: block; color: var(--tfm-green-dark); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tfm-minilist small { display: block; color: var(--tfm-muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tfm-minilist__amt { font-weight: 600; color: var(--tfm-green-dark); white-space: nowrap; }
.tfm-panel__sub { padding: .9rem 1.4rem .25rem; border-top: 1px solid var(--p-line); }
.tfm-panel__sub h3 { font-family: var(--tfm-sans); font-size: .82rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--tfm-muted); margin: 0; }
.tfm-portal__section { margin-top: 0; }

/* Tabs (segmented) */
.tfm-tabs { display: inline-flex; border: 1px solid var(--p-line); border-radius: 8px; overflow: hidden; }
.tfm-tabs [role="tab"] { background: none; border: 0; border-left: 1px solid var(--p-line); padding: .45rem .9rem; font: inherit; font-size: .78rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--tfm-muted); cursor: pointer; }
.tfm-tabs [role="tab"]:first-child { border-left: 0; }
.tfm-tabs [role="tab"]:hover { color: var(--tfm-green-dark); background: var(--p-bg); }
.tfm-tabs [role="tab"][aria-selected="true"] { background: var(--tfm-sage-light); color: var(--tfm-green-dark); }
.tfm-tabs [role="tab"]:focus-visible { outline: 2px solid var(--tfm-green); outline-offset: -2px; }

/* Stats row + legend */
.tfm-stats { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem 2.25rem; margin-bottom: 1rem; }
.tfm-stat { display: flex; flex-direction: column; gap: .15rem; }
.tfm-stat__label { font-size: .8rem; color: var(--tfm-muted); }
.tfm-stat__value { display: inline-flex; align-items: baseline; gap: .5rem; font-size: 1.35rem; font-weight: 600; color: var(--tfm-green-dark); letter-spacing: -.01em; line-height: 1.1; }
.tfm-stat--lead { margin-bottom: 1rem; }
.tfm-delta { display: inline-flex; align-items: center; gap: .1rem; font-size: .82rem; font-weight: 600; }
.tfm-delta--up { color: #2E7D5B; }
.tfm-delta--down { color: #B9770E; }
.tfm-delta--none { color: var(--tfm-muted); font-weight: 400; }
.tfm-delta__icon { width: 14px; height: 14px; }
.tfm-legend { list-style: none; margin: 0 0 0 auto; padding: 0; display: flex; gap: 1.25rem; font-size: .8rem; color: var(--tfm-muted); }
.tfm-legend li { display: inline-flex; align-items: center; gap: .45rem; }
.tfm-legend__line { width: 22px; height: 3px; border-radius: 2px; background: var(--tfm-green); }
.tfm-legend__line--muted { background: #C9CEC8; }

/* Line chart */
.tfm-line { position: relative; }
.tfm-line__svg { width: 100%; max-width: 100%; height: auto; display: block; overflow: visible; font-family: var(--tfm-sans); }
.tfm-line__grid { stroke: #EEF0EC; stroke-width: 1; }
.tfm-line__ylabel { font-size: 11px; fill: #8A918D; text-anchor: end; }
.tfm-line__xlabel { font-size: 11px; fill: #8A918D; text-anchor: middle; }
.tfm-line__path { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.tfm-line__path--main { stroke: var(--tfm-green); }
.tfm-line__path--muted { stroke: #C9CEC8; stroke-width: 2; }
.tfm-line__dot { fill: #fff; stroke: var(--tfm-green); stroke-width: 2; opacity: 0; transition: opacity .12s ease; cursor: crosshair; }
.tfm-line__dot.is-on, .tfm-line__dot:focus { opacity: 1; outline: none; }
.tfm-line__dot:last-of-type { opacity: 1; }
.tfm-line__cursor { stroke: #B7C7BF; stroke-width: 1; stroke-dasharray: 3 4; }
.tfm-line__cursor[hidden] { display: none; }
.tfm-line__tip { position: absolute; z-index: 5; pointer-events: none; background: #fff; border-radius: 8px; box-shadow: 0 10px 30px -10px rgba(26,54,48,.35), 0 0 0 1px var(--p-line); padding: .5rem .75rem; font-size: .82rem; min-width: 150px; }
.tfm-line__tip strong { display: block; color: var(--tfm-green-dark); margin-bottom: .25rem; }
.tfm-line__tip-row { display: flex; justify-content: space-between; gap: 1rem; color: var(--tfm-charcoal); }
.tfm-line__tip-row em { font-style: normal; color: var(--tfm-muted); padding-left: .9rem; position: relative; }
.tfm-line__tip-row em::before { content: ""; position: absolute; left: 0; top: .45em; width: 8px; height: 3px; border-radius: 2px; background: #C9CEC8; }
.tfm-line__tip-row--main em::before { background: var(--tfm-green); }

/* Donut */
.tfm-donut { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 1.25rem; align-items: center; }
.tfm-donut__ring { position: relative; width: 170px; height: 170px; }
.tfm-donut__svg { width: 100%; height: 100%; display: block; }
.tfm-donut__track { fill: none; stroke: #EEF0EC; stroke-width: 12; }
.tfm-donut__seg { fill: none; stroke-width: 12; stroke-linecap: round; }
.tfm-donut__center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.tfm-donut__center strong { font-size: 1.6rem; font-weight: 600; color: var(--tfm-green-dark); letter-spacing: -.02em; line-height: 1; }
.tfm-donut__center span { font-size: .75rem; color: var(--tfm-muted); margin-top: .3rem; }
.tfm-donut__legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .8rem; }
.tfm-donut__legend li { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "sw name" "sw val"; column-gap: .75rem; align-items: start; }
.tfm-donut__swatch { grid-area: sw; width: 4px; height: 2.4rem; border-radius: 2px; margin-top: .15rem; }
.tfm-donut__name { grid-area: name; font-weight: 600; color: var(--tfm-green-dark); font-size: .98rem; }
.tfm-donut__val { grid-area: val; color: var(--tfm-muted); font-size: .9rem; }
@media (max-width: 420px) { .tfm-donut { grid-template-columns: 1fr; justify-items: center; } }

/* Horizontal bars */
.tfm-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.tfm-bars li { display: grid; grid-template-columns: 2.4rem minmax(0, 1fr) 2.2rem; align-items: center; gap: .75rem; font-size: .82rem; }
.tfm-bars__label { color: var(--tfm-muted); }
.tfm-bars__track { height: 12px; border-radius: 6px; background: #EEF0EC; overflow: hidden; }
.tfm-bars__fill { display: block; height: 100%; border-radius: 6px; background: var(--tfm-green); min-width: 2px; }
.tfm-bars__value { text-align: right; color: var(--tfm-green-dark); font-weight: 600; }

/* Progress */
.tfm-progress { display: inline-grid; grid-template-columns: minmax(120px, 1fr) auto; align-items: center; gap: .75rem; width: 100%; max-width: 320px; }
.tfm-progress__track { height: 8px; border-radius: 4px; background: #EEF0EC; overflow: hidden; }
.tfm-progress__fill { display: block; height: 100%; border-radius: 4px; background: var(--tfm-green); }
.tfm-progress--mid .tfm-progress__fill { background: #D9A441; }
.tfm-progress--low .tfm-progress__fill { background: #C96A5B; }
.tfm-progress__pct { font-size: .92rem; font-weight: 600; color: var(--tfm-green-dark); min-width: 2.6rem; text-align: right; }

/* Attention list + activity */
.tfm-todo { list-style: none; margin: 0; padding: 0; }
.tfm-todo__item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 1rem; padding: .95rem 1.4rem; border-bottom: 1px solid var(--p-line); }
.tfm-todo__item:last-child { border-bottom: 0; }
.tfm-todo__icon { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--tfm-sage-light); color: var(--tfm-green); }
.tfm-todo__text { display: flex; flex-direction: column; min-width: 0; }
.tfm-todo__text strong { font-weight: 600; color: var(--tfm-green-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tfm-todo__text small { font-size: .85rem; color: var(--tfm-muted); }
.tfm-todo__item.is-soon .tfm-todo__text small { color: var(--tfm-amber); font-weight: 500; }
.tfm-todo__item.is-overdue .tfm-todo__icon { background: var(--tfm-amber-bg); color: var(--tfm-amber); }
.tfm-todo__item.is-overdue .tfm-todo__text small { color: var(--tfm-amber); font-weight: 600; }
@media (max-width: 520px) { .tfm-todo__item { grid-template-columns: auto minmax(0, 1fr); } .tfm-todo__item .tfm-btn { grid-column: 2; justify-self: start; } }
.tfm-activity { list-style: none; margin: 0; padding: .25rem 0 .5rem; }
.tfm-activity li { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: .75rem; padding: .55rem 1.4rem; font-size: .92rem; }
.tfm-activity__when { color: var(--tfm-muted); font-size: .82rem; padding-top: .1rem; white-space: nowrap; }
.tfm-activity__when::after { content: " ago"; }

/* ---------- Page heads inside views ---------- */
.tfm-welcome { font-family: var(--tfm-serif); font-size: 1.35rem; color: var(--tfm-green-dark); margin: 0; max-width: 50ch; }
.tfm-page-intro { color: var(--tfm-muted); max-width: 60ch; margin: 0; }
.tfm-meta-row { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; font-size: .92rem; color: var(--tfm-muted); margin: 0; }
.tfm-head-split { display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; flex-wrap: wrap; }
.tfm-head-split .tfm-meta-row { margin: 0; }

/* ---------- Tables ---------- */
.tfm-table-wrap { overflow-x: auto; background: var(--p-card); border: 1px solid var(--p-line); border-radius: var(--p-radius); }
.tfm-table-wrap--flush { border: 0; border-radius: 0 0 var(--p-radius) var(--p-radius); }
.tfm-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tfm-table th, .tfm-table td { padding: .95rem 1.4rem; text-align: left; border-bottom: 1px solid var(--p-line); vertical-align: middle; }
.tfm-table thead th { font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; color: var(--tfm-muted); font-weight: 600; background: #FAFBF9; }
.tfm-table tbody tr:last-child td { border-bottom: 0; }
.tfm-table tbody tr:hover td { background: #FAFBF9; }
.tfm-table .num { text-align: right; white-space: nowrap; }
.tfm-table a { text-decoration: none; }
.tfm-table a:hover { text-decoration: underline; }
.tfm-table__action { text-align: right; white-space: nowrap; }
.tfm-table__index { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 6px; background: var(--p-bg); color: var(--tfm-muted); font-size: .85rem; font-weight: 600; margin-right: .8rem; vertical-align: middle; }
.tfm-table tfoot th, .tfm-table tfoot td { border-top: 1px solid var(--p-line); border-bottom: 0; font-weight: 600; }
.tfm-table__due th, .tfm-table__due td { font-size: 1.05rem; color: var(--tfm-green-dark); }
@media (max-width: 760px) {
	.tfm-table:not(.tfm-table--lines) thead { display: none; }
	.tfm-table:not(.tfm-table--lines) tr { display: block; padding: .5rem 0; border-bottom: 1px solid var(--p-line); }
	.tfm-table:not(.tfm-table--lines) td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border: 0; padding: .35rem 1.4rem; }
	.tfm-table:not(.tfm-table--lines) td[data-label]::before { content: attr(data-label); font-size: .78rem; color: var(--tfm-muted); flex: none; }
	.tfm-table__action { justify-content: flex-end; }
	.tfm-table__index { display: none; }
	.tfm-progress { max-width: 200px; }
}

/* ---------- Detail layouts ---------- */
.tfm-two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 860px) { .tfm-two-col { grid-template-columns: 1fr; } }
.tfm-proposal-body { margin-bottom: 1rem; }
.tfm-file-link { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.tfm-decision h3 { font-family: var(--tfm-sans); font-size: 1.05rem; font-weight: 600; letter-spacing: 0; margin-bottom: .75rem; }
.tfm-decision--approved { border-color: var(--tfm-sage); background: #F3F7F4; }
.tfm-decline { margin-top: 1rem; border-top: 1px solid var(--p-line); padding-top: .75rem; }
.tfm-decline summary { cursor: pointer; font-size: .95rem; color: var(--tfm-muted); }
.tfm-decline textarea { width: 100%; }
.tfm-remember label { display: flex; gap: .5rem; align-items: center; font-weight: 400; font-size: .95rem; }
.tfm-agree label { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; font-size: .9rem; color: var(--tfm-muted); }
.tfm-balance { text-align: right; }
.tfm-balance__label { display: block; font-size: .85rem; color: var(--tfm-muted); }
.tfm-balance__amount { font-size: 2.25rem; font-weight: 600; color: var(--tfm-green-dark); line-height: 1.1; letter-spacing: -.01em; }
.tfm-invoice__parties { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; font-size: .95rem; }
.tfm-invoice__parties p { margin: 0; }
.tfm-invoice__parties .tfm-invoice__party-label { font-size: .82rem; color: var(--tfm-muted); margin-bottom: .25rem; }
.tfm-invoice__notes { margin-top: 1rem; }
.tfm-invoice .tfm-table-wrap { border: 0; border-radius: 0; }
.tfm-invoice .tfm-table th:first-child, .tfm-invoice .tfm-table td:first-child { padding-left: 0; }
.tfm-invoice .tfm-table th:last-child, .tfm-invoice .tfm-table td:last-child { padding-right: 0; }
.tfm-dl { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1.5rem; margin: 0 0 1rem; font-size: .95rem; }
.tfm-dl dt { color: var(--tfm-muted); }
.tfm-dl dd { margin: 0; }
.tfm-upload { margin-top: 1.5rem; }
.tfm-upload h3 { font-family: var(--tfm-sans); font-size: 1.05rem; font-weight: 600; letter-spacing: 0; margin-bottom: .25rem; }
.tfm-form input[type="file"] { display: block; width: 100%; padding: .6rem; border: 1px dashed #B9C0B8; border-radius: 8px; background: #fff; font-size: .95rem; }
.tfm-form input[type="password"]:focus-visible { outline: none; }

/* ---------- Signed-out: split auth layout ---------- */
.tfm-auth { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); min-height: 100vh; }
.tfm-auth__brand { display: flex; flex-direction: column; justify-content: space-between; gap: 2rem; background: linear-gradient(180deg, rgba(26,54,48,.78) 0%, rgba(26,54,48,.9) 62%, rgba(26,54,48,.96) 100%), var(--tfm-auth-img, none) center / cover no-repeat, var(--tfm-green-dark); color: var(--tfm-sage-light); padding: clamp(1.5rem, 4vw, 3rem); }
.tfm-auth__logo { display: inline-flex; align-items: center; gap: .7rem; color: var(--tfm-cream); text-decoration: none; font-family: var(--tfm-serif); font-size: 1.4rem; font-weight: 500; }
.tfm-auth__logo .tfm-mark { filter: brightness(1.35); }
.tfm-auth__copy h2 { color: var(--tfm-cream); font-size: clamp(2rem, 3vw, 2.75rem); max-width: 14ch; }
.tfm-auth__copy ul { list-style: none; padding: 0; margin: 1.25rem 0 0; }
.tfm-auth__copy li { position: relative; padding-left: 1.5rem; margin-bottom: .6rem; font-size: 1.05rem; }
.tfm-auth__copy li::before { content: ""; position: absolute; left: 0; top: .6em; width: .8rem; height: .4rem; border-left: 1.5px solid var(--tfm-sage); border-bottom: 1.5px solid var(--tfm-sage); transform: rotate(-45deg); }
.tfm-auth__foot { font-size: .85rem; color: var(--tfm-sage); margin: 0; }
.tfm-auth__main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: clamp(1.5rem, 4vw, 3rem); background: #fff; }
.tfm-auth__card { width: min(26rem, 100%); }
.tfm-auth__card h1 { font-size: 2.25rem; margin-bottom: .35rem; }
.tfm-auth__card .tfm-form { margin-top: 1.5rem; }
.tfm-auth__main .tfm-notice { margin-bottom: 1.25rem; }
@media (max-width: 860px) { .tfm-auth { grid-template-columns: 1fr; } .tfm-auth__brand { min-height: 0; gap: 1rem; } .tfm-auth__copy ul, .tfm-auth__foot { display: none; } .tfm-auth__copy h2 { font-size: 1.5rem; margin: 0; } }

/* ---------- Messages ---------- */
.tfm-threads { list-style: none; margin: 0; padding: 0; background: var(--p-card); border: 1px solid var(--p-line); border-radius: var(--p-radius); }
.tfm-threads__item + .tfm-threads__item { border-top: 1px solid var(--p-line); }
.tfm-threads__item a { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 1rem; align-items: center; padding: 1rem 1.4rem; text-decoration: none; color: inherit; }
.tfm-threads__item a:hover { background: #FAFBF9; }
.tfm-threads__icon { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--tfm-sage-light); color: var(--tfm-green); }
.tfm-threads__text { display: flex; flex-direction: column; min-width: 0; }
.tfm-threads__text strong { color: var(--tfm-green-dark); font-weight: 600; }
.tfm-threads__text small { color: var(--tfm-muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tfm-threads__item.is-unread .tfm-threads__text small { color: var(--tfm-charcoal); font-weight: 500; }
.tfm-threads__meta { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; font-size: .8rem; color: var(--tfm-muted); }
.tfm-thread-wrap { background: var(--p-card); border: 1px solid var(--p-line); border-radius: var(--p-radius); display: flex; flex-direction: column; min-height: 60vh; }
.tfm-thread-scroll { flex: 1; overflow-y: auto; max-height: 62vh; padding: 1.25rem; }
.tfm-thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .9rem; }
.tfm-thread__day { align-self: center; font-size: .78rem; color: var(--tfm-muted); margin: .5rem 0; }
.tfm-thread__day span { padding: .2rem .7rem; border: 1px solid var(--p-line); border-radius: 999px; background: var(--p-bg); }
.tfm-msg { display: flex; gap: .75rem; align-items: flex-end; max-width: 78%; }
.tfm-msg--mine { align-self: flex-end; flex-direction: row-reverse; }
.tfm-avatar--sm { width: 30px; height: 30px; font-size: .8rem; flex: none; }
.tfm-msg--manager .tfm-avatar { background: var(--tfm-green); color: var(--tfm-cream); }
.tfm-msg__bubble { background: var(--p-bg); border: 1px solid var(--p-line); border-radius: 12px 12px 12px 3px; padding: .75rem .95rem; min-width: 0; }
.tfm-msg--mine .tfm-msg__bubble { background: var(--tfm-sage-light); border-color: var(--tfm-sage-light); border-radius: 12px 12px 3px 12px; }
.tfm-msg__meta { display: flex; gap: .6rem; align-items: baseline; font-size: .8rem; color: var(--tfm-muted); margin-bottom: .25rem; }
.tfm-msg__meta strong { color: var(--tfm-green-dark); font-weight: 600; }
.tfm-msg__body { font-size: .97rem; overflow-wrap: anywhere; }
.tfm-msg__body a { word-break: break-all; }
.tfm-msg__file { display: inline-flex; align-items: center; gap: .4rem; margin-top: .5rem; padding: .4rem .7rem; border: 1px solid var(--p-line); border-radius: 8px; background: #fff; font-size: .9rem; text-decoration: none; }
.tfm-msg__file small { color: var(--tfm-muted); }
.tfm-composer { border-top: 1px solid var(--p-line); padding: 1rem 1.25rem 1.1rem; margin: 0; }
.tfm-composer textarea { width: 100%; min-height: 5.5rem; }
.tfm-composer__row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: .6rem; flex-wrap: wrap; }
.tfm-composer__attach { position: relative; display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; font-weight: 500; color: var(--tfm-green); cursor: pointer; }
.tfm-form .tfm-composer__attach input[type="file"] { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; margin: 0; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }
.tfm-composer__attach:focus-within { outline: 2px solid var(--tfm-green); outline-offset: 3px; border-radius: 2px; }
.tfm-composer__filename { font-size: .85rem; color: var(--tfm-muted); }
.tfm-composer .wp-element-button { gap: .5rem; }
@media (max-width: 600px) { .tfm-msg { max-width: 94%; } .tfm-thread-scroll { max-height: none; } }

@media (prefers-reduced-motion: reduce) { .tfm-portal * { transition: none !important; } }
