/* ---------------------------------------------------------------------------
   The Italian eInvoice Verifier, free on the site
   ---------------------------------------------------------------------------
   The product's verifier (Tools → Italian eInvoice Verifier) in the site's
   grammar: paper panels with a rule round them on the ruled sheet, flat grey
   for the drop zone, black pill buttons. Drawn by landing/src/einvoice.ts.

   Findings are notes, never red fills: an element with a rejection gets a red
   rule at its left edge, its name in red and a wash of a few percent; a
   warning the same in amber. The tree's values are in Geist Mono — they are
   the file's own characters, and a curly apostrophe has to look like one.
   --------------------------------------------------------------------------- */

.ev-head .ev-it {
  max-width: 62ch;
  margin-top: 14px;
  font-size: 15px;
  color: var(--text-dim);
}

.ev-section {
  padding-block: clamp(28px, 4vw, 48px) clamp(52px, 8vw, 96px);
}

.ev {
  position: relative;
  --ev-err-wash: color-mix(in srgb, var(--err) 7%, transparent);
  --ev-warn-wash: color-mix(in srgb, var(--warn) 9%, transparent);
  --ev-hover: color-mix(in srgb, var(--text) 4%, transparent);
  --ev-active: color-mix(in srgb, var(--text) 8%, transparent);
}

.ev-quiet {
  margin: 0;
  color: var(--text-dim);
  font-size: 13.5px;
}

.ev-pad {
  padding: 18px;
}

/* --- before anything is loaded --------------------------------------------- */

.ev-drop {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: clamp(40px, 7vw, 84px) 24px;
  border: 1px dashed var(--paper-rule);
  border-radius: var(--r-lg);
  background: var(--card);
  text-align: center;
}

.ev-drop-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: var(--text-soft);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ev-drop-title {
  margin: 6px 0 0;
  font-size: 22px;
  color: var(--text);
}

.ev-drop-hint {
  max-width: 46ch;
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
}

.ev-drop-act {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 0;
}

/* Dragging files over the tool. */
.ev.is-over::after {
  content: 'Drop to check these files';
  position: absolute;
  z-index: 3;
  inset: -8px;
  display: grid;
  place-items: center;
  border: 2px dashed var(--brand);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  color: var(--text);
  font-size: 20px;
  pointer-events: none;
}

.ev-failures {
  margin-bottom: 14px;
  padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--err) 30%, transparent);
  border-radius: var(--r);
  background: var(--ev-err-wash);
  color: var(--err);
  font-size: 14px;
}

.ev-failures p {
  margin: 0;
}

/* --- loaded ---------------------------------------------------------------- */

.ev-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.ev-bar p {
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
}

.ev-bar > span {
  display: flex;
  align-items: center;
  gap: 16px;
}

.is-error {
  color: var(--err);
}

.is-ok {
  color: var(--ok);
}

.ev-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-soft);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.ev-link:hover {
  color: var(--text);
}

.ev-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 14px;
  height: clamp(560px, 78vh, 880px);
}

.ev-side {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

.ev-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  overflow: hidden;
}

.ev-card h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 14px 16px 8px;
  font-size: 15px;
  font-weight: 600;
}

/* Files */

.ev-files ul {
  max-height: 210px;
  margin: 0;
  padding: 0 6px 6px;
  overflow: auto;
  list-style: none;
}

.ev-file {
  position: relative;
  border-radius: var(--r-sm);
}

.ev-file:hover {
  background: var(--ev-hover);
}

.ev-file.is-selected {
  background: var(--ev-active);
}

