/* Powerline UI, "Graphite Soft" v1.0: component recipes.
   Requires pl-tokens.css. Every colour, shadow and radius comes from a token. */

/* ---------- Base ---------- */
.pl-app {
  margin: 0;
  min-height: 100vh;
  background: var(--pl-canvas);
  color: var(--pl-text);
  font: 400 14px/20px var(--pl-font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
.pl-app *, .pl-app *::before, .pl-app *::after { box-sizing: border-box; }
.pl-app :where(h1, h2, h3, h4, p) { margin: 0; }
.pl-app :where(button, input, select, textarea) { font: inherit; color: inherit; }
.pl-app :focus-visible { outline: 2px solid var(--pl-focus); outline-offset: 2px; }
.pl-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pl-ico { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Type ---------- */
.pl-h1 { font-size: 24px; line-height: 28px; font-weight: 300; letter-spacing: -0.01em; }
.pl-h1 strong { font-weight: 800; }
.pl-h2 { font-size: 16px; line-height: 22px; font-weight: 700; }
.pl-sub { font-size: 13px; line-height: 18px; color: var(--pl-text-3); }
.pl-kpi-label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--pl-text-2); }
.pl-kpi-value { font-size: 36px; line-height: 40px; font-weight: 800; letter-spacing: -0.02em; }
.pl-kpi-note { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--pl-text-3); }
.pl-tone-success { color: var(--pl-success-text); }
.pl-tone-warning { color: var(--pl-warning-text); }
.pl-tone-danger { color: var(--pl-danger-text); }
.pl-tone-accent { color: var(--pl-accent-text); }

/* ---------- Surfaces ---------- */
/* Raised card: same colour as the page, lifted by two shadows. */
.pl-card { background: var(--pl-surface); border: 1px solid var(--pl-surface-edge); border-radius: var(--pl-radius-card); box-shadow: var(--pl-shadow-raised); }
/* Well: pressed into the page. Inputs, tracks, selected items. */
.pl-well { background: var(--pl-well); border: 1px solid transparent; border-radius: var(--pl-radius-control); box-shadow: var(--pl-shadow-inset); }
/* Small raised control surface. */
.pl-raised { background: var(--pl-control); border: 1px solid var(--pl-control-edge); border-radius: var(--pl-radius-control); box-shadow: var(--pl-shadow-raised-sm); }
/* Glass: floating layers only (top bar, one highlight card, menus, dialogs). */
.pl-glass { background: var(--pl-glass); border: 1px solid var(--pl-glass-edge); border-radius: var(--pl-radius-card); box-shadow: var(--pl-shadow-glass); -webkit-backdrop-filter: var(--pl-blur); backdrop-filter: var(--pl-blur); }
.pl-glass.is-strong { background: var(--pl-glass-strong); }
/* Text over glass uses the stronger secondary colour. */
.pl-glass .pl-sub { color: var(--pl-text-2); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .pl-glass { background: var(--pl-glass-strong); }
}
/* Orange light behind a highlight glass card. Parent needs position: relative. */
.pl-glow { position: absolute; border-radius: 50%; background: radial-gradient(closest-side, var(--pl-glow), transparent); pointer-events: none; }
.pl-pad { padding: var(--pl-space-6); }
.pl-stack { display: flex; flex-direction: column; gap: var(--pl-space-4); }
.pl-card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--pl-space-3); }
.pl-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pl-space-3); }
/* Highlight card: <div class="pl-spot"><div class="pl-glow"></div><section class="pl-glass">…</section></div>. One per screen. */
.pl-spot { position: relative; display: flex; }
.pl-spot > .pl-glow { inset-inline: 25% 0; inset-block: -24px 35%; }
.pl-spot > .pl-glass { position: relative; flex: 1; min-width: 0; }

/* ---------- App shell ---------- */
.pl-shell { max-width: 1440px; margin-inline: auto; padding: clamp(12px, 2vw, 24px); display: flex; flex-direction: column; gap: var(--pl-space-6); }
.pl-topbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pl-space-4); padding: 14px 18px; }
.pl-topbar-title { flex: 1 1 260px; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.pl-topbar-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--pl-space-3); }
.pl-logo { flex: none; display: block; height: 24px; width: auto; }
.pl-logo-plate { flex: none; display: inline-flex; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--pl-brand-charcoal); }
.pl-body { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--pl-space-6); }
.pl-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: var(--pl-space-6); }
.pl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(var(--pl-col, 210px), 100%), 1fr)); gap: var(--pl-space-6); }
@media (max-width: 520px) {
  .pl-grid.is-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--pl-space-3); }
}
.pl-row { display: flex; flex-wrap: wrap; gap: var(--pl-space-6); }
.pl-row > .is-wide { flex: 2 1 480px; min-width: 0; }
.pl-row > .is-narrow { flex: 1 1 280px; min-width: 0; }

