/* Portal de Previsões — identidade O Valor do Tempo (ovalordotempo.pt) */
:root {
  --navy: #1F2549;
  --navy-2: #2c3463;
  --navy-3: #3b4479;
  --gold: #9B8669;
  --gold-2: #C49A3A;
  --gold-soft: #e9e2d6;
  --beige: #F5F4F0;
  --ink: #353535;
  --muted: #7a7a7a;
  --line: #e4e1da;
  --white: #fff;
  --up: #2f7d4f;
  --up-bg: #e8f3ec;
  --down: #b3261e;
  --down-bg: #fbeaea;
  --warn: #8a6100;
  --warn-bg: #fdf4dc;
  --radius: 6px;
  --shadow: 0 2px 10px rgba(31, 37, 73, .07);
  --head: "El Messiri", Georgia, serif;
  --body: "Lato", Helvetica, Arial, sans-serif;
  --side: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--body); color: var(--ink); background: var(--beige); font-size: 14px; line-height: 1.45; }
a { color: var(--navy); }
h1, h2, h3 { font-family: var(--head); color: var(--navy); font-weight: 600; line-height: 1.2; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 0 0 .7rem; }
h3 { font-size: 1.05rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.up { color: var(--up); font-weight: 700; }
.down { color: var(--down); font-weight: 700; }
.gold { color: var(--gold); }

/* Barra lateral */
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--white); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 40; overflow-y: auto; }
.side-brand { display: block; padding: 18px 18px 8px; text-align: center; }
.side-brand img { max-width: 150px; height: auto; }
.side-store { text-align: center; font-family: var(--head); color: var(--gold); font-size: .95rem; letter-spacing: .06em; text-transform: uppercase; padding: 0 12px 14px; border-bottom: 1px solid var(--line); }
.side nav { flex: 1; padding: 8px 0; }
.side-group { padding: 6px 0; border-bottom: 1px solid var(--line); }
.side-group:last-child { border-bottom: 0; }
.side a { display: flex; align-items: center; gap: 11px; padding: 9px 20px; color: var(--ink); text-decoration: none; font-size: .93rem; border-left: 3px solid transparent; }
.side a .ico { color: var(--gold); flex: none; }
.side a:hover { background: var(--beige); }
.side a.on { background: var(--gold-soft); border-left-color: var(--gold); color: var(--navy); font-weight: 700; }
.side-foot { border-top: 1px solid var(--line); padding: 8px 0; }
.side-foot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Área principal */
.shell { margin-left: var(--side); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; background: var(--navy); color: var(--white); display: flex; align-items: center; gap: 16px; min-height: 58px; padding: 8px 22px; border-bottom: 3px solid var(--gold); }
.tb-title { font-family: var(--head); font-size: 1.25rem; letter-spacing: .03em; flex: 1; }
.tb-store select { font: inherit; padding: 7px 12px; border-radius: var(--radius); border: 1px solid var(--gold); background: var(--navy-2); color: var(--white); min-width: 240px; max-width: 360px; }
.burger { display: none; background: none; border: 0; color: var(--white); cursor: pointer; padding: 4px; }
.main { flex: 1; padding: 20px 22px 40px; width: 100%; max-width: 1500px; }
.foot { padding: 14px 22px; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); }
.side-veil { display: none; }

