/* Tarjouspyynnöt: a calm CRM for requests that arrive by email.
   One background: the whole app sits on a single warm canvas, and regions are divided by
   hairlines, never by cards. Only inputs, the reply draft and floating things (menus, search,
   notices) are white.
   Shape rule: controls 9px, buttons are pills, tags 6px; companies are rounded squares,
   people are circles.
   Colour rule: neutral ink for primary actions; the blue accent marks selection, links and
   "needs you"; red only for a late quote; stage tags carry the stage. */

:root {
  color-scheme: light;
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --canvas: #f7f7f5;
  --surface: #ffffff;
  --tint: rgba(24, 26, 38, 0.035);
  --tint-2: rgba(24, 26, 38, 0.06);
  --row: #fcfcfa;
  --row-hover: #f4f4f1;
  --bg-subtle: rgba(24, 26, 38, 0.06);
  --line: #e2e1dc;
  --line-2: #d5d4ce;
  --edge: rgba(24, 26, 38, 0.08);
  --text: #1f2027;
  --text-2: #5c5e6a;
  --text-3: #868894;
  --ink: #1f2027;
  --ink-hover: #363842;
  --accent: #3f5fd6;
  --accent-soft: #e9eefc;
  --accent-line: #cdd7f6;
  --accent-text: #3350c0;
  --red: #b0443b;
  --red-soft: #f9e8e5;
  --green: #2b7a4f;
  --green-soft: #e3f1e8;
  --amber: #8f5a10;
  --amber-soft: #f8ecd7;
  --violet: #6a4ec2;
  --violet-soft: #ece8fa;
  --shadow-pop: 0 18px 44px -14px rgba(30, 40, 70, 0.28), 0 0 0 1px rgba(24, 26, 38, 0.08);
  --rail: 72px;
  --rail-wide: 244px;
  --chat: 380px;
  --pad: 28px;
  --bar: 60px;
  --z-sticky: 2;
  --z-menu: 40;
  --z-overlay: 50;
  --z-toast: 60;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--canvas); color: var(--text); font: 13px/1.5 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.012em; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.soft { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.late-text { color: var(--red); font-weight: 500; }
.skip { position: absolute; left: -999px; top: 8px; z-index: var(--z-toast); background: #fff; padding: 8px 12px; border-radius: 8px; box-shadow: var(--shadow-pop); }
.skip:focus { left: 8px; }
i.ph, i.ph-light, i.ph-fill { line-height: 1; }

/* Frame --------------------------------------------------------------------------------- */
/* Rail, work area and, on Tänään, the assistant. One hairline runs under all three headers. */

.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); height: 100dvh; transition: grid-template-columns 0.22s ease; }
.app.wide { grid-template-columns: var(--rail-wide) minmax(0, 1fr); }
.app.with-chat { grid-template-columns: var(--rail) minmax(0, 1fr) var(--chat); }
.app.wide.with-chat { grid-template-columns: var(--rail-wide) minmax(0, 1fr) var(--chat); }

