/* ==========================================================================
   Registo de Ponto — folha de estilos (inspirada no estilo visual do Clockify)
   Azul claro, fundo cinza-azulado, painéis brancos com contorno fino,
   temporizador grande e tabelas simples. Tipo de letra: Roboto (servida
   localmente). Para mudar cores basta alterar as variáveis em :root.
   ========================================================================== */
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/roboto-latin.woff2") format("woff2");
}

:root {
  --bg: #F2F6F8;
  --surface: #FFFFFF;
  --surface-2: #F7F9FA;
  --head: #E4EAEE;
  --text: #333333;
  --text-2: #666666;
  --text-3: #999999;
  --border: #C6D2D9;
  --line: #E4EAEE;

  --brand: #03A9F4;
  --brand-dark: #0398DB;
  --brand-soft: #E1F5FE;

  --green: #4CAF50;
  --green-dark: #388E3C;
  --green-soft: #E8F5E9;
  --red: #F44336;
  --red-dark: #D32F2F;
  --red-soft: #FDECEA;
  --amber: #B26A00;
  --amber-soft: #FFF4E0;

  --radius: 2px;
  --shadow: none;
  --shadow-lg: 0 6px 24px rgba(0, 0, 0, 0.18);
  --topbar: 60px;

  --font: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 400; color: var(--text); }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