/* Blocos */
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 18px; min-width: 0; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-h h2 { margin: 0; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > .panel { margin-bottom: 0; }
.stack > * + * { margin-top: 18px; }

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; border-top: 3px solid var(--gold); }
.kpi-l { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kpi-v { font-family: var(--head); color: var(--navy); font-size: 1.55rem; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-s { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.kpi.big .kpi-v { font-size: 2.2rem; }
.kpi.navy { background: var(--navy); border-color: var(--navy); }
.kpi.navy .kpi-l, .kpi.navy .kpi-s { color: #c9cbe0; }
.kpi.navy .kpi-v { color: var(--white); }

/* Barra de filtros */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], select, textarea {
  font: inherit; font-size: .93rem; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
textarea { width: 100%; min-height: 70px; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .9rem; padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--navy); background: var(--navy); color: var(--white); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--gold); border-color: var(--gold); }
.btn.ghost { background: var(--white); color: var(--navy); }
.btn.ghost:hover { background: var(--beige); color: var(--navy); border-color: var(--gold); }
.btn.gold { background: var(--gold); border-color: var(--gold); }
.btn.gold:hover { background: var(--navy); border-color: var(--navy); }
.btn.danger { background: var(--white); color: var(--down); border-color: var(--down); }
.btn.sm { padding: 4px 10px; font-size: .8rem; }
.seg { display: inline-flex; border: 1px solid var(--navy); border-radius: var(--radius); overflow: hidden; }
.seg a { padding: 6px 14px; text-decoration: none; color: var(--navy); font-size: .8rem; letter-spacing: .05em; text-transform: uppercase; border-right: 1px solid var(--line); background: var(--white); }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--navy); color: var(--white); }
.seg a:hover:not(.on) { background: var(--beige); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { flex-direction: row; align-items: center; gap: 4px; text-transform: none; letter-spacing: 0; font-size: .85rem; color: var(--ink); background: var(--beige); padding: 4px 9px; border-radius: 14px; cursor: pointer; }

/* Tabelas */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th { text-align: left; font-weight: 700; color: var(--navy); background: var(--beige); padding: 8px 10px; border-bottom: 2px solid var(--gold); white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: #fbfaf7; }
.tbl .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl tr.total td { font-weight: 700; background: var(--beige); }
.tbl tr.hol td { background: #fff8ec; }
.tbl tr.today td { background: var(--gold-soft); }
.tbl-scroll { max-height: 520px; overflow: auto; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .75rem; background: var(--beige); color: var(--navy); white-space: nowrap; }
.tag.gold { background: var(--gold-soft); color: #6d5c41; }
.tag.navy { background: var(--navy); color: var(--white); }
.tag.ok { background: var(--up-bg); color: var(--up); }
.tag.bad { background: var(--down-bg); color: var(--down); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.bar { height: 8px; background: var(--beige); border-radius: 4px; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--gold); }

/* Gráficos */
.chart { position: relative; width: 100%; }

/* Mapa de calor */
.heat td.h { text-align: center; font-size: .78rem; padding: 6px 4px; color: var(--navy); }

/* Avisos */
.flash { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 14px; }
.flash-ok { background: var(--up-bg); color: var(--up); }
.flash-err { background: var(--down-bg); color: var(--down); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.empty { padding: 26px; text-align: center; color: var(--muted); background: var(--white); border: 1px dashed var(--line); border-radius: var(--radius); }
.note { font-size: .82rem; color: var(--muted); margin-top: 8px; }

/* Calendário */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dh { text-align: center; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 4px; }
.cal .d { min-height: 96px; background: var(--white); border: 1px solid var(--line); border-radius: 4px; padding: 5px 6px; font-size: .78rem; }
.cal .d.out { background: transparent; border-style: dashed; color: var(--muted); }
.cal .d.today { border: 2px solid var(--gold); }
.cal .d .n { font-weight: 700; color: var(--navy); }
.cal .ev { display: block; margin-top: 3px; padding: 1px 5px; border-radius: 3px; background: var(--navy); color: var(--white); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.cal .ho { display: block; margin-top: 3px; padding: 1px 5px; border-radius: 3px; background: var(--gold-soft); color: #6d5c41; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .fc { display: block; margin-top: 4px; color: var(--muted); }

/* Formulários */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.form-grid label, .field { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); }
.form-grid .wide { grid-column: 1 / -1; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* Login */
body.bare { background: var(--navy) url('relogio.jpg') center/cover; }
.bare-main { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; background: var(--white); border-radius: var(--radius); padding: 30px 28px; box-shadow: 0 10px 40px rgba(0,0,0,.25); border-top: 4px solid var(--gold); }
.login img { display: block; margin: 0 auto 10px; max-width: 170px; }
.login h1 { text-align: center; font-size: 1.25rem; color: var(--gold); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 20px; }
.login label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: .85rem; color: var(--muted); }
.login .btn { width: 100%; justify-content: center; padding: 10px; }

/* Telemóvel e tablet */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .g3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .side { transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  body.side-open .side { transform: none; }
  body.side-open .side-veil { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
  .shell { margin-left: 0; }
  .burger { display: block; }
  .topbar { padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
  .tb-store { width: 100%; }
  .tb-store select { width: 100%; max-width: none; min-width: 0; }
  .main { padding: 14px 12px 30px; }
  .g2, .g4 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-v { font-size: 1.25rem; }
  .cal .d { min-height: 64px; font-size: .7rem; }
}