.rail { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 0 12px 14px; overflow: hidden auto; border-right: 1px solid var(--line); }
.rail .lbl { overflow: hidden; white-space: nowrap; opacity: 0; max-width: 0; transition: opacity 0.14s, max-width 0.22s; }
.app.wide .rail .lbl { opacity: 1; max-width: 180px; }
.brand { flex: none; display: flex; align-items: center; gap: 10px; height: var(--bar); margin: 0 -12px 12px; padding: 0 21px; border-bottom: 1px solid var(--line); }
.ws-logo { width: 30px; height: 30px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--ink); color: #fff; font-weight: 700; font-size: 14px; }
.ws-name { font-weight: 600; font-size: 14px; }
.demo-flag { margin-left: auto; font-size: 10.5px; font-weight: 500; color: var(--text-3); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 5px; cursor: help; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-nav + .rail-nav { margin-top: 16px; }
.rail-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; height: 40px; padding: 0 14px;
  border: 0; border-radius: 12px; background: transparent; color: var(--text-2); cursor: pointer;
  font: 500 13px var(--font); text-align: left; transition: background 0.16s, color 0.16s;
}
.rail-item i { font-size: 20px; width: 20px; flex: none; }
.rail-item:hover { background: var(--tint); color: var(--text); }
.rail-item.active { background: var(--tint-2); color: var(--text); }
.rail-item kbd { margin-left: auto; }
.rail-item .count { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.app:not(.wide) .rail-item .count:not(.attn) { display: none; }
.rail-item .count.attn { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 600; font-size: 10.5px; }
.app:not(.wide) .rail-item .count.attn { position: absolute; top: 4px; left: 27px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; box-shadow: 0 0 0 2px var(--canvas); }
.app:not(.wide) .rail .demo-flag, .app:not(.wide) .rail kbd { display: none; }
.rail-foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.rail-sync { display: flex; align-items: center; gap: 12px; min-height: 36px; padding: 0 20px; font-size: 12px; color: var(--text-2); }
.rail-sync .live { width: 8px; height: 8px; flex: none; border-radius: 50%; background: #2fa565; box-shadow: 0 0 0 3px rgba(47, 165, 101, 0.16); }
.rail-sync .live.stale { background: #d99100; box-shadow: 0 0 0 3px rgba(217, 145, 0, 0.16); }
.rail-sync .live.demo { background: var(--text-3); box-shadow: 0 0 0 3px var(--tint-2); }
.rail-sync small, .rail-me small { display: block; font-size: 11px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.rail-me { display: flex; align-items: center; gap: 12px; padding: 4px 10px; min-height: 40px; }
.rail-me b { display: block; font-weight: 600; font-size: 12.5px; }
kbd { font: 500 10.5px var(--font); color: var(--text-3); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 5px; background: var(--surface); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; outline: none; container: main / inline-size; }
.topbar { height: var(--bar); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 var(--pad) 0 14px; border-bottom: 1px solid var(--line); }
.histnav { flex: none; display: flex; align-items: center; gap: 2px; }
.histnav .iconbtn { width: 28px; height: 28px; font-size: 16px; }
.histnav .iconbtn:disabled { background: transparent; color: var(--text-3); opacity: 0.4; cursor: default; }
.title { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; font-size: 14.5px; }
.title i { font-size: 17px; color: var(--text-2); }
.topbar .spacer, .chat-head .spacer { flex: 1; }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 14px; }
.crumbs a { color: var(--text-2); font-weight: 500; }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--text-3); font-size: 12px; }
.crumbs .here { font-weight: 600; }
.content { flex: 1; min-height: 0; overflow: auto; }
.content.fill { overflow: hidden; display: flex; flex-direction: column; }
.surface { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.banner { display: flex; align-items: center; gap: 10px; margin: 10px var(--pad) 0; padding: 10px 16px; border-radius: 12px; background: var(--amber-soft); color: var(--amber); font-size: 13px; }

/* Controls ------------------------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 32px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--surface); color: var(--text); font: 500 12.5px var(--font); white-space: nowrap; cursor: pointer;
  transition: background 0.16s, border-color 0.16s, transform 0.06s;
}
.btn:hover { background: #f3f3f0; }
.btn:active { transform: translateY(1px); }
.btn i { font-size: 16px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--tint-2); color: var(--text); }
.btn.sm { height: 28px; padding: 0 12px; font-size: 12px; }
.iconbtn { width: 30px; height: 30px; display: inline-grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); cursor: pointer; font-size: 17px; }
.iconbtn:hover { background: var(--tint-2); color: var(--text); }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--tint-2); border-radius: 11px; }
.seg button { height: 26px; padding: 0 11px; border: 0; border-radius: 8px; background: transparent; display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font: 500 12.5px var(--font); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--edge), 0 1px 3px rgba(24, 26, 38, 0.06); }
.seg button i { font-size: 15px; }
.seg .n { color: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }

.filter { display: flex; align-items: center; gap: 6px; height: 32px; width: 260px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); color: var(--text-3); }
.filter:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filter input { width: 100%; border: 0; outline: 0; background: transparent; font: 12.5px var(--font); color: var(--text); }
.filter input::placeholder { color: var(--text-3); }

.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--tint-2); color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag i { font-size: 13px; }
.tag.btnlike { border: 0; cursor: pointer; font-family: var(--font); }
.tag.btnlike:hover { filter: brightness(0.97); }
.tag.stage-receive_rfq { background: #e8ebf1; color: #464c5b; }
.tag.stage-sales_support { background: var(--violet-soft); color: var(--violet); }
.tag.stage-cost_calculation { background: var(--amber-soft); color: var(--amber); }
.tag.stage-release_quotation { background: #e5ecfc; color: #2e55b4; }
.tag.stage-won { background: var(--green-soft); color: var(--green); }
.tag.stage-lost { background: #ebebe8; color: #62636c; }
.tag.you { background: var(--accent-soft); color: var(--accent-text); }
.tag.late { background: var(--red-soft); color: var(--red); }
.tag.good { background: var(--green-soft); color: var(--green); }
.tag.warn { background: var(--amber-soft); color: var(--amber); }
.tag.new { height: 18px; padding: 0 6px; background: var(--accent); color: #fff; font-size: 10.5px; }

.avatar { flex: none; display: inline-grid; place-items: center; font-weight: 600; letter-spacing: 0; user-select: none; }
.avatar.co { border-radius: 7px; }
.avatar.person { border-radius: 50%; }
.avatar.s16 { width: 16px; height: 16px; font-size: 8.5px; border-radius: 5px; }
.avatar.s16.person { border-radius: 50%; }
.avatar.s20 { width: 20px; height: 20px; font-size: 9.5px; }
.avatar.s22 { width: 22px; height: 22px; font-size: 9.5px; }
.avatar.s24 { width: 24px; height: 24px; font-size: 10.5px; }
.avatar.s28 { width: 28px; height: 28px; font-size: 11px; border-radius: 8px; }
.avatar.s28.person { border-radius: 50%; }
.avatar.s32 { width: 32px; height: 32px; font-size: 12px; border-radius: 9px; }
.avatar.s32.person { border-radius: 50%; }
.avatar.s36 { width: 36px; height: 36px; font-size: 13px; border-radius: 10px; }
.avatar.s36.person { border-radius: 50%; }
.avatar.s44 { width: 44px; height: 44px; font-size: 16px; border-radius: 12px; }
.avatar.s44.person { border-radius: 50%; }
.stack { display: inline-flex; }
.stack .avatar { box-shadow: 0 0 0 2px var(--row); }
.stack .avatar + .avatar { margin-left: -6px; }

.chip { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.chip:hover .chip-name { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.link { color: var(--accent-text); font-weight: 500; }
a.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.linkish { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; font: 500 12.5px var(--font); color: var(--text-2); cursor: pointer; }
.linkish:hover { color: var(--text); }

/* Menus, search and notices --------------------------------------------------------------- */

.menu { position: fixed; z-index: var(--z-menu); min-width: 220px; max-width: 320px; padding: 5px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-pop); animation: pop 0.12s ease-out; }
.menu .menu-label { font-size: 11.5px; color: var(--text-3); padding: 6px 10px 4px; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; font-size: 13px; }
.menu button:hover, .menu button:focus-visible { background: var(--tint); outline: none; }
.menu button .check { margin-left: auto; color: var(--accent); font-size: 15px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.overlay { position: fixed; inset: 0; z-index: var(--z-overlay); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 0; background: rgba(30, 32, 44, 0.16); animation: fade 0.12s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.palette { width: 620px; max-width: 100%; overflow: hidden; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-pop); animation: pop 0.14s ease-out; }
.palette-input { display: flex; align-items: center; gap: 10px; height: 54px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.palette-input i { font-size: 18px; color: var(--text-3); }
.palette-input input { flex: 1; border: 0; outline: 0; background: transparent; font: 15px var(--font); color: var(--text); }
.palette-results { max-height: 52vh; overflow: auto; padding: 6px; }
.palette-group { padding: 10px 10px 4px; font-size: 11.5px; font-weight: 500; color: var(--text-3); }
.palette-item { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.palette-item .ellipsis { flex: 1; min-width: 0; }
.palette-item .muted { flex: none; font-size: 12px; }
.palette-item.on { background: var(--tint-2); }
.palette-empty { padding: 24px 16px; text-align: center; color: var(--text-3); }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; }
.app.with-chat ~ .toasts { right: calc(var(--chat) + 18px); }
.toast { display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: start; width: 360px; max-width: calc(100vw - 36px); padding: 12px 12px 12px 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-pop); animation: toast-in 0.22s ease-out; }
.toast .t-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 17px; }
.toast b { display: block; font-size: 13px; }
.toast span { display: block; margin-top: 2px; font-size: 12px; color: var(--text-2); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Shared blocks ---------------------------------------------------------------------------- */

.page { padding: 24px var(--pad) 40px; }
.section { margin-bottom: 32px; }
.section:last-child { margin-bottom: 0; }
.section-h { display: flex; align-items: center; gap: 8px; min-height: 24px; margin-bottom: 10px; }
.section-h h2, .section-h h3 { font-size: 13.5px; font-weight: 600; }
.section-h .n { color: var(--text-3); font-weight: 500; font-variant-numeric: tabular-nums; }
.section-h .aside { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 12.5px; }

/* A list is a band of light rows across the full width of its column, with hairlines between rows. */
.list { margin: 0 calc(-1 * var(--pad)); border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 13px var(--pad); background: var(--row); border-bottom: 1px solid var(--line); cursor: pointer; transition: background 0.12s; }
.row:hover { background: var(--row-hover); }
.row-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13.5px; }
.row-id { flex: none; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.row-reason { margin-top: 6px; max-width: 76ch; font-size: 13px; line-height: 1.55; color: var(--text-2); }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.row-side .muted { font-size: 12px; }
.row.compact { padding: 11px var(--pad); align-items: center; }
.row.compact .row-title { font-size: 13px; font-weight: 500; }
.row.compact .row-reason { margin-top: 2px; font-size: 12.5px; }
.row.compact .row-side { flex-direction: row; align-items: center; }
a.row:focus-visible, a.card:focus-visible, a.mail:focus-visible { outline-offset: -2px; }

.empty { padding: 48px 24px; text-align: center; color: var(--text-3); }
.empty i { display: block; margin-bottom: 8px; font-size: 28px; }

.props { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 11px 12px; margin: 0; font-size: 13px; }
.props dt { color: var(--text-3); }
.props dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.props dd .muted { font-size: 12.5px; }

.skeleton { border-radius: 10px; background: linear-gradient(90deg, #ecebe7 0%, #f3f3f0 50%, #ecebe7 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Tänään ---------------------------------------------------------------------------------- */
/* Three questions, top to bottom: what is ours to do, what others owe us, and how requests
   ended. Rows run the full width, so their hairlines meet the rail and the assistant. */

.top-note { font-size: 13px; color: var(--text-3); }
.home { padding-bottom: 64px; }

/* Section headings carry the counts. "Vaatii sinua" is the largest, with the blue count. */
.block { padding-top: 52px; }
.block:first-child { padding-top: 34px; }
.block-h { display: flex; align-items: center; gap: 8px; padding: 0 var(--pad) 14px; }
.block-h h2 { font-size: 17px; font-weight: 600; line-height: 1.3; letter-spacing: -0.016em; }
.block-h .count { font-size: 17px; line-height: 1.3; color: var(--text-3); font-variant-numeric: tabular-nums; }
.block.you .block-h h2 { font-size: 20px; letter-spacing: -0.02em; }
.block.you .block-h .count { font-size: 20px; }
.block-h .count.attn, .block.you .block-h .count.attn { box-sizing: border-box; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; line-height: 1; }
.block-h .aside { margin-left: auto; font-size: 12.5px; }
/* Rows are a shade lighter than the canvas and run the full width between the rail and the
   assistant, with hairlines between them: no corners, gaps or shadows, so a list reads as one
   band, not as cards. */
.needs, .lines { border-top: 1px solid var(--line); }
/* What needs you stands out a little: the band keeps its full width, and its outer hairlines are
   light blue instead of grey. */
.block.you .needs { border-top-color: var(--accent-line); border-bottom: 1px solid var(--accent-line); }
.block.you .needs > .item:last-child { border-bottom: 0; }
.item { background: var(--row); border-bottom: 1px solid var(--line); }
.item[data-href] { cursor: pointer; transition: background 0.12s; }
.item[data-href]:hover { background: var(--row-hover); }
.block-empty { display: flex; align-items: center; gap: 10px; padding: 16px var(--pad); color: var(--text-2); }
.block-empty.item { border-top: 1px solid var(--line); }
.block-empty i { font-size: 18px; color: var(--green); }

/* A request that needs you, as two lines like a message in a mail list. The top line reads
   across: customer and contact, the next to-do with how many more there are, how long it has
   been ours, the owner. Under it, the request and the customer's deadline. Opened, every to-do
   and the actions show underneath. At 1440 px the to-do starts where the text of "Odottaa
   muita" does, and the time and owner sit where theirs do. */
.need-head {
  display: grid;
  grid-template-columns: 32px 14px 306px 24px minmax(0, 1fr) 28px 140px 28px minmax(0, 131px) 32px;
  grid-template-rows: 20px 20px;
  grid-template-areas:
    "av . cust . next . when . own tog"
    "av . ttl  . .    . when . .   tog";
  align-items: center;
  padding: 9px var(--pad);
  cursor: pointer;
}
.need { transition: background 0.12s; }
.need:hover { background: #f9f9f7; }
.need.open { background: var(--surface); }
.need-head > .avatar { grid-area: av; }
.need-cust { grid-area: cust; display: flex; align-items: baseline; gap: 6px; min-width: 0; white-space: nowrap; }
.need-cust b { overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; font-weight: 600; letter-spacing: -0.006em; }
.need-cust span { flex: none; color: var(--text-3); }
.need-cust span + span { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
.need-cust .tag.new { align-self: center; margin-left: 4px; }
/* The link's hit area is 32px tall; the padding is taken back with a negative margin. */
.need-title { grid-area: ttl; justify-self: start; max-width: 100%; padding-block: 6px; margin-block: -6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.need-title:hover { color: var(--accent-text); text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 3px; }
.need-next { grid-area: next; display: flex; align-items: center; gap: 7px; min-width: 0; color: var(--text-2); }
.need-next > i { flex: none; font-size: 15px; }
.need-next-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.need-next-text .muted, .need-todo .muted { color: var(--text-3); }
.need-count { flex: none; margin-left: auto; height: 18px; padding: 0 6px; border-radius: 6px; display: inline-grid; place-items: center; background: var(--tint-2); color: var(--text-2); font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.need.open .need-next { visibility: hidden; }
.need-when { grid-area: when; align-self: start; display: flex; flex-direction: column; align-items: flex-end; line-height: 20px; white-space: nowrap; }
.need-ago { font-size: 12.5px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.need-due { font-size: 12px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.need-own { grid-area: own; display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.need-own > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.need-own.none { color: var(--text-3); }
.need-noav { flex: none; width: 20px; height: 20px; border: 1px dashed var(--line-2); border-radius: 50%; }
.need-tog { grid-area: tog; justify-self: end; width: 32px; height: 32px; color: var(--text-3); }
.need-tog i { font-size: 16px; transition: transform 0.16s; }
.need-tog[aria-expanded="true"] { color: var(--text); }
.need-tog[aria-expanded="true"] i { transform: rotate(180deg); }
/* Blue for things to send, amber for things to decide. */
.k-mail > i, .k-offer > i, .k-erp > i, .k-confirm > i, .k-purchase > i { color: var(--accent); }
.k-decide > i, .k-change > i { color: var(--amber); }
.k-after > i, .k-next > i { color: var(--text-3); }
.need-todo .k-after { color: var(--text-3); }
/* Opened: every to-do with its full detail, then the actions, starting under the customer. */
.need-body { padding: 4px var(--pad) 18px calc(var(--pad) + 46px); }
.need-todo { display: grid; gap: 7px; max-width: 791px; margin: 0; padding: 0; list-style: none; line-height: 20px; }
.need-todo li { display: flex; align-items: flex-start; gap: 8px; }
.need-todo li > i { flex: none; margin-top: 2px; font-size: 16px; }
.need-acts { display: flex; align-items: center; gap: 6px; margin-top: 14px; }
.need-acts .btn.primary { min-width: 152px; }
.need-acts .btn.ghost i { font-size: 14px; }

.line, .line-labels { display: grid; grid-template-columns: minmax(200px, 1.15fr) minmax(0, 2.2fr) 7rem minmax(128px, 0.7fr); gap: 28px; padding: 14px var(--pad); }
.line { align-items: center; min-height: 70px; }
.block-h:has(+ .line-labels) { padding-bottom: 6px; }
.line-labels { padding-block: 0 7px; }
.line-labels > span { font-size: 12px; font-weight: 500; color: var(--text-3); }
.line-labels .line-num { grid-column: 2 / 4; }
.line-labels .line-end { grid-column: 4; }
.line small { display: block; font-size: 11.5px; color: var(--text-3); }
.line-rec { display: flex; align-items: center; gap: 12px; min-width: 0; }
.line-rec > div { min-width: 0; }
.line-rec b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13px; transition: color 0.12s; }
.line-rec a:hover b { color: var(--accent-text); }
.line-rec small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-what { display: flex; align-items: flex-start; gap: 10px; min-width: 0; font-size: 12.5px; line-height: 1.5; color: var(--text-2); }
.line-what .tag { flex: none; margin-top: -2px; }
.line-what small { margin-top: 3px; }
.line-num { text-align: right; white-space: nowrap; }
.line-num b { font-weight: 600; font-size: 13px; }
.line-end { min-width: 0; font-size: 12.5px; }

@container main (max-width: 780px) {
  .line, .line-labels { grid-template-columns: minmax(0, 1fr) 7rem; gap: 8px 16px; }
  .line-labels .line-num { grid-column: 1 / 3; }
  .line-what { grid-column: 1 / -1; grid-row: 2; padding-left: 40px; }
  .line-end { display: none; }
  .need-head {
    grid-template-columns: 32px 12px minmax(0, 1fr) 12px auto 32px;
    grid-template-rows: 20px 20px 20px;
    grid-template-areas:
      "av . cust . when tog"
      "av . ttl  . when tog"
      "av . next . own  tog";
    padding: 10px var(--pad);
  }
  .need-body { padding: 4px var(--pad) 18px calc(var(--pad) + 44px); }
}

/* Avustaja ------------------------------------------------------------------------------- */
/* A conversation column beside Tänään: header, messages, and the composer pinned at the bottom. */

.chat { display: none; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--line); }
.app.with-chat .chat { display: flex; }
.chat-head { height: var(--bar); flex: none; display: flex; align-items: center; gap: 10px; padding: 0 14px 0 22px; border-bottom: 1px solid var(--line); }
.chat-flag { font-size: 10.5px; font-weight: 500; color: var(--text-3); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 5px; cursor: help; }
.chat-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; padding: 24px 22px 16px; }
.msg p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.6; }
.msg.me { align-self: flex-end; max-width: 86%; padding: 9px 14px; border-radius: 16px 16px 5px 16px; background: var(--tint-2); }
.msg.bot { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; align-items: start; }
.msg.bot p { color: var(--text); }
.bot-mark { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 8px; background: var(--ink); color: #fff; font-size: 12px; }
.dots { display: inline-flex; align-items: center; gap: 4px; height: 24px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.chat-foot { flex: none; padding: 8px 16px 16px; }
.chat-box { border: 1px solid var(--line-2); border-radius: 16px; background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s; }
.chat-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-box textarea { display: block; width: 100%; min-height: 44px; max-height: 168px; padding: 12px 14px 2px; border: 0; outline: 0; resize: none; background: transparent; font: 13.5px/1.5 var(--font); color: var(--text); }
.chat-box textarea::placeholder { color: var(--text-3); }
.chat-bar { display: flex; justify-content: flex-end; padding: 2px 8px 8px; }
.chat-send { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--ink); color: #fff; font-size: 16px; cursor: pointer; transition: background 0.15s; }
.chat-send:hover { background: var(--ink-hover); }
.chat-send:disabled { background: var(--tint-2); color: var(--text-3); cursor: default; }

/* Tables ---------------------------------------------------------------------------------- */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; flex: none; padding: 12px var(--pad); border-bottom: 1px solid var(--line); }
.toolbar .spacer { flex: 1; }
.toolbar .vsep { width: 1px; height: 20px; margin: 0 4px; background: var(--line-2); }
.table-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; }
table.grid { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.grid th {
  position: sticky; top: 0; z-index: var(--z-sticky); height: 38px; padding: 0 14px;
  background: var(--canvas); text-align: left; font-weight: 500; font-size: 12px; color: var(--text-3); white-space: nowrap;
  border-bottom: 1px solid var(--line); cursor: pointer; user-select: none;
}
.grid th:hover { color: var(--text-2); }
.grid th i { margin-right: 6px; font-size: 14px; vertical-align: -2px; }
.grid th .sort { margin: 0 0 0 4px; color: var(--text-2); }
.grid td { height: 46px; max-width: 380px; padding: 0 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--row); border-bottom: 1px solid var(--line); }
.grid th:first-child, .grid td:first-child { position: sticky; left: 0; padding-left: var(--pad); box-shadow: 1px 0 0 var(--line); }
.grid th:last-child, .grid td:last-child { padding-right: var(--pad); }
.grid th:first-child { z-index: calc(var(--z-sticky) + 1); }
.grid td:first-child { z-index: 1; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover td { background: var(--row-hover); }
.grid .rec { display: flex; align-items: center; gap: 10px; min-width: 0; }
.grid .rec b { overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.grid .right { text-align: right; }
.grid tfoot td { height: 40px; cursor: default; border-bottom: 0; background: var(--canvas); color: var(--text-3); font-size: 12px; }
.grid tfoot td:first-child { box-shadow: none; }

/* Board ----------------------------------------------------------------------------------- */

.board { flex: 1; min-height: 0; display: flex; gap: 8px; overflow: auto; align-items: flex-start; padding: 12px calc(var(--pad) - 8px) var(--pad); }
.col { flex: 1 1 0; min-width: 184px; max-width: 320px; max-height: 100%; display: flex; flex-direction: column; padding: 0 8px; border-radius: 14px; transition: background 0.12s; }
.col.drop { background: var(--accent-soft); }
.col-h { display: flex; align-items: center; gap: 8px; padding: 8px 0 10px; }
.col-h .n { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.col-body { display: flex; flex-direction: column; gap: 8px; min-height: 64px; overflow-y: auto; padding-bottom: 8px; }
.card { display: block; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--row); cursor: grab; transition: border-color 0.14s, box-shadow 0.14s, opacity 0.12s; }
.card:hover { border-color: var(--line-2); box-shadow: 0 8px 18px -14px rgba(30, 40, 70, 0.4); }
.card.dragging { opacity: 0.45; }
.card-co { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; color: var(--text-2); }
.card-title { margin-top: 6px; font-weight: 600; font-size: 13px; line-height: 1.35; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.card-foot .owner { margin-left: auto; }
.col-empty { padding: 16px 8px; border: 1px dashed var(--line-2); border-radius: 10px; text-align: center; color: var(--text-3); font-size: 12px; }

/* Record pages ---------------------------------------------------------------------------- */

.record-head { padding: 22px var(--pad) 0; }
.record-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.record-title h1 { font-size: 22px; font-weight: 500; line-height: 1.25; letter-spacing: -0.018em; }
.record-title .row-sub { font-size: 12.5px; color: var(--text-3); }
.row-sub { color: var(--text-3); font-size: 12.5px; }
.record-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 12px; color: var(--text-2); font-size: 13px; }
.record-meta .item { display: inline-flex; align-items: center; gap: 6px; }
.record-meta .item > i { font-size: 15px; color: var(--text-3); }
.picker { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 6px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); cursor: pointer; font: 500 12.5px var(--font); color: var(--text); }
.picker:hover { background: #f3f3f0; }
.picker .ph-caret-down { font-size: 12px; color: var(--text-3); }
.manual-note { font-size: 11.5px; color: var(--text-3); }

.stepper { display: grid; grid-template-columns: repeat(var(--steps, 5), minmax(0, 1fr)); gap: 6px; max-width: 760px; margin-top: 18px; }
.step .bar { height: 4px; border-radius: 2px; background: rgba(24, 26, 38, 0.08); }
.step.done .bar { background: #b3c2f1; }
.step.current .bar { background: var(--accent); }
.step.end-lost .bar { background: #c5c5cc; }
.step .lbl { margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--text-3); }
.step.current .lbl { color: var(--text); font-weight: 500; }

.tabs { display: flex; gap: 22px; margin-top: 16px; padding: 0 var(--pad); border-bottom: 1px solid var(--line); }
.tabs a { display: flex; align-items: center; gap: 6px; height: 38px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--text-2); font-weight: 500; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); border-bottom-color: var(--text); }
.tabs .n { color: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }

.record-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.record-main { min-width: 0; padding: 26px var(--pad) 48px; }
.record-side { min-width: 0; padding: 26px var(--pad) 48px 26px; border-left: 1px solid var(--line); }
.record-side h3 { margin-bottom: 14px; font-size: 13px; font-weight: 600; }
.record-side .section { margin-bottom: 28px; }
.record-wide { padding: 22px var(--pad) 48px; }

.callout { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 14px; padding: 16px 18px; border-radius: 12px; background: var(--tint); }
.callout.attn { background: var(--accent-soft); }
.callout .c-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: var(--surface); box-shadow: 0 0 0 1px var(--edge); color: var(--text-2); font-size: 17px; }
.callout.attn .c-icon { background: var(--accent); box-shadow: none; color: #fff; }
.callout .c-label { font-size: 12px; font-weight: 500; color: var(--text-3); }
.callout.attn .c-label { color: var(--accent-text); }
.callout .c-text { margin-top: 2px; font-size: 14.5px; font-weight: 500; line-height: 1.45; }
.callout .c-sub { margin-top: 6px; font-size: 13px; line-height: 1.55; color: var(--text-2); }
.callout .c-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* The reply draft is a document, so it stays white. */
.draft { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--row); }
.draft.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px var(--accent-line); } 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); } }
.draft-head { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); }
.draft-head i { font-size: 16px; color: var(--text-3); }
/* The reply text is the editor itself: click into it and type; it grows with the text. */
.draft { transition: border-color 0.15s, box-shadow 0.15s; }
.draft:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.draft-body { display: block; box-sizing: border-box; width: 100%; max-height: 480px; overflow: auto; margin: 0; padding: 16px 18px; border: 0; outline: 0; resize: none; background: transparent; color: var(--text); font: 13.5px/1.65 var(--font); white-space: pre-wrap; field-sizing: content; cursor: text; }
.draft-foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-3); }
.draft-foot > span { flex: 1 1 auto; min-width: 0; }
.draft-foot .btn { flex: none; }

