/* nVoice application shell, layered on top of the NACMO design system. */

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

/* Generative starfield canvas, behind the nebula wash and all content. */
#starfield { position: fixed; inset: 0; z-index: -3; display: block; pointer-events: none; }

/* ---- Centered auth / status shells -------------------------------------- */
.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--s-6);
  padding: var(--s-6);
}
.auth-holo { width: min(460px, 92vw); }
.auth-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: clamp(var(--s-5), 5vw, var(--s-8));
}
.auth-card h1 { margin-top: var(--s-2); }
/* Anchors used as buttons must not inherit `.nacmo a` link styling. */
.nacmo a.nacmo-btn { text-decoration: none; }
.nacmo a.nacmo-btn--ghost { color: var(--ink-300); }
.nacmo a.nacmo-btn--ghost:hover { color: var(--ink-50); }
.nacmo a.nacmo-btn--secondary { color: var(--cyan-200); }
.nacmo a.nacmo-btn--primary,
.nacmo a.nacmo-btn--highlight { color: var(--space-950); }
.auth-card .nacmo-btn { margin-top: var(--s-4); align-self: flex-start; }

.roles { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }

/* ---- Brand lockup ------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: var(--s-3); }
.brand .wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-h3);
  letter-spacing: -0.02em;
  color: var(--ink-50);
}

/* ---- Authenticated app shell ------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100dvh; align-items: start; }
.app-sidebar {
  display: flex; flex-direction: column; gap: var(--s-5);
  padding: var(--s-6); border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16,29,51,.5), rgba(11,20,38,.3));
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
}
.app-brand { display: flex; align-items: center; gap: var(--s-3); text-decoration: none; }
.app-brand .wordmark {
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--fs-h4); color: var(--ink-50);
}

/* Active-tenant context indicator */
.app-tenant {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 12px; border: 1px solid var(--line); clip-path: var(--cut-sm);
  background: rgba(4,7,15,.35);
}
.app-tenant__label { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-500); }
.app-tenant__name { font-weight: 600; color: var(--cyan-200); font-size: var(--fs-body-s); line-height: 1.3; }
.app-tenant details { margin-top: 2px; }
.app-tenant summary { cursor: pointer; font-size: var(--fs-caption); color: var(--ink-500); list-style: none; }
.app-tenant summary::-webkit-details-marker { display: none; }
.app-tenant summary:hover { color: var(--cyan-300); }
.app-tenant__menu { display: flex; flex-direction: column; gap: 2px; margin-top: var(--s-2); }
.nacmo a.app-tenant__opt { font-size: var(--fs-body-s); color: var(--ink-300); text-decoration: none; padding: 6px 8px; clip-path: var(--cut-sm); border: 1px solid transparent; }
.nacmo a.app-tenant__opt:hover { color: var(--ink-50); border-color: var(--line); }
.nacmo a.app-tenant__opt.is-active { color: var(--cyan-200); background: var(--info-bg); border-color: var(--line-cyan); }
.app-tenant--none { border-color: var(--orange-300); background: var(--warning-bg); }
.app-tenant__name--none { color: var(--orange-200); font-weight: 600; }
.app-tenant--none summary { color: var(--orange-200); }
.nacmo a.app-tenant__opt--exit { margin-top: 4px; border-top: 1px solid var(--line); color: var(--ink-500); }
.nacmo a.app-tenant__opt--exit:hover { color: var(--orange-200); }

/* Tenant switcher dropdown (multi-tenant users / global admin). */
.app-tenant--switch { padding: 0; cursor: pointer; transition: border-color .15s ease; }
.app-tenant--switch[open] { border-color: var(--line-cyan); }
.app-tenant--switch:hover { border-color: var(--line-cyan); }
.app-tenant__current { display: flex; align-items: center; gap: var(--s-2); padding: 9px 12px; list-style: none; cursor: pointer; }
.app-tenant__current::-webkit-details-marker { display: none; }
.app-tenant__id { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.app-tenant__role { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .06em; text-transform: uppercase; color: var(--orange-200); }
.app-tenant__chev { color: var(--ink-500); flex-shrink: 0; transition: transform .18s ease; }
.app-tenant--switch[open] .app-tenant__chev { transform: rotate(180deg); }
.app-tenant--switch .app-tenant__menu { margin: 0; padding: var(--s-2); border-top: 1px solid var(--line); }
.app-tenant__menu-head { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-500); padding: 2px 8px var(--s-1); }

/* Ingest slug editor: input + @domain suffix. */
.slug-row { display: flex; align-items: center; gap: var(--s-2); }
.slug-suffix { font-family: var(--font-mono); color: var(--ink-500); white-space: nowrap; }

/* Home tenant picker (global admin with no tenant entered). */
.tenant-pick { display: flex; flex-direction: column; gap: var(--s-3); align-items: flex-start; }
.tenant-pick__grid { display: flex; flex-wrap: wrap; gap: var(--s-2); }