/* ---------- Navigation ---------- */
.pl-nav { flex: 1 1 200px; display: flex; flex-wrap: wrap; gap: 6px; padding: var(--pl-space-3); }
.pl-nav a { flex: 1 1 150px; display: flex; align-items: center; gap: var(--pl-space-3); min-height: var(--pl-control-h); padding: 0 14px; border: 1px solid transparent; border-radius: var(--pl-radius-control); color: var(--pl-text-2); font-weight: 500; text-decoration: none; }
.pl-nav a:hover { background: var(--pl-hover); color: var(--pl-text); }
.pl-nav a[aria-current="page"] { background: var(--pl-well); box-shadow: var(--pl-shadow-inset); color: var(--pl-text); font-weight: 700; }
.pl-nav a[aria-current="page"] .pl-ico { color: var(--pl-accent); }
@media (min-width: 900px) {
  /* Sticky only where the bar is one line; on a phone it scrolls away with the page. */
  .pl-topbar { position: sticky; inset-block-start: 16px; z-index: 20; }
  .pl-nav { position: sticky; inset-block-start: 112px; }
}
.pl-tabs { display: flex; gap: 4px; overflow-x: auto; border-block-end: 1px solid var(--pl-line); }
.pl-tabs button { min-height: var(--pl-control-h); padding: 0 14px; border: 0; background: transparent; color: var(--pl-text-3); font: 600 14px/20px var(--pl-font); white-space: nowrap; cursor: pointer; }
.pl-tabs button:hover { color: var(--pl-text); }
.pl-tabs button[aria-selected="true"] { color: var(--pl-text); box-shadow: inset 0 -3px 0 var(--pl-accent); }

/* ---------- Buttons ---------- */
.pl-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--pl-control-h); padding: 0 18px; border: 1px solid transparent; border-radius: var(--pl-radius-control); background: transparent; color: var(--pl-text); font: 600 14px/20px var(--pl-font); white-space: nowrap; text-decoration: none; cursor: pointer; transition: background var(--pl-fast) var(--pl-ease), box-shadow var(--pl-fast) var(--pl-ease), color var(--pl-fast) var(--pl-ease); }
/* Primary: orange with CHARCOAL text. White on this orange is 3.5:1 and fails. */
.pl-btn-primary { background: var(--pl-accent); color: var(--pl-on-accent); box-shadow: var(--pl-shadow-accent); }
.pl-btn-primary:hover { background: var(--pl-accent-hover); }
.pl-btn-primary:active { box-shadow: inset 2px 2px 6px rgba(0, 0, 0, .3); }
.pl-btn-secondary, .pl-btn-danger { background: var(--pl-control); border-color: var(--pl-control-edge); box-shadow: var(--pl-shadow-raised-sm); }
.pl-btn-secondary:hover { color: var(--pl-accent-text); }
.pl-btn-danger { color: var(--pl-danger-text); }
.pl-btn-secondary:active, .pl-btn-danger:active { box-shadow: var(--pl-shadow-inset); }
.pl-btn-ghost:hover { background: var(--pl-hover); }
.pl-btn-icon { width: var(--pl-control-h); padding: 0; border-radius: 50%; }
.pl-btn:disabled, .pl-btn[aria-disabled="true"] { opacity: .5; box-shadow: none; cursor: not-allowed; }