.ev-file-open {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 34px 8px 10px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.ev-file-text {
  display: grid;
  flex: 1;
  min-width: 0;
}

.ev-file-name,
.ev-file-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ev-file-name {
  font-size: 14px;
}

.ev-file-sub {
  color: var(--text-dim);
  font-size: 12.5px;
}

.ev-status {
  flex: none;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 400;
  white-space: nowrap;
}

.ev-status.is-error {
  color: var(--err);
}

.ev-status.is-warning {
  color: var(--warn);
}

.ev-status.is-ok {
  color: var(--ok);
}

.ev-remove {
  position: absolute;
  top: 50%;
  right: 6px;
  display: none;
  width: 24px;
  height: 24px;
  padding: 4px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  translate: 0 -50%;
}

.ev-file:hover .ev-remove,
.ev-remove:focus-visible {
  display: block;
}

.ev-remove:hover {
  background: var(--ev-active);
  color: var(--text);
}

.ev-remove svg,
.ev-caret svg,
.ev-mark svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ev-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

.ev-dot.is-error {
  background: var(--err);
}

.ev-dot.is-warning {
  background: var(--warn-dot);
}

.ev-dot.is-other {
  background: var(--text-dim);
}

/* Findings */

.ev-findings-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.ev-findings {
  margin: 0;
  padding: 0 6px 6px;
  list-style: none;
}

.ev-finding {
  display: flex;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.ev-finding:hover:not(:disabled) {
  background: var(--ev-hover);
}

.ev-finding.is-active {
  background: var(--ev-active);
}

.ev-finding:disabled {
  cursor: default;
}

.ev-mark {
  flex: none;
  width: 15px;
  height: 15px;
  margin-top: 2px;
}

.ev-mark.is-error {
  color: var(--err);
}

.ev-mark.is-warning {
  color: var(--warn);
}

.ev-mark.is-info {
  color: var(--text-dim);
}

.ev-finding-body {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.ev-finding-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.ev-finding-text {
  font-size: 14px;
  line-height: 1.45;
}

.ev-finding-detail {
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.45;
}

.ev-code {
  display: inline-flex;
  flex: none;
  align-items: center;
  height: 19px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--seg);
  color: var(--text-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Nothing to report: a note with a hairline and a wash of green, as the app draws it. */
.ev-ok {
  margin: 2px 12px 14px;
  padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--ok) 28%, var(--panel));
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--ok) 6%, var(--panel));
  color: var(--ok);
  font-size: 14px;
  line-height: 1.45;
}

.ev-limits {
  flex: none;
  margin: 0;
  padding: 11px 16px 13px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.45;
}

/* The selected file */

.ev-summary {
  display: grid;
  flex: none;
  gap: 6px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.ev-summary-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ev-summary-name b {
  overflow: hidden;
  font-size: 16px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ev-chip {
  flex: none;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--seg);
  color: var(--text-soft);
  font-size: 12.5px;
}

.ev-summary-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  color: var(--text-soft);
  font-size: 14px;
}

.ev-summary-facts b {
  color: var(--text);
  font-weight: 600;
}

.ev-summary-facts i {
  color: var(--text-dim);
  font-style: normal;
}

.ev-main {
  min-height: 0;
}

.ev-tree-tools {
  display: flex;
  flex: none;
  align-items: center;
  gap: 16px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
}

.ev-tree-tools b {
  flex: 1;
  font-weight: 600;
}

/* A switch in the site's ink. */
.ev-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  cursor: pointer;
}

.ev-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ev-switch span {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: var(--line);
  transition: background-color 0.15s ease;
}

.ev-switch span::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--panel);
  transition: translate 0.15s ease;
}

.ev-switch input:checked + span {
  background: var(--btn);
}

.ev-switch input:checked + span::after {
  translate: 12px 0;
}

.ev-switch input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.ev-xml-error {
  display: flex;
  flex: none;
  gap: 10px;
  margin: 12px 14px 0;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--err) 26%, transparent);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--err) 4%, var(--panel));
  color: var(--err);
  font-size: 14px;
}

.ev-xml-error > div {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.ev-xml-error p {
  margin: 0;
}

.ev-xml-error code {
  display: block;
  overflow: hidden;
  padding: 7px 10px;
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font: 12.5px var(--mono);
  white-space: pre;
}

.ev-xml-error code i {
  margin-right: 12px;
  color: var(--text-dim);
  font-style: normal;
}

.ev-xml-error mark {
  border-radius: 2px;
  outline: 1px solid var(--err);
  background: color-mix(in srgb, var(--err) 20%, transparent);
  color: var(--err);
}

/* The tree */

.ev-tree {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 6px 0;
  overflow: auto;
}

.ev-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 12px 0 calc(8px + var(--d) * 16px);
  border-left: 2px solid transparent;
  font-size: 14px;
  /* Long invoices: rows off screen are not laid out until they are scrolled to. */
  content-visibility: auto;
  contain-intrinsic-size: auto 28px;
}

.ev-node {
  cursor: default;
}

.ev-node:hover {
  background: var(--ev-hover);
}

.ev-node.is-selected {
  background: var(--ev-active);
}

.ev-node.is-error,
.ev-msg.is-error {
  border-left-color: var(--err);
  background: var(--ev-err-wash);
}