.checklist { margin: 0 calc(-1 * var(--pad)); border-top: 1px solid var(--line); }
.check { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 11px var(--pad); background: var(--row); border-bottom: 1px solid var(--line); }
.check > i { font-size: 18px; }
.check .label { font-weight: 500; }
.check .label .muted { font-weight: 400; font-size: 12px; }
.check .note { margin-top: 2px; font-size: 12.5px; color: var(--text-3); }
.check .state { margin-top: 1px; white-space: nowrap; font-size: 12px; font-weight: 500; }
.st-saatu { color: var(--green); }
.st-puuttuu { color: var(--amber); }
.st-epäselvä, .st-ei-tarvita { color: var(--text-3); }

.plain-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.plain-list li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; font-size: 13.5px; line-height: 1.5; }
.plain-list li i { margin-top: 2px; font-size: 16px; color: var(--amber); }

/* An order: what differs from the offer, its facts, and the purchases' send button. */
.order-changes-h { margin-bottom: 8px; font-size: 12px; font-weight: 500; color: var(--text-3); }
.order-same { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13.5px; color: var(--text-2); }
.order-same i { font-size: 16px; color: var(--green); }
.order-props { grid-template-columns: 180px minmax(0, 1fr); margin-top: 16px; font-size: 13.5px; }
.purchases-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 12px; font-size: 12.5px; }
.summary { max-width: 74ch; font-size: 14px; line-height: 1.7; }
.provenance { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-3); cursor: help; }