/* ---------- Form fields ---------- */
.pl-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: var(--pl-space-4) var(--pl-space-6); }
.pl-label { display: block; margin-block-end: 6px; font-size: 13px; line-height: 18px; font-weight: 600; color: var(--pl-text-2); }
.pl-input { display: block; width: 100%; min-height: var(--pl-control-h); padding: 0 14px; border: 1px solid transparent; border-radius: var(--pl-radius-control); background: var(--pl-well); box-shadow: var(--pl-shadow-inset); color: var(--pl-text); font: 400 14px/20px var(--pl-font); -webkit-appearance: none; appearance: none; }
textarea.pl-input { min-height: 96px; padding-block: 12px; resize: vertical; }
.pl-input::placeholder { color: var(--pl-text-3); opacity: 1; }
.pl-input[aria-invalid="true"] { border-color: var(--pl-danger); }
.pl-help { margin-block-start: 6px; font-size: 12px; line-height: 16px; color: var(--pl-text-3); }
.pl-help.is-error { color: var(--pl-danger-text); }
.pl-select { position: relative; }
.pl-select .pl-input { padding-inline-end: 40px; }
.pl-select::after { content: ""; position: absolute; inset-inline-end: 16px; inset-block-start: 50%; width: 8px; height: 8px; margin-block-start: -6px; border-right: 2px solid var(--pl-text-3); border-bottom: 2px solid var(--pl-text-3); transform: rotate(45deg); pointer-events: none; }
/* Field with an icon: <div class="pl-field"><svg class="pl-ico">…</svg><input></div> */
.pl-field { display: flex; align-items: center; gap: 10px; min-height: var(--pl-control-h); padding: 0 14px; border: 1px solid transparent; border-radius: var(--pl-radius-control); background: var(--pl-well); box-shadow: var(--pl-shadow-inset); color: var(--pl-text-3); }
.pl-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--pl-text); font: 400 14px/20px var(--pl-font); -webkit-appearance: none; appearance: none; }
.pl-field input::placeholder { color: var(--pl-text-3); opacity: 1; }
.pl-field:focus-within { outline: 2px solid var(--pl-focus); outline-offset: 2px; }
@media (pointer: coarse) {
  /* 16px stops iPhone Safari zooming the page when a field gets focus. */
  .pl-input, .pl-field input { font-size: 16px; }
}

/* Checkbox and radio: <label class="pl-check"><input type="checkbox"> Label</label> */
.pl-check { display: inline-flex; align-items: center; gap: 10px; min-height: var(--pl-control-h); color: var(--pl-text-2); font-weight: 500; cursor: pointer; }
.pl-check input { -webkit-appearance: none; appearance: none; flex: none; display: grid; place-content: center; width: 22px; height: 22px; margin: 0; border: 1px solid var(--pl-edge); border-radius: 7px; background: var(--pl-well); box-shadow: var(--pl-shadow-inset); cursor: pointer; }
.pl-check input[type="radio"] { border-radius: 50%; }
.pl-check input::after { content: ""; width: 12px; height: 12px; background: var(--pl-on-accent); clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%); transform: scale(0); transition: transform var(--pl-fast) var(--pl-ease); }
.pl-check input[type="radio"]::after { width: 8px; height: 8px; border-radius: 50%; clip-path: none; }
.pl-check input:checked { border-color: transparent; background: var(--pl-accent); box-shadow: inset 1px 1px 3px rgba(0, 0, 0, .25); }
.pl-check input:checked::after { transform: scale(1); }

/* Switch: <label class="pl-switch"><input type="checkbox" role="switch"><span class="pl-switch-track"></span> Label</label> */
.pl-switch { position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: var(--pl-control-h); color: var(--pl-text-2); font-weight: 500; cursor: pointer; }
.pl-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.pl-switch-track { position: relative; flex: none; width: 56px; height: 32px; border-radius: var(--pl-radius-pill); background: var(--pl-well); box-shadow: var(--pl-shadow-inset); transition: background var(--pl-fast) var(--pl-ease); }
.pl-switch-track::after { content: ""; position: absolute; inset-block-start: 4px; inset-inline-start: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--pl-knob); box-shadow: 2px 2px 6px rgba(0, 0, 0, .3); transition: transform var(--pl-fast) var(--pl-ease); }
.pl-switch input:checked + .pl-switch-track { background: var(--pl-accent); box-shadow: inset 2px 2px 6px rgba(0, 0, 0, .28); }
.pl-switch input:checked + .pl-switch-track::after { transform: translateX(24px); }
[dir="rtl"] .pl-switch input:checked + .pl-switch-track::after { transform: translateX(-24px); }
.pl-switch input:focus-visible + .pl-switch-track { outline: 2px solid var(--pl-focus); outline-offset: 2px; }

/* Segmented control: a well with one raised thumb. State comes from aria-pressed. */
.pl-seg { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid transparent; border-radius: 16px; background: var(--pl-well); box-shadow: var(--pl-shadow-inset); }
.pl-seg button { min-height: 40px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--pl-radius-inner); background: transparent; color: var(--pl-text-3); font: 600 13px/18px var(--pl-font); cursor: pointer; }
.pl-seg button:hover { color: var(--pl-text); }
.pl-seg button[aria-pressed="true"] { background: var(--pl-control); border-color: var(--pl-control-edge); box-shadow: var(--pl-shadow-raised-sm); color: var(--pl-text); }

/* ---------- Data ---------- */
/* KPI card: <section class="pl-card pl-kpi"> label, value, note. */
.pl-kpi { display: flex; flex-direction: column; gap: 8px; padding: 20px; }