.ev-node.is-warning,
.ev-msg.is-warning {
  border-left-color: var(--warn);
  background: var(--ev-warn-wash);
}

.ev-node.is-error.is-selected {
  background: color-mix(in srgb, var(--err) 14%, transparent);
}

.ev-node.is-warning.is-selected {
  background: color-mix(in srgb, var(--warn) 16%, transparent);
}

.ev-node.is-error .ev-name {
  color: var(--err);
}

.ev-node.is-warning .ev-name {
  color: var(--warn);
}

.ev-caret {
  flex: none;
  width: 18px;
  height: 18px;
  padding: 2px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--text-dim);
}

button.ev-caret {
  cursor: pointer;
}

button.ev-caret:hover {
  background: var(--ev-active);
  color: var(--text);
}

.ev-name {
  flex: none;
  font-weight: 500;
}

.ev-attr {
  flex: none;
  color: var(--text-dim);
  font-size: 12.5px;
}

.ev-attr b {
  color: var(--text-soft);
  font-weight: 400;
}

.ev-value {
  min-width: 0;
  overflow: hidden;
  color: var(--text-soft);
  font: 12.5px var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ev-value.is-empty {
  color: var(--text-dim);
}

.ev-label {
  min-width: 0;
  max-width: 40%;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ev-count {
  flex: none;
  color: var(--text-dim);
  font-size: 12.5px;
}

.ev-inside {
  display: inline-grid;
  flex: none;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--err);
  color: var(--panel);
  font-size: 12px;
  font-weight: 600;
}

.ev-inside.is-warning {
  background: var(--warn);
}

.ev-gutter {
  display: flex;
  flex: none;
  gap: 12px;
  margin-left: auto;
  padding-left: 12px;
  color: var(--text-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.ev-ref {
  min-width: 64px;
  text-align: right;
}

.ev-line {
  min-width: 30px;
  text-align: right;
}

/* A required element that is not there, drawn where it belongs. */
.ev-ghost {
  border-left-color: var(--err);
}

.ev-ghost .ev-name {
  padding: 0 7px;
  border: 1px dashed color-mix(in srgb, var(--err) 65%, transparent);
  border-radius: 5px;
  color: var(--err);
  font-style: italic;
}

.ev-missing {
  flex: none;
  color: var(--err);
  font-size: 12.5px;
}

/* A finding, under the element it is about. */
.ev-msg {
  align-items: flex-start;
  min-height: 22px;
  padding-top: 1px;
  padding-bottom: 6px;
  padding-left: calc(12px + var(--d) * 16px);
  font-size: 13px;
  line-height: 1.45;
  contain-intrinsic-size: auto 22px;
}

.ev-msg.is-error {
  color: var(--err);
}

.ev-msg.is-warning {
  color: var(--warn);
}

.ev-msg.is-info {
  color: var(--text-soft);
}

.ev-msg .ev-mark {
  width: 14px;
  height: 14px;
  margin-top: 2px;
}

.ev-msg-text {
  flex: 1;
  min-width: 0;
}

/* --- below the tool -------------------------------------------------------- */

.ev-stages {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 34px;
}

.ev-stages > div {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
}

.ev-stages h3 {
  margin: 10px 0 8px;
}

.ev-stages h3 .dim {
  color: var(--text-dim);
  font-weight: 400;
}

.ev-stages p {
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.55;
}

.ev-stage-no {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--btn);
  color: var(--btn-text) !important;
  font-size: 14px !important;
  font-weight: 600;
}

.ev-stages code,
.ev-faq code {
  font: 0.92em var(--mono);
}

.ev-not {
  max-width: 72ch;
  margin-top: 26px;
}

.ev-faq {
  max-width: 820px;
  margin-top: 22px;
}

.ev-faq details {
  border-top: 1px solid var(--line);
}

.ev-faq details:last-child {
  border-bottom: 1px solid var(--line);
}

.ev-faq summary {
  padding: 18px 0;
  font-size: 18px;
  cursor: pointer;
}

.ev-faq details p {
  max-width: 68ch;
  margin: 0 0 20px;
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1.6;
}

@media (max-width: 860px) {
  .ev-grid {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  .ev-side {
    grid-template-rows: auto auto;
  }

  .ev-findings-scroll {
    max-height: 360px;
  }

  .ev-main {
    height: 72vh;
  }

  .ev-stages {
    grid-template-columns: minmax(0, 1fr);
  }

  .ev-ref {
    display: none;
  }
}
