/* ============================================================
   DESIGN SYSTEM — Tema escuro refinado, tipografia editorial
   ============================================================ */
:root {
  --bg:          #0a0a0b;
  --bg2:         #101011;
  --surface:     #141416;
  --surface2:    #1a1a1c;
  --border:      #26262a;
  --border2:     #34343a;
  --accent:      #206e13;
  --accent-h:    #2c9119;
  --accent-mute: rgba(32,110,19,.16);
  --text:        #e6e6e8;
  --text-dim:    #9a9aa2;
  --muted:       #56565e;
  --danger:      #f87171;
  --danger-bg:   rgba(248,113,113,.1);
  --success:     #34a521;
  --warn:        #e0a51a;
  --entry-c:      #34a521;
  --exit-c:       #f87171;
  --break-c:      #e0a51a;
  --other-c:      #6b8aa8;
  --vacation-c:   #4a90d0;
  --prevention-c: #f87171;
  --radius:      8px;
  --radius-lg:   14px;
  --shadow:      0 4px 24px rgba(0,0,0,.5);
  --transition:  .18s ease;
  --font-sans:   'Palatino Linotype','Book Antiqua', Palatino, serif;
  --font-mono:   'Courier New', monospace;
  --font-ui:     system-ui, -apple-system, sans-serif;
  --sidebar-w:   220px;
}
[data-theme="light"] {
  --bg:          #f4f4f8;
  --bg2:         #eaeaf2;
  --surface:     #ffffff;
  --surface2:    #f8f8fd;
  --border:      #d4d4e8;
  --border2:     #c0c0d8;
  --text:        #1e1e2e;
  --text-dim:    #4a4a6a;
  --muted:       #9090b0;
  --shadow:      0 4px 24px rgba(0,0,0,.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  margin: 0;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 299;
}

.sidebar-logo {
  padding: 1.4rem 1.2rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-logo img {
  height: 30px;
  filter: brightness(0) invert(1);
  opacity: .85;
}
[data-theme="light"] .sidebar-logo img {
  filter: brightness(0);
  opacity: .75;
}
.sidebar-logo .app-name {
  font-size: .75rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: .08em;
}

.nav-section {
  padding: .5rem .6rem;
}
.nav-label {
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--muted);
  padding: .6rem .6rem .3rem;
  font-family: var(--font-mono);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .75rem;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-dim);
  font-size: .85rem;
  font-family: var(--font-ui);
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--accent-mute); color: var(--text); }
.nav-item.active { background: var(--accent-mute); color: var(--accent-h); }

.sidebar-bottom {
  margin-top: auto;
  padding: .75rem .6rem;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem .75rem;
  border-radius: var(--radius);
}
.user-avatar {
  width: 28px; height: 28px;
  background: var(--accent-mute);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
  color: var(--accent-h);
  font-family: var(--font-mono);
  font-weight: bold;
  flex-shrink: 0;
}
.user-name {
  font-size: .78rem;
  color: var(--text-dim);
  font-family: var(--font-ui);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: .3rem;
  border-radius: 4px;
  display: flex;
  transition: color var(--transition);
}
.btn-icon:hover { color: var(--text); }
.btn-icon svg { width: 15px; height: 15px; }

/* ── Main ────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  flex-shrink: 0;
}
.topbar-title {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--muted);
  letter-spacing: .1em;
}
.topbar-title span { color: var(--text-dim); }
.topbar-actions { margin-left: auto; display: flex; gap: .5rem; }

.view {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: none;
}
.view.active { display: block; }

/* ── Cards e elementos comuns ────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: visible;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
}
.card-header h2 {
  font-size: .85rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  letter-spacing: .05em;
  font-weight: normal;
}
.card-body { padding: 1.25rem; }

/* ── Formulário ──────────────────────────────────────────── */
.form-grid { display: grid; gap: .9rem; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.field-group { display: flex; flex-direction: column; gap: .3rem; }
.field-group label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  font-family: var(--font-mono);
}
.field-group input,
.field-group select,
.field-group textarea {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .8rem;
  color: var(--text);
  font-size: .88rem;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}
