/* ==========================================================================
   Genesis — sistema visual
   Tipografia e linguagem de interface alinhadas com o site da Hostinger:
   DM Sans (300–700), paleta roxa, cartões de 16px, botões de 12px.
   ========================================================================== */

@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/fonts/dm-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
    U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/fonts/dm-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;

  /* marca */
  --brand: #673de6;
  --brand-hover: #471ea7;
  --brand-strong: #331c74;
  --brand-soft: #f0ebfe;
  --brand-tint: #f8f6ff;

  /* superfícies e texto */
  --paper: #f5f5f6;
  --surface: #ffffff;
  --surface-2: #f5f5f6;
  --side: #ffffff;
  --ink: #18181a;
  --muted: #58585e;
  --line: rgba(0, 0, 0, .10);
  --line-soft: rgba(0, 0, 0, .06);
  --line-strong: rgba(0, 0, 0, .20);
  --hover: #f5f5f6;

  /* acção principal */
  --primary: #673de6;
  --primary-deep: #673de6;
  --primary-deep-hover: #471ea7;
  --primary-ink: #ffffff;
  --primary-soft: #f0ebfe;
  --total: #7b66ff;

  /* estados */
  --danger: #be1025;
  --danger-soft: #ffeae9;
  --danger-line: #f4cfcd;
  --ok: #007a49;
  --ok-soft: #dcf8e3;
  --warn-soft: #ffeec8;
  --warn-line: #f2daa2;
  --warn-ink: #9b4600;
  --info-line: #ddd4fb;
  --info-ink: #4527a0;
  --on-accent: #ffffff;

  /* tabelas e diálogos */
  --t-head: #fafafa;
  --row-hover: #f8f6ff;
  --modal-foot: #fafafa;
  --leader: #c2c2c8;

  --shadow: rgba(24, 24, 26, .14);
  --shadow-sm: 0 1px 2px rgba(24, 24, 26, .05), 0 2px 6px rgba(24, 24, 26, .04);
  --shadow-md: 0 8px 24px rgba(24, 24, 26, .10);
  --shadow-lg: 0 24px 64px rgba(24, 24, 26, .20);
  --backdrop: rgba(24, 24, 26, .45);

  --tape-bg: #ffffff;

  /* formas */
  --radius: 12px;
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  /* letra */
  --serif: Georgia, "Times New Roman", "Liberation Serif", serif;
  --sans: "DM Sans", "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --display: var(--sans);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 400 15px/1.55 var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -.02em;
}
h1 { font-size: 30px; line-height: 1.2; }
h2 { font-size: 21px; line-height: 1.25; letter-spacing: -.015em; }
h3 { font-size: 15.5px; font-weight: 600; letter-spacing: -.005em; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--brand-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, kbd { font-family: var(--mono); font-size: .92em; }
::selection { background: rgba(103, 61, 230, .18); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: var(--mono); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100%; }
.side {
  background: var(--side);
  border-right: 1px solid var(--line);
  padding: 18px 14px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding: 6px 8px 20px; }
.brand-logo { height: 32px; width: auto; max-width: 100%; object-fit: contain; display: block; }
.brand b { display: block; font: 600 16px/1.2 var(--display); letter-spacing: -.02em; }
.brand span { display: block; margin-top: 0; color: var(--muted); font-size: 11px; letter-spacing: .01em; }
.nav-group {
  margin: 18px 10px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #8b8b93;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background .14s, color .14s;
}
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-hover); font-weight: 600; }
.nav a .nav-ic { display: inline-flex; flex: none; width: 20px; height: 20px; }
.nav a .nav-ic svg {
  width: 20px; height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav a[aria-current="page"] .nav-ic { color: var(--brand); }
.nav-lb { line-height: 1.25; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}
.top .grow { flex: 1; }
.btn.menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-meta { min-width: 0; }
.user-name { font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-sub { font-size: 12px; line-height: 1.3; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff;
}
.store-dot {
  width: 8px; height: 8px; flex: none; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18);
}
.store-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.store-meta b { font-size: 12.5px; max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store-meta span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.avatar {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #7b66ff, #673de6 60%, #4b21c9);
  border: 1px solid rgba(103, 61, 230, .35);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px -6px rgba(103, 61, 230, .8);
}
.view { padding: 28px 32px 64px; max-width: 1360px; width: 100%; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.view-head p { color: var(--muted); margin-top: 6px; font-size: 14.5px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- controlos ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s;
}
.btn:hover { background: var(--hover); }
.btn:not([disabled]):active { transform: translateY(1px); }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 1px 2px rgba(24, 24, 26, .14);
}
.btn.primary:hover { background: var(--primary-deep-hover); border-color: var(--primary-deep-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger-line); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.solid:hover { background: #9c0d1e; border-color: #9c0d1e; }
.btn.small, .btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }
/* Barra indeterminada enquanto um pedido esta em curso (envio AGT, gravacao de formularios). */
.btn .btn-progress {
  position: relative;
  flex: none;
  width: 30px;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, currentColor 22%, transparent);
}
.btn .btn-progress-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  border-radius: inherit;
  background: currentColor;
  animation: btn-progress 1.1s ease-in-out infinite;
}
@keyframes btn-progress {
  from { transform: translateX(-110%); }
  to { transform: translateX(260%); }
}
@media (prefers-reduced-motion: reduce) {
  .btn .btn-progress-fill { animation-duration: 2.4s; }
}

.input, select.input, textarea.input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #d7d7dd;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  transition: border-color .14s, box-shadow .14s, background .14s;
}
.input::placeholder { color: #97979f; }
.input:hover { border-color: #bcbcc4; }
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(103, 61, 230, .16);
}
.input[readonly] { background: var(--surface-2); }
textarea.input { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2358585e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 12px; color: var(--muted); }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.req { color: var(--danger); }

/* ---------- superfícies ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(24, 24, 26, .04);
}
.card-pad { padding: 20px; }
.card h3.card-title { padding: 18px 20px 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input { width: 280px; }
.toolbar .input.sm { width: 170px; }

/* ---------- tabelas ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
table.t { width: 100%; border-collapse: collapse; }
.t th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .01em;
  color: #6b6b73;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--t-head);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.t td { padding: 12px 18px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; font-size: 14px; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover td { background: var(--row-hover); }
.t tbody tr.click:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.t tfoot td { font-weight: 600; background: var(--surface-2); }
.t .num { text-align: right; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  background: #f0f0f2;
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge.info { background: var(--primary-soft); color: #4b21c9; }

/* ---------- painel ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { padding: 20px; }
.kpi .l { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .v { font: 600 30px/1.15 var(--display); letter-spacing: -.03em; margin-top: 8px; }
.kpi .s { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.dash-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 16px; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding: 8px 4px 0; }
.bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; height: 100%; }
.bar i {
  display: block;
  width: 100%;
  max-width: 42px;
  min-height: 3px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #a08bff, #673de6);
  transition: filter .15s;
}
.bar:hover i { filter: brightness(1.08); }
.bar.today i { background: linear-gradient(180deg, #9d8bff, #7b66ff); box-shadow: 0 8px 18px -10px rgba(103, 61, 230, .9); }
.bar span { font-size: 11.5px; color: var(--muted); }

/* ---------- construtor de facturas ---------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); flex-wrap: wrap; }
.seg button {
  border: 0;
  background: transparent;
  padding: 7px 16px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(24, 24, 26, .12); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(24, 24, 26, .12); }
/* filtros que juntam um selector de pesquisa com a etiqueta do valor escolhido */
.entidade { display: inline-flex; align-items: center; gap: 6px; }
.entidade .picker { width: auto; }
.picker { position: relative; }
.picker-list {
  position: absolute;
  z-index: 20;
  left: 0; right: 0;
  top: calc(100% + 6px);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  max-height: 300px;
  overflow-y: auto;
}
.picker-list button {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}
.picker-list button:hover, .picker-list button:focus-visible { background: var(--brand-soft); outline: 0; }
.picker-list .none { padding: 12px 10px; color: var(--muted); font-size: 14px; }
.lines .input { height: 36px; padding: 0 10px; border-radius: 10px; }
.lines td { padding: 8px 10px; }

/* talão lateral */
.tape {
  position: sticky;
  top: 84px;
  background: var(--tape-bg);
  border: 1px solid var(--line);
  padding: 24px 24px 34px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-sm);
  --zz: 8px;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(2 * var(--zz)) 100%;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(2 * var(--zz)) 100%;
}
.tape h3 { font-family: var(--display); font-size: 18px; font-weight: 600; margin-bottom: 2px; letter-spacing: -.015em; }
.tape .sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.leader { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; }
.leader::after { content: ""; order: 1; flex: 1; border-bottom: 1px dotted var(--leader); transform: translateY(-4px); }
.leader > :first-child { order: 0; }
.leader > :last-child { order: 2; }
.tape-lines { max-height: 190px; overflow-y: auto; margin-bottom: 12px; font-size: 13.5px; }
.tape-total { margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--ink); display: flex; justify-content: space-between; align-items: baseline; }
.tape-total span { font-size: 14px; }
.tape-total b { font: 600 34px/1 var(--display); letter-spacing: -.03em; border-bottom: 3px solid var(--total); padding-bottom: 2px; }
.tape .btn.primary { width: 100%; height: 44px; margin-top: 20px; font-size: 15px; }