.strong { font-weight: 500; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 28px; height: 28px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* --------------------------------------------------------------------------
   Componentes
   -------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-body { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; min-height: 48px; background: var(--head); border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { font-size: 15px; font-weight: 400; color: var(--text-2); }
.card-sub { font-size: 13px; color: var(--text-3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 18px;
  font-size: 14px; font-weight: 500; text-transform: uppercase; letter-spacing: .02em; line-height: 1.2;
  border-radius: var(--radius); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover:not(:disabled) { background: var(--green-dark); }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover:not(:disabled) { background: var(--red-dark); }
.btn-light { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn-light:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-text { background: none; color: var(--brand); text-transform: none; letter-spacing: 0; font-weight: 400; padding-left: 8px; padding-right: 8px; }
.btn-text:hover:not(:disabled) { text-decoration: underline; }
.btn-danger-text { background: none; color: var(--red); text-transform: none; letter-spacing: 0; font-weight: 400; padding-left: 8px; padding-right: 8px; }
.btn-danger-text:hover:not(:disabled) { text-decoration: underline; }
.btn-sm { min-height: 32px; padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-xl { min-height: 50px; font-size: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-size: 13px; color: var(--text-2); }
.field-help { font-size: 13px; color: var(--text-3); }
.input {
  width: 100%; min-height: 40px; padding: 8px 12px;
  font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.input::placeholder { color: #B0BCC4; }
.input:focus { outline: none; border-color: var(--brand); }
.input.is-invalid { border-color: var(--red); background: var(--red-soft); }
.input.time24 { font-variant-numeric: tabular-nums; }
textarea.input { min-height: 90px; resize: vertical; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }

.row { display: flex; gap: 12px; align-items: center; }
.row-wrap { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.spacer { flex: 1; }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius); font-size: 14px; border: 1px solid transparent; }
.alert .icon { margin-top: 1px; }
.alert-red { background: var(--red-soft); color: var(--red-dark); border-color: #F5C2BE; }
.alert-amber { background: var(--amber-soft); color: var(--amber); border-color: #F1D3A1; }
.alert-green { background: var(--green-soft); color: var(--green-dark); border-color: #C3E2C5; }
.alert-blue { background: var(--brand-soft); color: #0277BD; border-color: #B3E5FC; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 13px; white-space: nowrap; background: var(--head); color: var(--text-2); }
.pill-green { background: var(--green-soft); color: var(--green-dark); }
.pill-red { background: var(--red-soft); color: var(--red-dark); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-blue { background: var(--brand-soft); color: #0277BD; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

.empty { padding: 32px 20px; text-align: center; color: var(--text-3); }

.list > * + * { border-top: 1px solid var(--line); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; }
.list-row-main { min-width: 0; }
.list-row-title { font-weight: 500; }
.list-row-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }

.section-title { font-size: 13px; color: var(--text-3); margin: 4px 0 0; }

/* Diálogo + aviso */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px 16px; background: rgba(0, 0, 0, 0.45); overflow-y: auto; }
.modal-box { width: 100%; max-width: 480px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.modal-box.wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 20px; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; border: 0; background: none; color: var(--text-3); cursor: pointer; }
.icon-btn:hover { background: var(--bg); color: var(--text); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  max-width: 440px; margin: 0 auto; z-index: 200;
  padding: 14px 18px; border-radius: 4px; background: #333; color: #fff; font-size: 15px;
  box-shadow: var(--shadow-lg);
}
.toast.is-error { background: var(--red-dark); }
.toast.is-ok { background: var(--green-dark); }

/* Barra de topo (comum) */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner { display: flex; align-items: center; gap: 12px; height: var(--topbar); padding: 0 16px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 18px; font-weight: 500; white-space: nowrap; }
.logo-mark { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; }
.logo-mark .icon { width: 18px; height: 18px; stroke-width: 2.2; }
.logo-mark { font-size: 13px; font-weight: 700; letter-spacing: .02em; flex: none; }
.brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-size: 17px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand-sub { font-size: 12px; font-weight: 400; color: var(--text-3); white-space: nowrap; }
.logo-lg { flex-direction: column; gap: 14px; justify-content: center; text-align: center; }
.logo-lg .logo-mark { width: 64px; height: 64px; font-size: 22px; }
.logo-lg .brand { align-items: center; }
.logo-lg .brand-name { font-size: 28px; }
.logo-lg .brand-sub { font-size: 15px; margin-top: 4px; }
.logo-mark-img { display: block; height: 38px; width: auto; flex: none; }
.logo-lg .logo-mark-img { height: 96px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 14px; }

/* ==========================================================================
   APP DO TRABALHADOR
   ========================================================================== */
.w-page { min-height: 100dvh; display: flex; flex-direction: column; }
.w-wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 12px; }
.w-user { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.w-user-text { text-align: right; min-width: 0; }
.w-user-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-user-company { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-main { flex: 1; padding: 16px 0 calc(96px + env(safe-area-inset-bottom, 0px)); }

/* Entrar */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 28px 12px calc(28px + env(safe-area-inset-bottom, 0px)); max-width: 444px; }
.login-head { text-align: center; margin-bottom: 24px; }
.login-head .logo { justify-content: center; margin-bottom: 18px; }
.login-title { font-size: 26px; }
.login-sub { color: var(--text-3); margin-top: 4px; }
.login-card { padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.login .input { min-height: 48px; font-size: 17px; }
.pin-label-row { display: flex; justify-content: space-between; align-items: baseline; }
.pin-dots { display: flex; justify-content: center; gap: 16px; padding: 12px 0 16px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); transition: all .1s; }
.pin-dot.filled { background: var(--brand); border-color: var(--brand); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key { min-height: 58px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); font-size: 24px; color: var(--text); cursor: pointer; font-variant-numeric: tabular-nums; font-family: inherit; }
.key:active { background: var(--brand-soft); border-color: var(--brand); }
.key-fn { font-size: 13px; text-transform: uppercase; color: var(--text-3); background: var(--surface-2); }

/* Temporizador */
.timer { display: flex; flex-direction: column; }
.timer-top { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--text-2); font-size: 15px; }
.timer-top .icon { color: var(--brand); }
.timer-site { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-main { padding: 22px 18px 18px; text-align: center; }
.timer-caption { font-size: 14px; color: var(--text-3); }
.timer-caption.on { color: var(--green-dark); }
.clock { font-size: clamp(52px, 16vw, 68px); font-weight: 400; letter-spacing: -0.01em; line-height: 1.05; margin: 6px 0 4px; font-variant-numeric: tabular-nums; color: var(--text); }
.clock-date { font-size: 15px; color: var(--text-3); }
.punch-btn {
  width: 100%; min-height: 64px; margin-top: 20px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 0; border-radius: var(--radius); cursor: pointer;
  font-size: 20px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; color: #fff;
  font-family: inherit; transition: background-color .12s;
}
.punch-btn:disabled { opacity: .65; cursor: wait; }
.punch-btn.in { background: var(--brand); }
.punch-btn.in:hover:not(:disabled) { background: var(--brand-dark); }
.punch-btn.out { background: var(--red); }
.punch-btn.out:hover:not(:disabled) { background: var(--red-dark); }
.punch-btn .icon { width: 26px; height: 26px; stroke-width: 2.2; }
.loc-line { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 12px; font-size: 14px; color: var(--text-3); }
.loc-line.ok { color: var(--green-dark); }
.loc-line.bad { color: var(--red-dark); }
.loc-line .icon { width: 16px; height: 16px; }

/* Lista de registos (agrupada por dia, como no Clockify) */
.day-group-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; background: var(--head); color: var(--text-2); font-size: 14px; border-bottom: 1px solid var(--border); }
.day-group-head b { font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.entry { display: flex; align-items: center; gap: 12px; padding: 13px 18px; }
.entry + .entry { border-top: 1px solid var(--line); }
.entry-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; min-width: 86px; }
.entry-tag.in { color: var(--brand-dark); }
.entry-tag.out { color: var(--red-dark); }
.entry-main { flex: 1; min-width: 0; color: var(--text-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-main { display: flex; flex-direction: column; }
.entry-site, .entry-status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-status { font-size: 12px; }
.st-pending { color: var(--amber); font-size: 12px; font-weight: 400; }
.st-ok { color: var(--green-dark); }
.st-bad { color: var(--red-dark); }
.entry.is-rejected .entry-time { text-decoration: line-through; color: var(--text-3); }
.entry-time { font-size: 17px; font-variant-numeric: tabular-nums; color: var(--text); }
/* compatibilidade */
.timeline .tl-item { display: flex; }

.info-rows { margin: 0; padding: 0 18px; }
.info-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; font-size: 14px; }
.info-row + .info-row { border-top: 1px solid var(--line); }
.info-row dt { color: var(--text-3); }
.info-row dd { margin: 0; text-align: right; color: var(--text); white-space: pre-line; }

/* As minhas horas */
.period-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; }
.period-title { text-align: center; }
.period-title strong { display: block; font-size: 17px; font-weight: 500; }
.period-title span { font-size: 13px; color: var(--text-3); }
.round-btn { width: 42px; height: 42px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.round-btn:hover:not(:disabled) { color: var(--brand); border-color: var(--brand); }
.round-btn:disabled { opacity: .35; cursor: default; }
.totals { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.total { padding: 14px 18px; }
.total + .total { border-left: 1px solid var(--line); }
.total-label { font-size: 13px; color: var(--text-3); }
.total-value { font-size: 28px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.day-row { display: flex; align-items: center; gap: 14px; padding: 12px 18px; }
.day-date { width: 48px; text-align: center; flex: none; }
.day-date b { display: block; font-size: 20px; font-weight: 500; line-height: 1.1; }
.day-date span { font-size: 12px; color: var(--text-3); text-transform: uppercase; }
.day-main { flex: 1; min-width: 0; }
.day-hours { font-size: 17px; font-variant-numeric: tabular-nums; text-align: right; }

/* Navegação inferior */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabbar-inner { display: grid; grid-template-columns: repeat(3, 1fr); max-width: 560px; margin: 0 auto; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px 10px; border: 0; background: none; cursor: pointer; font-size: 12px; color: var(--text-3); font-family: inherit; }
.tab .icon { width: 24px; height: 24px; }
.tab.active { color: var(--brand); }

/* Confirmação grande */
.done-screen { position: fixed; inset: 0; z-index: 150; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; color: #fff; }
.done-screen.in { background: var(--brand); }
.done-screen.out { background: var(--red); }
.done-check { width: 92px; height: 92px; border-radius: 50%; border: 3px solid rgba(255,255,255,.85); display: flex; align-items: center; justify-content: center; }
.done-check .icon { width: 52px; height: 52px; stroke-width: 2.4; }
.done-title { font-size: 26px; color: #fff; }
.done-time { font-size: 64px; font-variant-numeric: tabular-nums; line-height: 1; }
.done-sub { font-size: 16px; opacity: .9; }
.done-screen .btn-light { color: var(--text); }

/* ==========================================================================
   PAINEL DE GESTÃO
   ========================================================================== */
.a-login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.a-login-box { width: 100%; max-width: 400px; }

.a-top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.a-menu-btn { display: none; }
.a-body { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100dvh - var(--topbar));
  background: linear-gradient(90deg, var(--surface) 0 219px, var(--border) 219px 220px, transparent 220px); }
.ov-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.a-side { background: var(--surface); position: sticky; top: var(--topbar); height: calc(100dvh - var(--topbar)); overflow-y: auto; display: flex; flex-direction: column; }
.a-nav { display: flex; flex-direction: column; padding: 8px 0; flex: 1; }
.a-nav-label { font-size: 12px; color: var(--text-3); text-transform: uppercase; padding: 14px 20px 6px; letter-spacing: .04em; }
.a-nav-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 11px 20px; border: 0; background: none; text-align: left; cursor: pointer;
  font-size: 14px; color: var(--text-2); text-transform: uppercase; letter-spacing: .02em; font-family: inherit;
  border-left: 3px solid transparent;
}
.a-nav-item .icon { color: var(--text-3); }
.a-nav-item:hover { background: var(--surface-2); color: var(--text); }
.a-nav-item.active { background: var(--brand-soft); color: var(--text); border-left-color: var(--brand); }
.a-nav-item.active .icon { color: var(--brand); }
.a-nav-item .count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; letter-spacing: 0; }
.a-nav-item .count.amber { background: #FB8C00; }

.a-main { min-width: 0; padding: 24px 28px 48px; }
.a-page { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.a-page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.a-page-head h1 { font-size: 24px; }
.a-page-head p { color: var(--text-3); margin-top: 2px; font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--border); }
.stat { padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; text-align: left; border: 0; border-right: 1px solid var(--line); background: none; font: inherit; color: inherit; border-radius: 0; }
.stat:last-child { border-right: 0; }
button.stat { cursor: pointer; }
button.stat:hover { background: var(--surface-2); }
.stat-label { font-size: 13px; color: var(--text-3); }
.stat-value { font-size: 28px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-note { font-size: 13px; color: var(--text-3); }
.stat.attention .stat-value { color: var(--red); }

.filters { padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { min-width: 150px; }

.table-scroll { width: 100%; overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 400; text-transform: uppercase; letter-spacing: .03em; color: var(--text-3); padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--head); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:hover td { background: #FAFCFD; }
.table tr:last-child td { border-bottom: 0; }
.table .right { text-align: right; }
.table .actions { text-align: right; white-space: nowrap; }
.table .total-row td { background: var(--head); font-weight: 500; }
.cell-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.reasons { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--red-dark); }
details.more { margin-top: 6px; font-size: 13px; color: var(--text-3); }
details.more summary { cursor: pointer; color: var(--brand); }
details.more dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0 0; }
details.more dd { margin: 0; color: var(--text-2); word-break: break-word; }
.bulk-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table .col-check { width: 44px; padding-right: 0; }
.table input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; vertical-align: middle; }
.table tr.is-selected td { background: var(--brand-soft); }
.inline-rate { display: inline-flex; align-items: center; gap: 6px; }
.inline-rate .input { width: 88px; min-height: 34px; padding: 4px 8px; text-align: right; font-size: 14px; }

.sites-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
.site-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 12px 18px; border: 0; background: var(--surface); text-align: left; cursor: pointer; font: inherit; color: inherit; border-left: 3px solid transparent; }
.site-item:hover { background: var(--surface-2); }
.site-item.active { background: var(--brand-soft); border-left-color: var(--brand); }
#leaflet-map { width: 100%; height: 560px; z-index: 1; }
.map-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
input[type="range"] { width: 100%; accent-color: var(--brand); height: 28px; }

.secret-box { font-size: 20px; letter-spacing: .08em; word-break: break-all; padding: 14px; background: var(--surface-2); border: 1px dashed var(--border); text-align: center; font-variant-numeric: tabular-nums; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.side-backdrop { position: fixed; inset: var(--topbar) 0 0 0; z-index: 35; background: rgba(0, 0, 0, 0.35); }

/* --------------------------------------------------------------------------
   Ecrãs pequenos
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .sites-layout { grid-template-columns: 1fr; }
  #leaflet-map { height: 380px; }
}
@media (max-width: 860px) {
  .a-menu-btn { display: inline-flex; }
  .a-body { grid-template-columns: minmax(0, 1fr); background: none; }
  .ov-grid { grid-template-columns: minmax(0, 1fr); }
  .a-side { border-right: 1px solid var(--border); }
  .a-side { display: none; position: fixed; left: 0; top: var(--topbar); bottom: 0; z-index: 38; width: min(280px, 84vw); height: auto; box-shadow: var(--shadow-lg); }
  .a-side.open { display: flex; }
  .a-main { padding: 16px 12px 40px; }
  .a-page-head h1 { font-size: 21px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .table th, .table td { padding: 10px 12px; }
  .a-top-hide { display: none; }
}
@media (max-width: 520px) {
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 22px; }
  .card-body { padding: 16px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-box { max-height: 94dvh; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .modal-foot .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ==========================================================================
   MODO ESCURO (painel de gestão) — ativado com <html data-theme="dark">
   ========================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121418;
  --surface: #1B1E23;
  --surface-2: #22262C;
  --head: #262B32;
  --text: #E6E8EB;
  --text-2: #B6BCC4;
  --text-3: #8A929C;
  --border: #363C45;
  --line: #2B3037;

  --brand: #29B6F6;
  --brand-dark: #4FC3F7;
  --brand-soft: #0F2A38;

  --green: #43A047;
  --green-dark: #81C784;
  --green-soft: #132A1A;
  --red: #E53935;
  --red-dark: #FF8A80;
  --red-soft: #3A1818;
  --amber: #FFB74D;
  --amber-soft: #33270F;

  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.6);
}
:root[data-theme="dark"] .input::placeholder { color: #5E6672; }
:root[data-theme="dark"] .alert-red { border-color: #5C2525; }
:root[data-theme="dark"] .alert-amber { border-color: #5A4316; }
:root[data-theme="dark"] .alert-green { border-color: #24502F; }
:root[data-theme="dark"] .alert-blue { border-color: #1B4A63; color: #81D4FA; }
:root[data-theme="dark"] .pill-blue { color: #81D4FA; }
:root[data-theme="dark"] .toast { background: #2C3138; border: 1px solid var(--border); }
:root[data-theme="dark"] .toast.is-error { background: #8E2020; border-color: #8E2020; }
:root[data-theme="dark"] .toast.is-ok { background: #1E5E2A; border-color: #1E5E2A; }
:root[data-theme="dark"] .table tbody tr:hover td { background: var(--surface-2); }
:root[data-theme="dark"] .table tr.is-selected td { background: var(--brand-soft); }
:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .btn-red,
:root[data-theme="dark"] .btn-green { color: #0B0D10; font-weight: 700; }
:root[data-theme="dark"] .btn-red { color: #fff; }
:root[data-theme="dark"] .modal { background: rgba(0, 0, 0, 0.65); }
:root[data-theme="dark"] .side-backdrop { background: rgba(0, 0, 0, 0.55); }
/* O desenho do logótipo é preto: inverter para ficar claro no fundo escuro */
:root[data-theme="dark"] .logo-mark-img { filter: invert(1) hue-rotate(180deg) brightness(0.95); }
/* Mapa mais escuro para não encandear */
:root[data-theme="dark"] .leaflet-tile-pane { filter: brightness(0.72) contrast(1.08) saturate(0.85); }
:root[data-theme="dark"] .leaflet-container { background: #1B1E23; }
:root[data-theme="dark"] .leaflet-bar a,
:root[data-theme="dark"] .leaflet-control-layers { background: var(--surface); color: var(--text); border-color: var(--border); }
:root[data-theme="dark"] .leaflet-popup-content-wrapper,
:root[data-theme="dark"] .leaflet-popup-tip { background: var(--surface); color: var(--text); }
:root[data-theme="dark"] .leaflet-control-attribution { background: rgba(27, 30, 35, 0.8) !important; color: var(--text-3); }
:root[data-theme="dark"] .leaflet-control-attribution a { color: var(--brand); }
.theme-btn .icon-sun { display: none; }
:root[data-theme="dark"] .theme-btn .icon-sun { display: block; }
:root[data-theme="dark"] .theme-btn .icon-moon { display: none; }