.inq { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px var(--pad); background: var(--row); border-bottom: 1px solid var(--line); }
.inq .about { font-weight: 500; }
.inq .meta { margin-top: 2px; font-size: 12.5px; color: var(--text-2); }

.timeline { display: flex; flex-direction: column; }
.tl-item { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding-bottom: 20px; }
.tl-item::before { content: ''; position: absolute; top: 32px; bottom: 4px; left: 13.5px; width: 1px; background: var(--line-2); }
.tl-item:last-child::before { display: none; }
.tl-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--canvas); box-shadow: 0 0 0 1px var(--line-2); color: var(--text-2); font-size: 14px; }
.tl-icon.out { background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent-line); color: var(--accent); }
.tl-icon.note { background: var(--amber-soft); box-shadow: 0 0 0 1px #ecd6ae; color: var(--amber); }
.tl-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; padding-top: 4px; font-size: 13px; }
.tl-head .who { font-weight: 600; }
.tl-head .muted { flex: none; margin-left: auto; white-space: nowrap; font-size: 12px; }
.tl-card { display: block; margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--row); cursor: pointer; transition: background 0.12s; }
.tl-card:hover { background: var(--row-hover); }
.tl-card .subj { font-weight: 500; font-size: 13px; }
.tl-card .prev { display: -webkit-box; margin-top: 2px; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 12.5px; color: var(--text-2); }
.tl-note { margin-top: 6px; white-space: pre-wrap; font-size: 13.5px; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.file-chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 6px; background: var(--tint-2); font-size: 12px; color: var(--text-2); }
.file-chip i { font-size: 14px; }