.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus { border-color: var(--accent); }
.field-group textarea { resize: vertical; min-height: 80px; }
.field-group select option { background: var(--surface); }

/* Tipo de evento */
.type-selector {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.type-btn {
  padding: .45rem .9rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  font-size: .78rem;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all var(--transition);
}
.type-btn:hover                { border-color: var(--border2); color: var(--text); }
.type-btn.active[data-t=entry],       .type-btn.active[data-type=entry]      { background: rgba(52,211,153,.15);  border-color: var(--entry-c); color: var(--entry-c); }
.type-btn.active[data-t=exit],        .type-btn.active[data-type=exit]       { background: rgba(248,113,113,.15); border-color: var(--exit-c);  color: var(--exit-c);  }
.type-btn.active[data-t=lunch],       .type-btn.active[data-type=lunch]      { background: rgba(251,191,36,.15);  border-color: var(--break-c); color: var(--break-c); }
.type-btn.active[data-t=other],       .type-btn.active[data-type=other]      { background: rgba(167,139,250,.15); border-color: var(--other-c); color: var(--other-c); }
.type-btn.active[data-t=prevention],  .type-btn.active[data-type=prevention] { background: rgba(248,113,113,.15); border-color: var(--prevention-c); color: var(--prevention-c); }
.type-btn.active[data-t=vacation],    .type-btn.active[data-type=vacation]   { background: rgba(96,165,250,.15);  border-color: var(--vacation-c);   color: var(--vacation-c);   }

/* Chips de sugestão */
.suggestions-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .4rem;
}
.suggestion-chip {
  padding: .25rem .65rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  font-size: .73rem;
  cursor: pointer;
  transition: all var(--transition);
}
.suggestion-chip:hover { border-color: var(--accent); color: var(--accent-h); }

/* Botões */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  font-size: .82rem;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all var(--transition);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-ghost { background: none; border: 1px solid var(--border); color: var(--text-dim); }
.btn-ghost:hover { border-color: var(--border2); color: var(--text); }
.btn-danger { background: var(--danger-bg); border: 1px solid rgba(248,113,113,.3); color: var(--danger); }
.btn-danger:hover { background: rgba(248,113,113,.2); }
.btn svg { width: 14px; height: 14px; }