.app-nav { display: flex; flex-direction: column; gap: var(--s-1); }
.app-nav__item {
  font-family: var(--font-display); font-weight: 500; font-size: var(--fs-body-s);
  color: var(--ink-300); text-decoration: none; padding: 10px 12px;
  clip-path: var(--cut-sm); border: 1px solid transparent;
  transition: all var(--d-fast) var(--ease-warp); white-space: nowrap;
}
.app-nav__item:hover { color: var(--ink-50); border-color: var(--line); }
.app-nav__item.is-active { color: var(--cyan-200); background: var(--info-bg); border-color: var(--line-cyan); }
.app-user { margin-top: auto; display: flex; flex-direction: column; gap: var(--s-3); align-items: stretch; }
.app-user__card {
  display: flex; align-items: center; gap: var(--s-3); min-width: 0;
  padding: 9px 10px; clip-path: var(--cut-sm);
  border: 1px solid var(--line); background: rgba(4, 7, 15, .35);
}
.app-user__avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; clip-path: var(--cut-sm);
  background: var(--info-bg); border: 1px solid var(--line-cyan); color: var(--cyan-200);
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-body-s);
}
.app-user__meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.app-user__name { font-weight: 600; color: var(--ink-50); font-size: var(--fs-body-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-user__email { font-size: var(--fs-micro); color: var(--ink-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-user__out { width: 100%; justify-content: center; }

/* Product attribution (fixed; not tenant-dependent) + language switch */
.app-foot { display: flex; flex-direction: column; gap: 1px; padding-top: var(--s-3); border-top: 1px solid var(--line-soft); }
.app-foot__top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.app-foot__name { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-caption); color: var(--ink-300); }
.app-foot__org { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .04em; color: var(--ink-700); }
.app-foot .app-lang { margin: 0; gap: 4px; }
.nacmo .app-foot a.app-lang__opt { padding: 1px 6px; font-size: 10px; }

.app-content { padding: clamp(20px, 4vw, var(--s-12)); max-width: var(--container); width: 100%; min-width: 0; }

/* ---- Language switcher (sidebar) --------------------------------------- */
.app-lang { display: flex; gap: var(--s-2); margin-bottom: var(--s-2); }
.nacmo a.app-lang__opt {
  font-family: var(--font-mono); font-size: var(--fs-micro); text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-500); text-decoration: none;
  padding: 3px 8px; border: 1px solid var(--line); clip-path: var(--cut-sm);
  transition: all var(--d-fast) var(--ease-warp);
}
.nacmo a.app-lang__opt:hover { color: var(--ink-100); border-color: var(--line-strong); }
.nacmo a.app-lang__opt.is-active { color: var(--cyan-200); border-color: var(--line-cyan); background: var(--info-bg); }

/* ---- Impersonation banner ---------------------------------------------- */
.imp-banner {
  position: sticky; top: 0; z-index: 40; margin-bottom: var(--s-6);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  padding: 10px 16px; clip-path: var(--cut-sm);
  background: var(--warning-bg); border: 1px solid var(--line-orange); color: var(--orange-200);
  font-family: var(--font-mono); font-size: var(--fs-body-s);
}
.imp-banner b { color: var(--orange-300); }
.imp-banner .imp-by { color: var(--ink-500); }
.imp-banner .nacmo-btn { min-height: 32px; padding: 4px 14px; }

/* ---- Flash toasts ------------------------------------------------------ */
.flash {
  margin-bottom: var(--s-6); padding: 11px 16px; clip-path: var(--cut-sm);
  font-size: var(--fs-body-s); border: 1px solid var(--line);
}
.flash--ok { background: var(--success-bg); border-color: rgba(45, 212, 167, .4); color: var(--success); }
.flash--err { background: var(--warning-bg); border-color: var(--line-orange); color: var(--orange-200); }

/* ---- Global search ----------------------------------------------------- */
.app-search { margin: var(--s-3) 0 0 0; }
.app-search input { width: 100%; }
.search-results { list-style: none; margin: 0; padding: 0; }
.search-results li { border-bottom: 1px solid var(--line-soft); }
.search-results a { display: flex; align-items: center; gap: var(--s-4); padding: 11px 4px; color: var(--ink-100); text-decoration: none; }
.search-results a:hover { background: rgba(143, 178, 235, .045); }
.search-kind {
  flex: none; min-width: 78px; text-align: center; font-family: var(--font-mono);
  font-size: var(--fs-micro); letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 8px; clip-path: var(--cut-sm); border: 1px solid var(--line); color: var(--ink-300);
}
.search-kind.k-invoice { color: var(--cyan-200); border-color: var(--line-cyan); background: var(--info-bg); }
.search-kind.k-client { color: var(--orange-200); border-color: var(--line-orange); background: var(--warning-bg); }
.search-kind.k-employee { color: var(--ink-200); }
.search-label { color: var(--ink-50); font-weight: 500; }
.search-sub { color: var(--ink-500); font-size: var(--fs-caption); }
.period-form { max-width: 320px; margin-bottom: var(--s-6); }

/* ---- Read-only role hint (accountants) --------------------------------- */
.readonly-note {
  margin-bottom: var(--s-6); padding: 8px 14px; clip-path: var(--cut-sm);
  background: var(--info-bg); border: 1px solid var(--line-cyan); color: var(--cyan-200);
  font-family: var(--font-mono); font-size: var(--fs-body-s);
}
.inline-form .nacmo-field.grow { flex: 1 1 auto; min-width: 0; }

/* ---- Time-edit safety warning (admin editing someone else's records) ---- */
.time-warn {
  margin-bottom: var(--s-6); padding: 10px 16px; clip-path: var(--cut-sm);
  background: var(--warning-bg); border: 1px solid var(--line-orange); color: var(--orange-200);
  font-family: var(--font-mono); font-size: var(--fs-body-s);
}

/* ---- "Today" timesheet row: gold = editable until midnight -------------- */
.data-table tbody tr.today-row {
  background: linear-gradient(90deg, rgba(212, 175, 55, .12), rgba(212, 175, 55, .04));
  box-shadow: inset 3px 0 0 #d4af37;
}
.data-table tbody tr.today-row:hover { background: rgba(212, 175, 55, .16); }
.data-table tbody tr.today-row td { color: var(--ink-50); }
.today-tag {
  display: inline-block; margin-left: 8px; padding: 1px 7px; vertical-align: middle;
  font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .08em;
  text-transform: uppercase; color: #1a1407; background: #d4af37;
  border-radius: 2px; clip-path: var(--cut-sm);
}

.page-head { margin-bottom: var(--s-8); }
.nacmo-panel { min-width: 0; }
.nacmo-panel + .nacmo-panel { margin-top: var(--s-6); }
.nacmo-panel h3 { margin-bottom: var(--s-4); }

/* ---- Custom-styled selects (native chevron replaced) ------------------- */
.nacmo select.nacmo-input {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2367E8F9' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 12px 8px;
}
.nacmo select.nacmo-input::-ms-expand { display: none; }
.nacmo select.nacmo-input option { background: var(--space-800); color: var(--ink-50); }
/* Inputs/selects must be able to shrink inside grids (kills the overlap bug) */
.nacmo-input { min-width: 0; max-width: 100%; }

/* ---- Data tables ------------------------------------------------------- */
/* Panels whose direct child is a list table scroll horizontally when narrow. */
.nacmo-panel:has(> .data-table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-body-s); }
.data-table th {
  text-align: left; color: var(--ink-500); font-family: var(--font-mono);
  font-size: var(--fs-micro); letter-spacing: .08em; text-transform: uppercase;
  padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); color: var(--ink-100); vertical-align: middle; }