.composer { margin-bottom: 20px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { display: block; width: 100%; min-height: 44px; max-height: 200px; padding: 11px 12px; border: 0; outline: 0; resize: vertical; background: transparent; font: 13.5px/1.5 var(--font); color: var(--text); }
.composer textarea::placeholder { color: var(--text-3); }
.composer .bar { display: flex; justify-content: flex-end; gap: 8px; padding: 0 8px 8px; }

.mails { display: flex; flex-direction: column; margin: 0 calc(-1 * var(--pad)); border-top: 1px solid var(--line); }
.mail-card { background: var(--row); border-bottom: 1px solid var(--line); }
.mail-card-head { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px var(--pad); cursor: pointer; transition: background 0.12s; }
.mail-card-head:hover { background: var(--row-hover); }
.mail-card-head .who { font-weight: 600; }
.mail-card-head .to { font-size: 12px; color: var(--text-3); }
.mail-card-head .subj { margin-top: 1px; font-size: 13px; }
.mail-card-body { padding: 4px var(--pad) 20px calc(var(--pad) + 44px); }
.mail-text { max-width: 76ch; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.65; color: var(--text); }
.mail-actions { display: flex; gap: 8px; margin-top: 14px; }

/* Inbox ----------------------------------------------------------------------------------- */

.inbox { flex: 1; min-height: 0; display: grid; grid-template-columns: 420px minmax(0, 1fr); }
.inbox-side { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.inbox-filter { flex: none; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.inbox-filter .seg { display: flex; }
.inbox-filter .seg button { flex: 1 1 auto; justify-content: center; padding: 0 8px; }
.inbox-list { flex: 1; min-height: 0; overflow-y: auto; }
.day { position: sticky; top: 0; z-index: 1; padding: 12px 18px 6px var(--pad); border-bottom: 1px solid var(--line); background: var(--canvas); font-size: 11.5px; font-weight: 500; color: var(--text-3); }
.mail { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; padding: 12px 18px 12px var(--pad); background: var(--row); border-bottom: 1px solid var(--line); cursor: pointer; transition: background 0.12s; }
.mail:hover { background: var(--row-hover); }
.mail.on { background: var(--accent-soft); }
.mail-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.mail-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13px; }
.mail-time { flex: none; margin-left: auto; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.mail-subj { margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.mail-route { display: flex; align-items: center; gap: 6px; min-width: 0; margin-top: 7px; }
.reader { min-height: 0; overflow-y: auto; padding: 28px 40px 56px; }
.reader h2 { font-size: 19px; font-weight: 500; line-height: 1.3; letter-spacing: -0.015em; }
.reader-meta { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; margin: 18px 0; }
.reader-meta .who { font-weight: 600; }
.reader-meta .addr { overflow-wrap: anywhere; font-size: 12px; color: var(--text-3); }
.route-box { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; max-width: 760px; margin-bottom: 24px; padding: 14px 16px; border-radius: 12px; background: var(--tint); }
.route-box .c-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: var(--surface); box-shadow: 0 0 0 1px var(--edge); color: var(--text-2); font-size: 17px; }
.route-box.linked .c-icon { background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent-line); color: var(--accent); }
.route-box b { display: block; font-size: 13.5px; }
.route-box span { display: block; margin-top: 2px; font-size: 12.5px; color: var(--text-2); }

/* Narrow screens --------------------------------------------------------------------------- */

@media (max-width: 1320px) {
  :root { --chat: 340px; --pad: 24px; }
}
@media (max-width: 1180px) {
  .record-body { grid-template-columns: minmax(0, 1fr); }
  .record-side { border-left: 0; border-top: 1px solid var(--line); padding-left: var(--pad); }
  .inbox { grid-template-columns: 340px minmax(0, 1fr); }
}
@media (max-width: 1000px) {
  .app.with-chat { grid-template-columns: var(--rail) minmax(0, 1fr); }
  .app.wide.with-chat { grid-template-columns: var(--rail-wide) minmax(0, 1fr); }
  .app.with-chat .chat { display: none; }
  .app.with-chat ~ .toasts { right: 18px; }
}
@media (max-width: 820px) {
  :root { --pad: 16px; }
  .app.wide, .app.wide.with-chat { grid-template-columns: var(--rail) minmax(0, 1fr); }
  .app.wide .rail .lbl { opacity: 0; max-width: 0; }
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .inbox.reading .inbox-side { display: none; }
  .inbox:not(.reading) .reader { display: none; }
  .reader { padding: 20px 16px 40px; }
  .filter { width: 100%; }
  .step .lbl { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Lines, costing and offer ------------------------------------------------------------------ */

.lines-sub { margin: -2px 0 14px; font-size: 12.5px; color: var(--text-3); }
.decide { margin: 0 calc(-1 * var(--pad)) 20px; }
.decide-h { display: flex; align-items: center; gap: 6px; padding: 0 var(--pad) 8px; font-size: 12.5px; font-weight: 600; color: var(--amber); }
.decide .list { margin: 0; }
.decide .meta b { font-weight: 600; color: var(--text); }
.line-ref { min-width: 28px; color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.lines-wrap { margin: 0 calc(-1 * var(--pad)); border-top: 1px solid var(--line); }
.lines-grid tbody tr { cursor: default; }
.lines-grid td { height: 40px; max-width: 220px; }
.lines-grid tbody tr.decide td { background: #fdf8ef; }
.lines-grid tbody tr:hover td { background: var(--row); }
.lines-grid tbody tr.decide:hover td { background: #fdf8ef; }
.costing { width: 100%; border-collapse: collapse; font-size: 13px; }
.costing th, .costing td { padding: 8px 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 400; }
.costing thead th { font-size: 12px; font-weight: 500; color: var(--text-3); }
.costing tbody th { color: var(--text-2); }
.costing .num { padding-left: 16px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.costing-wait { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.costing-wait i { margin-top: 2px; color: var(--amber); }
.costing-file { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--text-3); }
.costing-file > span { flex: 1 1 auto; min-width: 0; }
.costing-file b { font-weight: 500; color: var(--text-2); }
table.offer { width: 100%; border-collapse: collapse; font-size: 13px; }
table.offer th, table.offer td { padding: 9px 14px; border-bottom: 1px solid var(--line); text-align: left; }
table.offer thead th { font-size: 12px; font-weight: 500; color: var(--text-3); }
table.offer .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.offer tfoot td { border-bottom: 0; color: var(--text-2); }
.offer-terms { padding: 10px 14px 12px; font-size: 12.5px; line-height: 1.55; color: var(--text-2); }
.erp-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--tint-2); color: var(--text-2); font-size: 15px; }


/* The history under an open email: the company's emails and earlier orders, one line per step; an
   email line opens to show the email. */
.history { max-width: 760px; margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); }
.history-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 14px; }
.history-h h3 { font-size: 14px; font-weight: 600; }
.history-h .muted { font-size: 12.5px; }
.history .tl-item { padding-bottom: 8px; }
.history .tl-item::before { top: 30px; bottom: 2px; }
.history .tl-icon { background: var(--surface); }
.hist-line { display: flex; align-items: baseline; gap: 8px; width: 100%; min-width: 0; padding: 5px 0 0; border: 0; background: none; font: 13px var(--font); color: var(--text); text-align: left; }
button.hist-line { cursor: pointer; }
button.hist-line:hover .hist-text { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.hist-text { flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.hist-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); }
.hist-line .tag { flex: none; height: 20px; }
.hist-line .muted { flex: none; margin-left: auto; padding-left: 8px; font-size: 12px; white-space: nowrap; }
.tl-item.on .hist-text { color: var(--accent-text); }
.hist-detail { margin: 8px 0 6px; padding: 12px 14px; border-radius: 10px; background: var(--row); font-size: 13px; }
.hist-detail .mail-text { max-height: 320px; overflow-y: auto; font-size: 13px; }
.hist-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.history-more { margin: 2px 0 0 40px; padding: 0; border: 0; background: none; font: 500 12.5px var(--font); color: var(--accent-text); cursor: pointer; }
/* Saapuneet and Lähetetyt a step in under Sähköposti; the Arkisto link under the list; the actions
   in a route box; a meeting in the history; the history line's edit. The same as in the CRM. */
.rail-item.sub { height: 34px; }
.app.wide .rail-item.sub { padding-left: 34px; }
.rail-item.sub i { font-size: 17px; }
.mail-archive-link { display: flex; align-items: center; gap: 8px; width: 100%; padding: 12px var(--pad); border: 0; border-top: 1px solid var(--line); background: transparent; font: 500 12.5px var(--font); color: var(--text-2); text-align: left; cursor: pointer; }
.mail-archive-link:hover { background: var(--tint); color: var(--text); }
.mail-archive-link .muted { margin-left: auto; }
.route-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tl-icon.cal { background: var(--green-soft); box-shadow: 0 0 0 1px #c6e3d0; color: var(--green); }
.hist-detail .props { grid-template-columns: 96px minmax(0, 1fr); gap: 6px 10px; }
.hist-label { display: flex; flex: 1; align-items: center; gap: 8px; min-width: 220px; font-size: 12.5px; color: var(--text-3); }
.inline-input { width: 100%; height: 28px; margin: -5px 0 -5px -8px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; font: 13px var(--font); color: var(--text); }
.inline-input:hover { border-color: var(--line); }
.inline-input:focus { outline: 0; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.hist-label .inline-input { flex: 1; margin: 0; border-color: var(--line); background: var(--surface); }