/* ── Registo Diário ──────────────────────────────────────── */
.log-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: 1rem;
}
.log-entry {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition);
  cursor: pointer;
  min-height: 44px;
}
.log-entry:hover { border-color: var(--border2); }
.log-actions { display: flex; gap: .15rem; align-items: center; flex-shrink: 0; margin-left: auto; }
.log-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.log-entry[data-t=entry]  .log-dot { background: var(--entry-c); }
.log-entry[data-t=exit]   .log-dot { background: var(--exit-c); }
.log-entry[data-t=lunch]  .log-dot { background: var(--break-c); }
.log-entry[data-t=other]  .log-dot { background: var(--other-c); }
.log-time {
  font-family: var(--font-mono);
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
  min-width: 46px;
  flex-shrink: 0;
}
.log-desc {
  flex: 1;
  font-size: .85rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.log-badge {
  font-size: .65rem;
  padding: .15rem .5rem;
  border-radius: 12px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.log-entry[data-t=entry]  .log-badge { background: rgba(52,211,153,.12); color: var(--entry-c); }
.log-entry[data-t=exit]   .log-badge { background: rgba(248,113,113,.12); color: var(--exit-c); }
.log-entry[data-t=lunch]  .log-badge { background: rgba(251,191,36,.12);  color: var(--break-c); }
.log-entry[data-t=other]      .log-badge { background: rgba(167,139,250,.12); color: var(--other-c); }
.log-entry[data-t=prevention] .log-dot   { background: var(--prevention-c); }
.log-entry[data-t=prevention] .log-badge { background: rgba(248,113,113,.12); color: var(--prevention-c); }
.log-entry[data-t=vacation]   .log-dot   { background: var(--vacation-c); }
.log-entry[data-t=vacation]   .log-badge { background: rgba(96,165,250,.12); color: var(--vacation-c); }
.log-entry[data-t=other]      .log-dot   { background: var(--other-c); }


/* ── Work Summary Bar ────────────────────────────────────────── */
.work-summary {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text-dim);
  min-height: 38px;
  transition: all var(--transition);
  max-width: 1000px;
}
.work-summary.active { border-color: var(--border2); }
.work-summary .ws-block { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.work-summary .ws-label { color: var(--muted); font-size: .65rem; letter-spacing: .05em; }
.work-summary .ws-val   { color: var(--text); font-weight: 600; letter-spacing: .04em; }
.work-summary .ws-live  { color: var(--entry-c); animation: pulse-dot 2s infinite; }
.work-summary .ws-divider { width: 1px; height: 16px; background: var(--border2); flex-shrink: 0; }
@keyframes pulse-dot {
  0%,100% { opacity: 1; }
  50%      { opacity: .4; }
}

/* ── Date/Time picker popup (minimalista) ────────────────────── */
.dt-wrap { position: relative; }
.dt-wrap input[type=date],
.dt-wrap input[type=time] { cursor: pointer; }
.dt-cal-popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 500;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: .75rem;
  min-width: 260px;
  animation: fadeUp .12s ease;
}
.dt-cal-popup.right { left: auto; right: 0; }
.dt-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .6rem;
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--text);
}
.dt-cal-head button {
  background: none; border: none;
  color: var(--text-dim); cursor: pointer; font-size: .9rem;
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.dt-cal-head button:hover { background: var(--border); color: var(--text); }
.dt-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.dt-cal-grid .dow {
  text-align: center;
  font-size: .6rem;
  color: var(--muted);
  font-family: var(--font-mono);
  padding: .2rem 0;
}
.dt-cal-grid .day {
  text-align: center;
  font-size: .72rem;
  padding: .3rem .1rem;
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--font-mono);
  color: var(--text-dim);
  transition: background var(--transition);
}
.dt-cal-grid .day:hover  { background: var(--border2); color: var(--text); }
.dt-cal-grid .day.today  { color: var(--accent-h); font-weight: 700; }
.dt-cal-grid .day.sel    { background: var(--accent); color: #fff; }
.dt-cal-grid .day.other  { color: var(--muted); }
.dt-cal-grid .day.empty  { cursor: default; }

.dt-time-popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 500;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: .75rem 1rem;
  min-width: 180px;
  animation: fadeUp .12s ease;
}
.dt-time-popup .time-display {
  font-family: var(--font-mono);
  font-size: 2rem;
  text-align: center;
  color: var(--text);
  letter-spacing: .1em;
  margin-bottom: .6rem;
  cursor: default;
}
.dt-time-popup .time-display span { color: var(--accent-h); cursor: default; }
.time-spinners {
  display: grid;
  grid-template-columns: 1fr 16px 1fr;
  align-items: center;
  gap: .3rem;
  margin-bottom: .6rem;
}
.time-spinners .sep {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--muted);
}
.time-col { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.time-col button {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: .9rem; padding: .15rem .5rem; border-radius: 4px;
  transition: all var(--transition);
}
.time-col button:hover { background: var(--border2); color: var(--text); }
.time-col .val {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--text);
  min-width: 36px;
  text-align: center;
  padding: .1rem 0;
}
.dt-popup-footer {
  display: flex; justify-content: space-between; gap: .4rem; margin-top: .5rem;
}
.dt-popup-footer button {
  flex: 1; padding: .35rem .6rem; border-radius: 6px;
  font-size: .72rem; font-family: var(--font-mono); cursor: pointer;
  border: 1px solid var(--border2); background: none; color: var(--text-dim);
  transition: all var(--transition);
}
.dt-popup-footer button:hover { border-color: var(--accent); color: var(--accent-h); }
.dt-popup-footer button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.dt-popup-footer button.primary:hover { background: var(--accent-h); }