.data-table tbody tr { transition: background var(--d-fast) var(--ease-warp); }
.data-table tbody tr:hover { background: rgba(143, 178, 235, 0.045); }
.data-table a { color: var(--cyan-300); }
.muted, .data-table .muted { color: var(--ink-500); }

/* Compact, single-line actions/controls inside table rows */
.data-table form { margin: 0; }
.data-table .nacmo-input { max-width: 170px; }
.nacmo-btn.btn-sm { min-height: 32px; padding: 5px 14px; font-size: var(--fs-caption); white-space: nowrap; }
.row-actions { text-align: right; white-space: nowrap; width: 1%; }

/* Two-line identity cell (primary + muted secondary) */
.cell-id { display: flex; flex-direction: column; gap: 1px; }
.cell-id .pri { color: var(--ink-50); font-weight: 500; }
.cell-id .sec { color: var(--ink-500); font-size: var(--fs-caption); }

/* Inline badge group; role badges never wrap mid-label */
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }
.nacmo-badge { white-space: nowrap; }

/* Status pills */
.pill {
  display: inline-block; font-family: var(--font-mono); font-size: var(--fs-micro);
  letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px;
  clip-path: var(--cut-sm); border: 1px solid var(--line); color: var(--ink-300);
}
.pill--ok { color: var(--success); background: var(--success-bg); border-color: rgba(45, 212, 167, .4); }
.pill--wait { color: var(--warning); background: var(--warning-bg); border-color: rgba(255, 176, 32, .4); }
.pill--off { color: var(--ink-500); background: rgba(143, 178, 235, .06); border-color: var(--line); }

/* ---- Per-client color (derived from OIB) ------------------------------- */
/* Each bucket sets a hue; generic rules below turn it into a row tint + swatch. */
.client-c0 { --ch: 5; }    .client-c1 { --ch: 30; }   .client-c2 { --ch: 55; }
.client-c3 { --ch: 80; }   .client-c4 { --ch: 110; }  .client-c5 { --ch: 135; }
.client-c6 { --ch: 160; }  .client-c7 { --ch: 185; }  .client-c8 { --ch: 210; }
.client-c9 { --ch: 240; }  .client-c10 { --ch: 265; } .client-c11 { --ch: 290; }
.client-c12 { --ch: 320; } .client-c13 { --ch: 345; }

/* Lightly tinted invoice/client rows + a left accent stripe. */
.data-table tbody tr[class*="client-c"] { background: hsl(var(--ch) 55% 58% / 0.09); }
.data-table tbody tr[class*="client-c"]:hover { background: hsl(var(--ch) 55% 58% / 0.16); }
.data-table tbody tr[class*="client-c"] td:first-child { box-shadow: inset 3px 0 0 0 hsl(var(--ch) 70% 66%); }

/* Square client tag (full view). */
.client-swatch {
  display: inline-block; width: 13px; height: 13px; flex: none;
  clip-path: var(--cut-sm); background: hsl(var(--ch) 62% 72%);
  box-shadow: inset 0 0 0 1px hsl(var(--ch) 45% 45% / .6);
}
.cell-swatch { display: flex; align-items: center; gap: 8px; }
.client-tag { display: flex; align-items: center; gap: 8px; margin-top: var(--s-3); color: var(--ink-300); }
.client-tag .client-swatch { width: 16px; height: 16px; }
.client-tag .nacmo-label { margin-right: 2px; }

/* Swatch -> client legend beneath the invoice list. */
.client-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px var(--s-4);
  margin-top: var(--s-4); padding: var(--s-3) var(--s-4);
  font-size: var(--fs-caption); color: var(--ink-300);
}
.client-legend__title {
  font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-500);
}
.client-legend__item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* ---- Invoices month timeline (draggable scrubber) ---------------------- */
.tl { display: none; margin: 0 0 var(--s-6); padding: 2px 18px 0; user-select: none; }
.tl.is-ready { display: block; }
.tl-head { display: flex; align-items: center; gap: var(--s-4); min-height: 34px; margin-bottom: var(--s-1); }
.tl-sel { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-h4); color: var(--cyan-200); text-transform: capitalize; }
.tl-track { position: relative; height: 28px; touch-action: none; cursor: pointer; }
.tl-line { position: absolute; left: 0; right: 0; top: 50%; height: 2px; transform: translateY(-50%); background: var(--line); }
.tl-fill { position: absolute; left: 0; width: 0; top: 50%; height: 2px; transform: translateY(-50%); background: var(--cyan-500); box-shadow: var(--glow-soft); }
.tl-tick { position: absolute; top: 50%; width: 2px; height: 9px; transform: translate(-50%, -50%); background: var(--line-strong); pointer-events: none; }
.tl-tick.year { height: 15px; background: var(--ink-500); }
.tl-thumb {
  position: absolute; top: 50%; left: 100%; width: 18px; height: 18px; padding: 0;
  transform: translate(-50%, -50%); background: var(--cyan-400); border: none;
  clip-path: var(--cut-sm); box-shadow: var(--glow-cyan); cursor: grab;
}
.tl-thumb:active { cursor: grabbing; }
.tl-thumb:focus-visible { outline: 2px solid var(--cyan-200); outline-offset: 3px; }
.tl-ends { display: flex; justify-content: space-between; margin-top: 9px; font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-500); }