/* ---------- diálogos ---------- */
dialog.modal {
  border: 0;
  padding: 0;
  border-radius: var(--radius-xl);
  width: min(560px, 94vw);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
dialog.modal.wide { width: min(880px, 96vw); }
dialog.modal::backdrop { background: var(--backdrop); backdrop-filter: blur(2px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 24px 16px; border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { font-size: 19px; font-weight: 600; letter-spacing: -.015em; }
.modal-body { padding: 22px 24px; max-height: 72vh; overflow-y: auto; }
.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--modal-foot);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}
.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  background: var(--danger-soft);
  color: #8f0c1d;
  border: 1px solid var(--danger-line);
  font-size: 14px;
  line-height: 1.5;
}
.alert.info { background: var(--primary-soft); border-color: var(--info-line); color: var(--info-ink); }
.alert.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-ink); }
.alert[hidden] { display: none; }
.avisos { padding: 16px 32px 0; display: flex; flex-direction: column; gap: 10px; }
.avisos[hidden] { display: none; }
.avisos .alert { margin-bottom: 0; display: flex; align-items: flex-start; gap: 12px; }
.avisos .aviso-body { flex: 1; min-width: 0; }
.avisos .aviso-title { display: block; font-weight: 600; margin-bottom: 2px; }
.avisos .aviso-msg { white-space: pre-wrap; }
.avisos .aviso-close {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 3px 5px;
  opacity: .65;
  border-radius: 6px;
}
.avisos .aviso-close:hover { opacity: 1; background: rgba(0, 0, 0, .06); }
.login-avisos { width: min(420px, 100%); margin: 0 auto 16px; padding: 0; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  background: #18181a;
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius);
  max-width: 380px;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: toastIn .18s ease-out;
}
.toast.bad { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- entrada ---------- */
.login {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  background: var(--surface);
}
.login-art {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 48px;
  padding: 48px 56px;
  color: #fff;
  background:
    radial-gradient(90% 70% at 10% 6%, rgba(123, 102, 255, .55) 0%, rgba(123, 102, 255, 0) 60%),
    radial-gradient(80% 70% at 100% 100%, rgba(37, 18, 92, .9) 0%, rgba(37, 18, 92, 0) 62%),
    linear-gradient(150deg, #5a30d9 0%, #673de6 44%, #331c74 100%);
}
.login-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .07) 1px, transparent 1px);
  background-size: 52px 52px;
  -webkit-mask-image: radial-gradient(72% 72% at 50% 42%, #000 0%, transparent 76%);
  mask-image: radial-gradient(72% 72% at 50% 42%, #000 0%, transparent 76%);
  pointer-events: none;
}
.login-art > * { position: relative; z-index: 1; }
.login-art-brand { display: flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.login-art-logo {
  height: 36px; width: auto; max-width: 220px;
  display: block; object-fit: contain;
}
.login-art-copy { max-width: 470px; }
.login-art .eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: rgba(255, 255, 255, .72); margin-bottom: 14px; }
.login-art h1 { color: #fff; font-size: clamp(30px, 3.1vw, 44px); line-height: 1.12; font-weight: 500; letter-spacing: -.03em; }
.login-art-copy > p:last-child { margin-top: 16px; max-width: 410px; color: rgba(255, 255, 255, .78); font-size: 15.5px; line-height: 1.6; }
.login-art-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.login-art-list li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  font-size: 13px;
  font-weight: 500;
}
.login-art-list li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #b6f5c9; }
.login-art-foot { font-size: 12.5px; color: rgba(255, 255, 255, .62); }
.login-wrap { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: 32px 24px; }
.login-card { width: min(420px, 100%); margin: 0 auto; animation: loginIn .4s cubic-bezier(.2, .8, .3, 1); }
@keyframes loginIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.login-mark { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.login-logo {
  height: 42px; width: auto; max-width: 200px;
  display: block; object-fit: contain;
}
.login-card h2 { font-size: 30px; font-weight: 500; letter-spacing: -.03em; }
.login-card .tag { margin-top: 3px; color: var(--muted); font-size: 13.5px; }
.login-card p.sub { margin: 16px 0 18px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.login-card form { display: flex; flex-direction: column; gap: 13px; }
.login-card .field { gap: 6px; }
.login-card label { font-size: 13px; font-weight: 600; }
.login-card .input { height: 44px; border-radius: var(--radius); font-size: 15px; }
.login-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.login-tabs .tabs-head { display: flex; gap: 22px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.login-tabs .tab-btn {
  appearance: none;
  background: none;
  border: 0;
  margin-bottom: -1px;
  padding: 10px 2px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: 600 14px var(--sans);
  cursor: pointer;
}
.login-tabs .tab-btn:hover { color: var(--ink); }
.login-tabs .tab-btn.active { color: var(--ink); border-bottom-color: var(--primary); }
.login-tabs .tab-panel { display: flex; flex-direction: column; gap: 14px; }
.login-tabs .tab-panel[hidden] { display: none; }
.login-ok { padding: 12px 14px; border-radius: var(--radius); background: var(--ok-soft); border: 1px solid #bfe9cd; color: #00623b; font-size: 13.5px; line-height: 1.5; }
.btn.login-submit {
  width: 100%;
  height: 48px;
  justify-content: center;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 8px 20px -12px rgba(103, 61, 230, .9);
  transition: background .14s, border-color .14s, box-shadow .14s;
}
.btn.login-submit:hover { background: var(--primary-deep-hover); border-color: var(--primary-deep-hover); box-shadow: 0 12px 26px -14px rgba(71, 30, 167, .9); }
.btn.login-submit:active { transform: translateY(1px); }
.btn.login-submit:disabled { opacity: .6; box-shadow: none; }
.login-submit .arr { font-size: 17px; }
.login-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; text-align: center; }
.login-foot + .login-foot { margin-top: 0; padding-top: 6px; border-top: 0; }
.login-foot .mono { color: var(--muted); }
.login-links { margin-top: 8px; text-align: center; }
.link-btn { background: none; border: 0; padding: 4px 8px; border-radius: 6px; color: var(--primary); font-size: 13px; font-weight: 500; cursor: pointer; }
.link-btn:hover { background: var(--brand-soft); color: var(--brand-hover); }
.login-note { margin: 0; color: var(--muted); font-size: 12.5px; text-align: center; }
.reg-aviso { margin: 4px 0 2px; padding: 10px 12px; border-radius: var(--radius); background: var(--brand-tint);
  border: 1px solid var(--line); color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.reg-aviso a { color: var(--brand); font-weight: 600; }

/* ---------- utilidades de ecrã ---------- */
.perm-group { margin-bottom: 14px; }
.perm-group h3 { margin-bottom: 6px; }
.perm-item { display: flex; gap: 8px; align-items: center; padding: 5px 0; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.doc-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.doc-head-logo { width: 84px; max-height: 46px; object-fit: contain; flex: none; }
.hashline { font-size: 12.5px; color: var(--muted); word-break: break-all; }

/* ---------- logótipo da empresa (ecrã de configuração) ---------- */
.empresa-logo { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.empresa-logo-caixa { width: 190px; min-height: 110px; display: flex; align-items: center; justify-content: center; padding: 10px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.empresa-logo-img { max-width: 100%; max-height: 90px; object-fit: contain; display: block; }
.empresa-logo-vazio { margin: 0; color: var(--muted); font-size: 12.5px; text-align: center; }
.empresa-logo-acoes { flex: 1; min-width: 260px; }
.empresa-logo-acoes .hint { display: block; margin-top: 10px; font-size: 12px; color: var(--muted); max-width: 420px; }

/* ---------- empresa: dados + séries de numeração ---------- */
.empresa-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(330px, .95fr); gap: 18px; align-items: start; }
.empresa-col { min-width: 0; display: grid; gap: 16px; align-content: start; }
@media (max-width: 1180px) { .empresa-layout { grid-template-columns: minmax(0, 1fr); } }

.empresa-series { min-width: 0; }
.empresa-series-topo { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.empresa-series-topo h2 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
.empresa-series-topo p { margin: 4px 0 0; font-size: 12.5px; }
.empresa-series .alert { margin: 0 0 12px; padding: 9px 11px; font-size: 12.5px; }

.serie-lista { display: grid; gap: 10px; }
.serie-linha { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 13px; background: var(--surface-2); }
.serie-topo { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.serie-tipo { font-weight: 600; font-size: 13.5px; }
.serie-meta { font-size: 12px; margin-top: 2px; }
.serie-contador { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.serie-prefixo { font-size: 12.5px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; word-break: break-all; }
.serie-numeros { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; }
.serie-nota, .serie-aviso { font-size: 12px; line-height: 1.4; margin: 8px 0 0; }
.serie-aviso { color: var(--warn-ink); }
.serie-acoes { margin-top: 10px; }

.doc-qr { text-align: center; margin-top: 12px; }
.doc-qr img { width: 100px; height: 100px; image-rendering: pixelated; }

/* ---------- impressão ---------- */
.print-doc { display: none; }
@media print {
  @page { size: A4; margin: 11mm 10mm; }
  body { background: #fff; }
  body > #app, .toasts, dialog.modal { display: none !important; }
  .print-doc { display: block; padding: 0; color: #000; background: #fff; font-size: 12px; }
  .print-doc h1 { font-size: 20px; }
  .print-doc table { width: 100%; border-collapse: collapse; margin: 12px 0; }
  .print-doc th, .print-doc td { border-bottom: 1px solid #999; padding: 4px 6px; text-align: left; }
  .print-doc .num { text-align: right; }
  .print-doc .doc-f { max-width: none; margin: 0; }
  .print-doc .doc-f-art thead, .print-doc .doc-f-qri thead { display: table-header-group; }
  .print-doc .doc-f-art tr, .print-doc .doc-f-qri tr { page-break-inside: avoid; }
}

/* documento fiscal (modelo CONNECT1) — não segue o tema da aplicação */
.doc-f {
  font-family: var(--sans);
  color: #000;
  background: #fff;
  max-width: 820px;
  margin: 0 auto;
  font-size: 12px;
  line-height: 1.35;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.doc-f p { margin: 0; }
.doc-f-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.doc-f-logo { width: 94px; height: auto; display: block; }
.doc-f-page { text-align: right; }
.doc-f-page-n { display: flex; justify-content: flex-end; gap: 4px; font-size: 11px; }
.doc-f-page-n b { font-weight: 700; }
/* 92px ~= 24 mm no papel: com o URL curto (~33 modulos) cada modulo fica com ~0,6 mm e o QR le-se
   a partir do telemovel. Nao usar image-rendering: pixelated — ao reduzir para tamanho nao inteiro
   deixa cair modulos e o codigo deixa de ser lido. */
.doc-f-qr-top { width: 92px; height: 92px; display: block; margin: 4px 0 0 auto; }
.doc-f-id { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 10px; }
.doc-f-emp p { margin: 0; font-size: 12px; }
.doc-f-emp-nome { font-weight: 700; font-size: 13.5px; letter-spacing: .2px; }
.doc-f-cli { font-size: 12px; }
.doc-f-cli-label { margin-bottom: 2px !important; }
.doc-f-cli-nome { font-weight: 700; text-transform: uppercase; }
.doc-f-band { display: flex; align-items: baseline; margin-top: 16px; padding: 5px 9px; border: 1px solid #000; background: #efefef; font-size: 12.5px; }
.doc-f-band-t { font-weight: 700; }
.doc-f-band-ref { margin-left: 44px; }
.doc-f-band-via { margin-left: auto; }
.doc-f-info { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 11px; table-layout: fixed; }
.doc-f-info th, .doc-f-info td { border: 1px solid #000; padding: 3px 6px; text-align: left; }
.doc-f-info th { font-weight: 400; background: #f7f7f7; }
.doc-f-info td { font-weight: 700; }
.doc-f-art { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 11px; }
.doc-f-art th, .doc-f-art td { border: 1px solid #000; padding: 4px 6px; text-align: left; vertical-align: top; }
.doc-f-art th { font-weight: 700; background: #f7f7f7; }
.doc-f-art .num { text-align: right; }
.doc-f-vazio { padding: 9px 6px; }
.doc-f-impostos { margin-top: 14px; }
.doc-f-stitle { font-weight: 700; font-size: 11.5px; margin: 0 0 4px; }
.doc-f-qri { width: 100%; border-collapse: collapse; font-size: 10.5px; }
.doc-f-qri th, .doc-f-qri td { border: 1px solid #000; padding: 3px 5px; text-align: left; }
.doc-f-qri th { font-weight: 400; background: #f7f7f7; }
.doc-f-qri .num { text-align: right; }
.doc-f-banco { margin-top: 12px; font-size: 11px; }
.doc-f-banco p { margin: 1px 0; }
.doc-f-emp-bottom { margin-top: 12px; font-weight: 700; font-size: 11px; }
.doc-f-hash { margin-top: 10px; font-size: 11px; }
.doc-f-bottom { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; align-items: start; }
.doc-f-totais { margin-top: 14px; font-size: 11px; }
.doc-f-totais .row { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.doc-f-totais .row b { font-weight: 400; white-space: nowrap; }
.doc-f-totais .total { margin-top: 6px; padding-top: 8px; border-top: 1px solid #000; font-weight: 700; align-items: baseline; }
.doc-f-totais .total b { font-weight: 700; font-size: 15px; }
.doc-f-totais .nota { color: #333; }
.doc-f-totais .total + .nota { margin-top: 6px; }
.doc-f-legal { margin-top: 18px; padding-top: 8px; border-top: 1px solid #000; font-size: 11px; }
.doc-f-thanks { display: flex; justify-content: space-between; gap: 16px; margin-top: 4px; }
.doc-f-thanks span:last-child { text-align: right; }
.doc-f-nota { margin-top: 6px !important; }
.doc-f-semvalor { margin-top: 6px !important; font-weight: 700; }
.doc-f-extenso { margin-top: 10px !important; font-weight: 700; text-transform: uppercase; }
.doc-f-agt { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.doc-f-agtqr p { margin: 4px 0 0; font-size: 10px; text-align: center; }
.doc-f-agt-txt { max-width: 330px; font-size: 10.5px; }
.doc-f-agt-txt p { margin: 2px 0 0; }
.doc-f-dev { margin-top: 10px !important; text-align: center; font-size: 10.5px; }

/* ---------- adaptação a ecrãs pequenos ---------- */
@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed;
    z-index: 40;
    left: 0;
    top: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
    border-right: 1px solid var(--line);
  }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid, .builder { grid-template-columns: 1fr; }
  .tape { position: static; }
  .view { padding: 22px 20px 56px; }
  .avisos { padding: 12px 20px 0; }
  .top { padding: 12px 20px; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media (max-width: 760px) {
  .top { flex-wrap: wrap; }
  .store-meta span { display: none; }
  .store-chip { padding: 5px 10px; }
  .user-chip { gap: 8px; }
  .user-chip > div:nth-child(2) { display: none; }
  .kpis { grid-template-columns: 1fr; }
  .form-grid, .grid2 { grid-template-columns: 1fr; }
  .toolbar .input, .toolbar .input.sm { width: 100%; }
  .view-head { align-items: flex-start; }
  .t th, .t td { padding: 10px 12px; }
  h1 { font-size: 26px; }
}
@media (max-width: 560px) {
  .login-wrap { padding: 32px 20px; }
  .login-card h2 { font-size: 26px; }
  .modal-head, .modal-body, .modal-foot { padding-left: 18px; padding-right: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