/* ── Temporizador almoço ─────────────────────────────────── */
#lunchTimerOverlay.active { display: flex !important; }


/* ── Estatísticas ─────────────────────────────────────────── */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.kpi-val  { font-size: 1.6rem; font-family: var(--font-mono); font-weight: 700; color: var(--text); line-height: 1.1; }
.kpi-lbl  { font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-family: var(--font-mono); }
.kpi-sub  { font-size: .7rem; color: var(--muted); font-family: var(--font-mono); }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; }
.chart-title { font-size: .65rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-family: var(--font-mono); margin-bottom: .75rem; }
.bar-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.bar-label { font-size: .68rem; font-family: var(--font-mono); color: var(--text-dim); min-width: 28px; text-align: right; white-space: nowrap; }
.bar-track { flex: 1; height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 3px; transition: width .4s cubic-bezier(.4,0,.2,1); }
.bar-val   { font-size: .65rem; font-family: var(--font-mono); color: var(--muted); min-width: 36px; }
@media (max-width: 600px) {
  #statsCharts { grid-template-columns: 1fr !important; }
  #statsKpis   { grid-template-columns: repeat(2,1fr) !important; }
}

/* ── Férias ────────────────────────────────────────────────── */
.vacation-stat {
  display:flex;flex-direction:column;align-items:center;gap:.25rem;
  background:var(--surface2);border:1px solid var(--border);
  border-radius:var(--radius);padding:.75rem 1.25rem;min-width:110px;
}
.vacation-stat .vs-val { font-size:1.6rem;font-family:var(--font-mono);color:var(--text);font-weight:700;line-height:1; }
.vacation-stat .vs-label { font-size:.65rem;color:var(--muted);text-transform:uppercase;letter-spacing:.08em;font-family:var(--font-mono); }
.vacation-period {
  background:var(--surface2);border:1px solid var(--border);
  border-radius:var(--radius);padding:.65rem .9rem;
  display:flex;align-items:center;gap:.75rem;
}
.vacation-period .vp-dot { width:8px;height:8px;border-radius:50%;background:var(--vacation-c);flex-shrink:0; }
.vacation-period .vp-dates { font-family:var(--font-mono);font-size:.8rem;color:var(--text);flex:1; }
.vacation-period .vp-days { font-family:var(--font-mono);font-size:.72rem;background:rgba(96,165,250,.12);color:var(--vacation-c);border:1px solid rgba(96,165,250,.2);border-radius:12px;padding:.15rem .55rem;flex-shrink:0; }
.vacation-period .vp-adj { font-size:.65rem;color:var(--muted);font-family:var(--font-mono);margin-top:.15rem; }
.vacation-period .vp-info { flex:1;min-width:0; }
.vp-adj-row { display:flex;align-items:center;gap:.5rem;background:var(--surface2);border:1px solid var(--border);border-radius:6px;padding:.3rem .6rem; }
.vp-deduct-btn:hover { border-color:var(--accent);color:var(--accent-h); }
/* ── Calendário ──────────────────────────────────────────── */
.cal-header {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: 1rem;
}
.cal-header-row1 {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.cal-nav { display: flex; gap: .3rem; }
.cal-nav button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.cal-nav button:hover { border-color: var(--border2); color: var(--text); }
.cal-period {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--text);
  min-width: 160px;
  text-align: center;
  cursor: pointer;
  padding: .2rem .5rem;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}