/* No-JS fallback: plain month links */
.timeline-fallback { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0 0 var(--s-6); }
.nacmo a.timeline-month {
  font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--ink-500);
  text-decoration: none; padding: 6px 12px; border: 1px solid var(--line); clip-path: var(--cut-sm);
}
.nacmo a.timeline-month.is-active { color: var(--cyan-200); border-color: var(--line-cyan); background: var(--info-bg); }

/* ---- Per-row download icon (lit + check once downloaded) ---------------- */
.nacmo a.dl-btn {
  display: inline-flex; align-items: center; justify-content: center; position: relative;
  width: 32px; height: 32px; color: var(--ink-500); text-decoration: none;
  border: 1px solid var(--line); clip-path: var(--cut-sm);
  transition: all var(--d-fast) var(--ease-warp);
}
.nacmo a.dl-btn:hover { color: var(--cyan-300); border-color: var(--line-cyan); }
.nacmo a.dl-btn.is-downloaded { color: var(--cyan-300); border-color: var(--line-cyan); background: var(--info-bg); box-shadow: var(--glow-soft); }
.dl-btn .ic-check {
  display: none; position: absolute; top: -5px; right: -5px;
  color: var(--space-950); background: var(--success); border-radius: 50%;
  padding: 2px; box-shadow: 0 0 0 2px var(--space-700);
}
.dl-btn.is-downloaded .ic-check { display: block; }

/* ---- Forms ------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: var(--s-3); align-items: flex-start; }
.stack > .nacmo-field, .stack > .grid-2 { width: 100%; align-self: stretch; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3) var(--s-4); }
.app-content .nacmo-field { max-width: none; margin-bottom: 0; min-width: 0; }
.advanced { margin: var(--s-2) 0; color: var(--ink-300); width: 100%; }
.advanced summary { cursor: pointer; color: var(--cyan-300); font-size: var(--fs-body-s); margin-bottom: var(--s-4); }
.advanced[open] summary { margin-bottom: var(--s-4); }
.check { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-body-s); margin-top: var(--s-4); color: var(--ink-300); }
.inline-form { display: flex; gap: var(--s-3); align-items: flex-end; margin-top: var(--s-4); flex-wrap: wrap; }
.inline-form .nacmo-input { max-width: 320px; }

/* ---- Invoicing: toolbar, totals, line-item inputs ---------------------- */
.toolbar { display: flex; gap: var(--s-3); align-items: center; margin: var(--s-4) 0; flex-wrap: wrap; }
.toolbar form { margin: 0; }
td.num, .data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kv-grid .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Two-column summary tables (reports input-VAT / payable): keep label & value close. */
.report-kv { max-width: 460px; }
.invoice-form .grid-2 { margin-bottom: var(--s-4); }
.invoice-form h3 { margin: var(--s-6) 0 var(--s-3); }
.nacmo-input.sm { max-width: 120px; }
.nacmo-input.xs { max-width: 84px; }
.nacmo-field.full { max-width: none; margin-top: var(--s-4); }

/* ---- Invoice line cards -------------------------------------------------- */
/* Each line is one card: description + KPD code + KPD name on top, the measured
   fields (qty/unit/price/disc/vat) + the live line total on a second row. Field
   labels live in the placeholders. Odd/even tinting makes lines easy to scan. */
.line-list { display: flex; flex-direction: column; border: 1px solid var(--line-soft); clip-path: var(--cut-sm); margin-top: var(--s-2); }
.line-row { display: flex; align-items: stretch; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line-soft); }
.line-row:last-child { border-bottom: none; }
.line-row:nth-child(odd) { background: rgba(143,178,235,.04); }
.line-row:hover { background: rgba(34,211,238,.06); }
.line-row.dragging { opacity: .45; }

/* Drag grip — the only handle that starts a reorder, so inputs stay selectable. */
.line-grip {
  flex: 0 0 auto; align-self: stretch; display: flex; align-items: center; justify-content: center;
  width: 16px; cursor: grab; color: var(--ink-700); font-size: 14px; line-height: 1; user-select: none;
}
.line-grip:hover { color: var(--cyan-300); }
.line-grip:active { cursor: grabbing; }
.line-main { flex: 1 1 auto; min-width: 0; }

/* One shared input height across the whole line, so every field aligns. */
.line-main { --fld-h: 38px; }
.line-main .nacmo-input { height: var(--fld-h); width: 100%; max-width: none; padding: 0 10px; }

/* Field cell = tiny caption above its control. The cells are grid items, so the
   column tracks (below) — not per-field max-widths — decide every field's size. */
.fld { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fld-lab { font-family: var(--font-mono); font-size: 9px; line-height: 1; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-500); padding-left: 1px; }

/* Modular field grid shared by BOTH rows: 8 equal base columns + a fixed cell
   for the delete control. Every field spans 1 (S), 2 (M) or 4 (L) base columns
   (L = 4×S, M = 2×S). Identical tracks on both rows make the fields line up
   across the two rows and across every card.
   Row 1: description(L) · KPD(M) · classification(M).
   Row 2: qty(S) · unit(S) · price(M) · disc(S) · vat(S) · amount(M) · delete. */
.line-top, .line-bottom { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)) 30px; gap: var(--s-2); align-items: end; }
.line-bottom { margin-top: var(--s-2); }
.fld-s { grid-column: span 1; }
.fld-m { grid-column: span 2; }
.fld-l { grid-column: span 4; }