/* Track: an inset groove with an orange fill. Add role="progressbar" when it is the only source of the value. */
.pl-track { display: block; height: 14px; border: 1px solid transparent; border-radius: var(--pl-radius-pill); background: var(--pl-well); box-shadow: var(--pl-shadow-inset); overflow: hidden; }
.pl-track > span { display: block; height: 100%; border-radius: inherit; background: var(--pl-accent); }
.pl-track.is-sm { height: 10px; }
/* Meter: name and number as text, then the track. */
.pl-meter { display: flex; flex-direction: column; gap: 8px; }
.pl-meter-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.pl-meter-name { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-weight: 600; }
.pl-meter-value { color: var(--pl-text-2); }
/* Progress cell in a table. */
.pl-progress { display: flex; align-items: center; gap: 10px; }
.pl-progress .pl-track { flex: 1; min-width: 80px; }
.pl-progress-value { width: 36px; text-align: end; }

/* Status pill: always a dot plus a word, never colour alone. */
.pl-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: var(--pl-radius-pill); background: var(--pl-well); color: var(--pl-text-2); font-size: 12px; line-height: 16px; font-weight: 600; white-space: nowrap; }
.pl-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pl-pill.is-plain::before { display: none; }
.pl-pill.is-accent { background: var(--pl-accent-soft); color: var(--pl-accent-text); }
.pl-pill.is-success { background: var(--pl-success-soft); color: var(--pl-success-text); }
.pl-pill.is-warning { background: var(--pl-warning-soft); color: var(--pl-warning-text); }
.pl-pill.is-danger { background: var(--pl-danger-soft); color: var(--pl-danger-text); }
.pl-pill.is-info { background: var(--pl-info-soft); color: var(--pl-info-text); }

/* Table: always inside <div class="pl-table-wrap"> so it scrolls sideways on a phone. */
.pl-table-wrap { overflow-x: auto; }
.pl-table { width: 100%; border-collapse: collapse; }
.pl-table th { padding: 12px; border-block-end: 1px solid var(--pl-line); color: var(--pl-text-3); font-size: 12px; line-height: 16px; font-weight: 600; text-align: start; white-space: nowrap; }
.pl-table td { height: 56px; padding: 0 12px; border-block-end: 1px solid var(--pl-line); color: var(--pl-text-2); white-space: nowrap; }
.pl-table td.is-wrap { min-width: 220px; white-space: normal; }
.pl-table tbody tr:last-child td { border-block-end: 0; }
.pl-table tbody tr:hover td { background: var(--pl-hover); }
.pl-table td.is-key { color: var(--pl-text); font-weight: 700; }
.pl-table td.is-num, .pl-table th.is-num { text-align: end; }

/* Gauge (half circle). Set --pl-value and --pl-target (0 to 100) on .pl-gauge. */
.pl-gauge { display: grid; justify-items: center; }
.pl-gauge > svg { grid-area: 1 / 1; display: block; width: 100%; max-width: 280px; height: auto; }
.pl-gauge-track, .pl-gauge-value { fill: none; stroke-width: 16; stroke-linecap: round; }
.pl-gauge-track { stroke: var(--pl-track); }
.pl-gauge-value { stroke: var(--pl-accent); stroke-dasharray: var(--pl-value, 0) 100; }
.pl-gauge-target { stroke: var(--pl-text); stroke-width: 3; stroke-linecap: round; transform-origin: 100px 100px; transform: rotate(calc(var(--pl-target, 0) * 1.8deg)); }
.pl-gauge-number { grid-area: 1 / 1; align-self: end; font-size: 40px; line-height: 44px; font-weight: 800; letter-spacing: -0.02em; }

/* ---------- Overlays (glass) ---------- */
.pl-scrim { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--pl-space-4); background: var(--pl-scrim); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.pl-modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: var(--pl-space-6); }
.pl-menu { min-width: 200px; padding: 6px; border-radius: var(--pl-radius-tile); }
.pl-menu a, .pl-menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--pl-text-2); font: 500 14px/20px var(--pl-font); text-align: start; text-decoration: none; cursor: pointer; }
.pl-menu a:hover, .pl-menu button:hover { background: var(--pl-hover); color: var(--pl-text); }
.pl-toast { display: flex; align-items: center; gap: var(--pl-space-3); padding: 12px 16px; border-radius: var(--pl-radius-tile); font-weight: 500; }

/* ---------- User preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .pl-app *, .pl-app *::before, .pl-app *::after { transition: none !important; animation: none !important; }
}
/* No dark edge under "Increase contrast" in the CRM (Amr, 27 Nov 2026: "remove these black borders around each section
   and card"). His devices have it on; the rule drew a grey-black line round every card. crm-portal/HANDOFF.md 4.47. */