.cal-period:hover {
  background: var(--accent-mute);
  color: var(--accent-h);
}
.cal-view-tabs { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-view-tab {
  padding: .35rem .75rem;
  font-size: .75rem;
  font-family: var(--font-ui);
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}
.cal-view-tab.active { background: var(--accent-mute); color: var(--accent-h); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  width: 100%;
}
.cal-day-header {
  background: var(--surface);
  padding: .5rem;
  text-align: center;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  font-family: var(--font-mono);
}
.cal-day {
  background: var(--surface);
  min-height: 90px;
  padding: .4rem;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
}
.cal-day:hover { background: var(--surface2); }
.cal-day.other-month .cal-day-num { color: var(--muted); }
.cal-day.today { background: rgba(99,102,241,.06); }
.cal-day.today .cal-day-num {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
}
.cal-day-num {
  font-size: .75rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
}
.cal-event-dot {
  font-size: .68rem;
  padding: .1rem .35rem;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  font-family: var(--font-ui);
}

/* ── Calendários laterais ────────────────────────────────── */
.cal-sidebar {
  width: 200px;
  flex-shrink: 0;
}
.cal-list-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .4rem .5rem;
  border-radius: var(--radius);
  font-size: .8rem;
  font-family: var(--font-ui);
  color: var(--text-dim);
}
.cal-color-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.cal-toggle { margin-left: auto; accent-color: var(--accent); }

/* ── Anexos ──────────────────────────────────────────────── */
.attach-toolbar {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  justify-content: space-between;
}
.attach-toolbar-group {
  display: flex;
  gap: .4rem;
  align-items: center;
}
.attach-search {
  flex: 1;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .8rem;
  color: var(--text);
  font-size: .85rem;
  font-family: var(--font-ui);
  outline: none;
}
.attach-search:focus { border-color: var(--accent); }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: .75rem;
  font-family: var(--font-mono);
}
.breadcrumb a { color: var(--accent); cursor: pointer; text-decoration: none; }
.breadcrumb a:hover { color: var(--accent-h); }
.breadcrumb .sep { color: var(--muted); }

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .75rem;
}
.file-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  position: relative;
}
.file-item:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.file-icon { font-size: 2rem; }
.file-name { font-size: .72rem; color: var(--text); word-break: break-word; font-family: var(--font-ui); }
.file-meta { font-size: .62rem; color: var(--muted); font-family: var(--font-mono); }
.file-item .file-actions {
  position: absolute; top: .4rem; right: .4rem;
  display: none; gap: .2rem;
}
.file-item:hover .file-actions { display: flex; }

.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: .85rem;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 1rem;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); color: var(--accent-h); background: var(--accent-mute); }
.upload-zone svg { margin-bottom: .5rem; width: 32px; height: 32px; opacity: .5; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
  backdrop-filter: blur(4px);
}
.modal-backdrop.show { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  transform: scale(.96);
  transition: transform var(--transition);
}
.modal-backdrop.show .modal { transform: scale(1); }
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 {
  font-size: .88rem;
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: normal;
}
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; gap: .5rem; justify-content: flex-end;
}

/* Modal de visualização de ficheiro */
.modal.modal-viewer {
  max-width: 95vw;
  max-height: 95vh;
  width: auto;
}
.viewer-pdf {
  width: min(80vw, 1000px);
  height: 82vh;
  border: none;
  display: block;
}
.viewer-wrap {
  width: min(88vw, 1100px);
  height: 75vh;
  background: #050508;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  cursor: zoom-in;
}
.viewer-wrap.zoomed { cursor: grab; }
.viewer-wrap.zoomed.panning { cursor: grabbing; }
.viewer-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
  transform-origin: 0 0;
  transition: transform .12s ease;
}
.viewer-canvas.no-transition { transition: none; }
.viewer-img {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  border-radius: 2px;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.viewer-hint {
  font-size: .67rem;
  color: var(--muted);
  font-family: var(--font-mono);
  text-align: center;
  margin-top: .45rem;
  letter-spacing: .05em;
}
.viewer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  margin-top: .6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: .3rem .5rem;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
.viewer-zoom-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  border-radius: 20px;
  width: 30px; height: 30px;
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.viewer-zoom-btn:hover { background: var(--accent-mute); color: var(--accent-h); }
.viewer-zoom-level {
  font-size: .72rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  min-width: 48px;
  text-align: center;
  padding: 0 .4rem;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* ── Toast ───────────────────────────────────────────────── */
.toasts {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: .5rem;
  z-index: 999;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: .7rem 1rem;
  font-size: .8rem;
  font-family: var(--font-ui);
  color: var(--text);
  box-shadow: var(--shadow);
  animation: slideIn .2s ease;
  display: flex; align-items: center; gap: .5rem;
}
.toast.success::before { content: '✓'; color: var(--success); }
.toast.error::before   { content: '✕'; color: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity:0; } to { transform: none; opacity:1; } }

/* ── Settings ────────────────────────────────────────────── */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
  overflow: hidden;
}
.settings-section-header {
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: .75rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .1em;
}
.settings-section-body { padding: 1.25rem; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: .85rem; color: var(--text); font-family: var(--font-ui); }
.setting-desc  { font-size: .72rem; color: var(--muted); }