.line-main textarea.line-desc {
  height: var(--fld-h); min-height: var(--fld-h); padding: 8px 10px;
  line-height: 1.4; font-family: var(--font-body); resize: none; overflow: hidden;
  white-space: pre-wrap; word-break: break-word; display: block;
}
.kpd-name {
  align-self: end; padding-bottom: 9px;
  font-size: var(--fs-caption); color: var(--ink-500); line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.line-amt { justify-self: end; align-self: end; padding-bottom: 9px; font-variant-numeric: tabular-nums; color: var(--ink-100); font-size: var(--fs-body-s); white-space: nowrap; }
.line-bottom .line-del { align-self: end; justify-self: center; }

/* KPD is domestic-only: drop the KPD cell + name; description spans all 8 cols. */
.invoice-form.kpd-off .fld-kpd, .invoice-form.kpd-off .kpd-name { display: none; }
.invoice-form.kpd-off .line-top .fld-l { grid-column: 1 / span 8; }

/* ---- KPD picker on the invoice line ------------------------------------- */
/* A code input with a live ✓/✗ indicator and a search-as-you-type dropdown.
   The code is required on domestic B2B e-invoices but never printed on the PDF. */
.kpd-cell { position: relative; display: flex; align-items: center; gap: 4px; width: 100%; }
.kpd-cell .line-kpd { flex: 1 1 auto; width: auto; min-width: 0; font-family: var(--font-mono); letter-spacing: .01em; }
.kpd-status { flex: 0 0 auto; width: 1.1em; font-weight: 700; font-size: var(--fs-body-s); text-align: center; }
.kpd-status.ok { color: var(--success); }
.kpd-status.bad { color: var(--danger); }
.kpd-status.pending { color: var(--ink-500); }
/* Portaled to <body> and fixed-positioned by invoice.js, so it overlays the
   invoice panel rather than being clipped by its clip-path. */
.kpd-results {
  position: fixed; z-index: 1000;
  min-width: 300px; max-width: 380px; max-height: 260px; overflow-y: auto;
  background: var(--space-900); border: 1px solid var(--line-cyan);
  box-shadow: var(--e3);
}
.kpd-opt {
  display: flex; gap: var(--s-3); align-items: baseline; padding: 7px 11px;
  cursor: pointer; border-bottom: 1px solid var(--line-soft);
}
.kpd-opt:last-child { border-bottom: none; }
.kpd-opt:hover { background: var(--info-bg); }
.kpd-opt code { color: var(--cyan-200); font-family: var(--font-mono); font-size: var(--fs-body-s); flex: 0 0 auto; }
.kpd-opt__name { color: var(--ink-300); font-size: var(--fs-caption); line-height: 1.35; }

/* ---- KPD compliance panel (draft pre-issue) ----------------------------- */
.kpd-compliance { margin-top: var(--s-4); }
.kpd-compliance.is-blocked { border-color: var(--line-orange); }
.kpd-compliance__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-2); }
.kpd-compliance__head h2 { font-size: var(--fs-h5, var(--fs-h4)); color: var(--ink-50); margin: 0; }
.kpd-compliance__note { font-size: var(--fs-caption); color: var(--ink-500); margin: 0 0 var(--s-3); }
.kpd-compliance__warn { font-size: var(--fs-body-s); color: var(--orange-200); margin: var(--s-3) 0 0; }
.kpd-badge {
  font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .06em;
  text-transform: uppercase; padding: 4px 10px; clip-path: var(--cut-sm); white-space: nowrap;
}
.kpd-badge.ok { color: var(--success); background: var(--success-bg); border: 1px solid rgba(45,212,167,.4); }
.kpd-badge.bad { color: var(--orange-200); background: var(--warning-bg); border: 1px solid var(--line-orange); }
.kpd-compliance code { color: var(--cyan-200); font-family: var(--font-mono); }
.kpd-compliance tr.kpd-row-bad td { background: var(--warning-bg); }
.kpd-mark { font-weight: 700; }
.kpd-mark.ok { color: var(--success); }
.kpd-mark.bad { color: var(--danger); }
/* dynamic line add / remove */
.line-del {
  background: transparent; border: 1px solid var(--line); color: var(--ink-500);
  width: 30px; height: 30px; cursor: pointer; clip-path: var(--cut-sm); line-height: 1;
  font-size: 18px; transition: all var(--d-fast) var(--ease-warp);
}
.line-del:hover { color: var(--danger); border-color: rgba(255,84,112,.45); }
.line-add { margin-top: var(--s-3); }
.line-tools { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; margin-top: var(--s-3); }
.line-tools .line-add { margin-top: 0; }
.line-tools .ai-status { font-size: var(--fs-caption); }
.totals { margin-top: var(--s-4); display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-2); }
.totals > div { display: flex; gap: var(--s-6); min-width: min(320px, 100%); justify-content: space-between; }
.totals .grand { font-size: var(--fs-h4); color: var(--ink-50); border-top: 1px solid var(--line-strong); padding-top: var(--s-2); }
.statusrow { display: flex; gap: var(--s-3); align-items: center; margin: var(--s-2) 0; flex-wrap: wrap; }
/* Integrity panel: collapsed by default; summary reads as a panel heading. */
.integrity > summary {
  cursor: pointer; list-style: none; color: var(--ink-300);
  font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .08em;
  text-transform: uppercase;
}
.integrity > summary::-webkit-details-marker { display: none; }
.integrity > summary::before { content: "▸ "; color: var(--ink-500); }
.integrity[open] > summary::before { content: "▾ "; }
.integrity > summary:hover { color: var(--cyan-300); }
.integrity-body { margin-top: var(--s-3); }
.integrity .micro { word-break: break-all; margin: 2px 0; font-size: var(--fs-micro); }

/* client picker on the invoice form */
.client-pick { display: flex; gap: var(--s-3); align-items: flex-end; flex-wrap: wrap; margin-bottom: var(--s-4); }
.client-pick .nacmo-field { flex: 1 1 280px; }

