:root { --green: #2F6B3A; --green-dark: #24542D; --ink: #16211B; --paper: #F4F5F0; }
body { font-family: system-ui, sans-serif; max-width: 960px; margin: 2rem auto; padding: 0 1rem; color: var(--ink); background: #fff; }
header { margin: 0 0 1.5rem; }
header .brand { font-size: 1.6rem; font-weight: 700; color: inherit; text-decoration: none; }
section { margin-bottom: 2.5rem; }
table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid #ddd; }
code { background: #f3f3f3; padding: .1rem .3rem; border-radius: 3px; }
code.key { word-break: break-all; }
.muted { color: #777; }
.error { color: #a00; background: #fdeaea; padding: .5rem .75rem; border-radius: 4px; }
.card { border: 1px solid #ddd; border-radius: 6px; padding: .75rem 1rem; margin-bottom: 1rem; }
.card h3 { margin: 0 0 .5rem; }
.list { padding-left: 1.2rem; }
form.inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }
form.grid { display: grid; gap: .75rem; max-width: 420px; }
form.grid label { display: grid; gap: .25rem; }
form.grid label.check { display: flex; gap: .5rem; align-items: center; }
td.actions { display: flex; gap: .25rem; }
input.short { width: 5rem; }
button.link { background: none; border: none; color: var(--green); cursor: pointer; padding: 0 .25rem; font: inherit; }
button.link:disabled { color: #bbb; cursor: default; }
button.danger { color: #a00; }
a.danger, .danger { color: #a00; }
button.primary { background: var(--green); color: #fff; border: none; padding: .45rem 1rem; border-radius: 4px; cursor: pointer; }
button.danger-button { background: #a00; color: #fff; border: none; padding: .45rem 1rem; border-radius: 4px; cursor: pointer; }
.tag { font-size: .8rem; font-weight: normal; padding: .1rem .45rem; border-radius: 999px; background: #eee; color: #555; vertical-align: middle; }
.tag.warn { background: #fff4d6; color: #7a5600; }
.tag.ok { background: #e3f4e5; color: #1d6b2a; }
.tag.bad { background: #fdeaea; color: #a00; }
.space { white-space: nowrap; color: #555; font-size: .9rem; }
.space meter { width: 6rem; vertical-align: middle; }
fieldset { border: 1px solid #ddd; border-radius: 6px; margin: .75rem 0; padding: .5rem 1rem; }
label.check { display: flex; gap: .5rem; align-items: center; margin: .25rem 0; }
td.actions a { margin-right: .5rem; }
/* Pré-visualização: um "ecrã" preto 16:9. A versão vertical está guardada rodada para a TV
   deitada de lado; aqui roda-se de volta para se ver como quem está na loja a vê. */
.preview { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0; }
.preview .screen { background: #000; border: 6px solid #222; border-radius: 6px; overflow: hidden; }
.preview.horizontal .screen { width: 100%; max-width: 480px; aspect-ratio: 16 / 9; }
.preview.horizontal .screen > * { width: 100%; height: 100%; object-fit: contain; display: block; }
.preview.vertical .screen { width: 100%; max-width: 202px; aspect-ratio: 9 / 16; position: relative; }
.preview.vertical .screen > * { position: absolute; top: 50%; left: 50%; width: 177.78%; height: 56.25%;
  transform: translate(-50%, -50%) rotate(-90deg); object-fit: contain; }
.viewing-as { background: #fff4d6; color: #7a5600; padding: .5rem .75rem; border-radius: 4px; margin-bottom: 1rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.viewing-as form.inline { margin: 0; }
section.admin { border-top: 2px dashed #ddd; padding-top: 1rem; }
body.login main { max-width: 360px; margin: 4rem auto; }
body.login .brand { font-size: 2rem; }
a.button { display: inline-block; background: var(--green); color: #fff; padding: .45rem 1rem; border-radius: 4px; text-decoration: none; }
ol.steps { padding-left: 1.2rem; color: #444; }
input.code { font-family: ui-monospace, monospace; font-size: 1.4rem; letter-spacing: .15em; text-transform: uppercase; }
.ok-banner { background: #e3f4e5; color: #1d6b2a; padding: .5rem .75rem; border-radius: 4px; }
a { color: var(--green); }
header .brand img { height: 30px; display: block; }
body.login .brand img { height: 56px; }
footer.powered { margin: 3rem 0 1.5rem; display: flex; gap: .5rem; align-items: center; justify-content: center; color: #888; font-size: .8rem; }
footer.powered img { height: 30px; opacity: .8; }
/* Bolinha de informação, discreta como na Apple */
.section-head { display: flex; align-items: center; gap: .5rem; }
.section-head h2 { margin: .8em 0; }
.info { position: relative; display: inline-flex; }
.info-btn { width: 1.3rem; height: 1.3rem; border-radius: 50%; border: 1.5px solid #9aa09c; background: #fff; color: #6b716d;
  font: italic 700 .8rem/1 Georgia, "Times New Roman", serif; cursor: pointer; padding: 0; display: grid; place-items: center; }
.info-btn:hover, .info.open .info-btn, .info-btn:focus-visible { border-color: var(--green); color: var(--green); }
.info-bubble { display: none; position: absolute; left: -1rem; top: calc(100% + .6rem); z-index: 20;
  width: min(340px, calc(100vw - 2rem)); background: #fff; color: var(--ink); font-size: .92rem; line-height: 1.45;
  padding: .8rem 1rem; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.14), 0 0 0 1px rgba(0,0,0,.05); }
.info-bubble p { margin: .4rem 0; }
.info:hover .info-bubble, .info.open .info-bubble { display: block; }
.info-example { background: var(--paper); border-radius: 10px; padding: .6rem .8rem; margin: .4rem 0; }
.info-example ul { margin: .2rem 0 .5rem; padding-left: 1.2rem; }
.info-example ul:last-child { margin-bottom: 0; }

/* Cabeçalho: logo e conta na mesma linha; o caminho por baixo */
header .bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 48px; }
header .who { display: flex; align-items: center; gap: .5rem; min-width: 0; color: #777; font-size: .85rem; margin-left: auto; }
header .who .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
header .who form { margin: 0; }
header .sub { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-top: .5rem; }
header .crumbs { color: #555; font-size: .95rem; overflow-wrap: anywhere; min-width: 0; }
header .crumbs a { color: inherit; }

/* Campos e botões: letra de 16 px (o iPhone não faz zoom) e altura para o dedo */
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  font: inherit; font-size: 16px; padding: .55rem .7rem; border: 1px solid #c9cdc9; border-radius: 10px;
  background: #fff; color: var(--ink); min-height: 44px; box-sizing: border-box; }
input:focus, select:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: var(--green); }
form.grid input:not([type=checkbox]), form.grid select { width: 100%; }
button:not(.link):not(.info-btn), a.button {
  font: inherit; font-size: 16px; min-height: 44px; padding: .55rem 1.1rem; border-radius: 10px; cursor: pointer;
  border: 1px solid #c9cdc9; background: #fff; color: var(--ink); box-sizing: border-box; }
button.primary:not(.link), a.button, label.button { background: var(--green); border-color: var(--green); color: #fff; }
button.primary:not(.link):hover, a.button:hover, label.button:hover { background: var(--green-dark); }
a.button, label.button { font: inherit; font-size: 16px; min-height: 44px; padding: .55rem 1.1rem; border-radius: 10px;
  border: 1px solid var(--green); box-sizing: border-box; display: inline-flex; align-items: center; text-decoration: none; }
button.danger-button:not(.link) { background: #a00; border-color: #a00; color: #fff; }
input.code { font-size: 1.4rem; }
input.code::placeholder { letter-spacing: .15em; color: #b5b9b6; }

/* Carregar: o nosso botão, e a zona onde se larga o ficheiro */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
form.upload { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .9rem; margin: .5rem 0 1rem;
  border: 2px dashed #d3d7d3; border-radius: 14px; }
form.upload.drag { border-color: var(--green); background: #f1f7f2; }
form.upload.sending { opacity: .7; pointer-events: none; }
form.upload label.button { cursor: pointer; }

/* Tabelas: o nome do ficheiro parte-se só se for preciso; os estados nunca */
td.file { overflow-wrap: break-word; word-break: normal; }
.tag { white-space: nowrap; }
@media (max-width: 600px) {
  body { margin-top: 1rem; }
  th.opt, td.opt { display: none; }
  /* Listas em cartões: o nome numa linha; o estado, o tempo e as ações por baixo */
  table.cards thead { display: none; }
  table.cards tr { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .75rem;
    padding: .7rem 0; border-bottom: 1px solid #e3e5e3; }
  table.cards td { border: 0; padding: 0; }
  table.cards td.file { flex: 1 1 100%; font-weight: 500; }
  table.cards td.num { display: none; }
  table.cards td.actions { margin-left: auto; gap: .6rem; }
  table.playlist td.time form.inline { margin: 0; flex-wrap: nowrap; }
  table.playlist td.time input.short { flex: 0 0 4.5rem; width: 4.5rem; }
  th, td { padding: .5rem .4rem; }
  form.inline { gap: .5rem; }
  form.inline input:not([type=checkbox]) { flex: 1 1 10rem; }
  .space meter { width: 4rem; }
}
header .client-brand { font-size: 1.45rem; font-weight: 700; color: var(--ink); text-decoration: none; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header .client-brand img { max-height: 48px; max-width: 45vw; display: block; }
@media (max-width: 600px) {
  header .brand img { height: 24px; }
  header .client-brand { font-size: 1.2rem; }
  header .client-brand img { max-height: 40px; }
}

/* Código do ecrã: seis quadrados, em dois grupos de três como no ecrã */
.code-field { display: grid; gap: .4rem; }
.code-boxes { display: flex; gap: .4rem; align-items: center; }
.code-box { width: 2.6rem; height: 3.1rem; padding: 0; text-align: center; font-size: 1.5rem;
  font-weight: 600; font-family: ui-monospace, "SF Mono", Menlo, monospace; text-transform: uppercase;
  border: 1.5px solid #cfd5ca; border-radius: 10px; background: #fff; color: var(--ink, #16211B); }
.code-box:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(47,107,58,.15); }
.code-gap { width: .7rem; }
@media (max-width: 380px) { .code-box { width: 2.2rem; height: 2.8rem; font-size: 1.3rem; } }

/* Barra "a enviar para o ecrã" (#17) */
.sync { margin: 0 0 1rem; padding: .7rem .9rem; border-radius: 12px; background: #eef4ea;
  font-size: .95rem; }
.sync-track { height: 6px; margin-top: .5rem; border-radius: 3px; background: #d6e3cf; overflow: hidden; }
.sync-fill { width: 0; height: 100%; background: var(--green); transition: width .6s ease; }
.sync.waiting .sync-fill { width: 30% !important; animation: sync-wait 1.4s ease-in-out infinite; }
@keyframes sync-wait { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.sync.warn { background: #fbefe6; color: #7a3b12; }