/* Toggle switch */
.toggle {
  position: relative; width: 38px; height: 20px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border2);
  border-radius: 20px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::after {
  content: '';
  position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::after { transform: translateX(18px); background: #fff; }

/* IP list */
.ip-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem .75rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .4rem;
  font-size: .82rem;
  font-family: var(--font-ui);
}
.ip-item .ip-label { flex: 1; color: var(--text-dim); }
.ip-item .ip-addr  { font-family: var(--font-mono); font-size: .75rem; color: var(--muted); }
.suggestion-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .3rem;
  cursor: default;
  transition: border-color var(--transition), box-shadow var(--transition);
  user-select: none;
}
.suggestion-item.drag-over { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.suggestion-item.dragging  { opacity: .35; }
.suggestion-drag-handle {
  color: var(--muted);
  cursor: grab;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: .1rem;
}
.suggestion-drag-handle:hover { color: var(--accent-h); }
.suggestion-order {
  font-size: .65rem;
  font-family: var(--font-mono);
  color: var(--muted);
  min-width: 16px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Responsivo ──────────────────────────────────────────── */
/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0; }

  .sidebar {
    position: fixed;
    width: 240px;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 300;
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.4); }

  /* sidebar overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 299;
  }
  .sidebar.open ~ .sidebar-overlay { display: block; }

  .view { padding: 1rem .75rem; }

  /* Daily view: stack vertically on mobile */
  #viewDaily .daily-grid {
    grid-template-columns: 1fr !important;
  }

  /* Calendar */
  .cal-layout { flex-direction: column; }
  .cal-sidebar { display: none; }
  .cal-day { min-height: 48px; font-size: .7rem; }
  .cal-event-dot { display: none; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }
  .type-selector { flex-wrap: wrap; }
  .type-btn { flex: 1; min-width: 80px; }

  /* Attachments */
  .attach-toolbar { flex-direction: column; align-items: stretch; }
  .attach-toolbar-group { justify-content: flex-start; }
  .attach-search { width: 100%; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }

  /* Topbar */
  .topbar { padding: 0 .75rem; }
  #btnMenuToggle { display: flex !important; }

  /* Modal */
  .modal { max-width: calc(100vw - 1rem); max-height: 90dvh; }
  .modal-body { max-height: 65dvh; }

  /* Settings */
  .settings-section-body { padding: .75rem; }

  /* Week view */
  .cal-week-grid { font-size: .7rem; }
  .cal-week-time { width: 36px; }
  /* Semana mobile — evitar overflow de texto */
  #calGrid > div[style*="flex:1"] { min-width: 40px; }
  #calGrid > div[style*="flex:1"] > div[style*="background"] { word-break: break-word; }
  #calGrid > div[style*="flex:1"] > div[style*="background"] > div { white-space: normal !important; overflow: hidden; }
}

@media (min-width: 769px) and (max-width: 1200px) {
  #viewDaily > div {
    grid-template-columns: 1fr 280px !important;
  }
}