/* AI invoice-builder block — collapsed by default (<details>). */
.invoice-form .ai-block { border-color: var(--line-cyan); margin: var(--s-6) 0; background: var(--grad-primary-soft), var(--grad-surface); }
.ai-block h3 { color: var(--cyan-200); margin-top: 0; }
.ai-block > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: .4em;
  color: var(--cyan-200); font-family: var(--font-display); font-weight: 600; font-size: var(--fs-h4);
}
.ai-block > summary::-webkit-details-marker { display: none; }
.ai-block > summary::before { content: "▸"; color: var(--ink-500); font-size: .8em; }
.ai-block[open] > summary::before { content: "▾"; }
.ai-block[open] > summary { margin-bottom: var(--s-3); }
.ai-status { font-size: var(--fs-caption); }
textarea.nacmo-input { resize: vertical; min-height: 60px; font-family: var(--font-body); line-height: 1.5; }

/* ---- Invoice "paper": a print-style white document ---------------------- */
.invoice-paper {
  background: #fff; color: #1a1a1a; max-width: 840px; width: 100%; margin: var(--s-4) 0;
  padding: clamp(20px, 4vw, 44px); font-family: Arial, "Helvetica Neue", sans-serif;
  font-size: 13px; line-height: 1.5; filter: drop-shadow(var(--e3));
}
.invoice-paper b, .invoice-paper strong { color: #000; }
.invoice-paper hr { border: none; border-top: 1px solid #ddd; margin: 20px 0; }
.ip-head { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.ip-bank { border: 1px dashed #bbb; padding: 8px 12px; font-size: 12px; }
.ip-meta { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 16px; flex-wrap: wrap; }
.ip-client { text-align: right; }
.ip-no { font-size: 18px; }
.ip-sub { color: #777; font-size: 11px; }
.ip-dates { text-align: right; color: #444; margin-bottom: 16px; }
table.ip-lines { width: 100%; border-collapse: collapse; margin: 12px 0; }
table.ip-lines th, table.ip-lines td { border: 1px solid #ccc; padding: 8px 10px; text-align: left; vertical-align: top; }
table.ip-lines th { background: #f4f4f4; font-weight: 600; font-size: 12px; }
table.ip-lines th span { display: block; color: #888; font-weight: 400; font-size: 10px; margin-top: 1px; }
.ip-bank-name { font-weight: 700; }
.ip-lines .ip-en { display: block; color: #888; font-weight: 400; font-size: 10px; }
.invoice-paper .num { text-align: right; }
.ip-totals { margin-top: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.ip-trow { display: flex; gap: 24px; min-width: min(300px, 100%); justify-content: space-between; }
.ip-grand { font-size: 16px; border-top: 2px solid #333; padding-top: 6px; margin-top: 4px; }
.ip-foreign b { font-weight: 600; color: #444; font-size: 13px; }
.ip-note { color: #666; font-style: italic; margin-top: 16px; }
.ip-resp { text-align: right; margin-top: 36px; }
/* logo + office + operator + totals-in-table + legal footer (match samples) */
.ip-seller { display: flex; align-items: flex-start; gap: 14px; }
.ip-logo { width: 62px; height: auto; max-height: 84px; }
.ip-office { color: #555; font-size: 12px; }
.ip-operator { color: #777; font-size: 11px; margin: 12px 0 2px; }
table.ip-lines tfoot td { border: 1px solid #ccc; padding: 8px 10px; }
.ip-lines .ip-totlabel { text-align: right; }
.ip-lines .ip-en { color: #888; font-weight: 400; font-size: 11px; }
.ip-lines .ip-totgrand td { font-size: 15px; }
.ip-lines .ip-totforeign td { color: #777; font-size: 12px; }
.ip-foot { margin-top: 32px; border-top: 1px solid #ddd; padding-top: 8px; color: #9a9a9a; font-size: 10.5px; line-height: 1.5; }
.ip-foot-name { color: #777; }
.ip-foot-meta span { margin-right: 14px; }

/* Tenant logo management preview (dark page → white plate so a black logo shows) */
.logo-row { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; margin-top: var(--s-3); }
.tenant-logo { height: 64px; width: auto; max-width: 240px; background: #fff; padding: 6px 12px; clip-path: var(--cut-sm); }

/* ---- Key/value detail lists (HR) --------------------------------------- */
.kv { margin: 0; }
.kv-row { display: grid; grid-template-columns: 220px 1fr; gap: var(--s-4); padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.kv-row dt { color: var(--ink-500); font-size: var(--fs-body-s); }
.kv-row dd { margin: 0; color: var(--ink-100); word-break: break-word; }

/* ---- HR stat cards, action buttons, dimmed rows ------------------------ */
.home-body { margin-top: var(--s-6); display: flex; flex-direction: column; gap: var(--s-6); }
.stat-cards { display: flex; flex-wrap: wrap; gap: var(--s-6) var(--s-10); }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat b { font-size: var(--fs-h3); color: var(--ink-50); }
.stat b.hl { color: var(--cyan-300); }
.actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.actions form { margin: 0; }
tr.dim td { color: var(--ink-500); }
.data-table tfoot td { border-top: 1px solid var(--line-strong); padding-top: 10px; }

/* ---- Team calendar ----------------------------------------------------- */
.cal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: var(--s-6); align-items: start; }
/* Cancel the stacked-panel top margin for side-by-side grid cells, so the
   boxes align at the top instead of the second being pushed down. */
.cal-grid > .nacmo-panel { margin-top: 0; }
.cal-row { display: flex; justify-content: space-between; gap: var(--s-4); padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.cal-row .hl { color: var(--cyan-300); }

/* ---- Dashboard: invoice tiles + team absence breakdown ----------------- */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-4); }
.panel-head h3 { margin: 0; }
.inv-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: var(--s-4); }
.inv-tile { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4) var(--s-5); clip-path: var(--cut-sm); border: 1px solid var(--line); background: rgba(143, 178, 235, .04); }
.inv-ic { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; clip-path: var(--cut-sm); flex: none; }
.inv-in .inv-ic { color: var(--cyan-300); background: var(--info-bg); border: 1px solid var(--line-cyan); }
.inv-out .inv-ic { color: var(--orange-300); background: var(--warning-bg); border: 1px solid var(--line-orange); }
.inv-tx { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.inv-tx .inv-count { font-size: var(--fs-h3); color: var(--ink-50); line-height: 1.1; }
.inv-tx .inv-total { font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--ink-500); }

/* Current-month: condensed, de-emphasized line (no download). */
.current-month { padding-top: var(--s-3); padding-bottom: var(--s-3); background: rgba(143, 178, 235, .03); }
.cm-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-6); font-size: var(--fs-body-s); }
.cm-title { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-500); margin-right: auto; }
.cm-stat { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-300); }
.cm-stat svg { color: var(--ink-500); }
.cm-stat b { color: var(--ink-50); }
.cm-amt { font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--ink-500); }

/* Capitalized month in the previous-month panel title. */
.pm-month { text-transform: capitalize; }

/* Previous-month workforce ticker: compact inline icon · value · label items. */
.labor-ticker { display: flex; flex-wrap: wrap; gap: 6px var(--s-5); margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--line-soft); }
.lt { display: inline-flex; align-items: center; gap: 6px; }
.lt-ic { display: inline-flex; color: var(--ink-500); }
.lt-ic svg { width: 13px; height: 13px; }
.lt-val { font-size: var(--fs-body-s); font-weight: 600; color: var(--ink-100); }
.lt-label { font-size: var(--fs-caption); color: var(--ink-500); }
.lt--zero { opacity: .38; }

.absence-row { display: flex; flex-wrap: wrap; gap: var(--s-5) var(--s-8); margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--line-soft); }
.abs-dot { display: inline-block; width: 10px; height: 10px; clip-path: var(--cut-sm); vertical-align: middle; margin-right: 5px; }
.k-vacation { background: var(--cyan-400); }
.k-sick { background: var(--danger); }
.k-paid_leave { background: var(--orange-500); }
.k-unpaid_leave { background: var(--ink-500); }

/* ---- Work-activity heatmap (GitHub-style) ------------------------------ */
.heat-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 4px 0; }
.heat { display: inline-flex; gap: 14px; align-items: flex-start; }
.heat-month { display: flex; flex-direction: column; gap: 6px; }
.heat-month__label { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-500); white-space: nowrap; }
.heat-month__label.is-current { color: var(--cyan-300); }
.heat-month__label.is-future { color: var(--ink-700); }
.heat-cols { display: flex; gap: 4px; align-items: flex-start; }
.heat-days { display: grid; grid-template-rows: repeat(7, 15px); gap: 4px; }
.heat-days span { font-size: 10px; line-height: 15px; color: var(--ink-500); }
/* Pin column width to the cell size: a long month label (e.g. "September")
   would otherwise widen the flex column and stretch the auto tracks, spreading
   the squares apart and breaking the grid alignment. */
.heat-grid { display: grid; grid-template-rows: repeat(7, 15px); grid-auto-flow: column; grid-auto-columns: 15px; gap: 4px; justify-content: start; }
.heat-month { align-items: flex-start; }
.heat-cell { width: 15px; height: 15px; background: var(--space-400); }
.heat-empty { background: transparent; }
.heat-l0 { background: var(--space-400); }
.heat-l1 { background: rgba(34, 211, 238, 0.30); }
.heat-l2 { background: rgba(34, 211, 238, 0.55); }
.heat-l3 { background: var(--cyan-500); }
.heat-l4 { background: var(--orange-500); }
.heat-leave { background: rgba(255, 176, 32, 0.55); }
.heat-holiday { box-shadow: inset 0 0 0 2px var(--orange-500); }
.heat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: var(--s-4); font-size: var(--fs-caption); color: var(--ink-500); }
.heat-legend .heat-cell { width: 13px; height: 13px; }
.heat-legend .sep { color: var(--space-200); }

/* Hamburger toggle is desktop-hidden; revealed only in the mobile top bar. */
.nav-toggle { display: none; }
.nav-burger { display: none; }

/* ---- Responsive: collapse sidebar to a sticky top bar ------------------ */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .app-sidebar {
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-4);
    height: auto; position: sticky; top: 0; z-index: 30;
    border-right: none; border-bottom: 1px solid var(--line);
    background: rgba(8,14,28,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .app-brand { margin-right: auto; }

  /* Hamburger: a CSS-only (no-JS) menu toggle. The checkbox is visually
     hidden but stays keyboard-focusable via its label. */
  .nav-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
  .nav-burger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; cursor: pointer; color: var(--ink-100);
    border: 1px solid var(--line-strong); clip-path: var(--cut-sm); background: rgba(143,178,235,.05);
  }
  .nav-burger:hover { color: var(--cyan-200); border-color: var(--line-cyan); }
  .nav-toggle:focus-visible + .nav-burger { outline: 2px solid var(--cyan-400); outline-offset: 2px; }

  /* Everything but the brand + burger collapses into the toggled menu. */
  .app-tenant, .app-nav, .app-search, .app-user, .app-foot { display: none; flex-basis: 100%; }
  .nav-toggle:checked ~ .app-tenant { display: flex; order: 3; flex-direction: row; align-items: center; flex-wrap: wrap; gap: var(--s-2); padding: 6px 10px; }
  /* The tenant switcher is a <details> dropdown — keep it block so the menu opens below the summary. */
  .nav-toggle:checked ~ .app-tenant--switch { display: block; order: 3; padding: 0; }
  .nav-toggle:checked ~ .app-search { display: block; order: 4; }
  .nav-toggle:checked ~ .app-nav { display: flex; order: 5; flex-direction: column; align-items: stretch; gap: var(--s-1); }
  .nav-toggle:checked ~ .app-user { display: flex; order: 6; flex-direction: column; align-items: stretch; gap: var(--s-2); margin-top: var(--s-2); }
  .nav-toggle:checked ~ .app-foot { display: flex; order: 7; }
  /* Bigger tap targets in the menu. */
  .app-nav__item { padding: 11px 12px; }
  .app-lang { margin-bottom: 0; }

  /* Comfortable hit areas for row actions and buttons on touch. */
  .nacmo-btn { min-height: 40px; }
  .data-table td, .data-table th { padding: 10px 9px; }
  /* A faint inset shadow hints that wide tables scroll horizontally. */
  .nacmo-panel:has(> .data-table) { background-attachment: local; }
}

@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kv-row { grid-template-columns: 1fr; gap: 2px; padding: 8px 0; }
  .kv-row dt { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .06em; text-transform: uppercase; }
  .totals > div { min-width: 100%; }
  .app-brand .wordmark { display: none; }
  /* Stack toolbar buttons full-width so each is an easy tap target. */
  .toolbar { gap: var(--s-2); }
  .toolbar > .nacmo-btn, .toolbar > form, .toolbar > form > .nacmo-btn { width: 100%; }
  .page-head h1 { font-size: clamp(1.7rem, 8vw, 2.4rem); }
}

/* ---- Invoice templates -------------------------------------------------- */
.toolbar .tpl-create { margin-left: auto; }   /* "Save as template" sits at the right */
.tpl-list { display: flex; flex-direction: column; gap: var(--s-3); margin-top: var(--s-4); }
.tpl-card {
  display: flex; align-items: center; gap: var(--s-3);
  background: var(--grad-surface); border: 1px solid var(--line); clip-path: var(--cut-sm);
  padding: var(--s-3) var(--s-4); transition: border-color var(--d-fast) var(--ease-warp);
}
.tpl-card:hover { border-color: var(--line-strong); }
.tpl-card.is-starred { border-color: var(--line-orange); }
.tpl-card.dragging { opacity: .45; }
.tpl-grip { flex: 0 0 auto; width: 16px; cursor: grab; color: var(--ink-700); font-size: 14px; line-height: 1; user-select: none; text-align: center; }
.tpl-grip:hover { color: var(--cyan-300); }
.tpl-grip:active { cursor: grabbing; }
.tpl-body { flex: 1 1 auto; min-width: 0; }
.tpl-title { display: flex; align-items: center; gap: .5em; }
.tpl-name { font-weight: 600; color: var(--ink-50); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-flag { color: #D4AF37; font-size: var(--fs-caption); }
.tpl-sub { margin: 2px 0 0; font-size: var(--fs-caption); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-actions { flex: 0 0 auto; display: flex; align-items: center; gap: var(--s-2); }
.tpl-actions form { margin: 0; }
.tpl-star, .tpl-del {
  background: transparent; border: 1px solid var(--line); color: var(--ink-500);
  width: 32px; height: 32px; cursor: pointer; clip-path: var(--cut-sm); line-height: 1; font-size: 15px;
  transition: all var(--d-fast) var(--ease-warp);
}
.tpl-star:hover { color: #D4AF37; border-color: rgba(212,175,55,.45); }
.tpl-star.on { color: #D4AF37; border-color: rgba(212,175,55,.5); background: rgba(212,175,55,.1); }
.tpl-del:hover { color: var(--danger); border-color: rgba(255,84,112,.45); }

/* ---- Inbound invoices --------------------------------------------------- */
.inbound-addr { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin: var(--s-3) 0 var(--s-4); }
.inbound-addr code { color: var(--cyan-200); font-family: var(--font-mono); background: var(--space-900); border: 1px solid var(--line-cyan); padding: 4px 10px; clip-path: var(--cut-sm); }
.inbound-subj { font-size: var(--fs-caption); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }

/* Clickable rows (inbound list) */
tr.is-clickable { cursor: pointer; }
tr.is-clickable:hover { background: rgba(56,189,248,.06); }
.nacmo a.row-link { color: var(--ink-50); text-decoration: none; font-weight: 500; }
.nacmo a.row-link:hover { color: var(--cyan-200); }

/* Inbound detail */
.inbound-detail__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-3); }
.inbound-detail__head h3 { margin: 0; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-3) var(--s-4); margin: 0; }
.kv-grid > div { display: flex; flex-direction: column; gap: 2px; }
.kv-grid dt { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-500); }
.kv-grid dd { margin: 0; color: var(--ink-100); }
.kv-grid dd.hl { color: var(--cyan-200); font-weight: 600; font-size: var(--fs-body-l); }
.att-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.att-list a { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--ink-100); text-decoration: none; padding: 8px 10px; border: 1px solid var(--line); clip-path: var(--cut-sm); width: fit-content; }
.att-list a:hover { border-color: var(--line-cyan); color: var(--cyan-200); }
.action-row { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.action-row form { margin: 0; }
.pdf-frame { width: 100%; height: 70vh; min-height: 480px; border: 1px solid var(--line); clip-path: var(--cut-sm); background: #fff; }
.ingest-rules textarea { font-family: var(--font-mono); font-size: var(--fs-body-s); }
.ingest-rules { margin-top: var(--s-3); border-top: 1px solid var(--line); padding-top: var(--s-3); }

/* Confirmation modal (inbound actions) */
.modal-overlay { position: fixed; inset: 0; background: rgba(2,4,10,.66); display: none; align-items: center; justify-content: center; z-index: 1000; padding: var(--s-4); }
.modal-overlay.is-open { display: flex; }
.modal-card { background: var(--space-900, #0a0f1c); border: 1px solid var(--line-cyan); clip-path: var(--cut); padding: var(--s-4); max-width: 420px; width: 100%; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.modal-msg { margin: 0 0 var(--s-4); color: var(--ink-50); line-height: 1.5; }
.modal-actions { display: flex; gap: var(--s-2); justify-content: flex-end; }

/* ---- Invoice Outbound/Inbound subtabs ---------------------------------- */
.invoice-tabs { margin: var(--s-4) 0; }
.nacmo a.nacmo-tab { color: var(--ink-500); text-decoration: none; }
.nacmo a.nacmo-tab:hover { color: var(--ink-100); }
.nacmo a.nacmo-tab.is-active { color: var(--cyan-200); }
