:root, [data-theme="claro"] {
  --ink: #1d2420;
  --ink-2: #4b554f;
  --ink-3: #7c857f;
  --paper: #f4f1ea;
  --card: #ffffff;
  --line: #e2ddd2;
  --brand: #1f2a24;
  --btn: #1f2a24;
  --accent: #e8a317;
  --accent-ink: #3a2a00;
  --ok: #2f7d4f;
  --ok-bg: #e3f2e8;
  --ok-ink: #184d2e;
  --warn: #9a6400;
  --warn-bg: #fdf0d4;
  --warn-ink: #6b4500;
  --bad: #b3261e;
  --bad-bg: #fbe3e1;
  --bad-ink: #7a1610;
  --info: #2b5c8a;
  --info-bg: #e2edf7;
  --mute-bg: #ece9e2;
  --field: #ffffff;
  --field-line: #cfc9bc;
  --soft: #faf8f3;
  --nav: #ffffff;
  --nav-on: #1f2a24;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
[data-theme="escuro"] {
  --ink: #e6ebe8;
  --ink-2: #b8c1bb;
  --ink-3: #8b958f;
  --paper: #111513;
  --card: #1a1f1c;
  --line: #2c3430;
  --brand: #0b100d;
  --btn: #2f5a45;
  --accent: #e8a317;
  --accent-ink: #2a1e00;
  --ok: #74d39c;
  --ok-bg: #163021;
  --ok-ink: #a9e8c2;
  --warn: #f2bb55;
  --warn-bg: #3a2b0e;
  --warn-ink: #f7d48f;
  --bad: #ff8f85;
  --bad-bg: #3e1916;
  --bad-ink: #ffbdb6;
  --info: #8fbde9;
  --info-bg: #15283a;
  --mute-bg: #262d29;
  --field: #141916;
  --field-line: #3b443f;
  --soft: #1f2522;
  --nav: #161b18;
  --nav-on: #e8a317;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
  --ink: #e6ebe8;
  --ink-2: #b8c1bb;
  --ink-3: #8b958f;
  --paper: #111513;
  --card: #1a1f1c;
  --line: #2c3430;
  --brand: #0b100d;
  --btn: #2f5a45;
  --accent: #e8a317;
  --accent-ink: #2a1e00;
  --ok: #74d39c;
  --ok-bg: #163021;
  --ok-ink: #a9e8c2;
  --warn: #f2bb55;
  --warn-bg: #3a2b0e;
  --warn-ink: #f7d48f;
  --bad: #ff8f85;
  --bad-bg: #3e1916;
  --bad-ink: #ffbdb6;
  --info: #8fbde9;
  --info-bg: #15283a;
  --mute-bg: #262d29;
  --field: #141916;
  --field-line: #3b443f;
  --soft: #1f2522;
  --nav: #161b18;
  --nav-on: #e8a317;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: clip; }  /* nunca deslocar a página para o lado */
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--info); }
h1 { font-size: 1.5rem; margin: .2rem 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
.muted { color: var(--ink-3); }
.small { font-size: .87rem; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* ---------- topo */
.top {
  background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20;
  padding: .55rem 1rem; display: flex; align-items: center; gap: 1rem;
  padding-top: calc(.55rem + env(safe-area-inset-top));
}
.top .logo { color: #fff; text-decoration: none; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.top .logo span.dot { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-grid; place-items: center; color: var(--accent-ink); font-size: .8rem; }
.top nav { display: flex; gap: .2rem; margin-left: 1rem; }
.top nav a { white-space: nowrap; color: #d6dcd8; text-decoration: none; padding: .4rem .7rem; border-radius: 8px; font-size: .95rem; }
.top nav a.on, .top nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.top .who { margin-left: auto; display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.top .who a { color: #fff; text-decoration: none; }
.badge-count { background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 .45rem; font-size: .75rem; font-weight: 700; margin-left: .2rem; }

/* ---------- navegação inferior (telemóvel) */
.bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--nav); border-top: 1px solid var(--line);
  display: none; justify-content: space-around; align-items: flex-end;
  padding: .3rem .3rem calc(.3rem + env(safe-area-inset-bottom));
}
.bottom a { flex: 1; text-align: center; color: var(--ink-2); text-decoration: none; font-size: .72rem; padding: .25rem 0; }
.bottom a svg { width: 24px; height: 24px; display: block; margin: 0 auto 2px; }
.bottom a.on { color: var(--nav-on); font-weight: 600; }
.bottom a.scan { position: relative; top: -14px; }
.bottom a.scan .ring { width: 58px; height: 58px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; margin: 0 auto 2px; box-shadow: 0 4px 12px rgba(0,0,0,.18); color: var(--accent-ink); }
.bottom a.scan svg { width: 28px; height: 28px; margin: 0; }

@media (max-width: 760px) {
  .top nav, .top .who .name { display: none; }
  .bottom { display: flex; }
}
@media (min-width: 761px) { body { padding-bottom: 2rem; } }

main { max-width: 1080px; margin: 0 auto; padding: 1rem; }

/* ---------- mensagens */
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: .7rem; font-size: .95rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash.erro { background: var(--bad-bg); color: var(--bad-ink); }
.flash.aviso { background: var(--warn-bg); color: var(--warn-ink); }

/* ---------- cartões e grelhas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: .8rem; }
.grid { display: grid; gap: .8rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; text-decoration: none; color: inherit; border-left: 5px solid var(--line); }
.stat b { display: block; font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .85rem; color: var(--ink-2); }
.stat.s-disponivel { border-left-color: var(--ok); }
.stat.s-em_uso, .stat.s-reservada { border-left-color: var(--info); }
.stat.s-avariada { border-left-color: var(--bad); }
.stat.s-oficina { border-left-color: var(--warn); }
.stat.s-inativa { border-left-color: var(--ink-3); }

.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------- listas */
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.list a.item, .list .item { display: flex; gap: .8rem; align-items: center; padding: .75rem 1rem; color: inherit; text-decoration: none; }
.list a.item:hover { background: var(--soft); }
.item .main { flex: 1; min-width: 0; }
.item .main .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .main .s { font-size: .85rem; color: var(--ink-3); }
.empty { padding: 1.4rem; text-align: center; color: var(--ink-3); }

@font-face {
  font-family: "Matricula"; font-weight: 500; font-display: swap;
  src: url("/static/fonts/barlow-semi-condensed-latin-500-normal.woff2") format("woff2");
}
/* Matrícula portuguesa: fundo branco, faixa azul da UE com estrelas e «P» */
.plate {
  display: inline-flex; align-items: center; gap: .38em; flex: none;
  background: #fff; color: #111; text-decoration: none; white-space: nowrap;
  border: 2px solid #111; border-radius: .3em; overflow: hidden;
  font-family: "Matricula", "Bahnschrift", "Arial Narrow", "Roboto Condensed", sans-serif;
  font-weight: 500; font-size: 1.05rem; line-height: 1; letter-spacing: .03em;
  padding: 0 .45em 0 0; box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.plate::before {
  content: "P"; flex: none; align-self: stretch; width: 1.95em; font-size: .52em; color: #fff;
  font-family: Arial, Helvetica, sans-serif; font-weight: 700; letter-spacing: 0;
  background: #1747b0 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><g fill='%23ffcc00'><polygon points='83.00,41.50 85.00,47.25 91.08,47.37 86.23,51.05 88.00,56.88 83.00,53.40 78.00,56.88 79.77,51.05 74.92,47.37 81.00,47.25'/><polygon points='78.58,58.00 80.58,63.75 86.66,63.87 81.81,67.55 83.58,73.38 78.58,69.90 73.58,73.38 75.35,67.55 70.49,63.87 76.58,63.75'/><polygon points='66.50,70.08 68.50,75.83 74.58,75.95 69.73,79.63 71.50,85.46 66.50,81.98 61.50,85.46 63.27,79.63 58.42,75.95 64.50,75.83'/><polygon points='50.00,74.50 52.00,80.25 58.08,80.37 53.23,84.05 55.00,89.88 50.00,86.40 45.00,89.88 46.77,84.05 41.92,80.37 48.00,80.25'/><polygon points='33.50,70.08 35.50,75.83 41.58,75.95 36.73,79.63 38.50,85.46 33.50,81.98 28.50,85.46 30.27,79.63 25.42,75.95 31.50,75.83'/><polygon points='21.42,58.00 23.42,63.75 29.51,63.87 24.65,67.55 26.42,73.38 21.42,69.90 16.42,73.38 18.19,67.55 13.34,63.87 19.42,63.75'/><polygon points='17.00,41.50 19.00,47.25 25.08,47.37 20.23,51.05 22.00,56.88 17.00,53.40 12.00,56.88 13.77,51.05 8.92,47.37 15.00,47.25'/><polygon points='21.42,25.00 23.42,30.75 29.51,30.87 24.65,34.55 26.42,40.38 21.42,36.90 16.42,40.38 18.19,34.55 13.34,30.87 19.42,30.75'/><polygon points='33.50,12.92 35.50,18.67 41.58,18.79 36.73,22.47 38.50,28.30 33.50,24.82 28.50,28.30 30.27,22.47 25.42,18.79 31.50,18.67'/><polygon points='50.00,8.50 52.00,14.25 58.08,14.37 53.23,18.05 55.00,23.88 50.00,20.40 45.00,23.88 46.77,18.05 41.92,14.37 48.00,14.25'/><polygon points='66.50,12.92 68.50,18.67 74.58,18.79 69.73,22.47 71.50,28.30 66.50,24.82 61.50,28.30 63.27,22.47 58.42,18.79 64.50,18.67'/><polygon points='78.58,25.00 80.58,30.75 86.66,30.87 81.81,34.55 83.58,40.38 78.58,36.90 73.58,40.38 75.35,34.55 70.49,30.87 76.58,30.75'/></g></svg>") no-repeat center .32em / 1.45em 1.45em;
  display: flex; align-items: flex-end; justify-content: center; padding: 2.05em 0 .28em;
}
.plate.big { font-size: 1.85rem; border-width: 3px; }

/* ---------- etiquetas de estado */
.tag { display: inline-block; padding: .12rem .55rem; border-radius: 99px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--mute-bg); color: var(--ink-2); }
.tag.disponivel, .tag.resolvida { background: var(--ok-bg); color: var(--ok); }
.tag.em_uso, .tag.reservada, .tag.em_analise { background: var(--info-bg); color: var(--info); }
.tag.avariada, .tag.imobilizada, .tag.alta, .tag.aberta { background: var(--bad-bg); color: var(--bad); }
.tag.oficina, .tag.em_reparacao, .tag.aguarda_pecas, .tag.media { background: var(--warn-bg); color: var(--warn); }
.tag.pendente { background: var(--warn-bg); color: var(--warn); }
.tag.ativo { background: var(--ok-bg); color: var(--ok); }
.tag.bloqueado { background: var(--bad-bg); color: var(--bad); }

/* ---------- formulários */
label { display: block; font-weight: 600; font-size: .9rem; margin: .8rem 0 .25rem; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; margin: .35rem 0; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: .65rem .75rem; border: 1px solid var(--field-line); border-radius: 10px; background: var(--field); color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(232,163,23,.35); border-color: var(--accent); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 .8rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-weight: 600;
  padding: .65rem 1.05rem; border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background: var(--btn); color: #fff; min-height: 44px;
}
.btn:hover { filter: brightness(1.12); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--field); color: var(--ink); border-color: var(--field-line); }
.btn.danger { background: var(--bad); }
.btn.small { padding: .35rem .7rem; min-height: 34px; font-size: .88rem; }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

.chips { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .8rem; }
.chips a { padding: .35rem .75rem; border-radius: 99px; background: var(--card); border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; font-size: .88rem; }
.chips a.on { background: var(--btn); color: #fff; border-color: var(--btn); }

/* ---------- anexos / captura */
.capture { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .3rem; }
.capture .cap { display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .8rem .3rem; border: 1px dashed var(--field-line); border-radius: 10px; background: var(--soft); cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--ink-2); text-align: center; }
.capture .cap svg { width: 28px; height: 28px; }
.capture .cap.rec { border-color: var(--bad); color: var(--bad); background: var(--bad-bg); }
.capture input[type=file] { display: none; }
.pending { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.pending .pf { position: relative; width: 88px; height: 88px; border-radius: 8px; background: var(--mute-bg); overflow: hidden; display: grid; place-items: center; font-size: .72rem; text-align: center; padding: .2rem; color: var(--ink-2); }
.pending .pf img, .pending .pf video { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.pending .pf button { position: absolute; top: 3px; right: 3px; z-index: 2; border: 0; background: rgba(0,0,0,.6); color: #fff; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; line-height: 1; }
.progress { height: 8px; background: var(--mute-bg); border-radius: 99px; overflow: hidden; margin-top: .8rem; display: none; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .4rem; margin-top: .6rem; }
.gallery a img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; background: var(--mute-bg); }
.media-block { margin-top: .6rem; }
.media-block video { width: 100%; max-height: 420px; border-radius: 8px; background: #000; }
.media-block audio { width: 100%; }

/* ---------- linha temporal da avaria */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline > li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: .6rem; }
.timeline > li.system { background: var(--soft); border-style: dashed; }
.timeline .meta { font-size: .82rem; color: var(--ink-3); margin-bottom: .3rem; }
.timeline .txt { white-space: pre-wrap; }

table.tbl { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: .93rem; }
.tbl th, .tbl td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { background: var(--soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }

details.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .2rem 1rem; margin-bottom: .6rem; }
details.box summary { cursor: pointer; padding: .7rem 0; font-weight: 600; }
details.box[open] { padding-bottom: 1rem; }

/* ---------- autenticação */
.auth { max-width: 420px; margin: 6vh auto 2rem; }
.auth .brand { text-align: center; margin-bottom: 1.2rem; }
.auth .brand .dot { width: 54px; height: 54px; border-radius: 14px; background: var(--brand); color: var(--accent); display: inline-grid; place-items: center; font-weight: 800; font-size: 1.3rem; }

/* ---------- leitor */
.scanner { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3/4; max-height: 70vh; margin: 0 auto; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%);
  width: 72%; aspect-ratio: 1; border: 3px solid var(--accent); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0,0,0,.4);
  transition: width .2s, aspect-ratio .2s, border-radius .2s; }
/* matrícula portuguesa: 520 × 110 mm ≈ 4,7 : 1 */
.scanner[data-mode="plate"] { aspect-ratio: 4/3; }
.scanner[data-mode="plate"] .frame { width: 88%; aspect-ratio: 4.7; border-radius: 6px; }
.scanner .torch { position: absolute; top: .6rem; right: .6rem; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.5); color: #fff; font-size: 1.2rem; cursor: pointer; }
.scanner .torch.on { background: var(--accent); }
.seg { display: flex; background: var(--mute-bg); border-radius: 10px; padding: 3px; margin-bottom: .7rem; }
.seg button { flex: 1; border: 0; background: transparent; padding: .55rem; border-radius: 8px; font: inherit; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.scanner .hint { position: absolute; bottom: .8rem; left: 0; right: 0; text-align: center; color: #fff; font-size: .9rem; text-shadow: 0 1px 3px #000; }

/* ---------- etiquetas para imprimir */
.labels { display: grid; grid-template-columns: repeat(auto-fill, 62mm); gap: 4mm; }
.label { width: 62mm; border: 1px solid #000; border-radius: 3mm; padding: 3mm; text-align: center; background: #fff; break-inside: avoid; }
.label img { width: 44mm; height: 44mm; display: block; margin: 0 auto 2mm; }
.label .plate { font-size: 17pt; }
.label .lt { font-size: 8pt; margin-top: 1.5mm; color: #333; }
@media print {
  :root, [data-theme] { --ink: #000; --paper: #fff; --card: #fff; --line: #ccc; color-scheme: light; }
  .top, .bottom, .noprint, .flash { display: none !important; }
  body { background: #fff; padding: 0; }
  main { max-width: none; padding: 0; }
}

/* ---------- logótipo e tema */
.top .logo img { height: 36px; max-width: 170px; object-fit: contain; display: block; }
.auth .brand img { max-height: 90px; max-width: 240px; object-fit: contain; }
.theme-btn { background: transparent; border: 1px solid rgba(255,255,255,.25); color: #fff; border-radius: 8px; width: 34px; height: 30px; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; }
.theme-btn:hover { background: rgba(255,255,255,.1); }
.subnav { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.subnav a { padding: .4rem .8rem; border-radius: 8px; text-decoration: none; color: var(--ink-2); background: var(--card); border: 1px solid var(--line); font-size: .9rem; }
.subnav a.on { background: var(--btn); color: #fff; border-color: var(--btn); }
.logo-preview { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.logo-preview .box { padding: 1rem; border-radius: var(--radius); display: grid; place-items: center; min-width: 160px; min-height: 80px; }
.logo-preview img { max-height: 60px; max-width: 200px; object-fit: contain; }

/* ---------- instalar app */
.install { position: fixed; left: .6rem; right: .6rem; bottom: calc(72px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: .8rem .9rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.18); display: flex; gap: .7rem; align-items: center; max-width: 520px; margin: 0 auto; }
.install img { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.install .txt { flex: 1; font-size: .9rem; line-height: 1.3; }
.install .x { background: none; border: 0; color: var(--ink-3); font-size: 1.3rem; cursor: pointer; padding: .2rem .4rem; }
@media (min-width: 761px) { .install { bottom: 1rem; right: 1rem; left: auto; } }

/* ---------- cabeçalho do painel */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem 1rem; margin-bottom: 1.2rem; }
.page-head h1 { margin: 0; }
@media (max-width: 760px) {
  .page-head { flex-direction: column; align-items: center; text-align: center; }
  .page-head .scan-cta { width: 100%; max-width: 360px; min-height: 52px; }
}

/* ---------- tabela de permissões: cabe sempre no ecrã */
table.perm { table-layout: fixed; width: 100%; }
table.perm col:first-child { width: 44%; }
table.perm th, table.perm td { padding: .5rem .4rem; }
table.perm td:not(:first-child), table.perm th:not(:first-child) { text-align: center; }
table.perm td:first-child { overflow-wrap: anywhere; }
table.perm .s { display: none; }
@media (max-width: 520px) {
  table.perm { font-size: .8rem; }
  table.perm col:first-child { width: 40%; }
  table.perm th { font-size: .68rem; letter-spacing: 0; text-transform: none; }
  table.perm .l { display: none; }
  table.perm .s { display: inline; }
}

/* ---------- lista de utilizadores em cartões no telemóvel */
@media (max-width: 640px) {
  table.users thead { display: none; }
  table.users, table.users tbody, table.users tr { display: block; width: 100%; }
  table.users tr { display: grid; grid-template-columns: 1fr auto; gap: .35rem .6rem; align-items: center;
    padding: .75rem .85rem; border-bottom: 1px solid var(--line); }
  table.users td { display: block; border: 0; padding: 0; min-width: 0; }
  table.users td:nth-child(1) { grid-column: 1 / -1; }
  table.users td:nth-child(2) select { width: 100%; max-width: 220px; }
  table.users td:nth-child(4) { grid-column: 1 / -1; }
  table.users td:nth-child(5) { grid-column: 1 / -1; }
  table.users td:nth-child(5):empty { display: none; }
  table.users td[data-l]::before { content: attr(data-l) ": "; color: var(--ink-3); }
  table.users td input[name=password] { width: 100% !important; max-width: 220px; }
}

/* ---------- administração → ficheiros */
.fsum { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin-bottom: .8rem; }
.flist .item { cursor: pointer; align-items: flex-start; }
.flist .item input[type=checkbox] { width: 20px; height: 20px; margin-top: .9rem; flex: none; }
.fthumb { width: 56px; height: 56px; border-radius: 8px; background: var(--mute-bg); flex: none; position: relative;
  overflow: hidden; display: grid; place-items: center; font-size: 1.5rem; }
.fthumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fthumb .ficon { position: relative; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.flist .main .t { white-space: normal; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.flist .main .s { margin-top: .25rem; display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.flist .plate { font-size: .85rem; }
.bulkbar { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 15; margin-top: .8rem;
  display: flex; gap: .5rem; align-items: center; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: .6rem .8rem; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
@media (min-width: 761px) { .bulkbar { bottom: 1rem; } }

/* filtros dos ficheiros: 2 colunas no telemóvel */
@media (max-width: 640px) {
  .ffilter .fields { grid-template-columns: 1fr 1fr; }
  .ffilter label { margin-top: .5rem; }
  .bulkbar .btn { padding: .35rem .6rem; white-space: nowrap; }
}
.bulkbar .btn, .bulkbar span { white-space: nowrap; }
