:root{
  --topbarH: 62px;
}

.appTopbar{
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--panel2);
  border-bottom: 1px solid var(--line2);
}

.appTopbarInner{
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

.appTopbarLeft{display:flex;align-items:center;gap:12px;min-width:0}
.appTopbarTitle{min-width:0}
.appTopbarH1{font-weight:900;font-size:16px;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.appTopbarSub{font-size:12px;color:var(--muted);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.appTopbarRight{display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}

/* Title row with inline controls (used by Bookkeeping header on mobile) */
.appTopbarH1Row{display:flex;align-items:center;gap:10px;min-width:0}
.appTopbarTitleRight{display:flex;align-items:center;gap:10px;margin-left:auto;min-width:0;flex:0 0 auto}

@media (max-width: 520px){
  .appTopbarH1Row{gap:8px}
  /* Keep header contents within viewport; prevent the right cluster from drifting off-screen */
  .appTopbarTitleRight{gap:8px}
  /* Long subtitles must not force horizontal scrolling */
  .appTopbarSub{white-space:normal;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
}

/* Mobile: prevent horizontal scrolling (e.g. caused by wide charts) */
@media (max-width: 520px){
  html, body{max-width:100%; overflow-x:hidden;}
  .appTopbar{max-width:100vw; overflow-x:hidden;}
}

.homeBtn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--line2);
  background: var(--panel);
  text-decoration:none;
  color: inherit;
  font-weight: 850;
}
.homeBtn:hover{filter:brightness(1.02)}
.homeBtnIcon{font-size:16px;line-height:1}
.homeBtnText{font-size:13px}
@media(max-width:620px){.homeBtnText{display:none}}

/* Dashboard tiles */
.dashWrap{max-width:1100px;margin:18px auto;padding:0 16px}
.dashIntro{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.brandInline{display:flex;gap:10px;align-items:center;min-width:0}
.brandInline img{height:38px;width:auto;border-radius:12px}
.brandInline .t1{font-weight:900;font-size:18px;line-height:1.1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.brandInline .t2{color:var(--muted);font-weight:750;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

.tileGrid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-top:16px}
@media(max-width:980px){.tileGrid{grid-template-columns:repeat(2,1fr)}}
@media(max-width:620px){.tileGrid{grid-template-columns:1fr}}

.tile{
  display:flex;
  gap:12px;
  align-items:flex-start;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line2);
  background: var(--panel);
  box-shadow: var(--shadow);
  text-decoration:none;
  color: inherit;
  transition: transform .12s ease;
}
.tile:hover{transform: translateY(-1px)}
.tileIcon{
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: linear-gradient(135deg, rgba(255,255,255,.10), rgba(0,0,0,.03));
  border: 1px solid var(--line2);
  font-size: 20px;
}
[data-theme='dark'] .tileIcon{background: linear-gradient(135deg, rgba(255,255,255,.08), rgba(0,0,0,.18))}
.tileText{min-width:0}
.tileName{font-weight:900;font-size:15px;line-height:1.15;margin-top:2px}
.tileDesc{font-size:12px;color:var(--muted);margin-top:4px;line-height:1.3}

/* Page layout helper */
.pageWrap{max-width:1100px;margin:0 auto;padding:16px}


/* Floating mini timer (Bookkeeping) */

#bkMiniTimer{ position:fixed; right:16px; bottom:16px; z-index:9999; display:none; }
#bkMiniTimer .bkMiniCard{
  background: rgba(20,20,20,0.88);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  padding: 12px 12px 10px;
  min-width: 230px;
  max-width: 320px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  backdrop-filter: blur(10px);
}
#bkMiniTimer .bkMiniRow{ display:flex; justify-content:space-between; gap:10px; align-items:center; }
#bkMiniTimer .bkMiniTitle{ font-weight:700; font-size:14px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width: 190px; }
#bkMiniTimer .bkMiniTime{ font-variant-numeric: tabular-nums; font-weight:800; font-size:16px; }
#bkMiniTimer .bkMiniBtns{ margin-top:10px; display:flex; gap:8px; }
#bkMiniTimer .bkMiniBtns .btn{ flex:1; padding:10px 12px; border-radius: 999px; }
#bkMiniTimer .bkMiniBtns .btn.danger{ background: rgba(255,0,0,0.14); border-color: rgba(255,0,0,0.22); }
#bkMiniToast{
  position: fixed; right: 16px; bottom: 92px; z-index: 9999;
  background: rgba(0,0,0,0.75); color: #fff; padding: 10px 12px; border-radius: 999px;
  transition: opacity .25s ease; opacity: 0; pointer-events:none;
  max-width: 320px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
@media (max-width: 520px){
  #bkMiniTimer{ right:12px; bottom:12px; }
  #bkMiniTimer .bkMiniCard{ min-width: 210px; }
}
